PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_lwgeom_segmentize2d()

static void test_lwgeom_segmentize2d ( void  )
static

Definition at line 563 of file cu_measures.c.

564 {
565  LWGEOM *linein = lwgeom_from_wkt("LINESTRING(0 0,10 0)", LW_PARSER_CHECK_NONE);
566  LWGEOM *lineout = lwgeom_segmentize2d(linein, 5);
567  char *strout = lwgeom_to_ewkt(lineout);
568  ASSERT_STRING_EQUAL(strout, "LINESTRING(0 0,5 0,10 0)");
569  lwfree(strout);
570  lwgeom_free(linein);
571  lwgeom_free(lineout);
572 
573  /* test interruption */
574 
575  linein = lwgeom_from_wkt("LINESTRING(0 0,10 0)", LW_PARSER_CHECK_NONE);
577  lineout = lwgeom_segmentize2d(linein, 1e-100);
578  CU_ASSERT_EQUAL(lineout, NULL);
579  lwgeom_free(linein);
580 
581  linein = lwgeom_from_wkt("MULTILINESTRING((0 0,10 0),(20 0, 30 0))", LW_PARSER_CHECK_NONE);
583  lineout = lwgeom_segmentize2d(linein, 1e-100);
584  CU_ASSERT_EQUAL(lineout, NULL);
585  lwgeom_free(linein);
586 
587  linein = lwgeom_from_wkt(
588  "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)))"
591  lineout = lwgeom_segmentize2d(linein, 1e-100);
592  CU_ASSERT_EQUAL(lineout, NULL);
593  lwgeom_free(linein);
594 
595  linein = lwgeom_from_wkt(
596  "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))"
598  CU_ASSERT_FATAL(linein != NULL);
600  lineout = lwgeom_segmentize2d(linein, 1e-100);
601  CU_ASSERT_EQUAL(lineout, NULL);
602  lwgeom_free(linein);
603 
604  linein = lwgeom_from_wkt("LINESTRING(20 0, 30 0)", LW_PARSER_CHECK_NONE);
605  /* NOT INTERRUPTED */
606  lineout = lwgeom_segmentize2d(linein, 5);
607  strout = lwgeom_to_ewkt(lineout);
608  ASSERT_STRING_EQUAL(strout, "LINESTRING(20 0,25 0,30 0)");
609  lwfree(strout);
610  lwgeom_free(linein);
611  lwgeom_free(lineout);
612 }
#define ASSERT_STRING_EQUAL(o, e)
void lwgeom_request_interrupt(void)
Request interruption of any running code.
Definition: lwgeom_api.c:728
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2005
LWGEOM * lwgeom_segmentize2d(const LWGEOM *line, double dist)
Definition: lwgeom.c:762
char * lwgeom_to_ewkt(const LWGEOM *lwgeom)
Return an alloced string.
Definition: lwgeom.c:556
void lwfree(void *mem)
Definition: lwutil.c:244
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904

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().

Here is the call graph for this function:
Here is the caller graph for this function: