PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_lwgeom_segmentize2d()

static void test_lwgeom_segmentize2d ( void  )
static

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

451 {
452  LWGEOM *linein = lwgeom_from_wkt("LINESTRING(0 0,10 0)", LW_PARSER_CHECK_NONE);
453  LWGEOM *lineout = lwgeom_segmentize2d(linein, 5);
454  char *strout = lwgeom_to_ewkt(lineout);
455  CU_ASSERT_STRING_EQUAL(strout, "LINESTRING(0 0,5 0,10 0)");
456  lwfree(strout);
457  lwgeom_free(linein);
458  lwgeom_free(lineout);
459 
460  /* test interruption */
461 
462  linein = lwgeom_from_wkt("LINESTRING(0 0,10 0)", LW_PARSER_CHECK_NONE);
464  lineout = lwgeom_segmentize2d(linein, 1e-100);
465  CU_ASSERT_EQUAL(lineout, NULL);
466  lwgeom_free(linein);
467 
468  linein = lwgeom_from_wkt("MULTILINESTRING((0 0,10 0),(20 0, 30 0))", LW_PARSER_CHECK_NONE);
470  lineout = lwgeom_segmentize2d(linein, 1e-100);
471  CU_ASSERT_EQUAL(lineout, NULL);
472  lwgeom_free(linein);
473 
474  linein = lwgeom_from_wkt(
475  "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)))"
478  lineout = lwgeom_segmentize2d(linein, 1e-100);
479  CU_ASSERT_EQUAL(lineout, NULL);
480  lwgeom_free(linein);
481 
482  linein = lwgeom_from_wkt(
483  "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))"
485  CU_ASSERT_FATAL(linein != NULL);
487  lineout = lwgeom_segmentize2d(linein, 1e-100);
488  CU_ASSERT_EQUAL(lineout, NULL);
489  lwgeom_free(linein);
490 
491  linein = lwgeom_from_wkt("LINESTRING(20 0, 30 0)", LW_PARSER_CHECK_NONE);
492  /* NOT INTERRUPTED */
493  lineout = lwgeom_segmentize2d(linein, 5);
494  strout = lwgeom_to_ewkt(lineout);
495  CU_ASSERT_STRING_EQUAL(strout, "LINESTRING(20 0,25 0,30 0)");
496  lwfree(strout);
497  lwgeom_free(linein);
498  lwgeom_free(lineout);
499 }
void lwfree(void *mem)
Definition: lwutil.c:244
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:518
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
void lwgeom_request_interrupt(void)
Request interruption of any running code.
Definition: lwgeom_api.c:698
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2013
LWGEOM * lwgeom_segmentize2d(LWGEOM *line, double dist)
Definition: lwgeom.c:717
Here is the call graph for this function:
Here is the caller graph for this function: