PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ test_lwgeom_segmentize2d()

static void test_lwgeom_segmentize2d ( void  )
static

Definition at line 511 of file cu_measures.c.

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

Referenced by measures_suite_setup().

512 {
513  LWGEOM *linein = lwgeom_from_wkt("LINESTRING(0 0,10 0)", LW_PARSER_CHECK_NONE);
514  LWGEOM *lineout = lwgeom_segmentize2d(linein, 5);
515  char *strout = lwgeom_to_ewkt(lineout);
516  ASSERT_STRING_EQUAL(strout, "LINESTRING(0 0,5 0,10 0)");
517  lwfree(strout);
518  lwgeom_free(linein);
519  lwgeom_free(lineout);
520 
521  /* test interruption */
522 
523  linein = lwgeom_from_wkt("LINESTRING(0 0,10 0)", LW_PARSER_CHECK_NONE);
525  lineout = lwgeom_segmentize2d(linein, 1e-100);
526  CU_ASSERT_EQUAL(lineout, NULL);
527  lwgeom_free(linein);
528 
529  linein = lwgeom_from_wkt("MULTILINESTRING((0 0,10 0),(20 0, 30 0))", LW_PARSER_CHECK_NONE);
531  lineout = lwgeom_segmentize2d(linein, 1e-100);
532  CU_ASSERT_EQUAL(lineout, NULL);
533  lwgeom_free(linein);
534 
535  linein = lwgeom_from_wkt(
536  "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)))"
539  lineout = lwgeom_segmentize2d(linein, 1e-100);
540  CU_ASSERT_EQUAL(lineout, NULL);
541  lwgeom_free(linein);
542 
543  linein = lwgeom_from_wkt(
544  "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))"
546  CU_ASSERT_FATAL(linein != NULL);
548  lineout = lwgeom_segmentize2d(linein, 1e-100);
549  CU_ASSERT_EQUAL(lineout, NULL);
550  lwgeom_free(linein);
551 
552  linein = lwgeom_from_wkt("LINESTRING(20 0, 30 0)", LW_PARSER_CHECK_NONE);
553  /* NOT INTERRUPTED */
554  lineout = lwgeom_segmentize2d(linein, 5);
555  strout = lwgeom_to_ewkt(lineout);
556  ASSERT_STRING_EQUAL(strout, "LINESTRING(20 0,25 0,30 0)");
557  lwfree(strout);
558  lwgeom_free(linein);
559  lwgeom_free(lineout);
560 }
void lwfree(void *mem)
Definition: lwutil.c:244
#define ASSERT_STRING_EQUAL(o, e)
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:556
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
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:718
LWGEOM * lwgeom_segmentize2d(const LWGEOM *line, double dist)
Definition: lwgeom.c:762
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2004
Here is the call graph for this function:
Here is the caller graph for this function: