[postgis-tickets] r15965 - Fix rare missing boxes in geometry subdivision
Paul Ramsey
pramsey at cleverelephant.ca
Wed Oct 11 07:05:26 PDT 2017
Author: pramsey
Date: 2017-10-11 07:05:25 -0700 (Wed, 11 Oct 2017)
New Revision: 15965
Modified:
branches/2.4/NEWS
branches/2.4/liblwgeom/lwgeom_geos.c
Log:
Fix rare missing boxes in geometry subdivision
References #3886
Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS 2017-10-11 13:51:10 UTC (rev 15964)
+++ branches/2.4/NEWS 2017-10-11 14:05:25 UTC (rev 15965)
@@ -15,6 +15,7 @@
- #3882, undefined behaviour in zigzag with negative inputs
- #3891, undefined behaviour in pointarray_to_encoded_polyline
- #3895, throw error on malformed WKB input
+ - #3886, fix rare missing boxes in geometry subdivision
PostGIS 2.4.0
Modified: branches/2.4/liblwgeom/lwgeom_geos.c
===================================================================
--- branches/2.4/liblwgeom/lwgeom_geos.c 2017-10-11 13:51:10 UTC (rev 15964)
+++ branches/2.4/liblwgeom/lwgeom_geos.c 2017-10-11 14:05:25 UTC (rev 15965)
@@ -262,19 +262,25 @@
if ( autofix )
{
- /* check ring for being closed and fix if not */
- if ( ! ptarray_is_closed_2d(pa) )
+ if (pa->npoints < 1)
{
- npa = ptarray_addPoint(pa, getPoint_internal(pa, 0), FLAGS_NDIMS(pa->flags), pa->npoints);
- pa = npa;
+ lwerror("ptarray_to_GEOSLinearRing called with autofix and 0 vertices in ring, cannot fix");
}
- /* TODO: check ring for having at least 4 vertices */
-#if 0
+
+ /*
+ * Check ring for being closed and fix if not.
+ * Also create a copy of geometry to operate on.
+ */
+ if ( ! ptarray_is_closed_2d(pa) || pa->npoints < 4 )
+ {
+ pa = ptarray_addPoint(pa, getPoint_internal(pa, 0), FLAGS_NDIMS(pa->flags), pa->npoints);
+ npa = pa;
+ }
+ /* Check ring for having at least 4 vertices */
while ( pa->npoints < 4 )
{
- npa = ptarray_addPoint(npa, getPoint_internal(pa, 0), FLAGS_NDIMS(pa->flags), pa->npoints);
+ ptarray_append_point(pa, getPoint_internal(pa, 0), LW_TRUE);
}
-#endif
}
sq = ptarray_to_GEOSCoordSeq(pa);
More information about the postgis-tickets
mailing list