PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ test_geography_substring()

static void test_geography_substring ( void  )
static

Definition at line 1597 of file cu_geodetic.c.

1598{
1599 LWGEOM *lwg;
1600 LWGEOM *result;
1601 double length;
1602 SPHEROID s;
1603
1604 /* Init to Sphere */
1606 s.a = s.b = s.radius;
1607
1608 /*
1609 * geography_substring(
1610 * const LWLINE *lwline,
1611 * const SPHEROID *s,
1612 * double from, double to, double tolerance
1613 */
1614
1615 lwg = lwgeom_from_wkt("LINESTRING(2 48, 2 49, 2 50)", LW_PARSER_CHECK_NONE);
1616 length = lwgeom_length(lwg);
1617 CU_ASSERT_DOUBLE_EQUAL(length, 2.0, 0.001);
1618 result = geography_substring((LWLINE*)lwg, &s, 0.0, 1.0, 0.01);
1619 length = lwgeom_length(result);
1620 CU_ASSERT_DOUBLE_EQUAL(length, 2.0, 0.001);
1621 lwgeom_free(lwg);
1623
1624 lwg = lwgeom_from_wkt("LINESTRING(2 48, 2 49)", LW_PARSER_CHECK_NONE);
1625 length = lwgeom_length(lwg);
1626 CU_ASSERT_DOUBLE_EQUAL(length, 1.0, 0.001);
1627 result = geography_substring((LWLINE*)lwg, &s, 0.0, 1.0, 0.01);
1628 length = lwgeom_length(result);
1629 CU_ASSERT_DOUBLE_EQUAL(length, 1.0, 0.001);
1630 lwgeom_free(lwg);
1632
1633 lwg = lwgeom_from_wkt("LINESTRING(2 48)", LW_PARSER_CHECK_NONE);
1634 length = lwgeom_length(lwg);
1635 CU_ASSERT_DOUBLE_EQUAL(length, 0.0, 0.001);
1636 result = geography_substring((LWLINE*)lwg, &s, 0.0, 1.0, 0.01);
1637 length = lwgeom_length(result);
1638 CU_ASSERT_DOUBLE_EQUAL(length, 0.0, 0.001);
1639 lwgeom_free(lwg);
1641}
char * s
Definition cu_in_wkt.c:23
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
#define LW_PARSER_CHECK_NONE
Definition liblwgeom.h:2149
LWGEOM * geography_substring(const LWLINE *line, const SPHEROID *s, double from, double to, double tolerance)
Return the part of a line between two fractional locations.
#define WGS84_RADIUS
Definition liblwgeom.h:148
double lwgeom_length(const LWGEOM *geom)
Definition lwgeom.c:2066
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
Definition lwspheroid.c:39
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition lwin_wkt.c:940

References geography_substring(), LW_PARSER_CHECK_NONE, lwgeom_free(), lwgeom_from_wkt(), lwgeom_length(), result, s, spheroid_init(), and WGS84_RADIUS.

Referenced by geodetic_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: