]> granicus.if.org Git - postgis/commitdiff
Use GEOSMakeValid and GEOSBuildArea for GEOS 3.8+
authorDaniel Baston <dbaston@gmail.com>
Sat, 14 Sep 2019 19:04:46 +0000 (19:04 +0000)
committerDaniel Baston <dbaston@gmail.com>
Sat, 14 Sep 2019 19:04:46 +0000 (19:04 +0000)
Fixes #4507
Closes https://github.com/postgis/postgis/pull/477

git-svn-id: http://svn.osgeo.org/postgis/trunk@17810 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
liblwgeom/lwgeom_geos.c
liblwgeom/lwgeom_geos.h
liblwgeom/lwgeom_geos_clean.c
postgis/mvt.c

diff --git a/NEWS b/NEWS
index 1d67b5ff473805ec56adcf713ba3e5ef3560205f..acaabc9cfcf5c9f5b468042ae7418f5e7c520f8f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ Additional features enabled if you are running Proj6+ and PostgreSQL 12
   - #4501, Allow postgis_tiger_geocoder to be installable by non-super users (Regina Obe)
   - #4503, Speed up the calculation of cartesian bbox (Raúl Marín)
   - #4504, shp2pgsql -D not working with schema qualified tables
+  - #4507, Use GEOSMakeValid and GEOSBuildArea for GEOS 3.8+ (Dan Baston)
 
 PostGIS 3.0.0alpha4
 2019/08/10
index de6c7f1e2a43cae4de6640d9c8e8cd7c1a944de9..6b2914d400db3673c158f51c81cca891f39c295c 100644 (file)
@@ -919,7 +919,7 @@ lwgeom_clip_by_rect(const LWGEOM *geom1, double x1, double y1, double x2, double
 }
 
 /* ------------ BuildArea stuff ---------------------------------------------------------------------{ */
-
+#if POSTGIS_GEOS_VERSION < 38
 typedef struct Face_t
 {
        const GEOSGeometry* geom;
@@ -1165,6 +1165,7 @@ LWGEOM_GEOS_buildArea(const GEOSGeometry* geom_in)
 
        return shp;
 }
+#endif
 
 LWGEOM*
 lwgeom_buildarea(const LWGEOM* geom)
@@ -1183,7 +1184,11 @@ lwgeom_buildarea(const LWGEOM* geom)
 
        if (!(g1 = LWGEOM2GEOS(geom, AUTOFIX))) GEOS_FAIL();
 
+#if POSTGIS_GEOS_VERSION < 38
        g3 = LWGEOM_GEOS_buildArea(g1);
+#else
+       g3 = GEOSBuildArea(g1);
+#endif
 
        if (!g3) GEOS_FREE_AND_FAIL(g1);
        GEOSSetSRID(g3, srid);
index 9845cff11578379580ca6f7f856aba4ccb73df55..ae21aef794fe568908df387204591f3808523d6b 100644 (file)
 LWGEOM* GEOS2LWGEOM(const GEOSGeometry* geom, uint8_t want3d);
 GEOSGeometry* LWGEOM2GEOS(const LWGEOM* g, uint8_t autofix);
 GEOSGeometry* GBOX2GEOS(const GBOX* g);
+#if POSTGIS_GEOS_VERSION < 38
 GEOSGeometry* LWGEOM_GEOS_buildArea(const GEOSGeometry* geom_in);
 GEOSGeometry* LWGEOM_GEOS_makeValid(const GEOSGeometry*);
+#endif
 
 GEOSGeometry* make_geos_point(double x, double y);
 GEOSGeometry* make_geos_segment(double x1, double y1, double x2, double y2);
index 7cc9c76d5d699d83474af52388daa92c7b9a1d29..9ef310875defae115e3de44554df202d66d8ae4f 100644 (file)
@@ -35,6 +35,7 @@
 /* #define PARANOIA_LEVEL 2 */
 #undef LWGEOM_PROFILE_MAKEVALID
 
+#if POSTGIS_GEOS_VERSION < 38
 /*
  * Return Nth vertex in GEOSGeometry as a POINT.
  * May return NULL if the geometry has NO vertex.
@@ -108,6 +109,7 @@ LWGEOM_GEOS_getPointN(const GEOSGeometry* g_in, uint32_t n)
 
        return GEOSGeom_createPoint(seq_out);
 }
+#endif
 
 LWGEOM* lwcollection_make_geos_friendly(LWCOLLECTION* g);
 LWGEOM* lwline_make_geos_friendly(LWLINE* line);
@@ -314,6 +316,8 @@ lwcollection_make_geos_friendly(LWCOLLECTION* g)
        return (LWGEOM*)ret;
 }
 
+#if POSTGIS_GEOS_VERSION < 38
+
 /*
  * Fully node given linework
  */
@@ -843,6 +847,7 @@ LWGEOM_GEOS_makeValid(const GEOSGeometry* gin)
 
        return gout;
 }
+#endif
 
 /* Exported. Uses GEOS internally */
 LWGEOM*
@@ -889,7 +894,11 @@ lwgeom_make_valid(LWGEOM* lwgeom_in)
                lwgeom_out = lwgeom_in;
        }
 
+#if POSTGIS_GEOS_VERSION < 38
        geosout = LWGEOM_GEOS_makeValid(geosgeom);
+#else
+       geosout = GEOSMakeValid(geosgeom);
+#endif
        GEOSGeom_destroy(geosgeom);
        if (!geosout) return NULL;
 
index 495e6435912fcdafbd8db5259aae04caf3825513..e1fc08540299be45749b39a2a3e28d5af071c1dc 100644 (file)
@@ -1050,7 +1050,12 @@ mvt_grid_and_validate_geos(LWGEOM *ng, uint8_t basic_type)
 
                while (!valid && iterations < max_iterations)
                {
+#if POSTGIS_GEOS_VERSION < 38
                        GEOSGeometry *geo_valid = LWGEOM_GEOS_makeValid(geo);
+#else
+                       GEOSGeometry *geo_valid = GEOSMakeValid(geo);
+#endif
+
                        GEOSGeom_destroy(geo);
                        if (!geo_valid)
                                return NULL;