lwgeom_free(gout);
lwgeom_free(gin);
+ /* Test unclosed polygon */
+
+ gin = lwgeom_from_hexwkb(
+"0103000000010000000400000000000000000024400000000000003640000000000000244000000000000040400000000000003440000000000000404000000000000034400000000000003640",
+ LW_PARSER_CHECK_NONE);
+ CU_ASSERT(gin != NULL);
+
+ gout = lwgeom_make_valid(gin);
+ CU_ASSERT(gout != NULL);
+
+ ewkt = lwgeom_to_ewkt(gout);
+ /* printf("c = %s\n", ewkt); */
+ CU_ASSERT_STRING_EQUAL(ewkt,
+"POLYGON((10 22,10 32,20 32,20 22,10 22))");
+ lwfree(ewkt);
+
+ lwgeom_free(gout);
+ lwgeom_free(gin);
+
#endif /* POSTGIS_GEOS_VERSION >= 33 */
}
ring_make_geos_friendly(POINTARRAY* ring)
{
POINTARRAY* closedring;
+ POINTARRAY* ring_in = ring;
/* close the ring if not already closed (2d only) */
closedring = ptarray_close2d(ring);
if (closedring != ring )
{
- ptarray_free(ring); /* should we do this ? */
ring = closedring;
}
while ( ring->npoints < 4 )
{
+ POINTARRAY *oring = ring;
LWDEBUGF(4, "ring has %d points, adding another", ring->npoints);
/* let's add another... */
ring = ptarray_addPoint(ring,
getPoint_internal(ring, 0),
FLAGS_NDIMS(ring->flags),
ring->npoints);
+ if ( oring != ring_in ) ptarray_free(oring);
}
if ( ring_in != ring_out )
{
LWDEBUGF(3, "lwpoly_make_geos_friendly: ring %d cleaned, now has %d points", i, ring_out->npoints);
- /* this may come right from
- * the binary representation lands
- */
- /*ptarray_free(ring_in); */
+ ptarray_free(ring_in);
}
else
{