PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ test_geos_subdivide()

static void test_geos_subdivide ( void  )
static

Definition at line 131 of file cu_geos.c.

References geos_suite_setup(), LW_PARSER_CHECK_NONE, lwcollection_free(), lwfree(), lwgeom_free(), lwgeom_from_wkt(), lwgeom_segmentize_sphere(), lwgeom_subdivide(), and lwgeom_to_ewkt().

Referenced by geos_suite_setup().

132 {
133 #if POSTGIS_GEOS_VERSION < 35
134  return;
135 #else
136  char *ewkt = "LINESTRING(0 0, 10 10)";
137  char *out_ewkt;
139  /* segmentize as geography to generate a non-simple curve */
140  LWGEOM *geom2 = lwgeom_segmentize_sphere(geom1, 0.002);
141 
142  LWCOLLECTION *geom3 = lwgeom_subdivide(geom2, 80);
143  out_ewkt = lwgeom_to_ewkt((LWGEOM*)geom3);
144  // printf("\n--------\n%s\n--------\n", out_ewkt);
145  CU_ASSERT_EQUAL(2, geom3->ngeoms);
146  lwfree(out_ewkt);
147  lwcollection_free(geom3);
148 
149  geom3 = lwgeom_subdivide(geom2, 20);
150  out_ewkt = lwgeom_to_ewkt((LWGEOM*)geom3);
151  // printf("\n--------\n%s\n--------\n", out_ewkt);
152  CU_ASSERT_EQUAL(8, geom3->ngeoms);
153  lwfree(out_ewkt);
154  lwcollection_free(geom3);
155 
156  lwgeom_free(geom2);
157  lwgeom_free(geom1);
158 #endif
159 }
void lwfree(void *mem)
Definition: lwutil.c:244
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
uint32_t ngeoms
Definition: liblwgeom.h:509
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2004
LWCOLLECTION * lwgeom_subdivide(const LWGEOM *geom, uint32_t maxvertices)
Definition: lwgeom.c:2412
LWGEOM * lwgeom_segmentize_sphere(const LWGEOM *lwg_in, double max_seg_length)
Derive a new geometry with vertices added to ensure no vertex is more than max_seg_length (in radians...
Definition: lwgeodetic.c:1656
void lwcollection_free(LWCOLLECTION *col)
Definition: lwcollection.c:356
Here is the call graph for this function:
Here is the caller graph for this function: