PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_lwgeom_is_trajectory()

static void test_lwgeom_is_trajectory ( void  )
static

Definition at line 1285 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().

1286 {
1287  LWGEOM *g;
1288  int ret;
1289 
1290  g = lwgeom_from_wkt("POINT M(0 0 1)", LW_PARSER_CHECK_NONE);
1291  ret = lwgeom_is_trajectory(g);
1292  lwgeom_free(g);
1293  ASSERT_INT_EQUAL(ret, LW_FALSE); /* not a linestring */
1294 
1295  g = lwgeom_from_wkt("LINESTRING Z(0 0 1, 0 0 1)", LW_PARSER_CHECK_NONE);
1296  ret = lwgeom_is_trajectory(g);
1297  lwgeom_free(g);
1298  ASSERT_INT_EQUAL(ret, LW_FALSE); /* no measure */
1299 
1300  g = lwgeom_from_wkt("LINESTRING M(0 0 1, 0 0 1)", LW_PARSER_CHECK_NONE);
1301  ret = lwgeom_is_trajectory(g);
1302  lwgeom_free(g);
1303  ASSERT_INT_EQUAL(ret, LW_FALSE); /* same measure in two points */
1304 
1305  g = lwgeom_from_wkt("LINESTRING M(0 0 1, 0 0 0)", LW_PARSER_CHECK_NONE);
1306  ret = lwgeom_is_trajectory(g);
1307  lwgeom_free(g);
1308  ASSERT_INT_EQUAL(ret, LW_FALSE); /* backward measure */
1309 
1310  g = lwgeom_from_wkt("LINESTRING M(0 0 1, 1 0 3, 2 2 2)", LW_PARSER_CHECK_NONE);
1311  ret = lwgeom_is_trajectory(g);
1312  lwgeom_free(g);
1313  ASSERT_INT_EQUAL(ret, LW_FALSE); /* backward measure */
1314 
1315  g = lwgeom_from_wkt("LINESTRING M(0 0 1, 0 0 2)", LW_PARSER_CHECK_NONE);
1316  ret = lwgeom_is_trajectory(g);
1317  lwgeom_free(g);
1318  ASSERT_INT_EQUAL(ret, LW_TRUE); /* ok (still) */
1319 
1320  g = lwgeom_from_wkt("LINESTRING M EMPTY", LW_PARSER_CHECK_NONE);
1321  ret = lwgeom_is_trajectory(g);
1322  lwgeom_free(g);
1323  ASSERT_INT_EQUAL(ret, LW_TRUE); /* ok (empty) */
1324 
1325  g = lwgeom_from_wkt("LINESTRING M (0 0 1)", LW_PARSER_CHECK_NONE);
1326  ret = lwgeom_is_trajectory(g);
1327  lwgeom_free(g);
1328  ASSERT_INT_EQUAL(ret, LW_TRUE); /* ok (corner case) */
1329 }
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:2080
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
#define LW_FALSE
Definition: liblwgeom.h:77
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
#define ASSERT_INT_EQUAL(o, e)
Here is the call graph for this function:
Here is the caller graph for this function: