PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ test_lwgeom_segmentize2d()

static void test_lwgeom_segmentize2d ( void  )
static

Definition at line 404 of file cu_measures.c.

References LW_PARSER_CHECK_NONE, lwfree(), lwgeom_free(), lwgeom_from_wkt(), lwgeom_request_interrupt(), lwgeom_segmentize2d(), and lwgeom_to_ewkt().

Referenced by measures_suite_setup().

405 {
406  LWGEOM *linein = lwgeom_from_wkt("LINESTRING(0 0,10 0)", LW_PARSER_CHECK_NONE);
407  LWGEOM *lineout = lwgeom_segmentize2d(linein, 5);
408  char *strout = lwgeom_to_ewkt(lineout);
409  CU_ASSERT_STRING_EQUAL(strout, "LINESTRING(0 0,5 0,10 0)");
410  lwfree(strout);
411  lwgeom_free(linein);
412  lwgeom_free(lineout);
413 
414  /* test interruption */
415 
416  linein = lwgeom_from_wkt("LINESTRING(0 0,10 0)", LW_PARSER_CHECK_NONE);
418  lineout = lwgeom_segmentize2d(linein, 1e-100);
419  CU_ASSERT_EQUAL(lineout, NULL);
420  lwgeom_free(linein);
421 
422  linein = lwgeom_from_wkt("MULTILINESTRING((0 0,10 0),(20 0, 30 0))", LW_PARSER_CHECK_NONE);
424  lineout = lwgeom_segmentize2d(linein, 1e-100);
425  CU_ASSERT_EQUAL(lineout, NULL);
426  lwgeom_free(linein);
427 
428  linein = lwgeom_from_wkt(
429  "MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6)),((40 0,40 20,60 20,60 0,40 0),(42 2,42 4,44 4,44 2,42 2)))"
432  lineout = lwgeom_segmentize2d(linein, 1e-100);
433  CU_ASSERT_EQUAL(lineout, NULL);
434  lwgeom_free(linein);
435 
436  linein = lwgeom_from_wkt(
437  "GEOMETRYCOLLECTION(MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6)),((40 0,40 20,60 20,60 0,40 0),(42 2,42 4,44 4,44 2,42 2))),MULTILINESTRING((0 0,10 0),(20 0, 30 0)),MULTIPOINT(0 0, 3 4))"
439  CU_ASSERT_FATAL(linein != NULL);
441  lineout = lwgeom_segmentize2d(linein, 1e-100);
442  CU_ASSERT_EQUAL(lineout, NULL);
443  lwgeom_free(linein);
444 
445  linein = lwgeom_from_wkt("LINESTRING(20 0, 30 0)", LW_PARSER_CHECK_NONE);
446  /* NOT INTERRUPTED */
447  lineout = lwgeom_segmentize2d(linein, 5);
448  strout = lwgeom_to_ewkt(lineout);
449  CU_ASSERT_STRING_EQUAL(strout, "LINESTRING(20 0,25 0,30 0)");
450  lwfree(strout);
451  lwgeom_free(linein);
452  lwgeom_free(lineout);
453 }
void lwfree(void *mem)
Definition: lwutil.c:214
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:469
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:890
void lwgeom_request_interrupt(void)
Request interruption of any running code.
Definition: lwgeom_api.c:824
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1869
LWGEOM * lwgeom_segmentize2d(LWGEOM *line, double dist)
Definition: lwgeom.c:668
Here is the call graph for this function:
Here is the caller graph for this function: