PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ test_lwgeom_is_trajectory()

static void test_lwgeom_is_trajectory ( void  )
static

Definition at line 1336 of file cu_measures.c.

References ASSERT_INT_EQUAL, LW_FALSE, LW_PARSER_CHECK_NONE, LW_TRUE, lwgeom_free(), lwgeom_from_wkt(), lwgeom_is_trajectory(), and measures_suite_setup().

Referenced by measures_suite_setup().

1337 {
1338  LWGEOM *g;
1339  int ret;
1340 
1341  g = lwgeom_from_wkt("POINT M(0 0 1)", LW_PARSER_CHECK_NONE);
1342  ret = lwgeom_is_trajectory(g);
1343  lwgeom_free(g);
1344  ASSERT_INT_EQUAL(ret, LW_FALSE); /* not a linestring */
1345 
1346  g = lwgeom_from_wkt("LINESTRING Z(0 0 1, 0 0 1)", LW_PARSER_CHECK_NONE);
1347  ret = lwgeom_is_trajectory(g);
1348  lwgeom_free(g);
1349  ASSERT_INT_EQUAL(ret, LW_FALSE); /* no measure */
1350 
1351  g = lwgeom_from_wkt("LINESTRING M(0 0 1, 0 0 1)", LW_PARSER_CHECK_NONE);
1352  ret = lwgeom_is_trajectory(g);
1353  lwgeom_free(g);
1354  ASSERT_INT_EQUAL(ret, LW_FALSE); /* same measure in two points */
1355 
1356  g = lwgeom_from_wkt("LINESTRING M(0 0 1, 0 0 0)", LW_PARSER_CHECK_NONE);
1357  ret = lwgeom_is_trajectory(g);
1358  lwgeom_free(g);
1359  ASSERT_INT_EQUAL(ret, LW_FALSE); /* backward measure */
1360 
1361  g = lwgeom_from_wkt("LINESTRING M(0 0 1, 1 0 3, 2 2 2)", LW_PARSER_CHECK_NONE);
1362  ret = lwgeom_is_trajectory(g);
1363  lwgeom_free(g);
1364  ASSERT_INT_EQUAL(ret, LW_FALSE); /* backward measure */
1365 
1366  g = lwgeom_from_wkt("LINESTRING M(0 0 1, 0 0 2)", LW_PARSER_CHECK_NONE);
1367  ret = lwgeom_is_trajectory(g);
1368  lwgeom_free(g);
1369  ASSERT_INT_EQUAL(ret, LW_TRUE); /* ok (still) */
1370 
1371  g = lwgeom_from_wkt("LINESTRING M EMPTY", LW_PARSER_CHECK_NONE);
1372  ret = lwgeom_is_trajectory(g);
1373  lwgeom_free(g);
1374  ASSERT_INT_EQUAL(ret, LW_TRUE); /* ok (empty) */
1375 
1376  g = lwgeom_from_wkt("LINESTRING M (0 0 1)", LW_PARSER_CHECK_NONE);
1377  ret = lwgeom_is_trajectory(g);
1378  lwgeom_free(g);
1379  ASSERT_INT_EQUAL(ret, LW_TRUE); /* ok (corner case) */
1380 }
int lwgeom_is_trajectory(const LWGEOM *geom)
Return LW_TRUE or LW_FALSE depending on whether or not a geometry is a linestring with measure value ...
Definition: lwgeom.c:2449
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2004
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
#define ASSERT_INT_EQUAL(o, e)
Here is the call graph for this function:
Here is the caller graph for this function: