#3365, remove code paths for POSTGIS_GEOS_VERSION < 33
authorDaniel Baston <dbaston@gmail.com>
Tue, 1 Dec 2015 23:16:41 +0000 (23:16 +0000)
committerDaniel Baston <dbaston@gmail.com>
Tue, 1 Dec 2015 23:16:41 +0000 (23:16 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@14466 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_clean.c
liblwgeom/cunit/cu_node.c
liblwgeom/cunit/cu_split.c
liblwgeom/lwgeom_geos.c
liblwgeom/lwgeom_geos_clean.c
liblwgeom/lwgeom_geos_node.c
postgis/lwgeom_geos.c
postgis/lwgeom_geos_clean.c
postgis/lwgeom_geos_relatematch.c
raster/rt_core/rt_geometry.c
raster/test/cunit/cu_raster_geometry.c

index df313654289f399af2b2f9c152eabeba5b4ee910..98f91f7df8e46557c404c23433a53e2355cc0c6c 100644 (file)
@@ -41,7 +41,6 @@
        
 static void test_lwgeom_make_valid(void)
 {
-#if POSTGIS_GEOS_VERSION >= 33
        LWGEOM *gin, *gout, *gexp;
        char *ewkt;
 
@@ -148,8 +147,6 @@ static void test_lwgeom_make_valid(void)
 
        lwgeom_free(gout);
        lwgeom_free(gin);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
 }
 
 /* TODO: add more tests ! */
index a1aa5c6aa0897d3d7fb3c6eb98c4e96f799ee18e..a88241e86196c268636f74659498f2af765fe532 100644 (file)
@@ -18,7 +18,6 @@
 
 static void test_lwgeom_node(void)
 {
-#if POSTGIS_GEOS_VERSION >= 33
        LWGEOM *in, *out;
        const char *wkt;
        char *tmp;
@@ -57,7 +56,6 @@ static void test_lwgeom_node(void)
 "MULTILINESTRING((0 0,2.5 2.5),(0 5,2.5 2.5),(22 0,20 0),(20 0,12 0,11 0,10 0),(10 0,5 5,2.5 2.5),(2.5 2.5,5 0))",
                tmp);
        lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
 }
 
 /*
index 205b9a5e40ddc5d04ca78e03501d5264472bd32e..285491e9d48fa8d6370b1087b3ea370c7f8331a4 100644 (file)
@@ -18,7 +18,6 @@
 
 static void test_lwline_split_by_point_to(void)
 {
-#if POSTGIS_GEOS_VERSION >= 33
        LWLINE *line;
        LWPOINT *point;
        LWMLINE *coll;
@@ -76,8 +75,6 @@ static void test_lwline_split_by_point_to(void)
 
        lwcollection_free((LWCOLLECTION*)coll);
        lwline_free(line);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
 }
 
 static void test_lwgeom_split(void)
index a6f0c16e01732589d35af6292292f6665b536a69..e297317f66aab3d021f1bb2daeb3f63c6095298b 100644 (file)
@@ -227,15 +227,6 @@ ptarray_to_GEOSCoordSeq(const POINTARRAY *pa)
                        LWDEBUGF(4, "Point: %g,%g", p2d->x, p2d->y);
                }
 
-#if POSTGIS_GEOS_VERSION < 33
-               /* Make sure we don't pass any infinite values down into GEOS */
-               /* GEOS 3.3+ is supposed to  handle this stuff OK */
-               if ( isinf(p2d->x) || isinf(p2d->y) || (dims == 3 && isinf(p3d->z)) )
-                       lwerror("Infinite coordinate value found in geometry.");
-               if ( isnan(p2d->x) || isnan(p2d->y) || (dims == 3 && isnan(p3d->z)) )
-                       lwerror("NaN coordinate value found in geometry.");
-#endif
-
                GEOSCoordSeq_setX(sq, i, p2d->x);
                GEOSCoordSeq_setY(sq, i, p2d->y);
                
@@ -349,23 +340,13 @@ LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
                LWPOLY *lwpoly = NULL;
                LWLINE *lwl = NULL;
                LWCOLLECTION *lwc = NULL;
-#if POSTGIS_GEOS_VERSION < 33
-               POINTARRAY *pa = NULL;
-#endif
                
        case POINTTYPE:
                lwp = (LWPOINT *)lwgeom;
                
                if ( lwgeom_is_empty(lwgeom) )
                {
-#if POSTGIS_GEOS_VERSION < 33
-                       pa = ptarray_construct_empty(lwgeom_has_z(lwgeom), lwgeom_has_m(lwgeom), 2);
-                       sq = ptarray_to_GEOSCoordSeq(pa);
-                       shell = GEOSGeom_createLinearRing(sq);
-                       g = GEOSGeom_createPolygon(shell, NULL, 0);
-#else
                        g = GEOSGeom_createEmptyPolygon();
-#endif
                }
                else
                {
@@ -401,14 +382,7 @@ LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
                lwpoly = (LWPOLY *)lwgeom;
                if ( lwgeom_is_empty(lwgeom) )
                {
-#if POSTGIS_GEOS_VERSION < 33
-                       POINTARRAY *pa = ptarray_construct_empty(lwgeom_has_z(lwgeom), lwgeom_has_m(lwgeom), 2);
-                       sq = ptarray_to_GEOSCoordSeq(pa);
-                       shell = GEOSGeom_createLinearRing(sq);
-                       g = GEOSGeom_createPolygon(shell, NULL, 0);
-#else
                        g = GEOSGeom_createEmptyPolygon();
-#endif
                }
                else
                {
@@ -1413,14 +1387,6 @@ lwgeom_geos_noop(const LWGEOM* geom_in)
 LWGEOM*
 lwgeom_snap(const LWGEOM* geom1, const LWGEOM* geom2, double tolerance)
 {
-#if POSTGIS_GEOS_VERSION < 33
-       lwerror("The GEOS version this lwgeom library "
-               "was compiled against (%d) doesn't support "
-               "'Snap' function (3.3.0+ required)",
-               POSTGIS_GEOS_VERSION);
-       return NULL;
-#else /* POSTGIS_GEOS_VERSION >= 33 */
-
        int srid, is3d;
        GEOSGeometry *g1, *g2, *g3;
        LWGEOM* out;
@@ -1470,20 +1436,11 @@ lwgeom_snap(const LWGEOM* geom1, const LWGEOM* geom2, double tolerance)
        GEOSGeom_destroy(g3);
 
        return out;
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
 }
 
 LWGEOM*
 lwgeom_sharedpaths(const LWGEOM* geom1, const LWGEOM* geom2)
 {
-#if POSTGIS_GEOS_VERSION < 33
-       lwerror("The GEOS version this postgis binary "
-               "was compiled against (%d) doesn't support "
-               "'SharedPaths' function (3.3.0+ required)",
-               POSTGIS_GEOS_VERSION);
-       return NULL;
-#else /* POSTGIS_GEOS_VERSION >= 33 */
        GEOSGeometry *g1, *g2, *g3;
        LWGEOM *out;
        int is3d, srid;
@@ -1532,15 +1489,11 @@ lwgeom_sharedpaths(const LWGEOM* geom1, const LWGEOM* geom2)
        }
 
        return out;
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
 }
 
 LWGEOM*
 lwgeom_offsetcurve(const LWLINE *lwline, double size, int quadsegs, int joinStyle, double mitreLimit)
 {
-#if POSTGIS_GEOS_VERSION < 32
-       lwerror("lwgeom_offsetcurve: GEOS 3.2 or higher required");
-#else
        GEOSGeometry *g1, *g3;
        LWGEOM *lwgeom_result;
        LWGEOM *lwgeom_in = lwline_as_lwgeom(lwline);
@@ -1554,14 +1507,8 @@ lwgeom_offsetcurve(const LWLINE *lwline, double size, int quadsegs, int joinStyl
                return NULL;
        }
 
-#if POSTGIS_GEOS_VERSION < 33
-       /* Size is always positive for GEOSSingleSidedBuffer, and a flag determines left/right */
-       g3 = GEOSSingleSidedBuffer(g1, size < 0 ? -size : size,
-                                  quadsegs, joinStyle, mitreLimit,
-                                  size < 0 ? 0 : 1);
-#else
        g3 = GEOSOffsetCurve(g1, size, quadsegs, joinStyle, mitreLimit);
-#endif
+
        /* Don't need input geometry anymore */
        GEOSGeom_destroy(g1);
 
@@ -1584,8 +1531,6 @@ lwgeom_offsetcurve(const LWLINE *lwline, double size, int quadsegs, int joinStyl
        }
 
        return lwgeom_result;
-       
-#endif /* POSTGIS_GEOS_VERSION < 32 */
 }
 
 LWTIN *lwtin_from_geos(const GEOSGeometry *geom, int want3d) {
index 9dd159e10a99b4c0be8cdd4d2fe058c4ad2d62f7..390082077c3f710a59719f43791b78c43be47a6d 100644 (file)
@@ -381,7 +381,6 @@ LWGEOM_GEOS_nodeLines(const GEOSGeometry* lines)
        return noded;
 }
 
-#if POSTGIS_GEOS_VERSION >= 33
 /*
  * We expect initGEOS being called already.
  * Will return NULL on error (expect error handler being called by then)
@@ -1066,5 +1065,3 @@ lwgeom_make_valid(LWGEOM* lwgeom_in)
        return lwgeom_out;
 }
 
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
-
index 61a089497560c9c39769959bb9bd8698ccaf1901..0bce801e16c2c7ba8114a741bcd95efdc1380a7b 100644 (file)
@@ -85,13 +85,6 @@ lwgeom_extract_endpoints(const LWGEOM* lwg)
 static LWGEOM*
 lwgeom_extract_unique_endpoints(const LWGEOM* lwg)
 {
-#if POSTGIS_GEOS_VERSION < 33
-       lwerror("The GEOS version this postgis binary "
-               "was compiled against (%d) doesn't support "
-               "'GEOSUnaryUnion' function (3.3.0+ required)",
-               POSTGIS_GEOS_VERSION);
-       return NULL;
-#else /* POSTGIS_GEOS_VERSION >= 33 */
        LWGEOM* ret;
        GEOSGeometry *gepu;
        LWMPOINT *epall = lwgeom_extract_endpoints(lwg);
@@ -120,7 +113,6 @@ lwgeom_extract_unique_endpoints(const LWGEOM* lwg)
        }
 
        return ret;
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
 }
 
 /* exported */
@@ -128,13 +120,6 @@ extern LWGEOM* lwgeom_node(const LWGEOM* lwgeom_in);
 LWGEOM*
 lwgeom_node(const LWGEOM* lwgeom_in)
 {
-#if POSTGIS_GEOS_VERSION < 33
-       lwerror("The GEOS version this postgis binary "
-               "was compiled against (%d) doesn't support "
-               "'GEOSUnaryUnion' function (3.3.0+ required)",
-               POSTGIS_GEOS_VERSION);
-       return NULL;
-#else /* POSTGIS_GEOS_VERSION >= 33 */
        GEOSGeometry *g1, *gu, *gm;
        LWGEOM *ep, *lines;
        LWCOLLECTION *col, *tc;
@@ -254,6 +239,5 @@ lwgeom_node(const LWGEOM* lwgeom_in)
 
        lines->srid = lwgeom_in->srid;
        return (LWGEOM*)lines;
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
 }
 
index b22f1c7078ec0982da132f785f8093fd859c69a8..fdf722d39332a02245a02a2526969d963f7112a9 100644 (file)
@@ -116,13 +116,6 @@ Datum postgis_geos_version(PG_FUNCTION_ARGS)
 PG_FUNCTION_INFO_V1(hausdorffdistance);
 Datum hausdorffdistance(PG_FUNCTION_ARGS)
 {
-#if POSTGIS_GEOS_VERSION < 32
-       lwpgerror("The GEOS version this PostGIS binary "
-               "was compiled against (%d) doesn't support "
-               "'ST_HausdorffDistance' function (3.2.0+ required)",
-               POSTGIS_GEOS_VERSION);
-       PG_RETURN_NULL();
-#else
        GSERIALIZED *geom1;
        GSERIALIZED *geom2;
        GEOSGeometry *g1;
@@ -169,7 +162,6 @@ Datum hausdorffdistance(PG_FUNCTION_ARGS)
        PG_FREE_IF_COPY(geom2, 1);
 
        PG_RETURN_FLOAT8(result);
-#endif
 }
 
 /**
@@ -182,13 +174,6 @@ Datum hausdorffdistance(PG_FUNCTION_ARGS)
 PG_FUNCTION_INFO_V1(hausdorffdistancedensify);
 Datum hausdorffdistancedensify(PG_FUNCTION_ARGS)
 {
-#if POSTGIS_GEOS_VERSION < 32
-       lwpgerror("The GEOS version this PostGIS binary "
-               "was compiled against (%d) doesn't support "
-               "'ST_HausdorffDistance' function (3.2.0+ required)",
-               POSTGIS_GEOS_VERSION);
-       PG_RETURN_NULL();
-#else
        GSERIALIZED *geom1;
        GSERIALIZED *geom2;
        GEOSGeometry *g1;
@@ -236,7 +221,6 @@ Datum hausdorffdistancedensify(PG_FUNCTION_ARGS)
        PG_FREE_IF_COPY(geom2, 1);
 
        PG_RETURN_FLOAT8(result);
-#endif
 }
 
 
@@ -250,7 +234,6 @@ Datum hausdorffdistancedensify(PG_FUNCTION_ARGS)
  */
 PG_FUNCTION_INFO_V1(pgis_union_geometry_array);
 Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
-#if POSTGIS_GEOS_VERSION >= 33
 {
        /*
        ** For GEOS >= 3.3, use the new UnaryUnion functionality to merge the
@@ -436,297 +419,6 @@ Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
        PG_RETURN_POINTER(gser_out);
 }
 
-#else
-{
-/* For GEOS < 3.3, use the old CascadedUnion function for polygons and
-   brute force two-by-two for other types. */
-       ArrayType *array;
-       int is3d = 0;
-       int nelems = 0;
-       GSERIALIZED *result = NULL;
-       GSERIALIZED *pgis_geom = NULL;
-       GEOSGeometry * g1 = NULL;
-       GEOSGeometry * g2 = NULL;
-       GEOSGeometry * geos_result = NULL;
-       int srid = SRID_UNKNOWN;
-       int count;
-
-       ArrayIterator iterator;
-       Datum value;
-       bool isnull;
-
-       int gotsrid = 0;
-       int allpolys = 1;
-
-       if ( PG_ARGISNULL(0) )
-               PG_RETURN_NULL();
-       
-       array = PG_GETARG_ARRAYTYPE_P(0);
-       nelems = ArrayGetNItems(ARR_NDIM(array), ARR_DIMS(array));
-       
-       POSTGIS_DEBUGF(3, "%s: number of elements: %d", __func__, nelems);
-
-       /* Zero elements in array? return NULL */
-       if ( nelems == 0 ) 
-               PG_RETURN_NULL();
-
-       /*
-       ** First, see if all our elements are POLYGON/MULTIPOLYGON
-       ** If they are, we can use UnionCascaded for faster results.
-       */
-       count = 0;
-#if POSTGIS_PGSQL_VERSION >= 95        
-       iterator = array_create_iterator(array, 0, NULL);
-#else
-       iterator = array_create_iterator(array, 0);
-#endif
-       while( array_iterate(iterator, &value, &isnull) )
-       {
-               GSERIALIZED *pggeom;
-               int pgtype;
-               
-               /* Don't do anything for NULL values */
-               if ( isnull )
-                       continue;
-
-               pggeom = (GSERIALIZED *)DatumGetPointer(value);
-               pgtype = gserialized_get_type(pggeom);
-               
-               if ( ! gotsrid ) /* Initialize SRID */
-               {
-                       srid = gserialized_get_srid(pggeom);
-                       gotsrid = 1;
-                       if ( gserialized_has_z(pggeom) ) is3d = 1;
-               }
-               else
-               {
-                       error_if_srid_mismatch(srid, gserialized_get_srid(pggeom));
-               }
-
-               if ( pgtype != POLYGONTYPE && pgtype != MULTIPOLYGONTYPE )
-               {
-                       allpolys = 0;
-                       break;
-               }
-               
-               count++;
-       }
-       array_free_iterator(iterator);
-
-       /* All the components are null? Return null */
-       if ( count == 0 )
-               PG_RETURN_NULL();
-
-       /* Just one non-null component? Return that */
-       if ( count == 1 && nelems == 1 )
-               PG_RETURN_POINTER((GSERIALIZED *)(ARR_DATA_PTR(array)));
-
-       /* Ok, we really need geos now ;) */
-       initGEOS(lwpgnotice, lwgeom_geos_error);
-
-
-       if ( allpolys )
-       {
-               /*
-               ** Everything is polygonal, so let's run the cascaded polygon union!
-               */
-               int geoms_size = nelems;
-               int curgeom = 0;
-               GEOSGeometry **geoms = NULL;
-               geoms = palloc(sizeof(GEOSGeometry *) * geoms_size);
-               /*
-               ** We need to convert the array of GSERIALIZED into a GEOS MultiPolygon.
-               ** First make an array of GEOS Polygons.
-               */
-#if POSTGIS_PGSQL_VERSION >= 95        
-               iterator = array_create_iterator(array, 0, NULL);
-#else
-               iterator = array_create_iterator(array, 0);
-#endif
-               while( array_iterate(iterator, &value, &isnull) )
-               {
-                       GEOSGeometry* g;
-                       GSERIALIZED *pggeom;
-                       int pgtype;
-                                                       
-                       /* Don't do anything for NULL values */
-                       if ( isnull )
-                               continue;
-
-                       pggeom = (GSERIALIZED *)(ARR_DATA_PTR(array)+offset);
-                       pgtype = gserialized_get_type(pggeom);
-
-                       if ( pgtype == POLYGONTYPE )
-                       {
-                               if ( curgeom == geoms_size )
-                               {
-                                       geoms_size *= 2;
-                                       geoms = repalloc( geoms, sizeof(GEOSGeom) * geoms_size );
-                               }
-                               g = (GEOSGeometry *)POSTGIS2GEOS(pggeom);
-                               if ( 0 == g )   /* exception thrown at construction */
-                               {
-                                       /* TODO: release GEOS allocated memory ! */
-                                       HANDLE_GEOS_ERROR("One of the geometries in the set "
-                                                   "could not be converted to GEOS");
-                                       PG_RETURN_NULL();
-                               }
-                               geoms[curgeom] = g;
-                               curgeom++;
-                       }
-                       if ( pgtype == MULTIPOLYGONTYPE )
-                       {
-                               int j = 0;
-                               LWMPOLY *lwmpoly = (LWMPOLY*)lwgeom_from_gserialized(pggeom);;
-                               for ( j = 0; j < lwmpoly->ngeoms; j++ )
-                               {
-                                       GEOSGeometry* g;
-                                       if ( curgeom == geoms_size )
-                                       {
-                                               geoms_size *= 2;
-                                               geoms = repalloc( geoms, sizeof(GEOSGeom) * geoms_size );
-                                       }
-                                       /* This builds a LWPOLY on top of the serialized form */
-                                       g = LWGEOM2GEOS(lwpoly_as_lwgeom(lwmpoly->geoms[j], 0));
-                                       if ( 0 == g )   /* exception thrown at construction */
-                                       {
-                                               /* TODO: cleanup all GEOS memory */
-                                               HANDLE_GEOS_ERROR("Geometry could not be converted to GEOS");
-                                               PG_RETURN_NULL();
-                                       }
-                                       geoms[curgeom++] = g;
-                               }
-                               lwmpoly_free(lwmpoly);
-                       }
-
-               }
-               array_free_iterator(iterator);
-               
-               /*
-               ** Take our GEOS Polygons and turn them into a GEOS MultiPolygon,
-               ** then pass that into cascaded union.
-               */
-               if (curgeom > 0)
-               {
-                       g1 = GEOSGeom_createCollection(GEOS_MULTIPOLYGON, geoms, curgeom);
-                       if ( ! g1 )
-                       {
-                               /* TODO: cleanup geoms memory */
-                               HANDLE_GEOS_ERROR("Could not create MULTIPOLYGON from geometry array");
-                               PG_RETURN_NULL();
-                       }
-                       g2 = GEOSUnionCascaded(g1);
-                       GEOSGeom_destroy(g1);
-                       if ( ! g2 )
-                       {
-                               HANDLE_GEOS_ERROR("GEOSUnionCascaded");
-                               PG_RETURN_NULL();
-                       }
-
-                       GEOSSetSRID(g2, srid);
-                       result = GEOS2POSTGIS(g2, is3d);
-                       GEOSGeom_destroy(g2);
-               }
-               else
-               {
-                       /* All we found were NULLs, so let's return NULL */
-                       PG_RETURN_NULL();
-               }
-       }
-       else
-       {
-               /*
-               ** Heterogeneous result, let's slog through this one union at a time.
-               */
-
-#if POSTGIS_PGSQL_VERSION >= 95        
-               iterator = array_create_iterator(array, 0, NULL);
-#else
-               iterator = array_create_iterator(array, 0);
-#endif
-               while( array_iterate(iterator, &value, &isnull) )
-               {
-                       GSERIALIZED *geom;
-                                                       
-                       /* Don't do anything for NULL values */
-                       if ( isnull )
-                               continue;
-                       
-                       geom = (GSERIALIZED *)DatumGetPointer(value);
-                       pgis_geom = geom;
-
-                       POSTGIS_DEBUGF(3, "geom %d @ %p", i, geom);
-
-                       /* Check is3d flag */
-                       if ( gserialized_has_z(geom) ) is3d = 1;
-
-                       /* Check SRID homogeneity and initialize geos result */
-                       if ( ! geos_result )
-                       {
-                               geos_result = (GEOSGeometry *)POSTGIS2GEOS(geom);
-                               if ( 0 == geos_result )   /* exception thrown at construction */
-                               {
-                                       HANDLE_GEOS_ERROR("geometry could not be converted to GEOS");
-                                       PG_RETURN_NULL();
-                               }
-                               srid = gserialized_get_srid(geom);
-                               POSTGIS_DEBUGF(3, "first geom is a %s", lwtype_name(gserialized_get_type(geom)));
-                       }
-                       else
-                       {
-                               error_if_srid_mismatch(srid, gserialized_get_srid(geom));
-
-                g1 = POSTGIS2GEOS(pgis_geom);
-                if ( 0 == g1 )   /* exception thrown at construction */
-                {
-                    /* TODO: release GEOS allocated memory ! */
-                    HANDLE_GEOS_ERROR("First argument geometry could not be converted to GEOS");
-                    PG_RETURN_NULL();
-                }
-
-                               POSTGIS_DEBUGF(3, "unite_garray(%d): adding geom %d to union (%s)",
-                                              call, i, lwtype_name(gserialized_get_type(geom)));
-
-                               g2 = GEOSUnion(g1, geos_result);
-                               if ( g2 == NULL )
-                               {
-                                       GEOSGeom_destroy((GEOSGeometry *)g1);
-                                       GEOSGeom_destroy((GEOSGeometry *)geos_result);
-                                       HANDLE_GEOS_ERROR("GEOSUnion");
-                               }
-                               GEOSGeom_destroy((GEOSGeometry *)g1);
-                               GEOSGeom_destroy((GEOSGeometry *)geos_result);
-                               geos_result = g2;
-                       }
-               }
-               array_free_iterator(iterator);
-
-               /* If geos_result is set then we found at least one non-NULL geometry */
-               if (geos_result)
-               {
-                       GEOSSetSRID(geos_result, srid);
-                       result = GEOS2POSTGIS(geos_result, is3d);
-                       GEOSGeom_destroy(geos_result);
-               }
-               else
-               {
-                       /* All we found were NULLs, so let's return NULL */
-                       PG_RETURN_NULL();
-               }
-
-       }
-
-       if ( result == NULL )
-       {
-               /* Union returned a NULL geometry */
-               PG_RETURN_NULL();
-       }
-
-       PG_RETURN_POINTER(result);
-
-}
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
-
 /**
  * @example ST_UnaryUnion {@link #geomunion} SELECT ST_UnaryUnion(
  *      'POLYGON((0 0, 10 0, 0 10, 10 10, 0 0))'
@@ -1186,29 +878,9 @@ Datum buffer(PG_FUNCTION_ARGS)
 
        }
 
-#if POSTGIS_GEOS_VERSION >= 32
-
        g3 = GEOSBufferWithStyle(g1, size, quadsegs, endCapStyle, joinStyle, mitreLimit);
        GEOSGeom_destroy(g1);
 
-#else /* POSTGIS_GEOS_VERSION < 32 */
-
-       if ( mitreLimit != DEFAULT_MITRE_LIMIT ||
-               endCapStyle != DEFAULT_ENDCAP_STYLE ||
-               joinStyle != DEFAULT_JOIN_STYLE )
-       {
-               lwpgerror("The GEOS version this PostGIS binary "
-                       "was compiled against (%d) doesn't support "
-                       "specifying a mitre limit != %d or styles different "
-                       "from 'round' (needs 3.2 or higher)",
-                       DEFAULT_MITRE_LIMIT, POSTGIS_GEOS_VERSION);
-       }
-
-       g3 = GEOSBuffer(g1,size,quadsegs);
-       GEOSGeom_destroy(g1);
-
-#endif /* POSTGIS_GEOS_VERSION < 32 */
-
        if (g3 == NULL)
        {
                HANDLE_GEOS_ERROR("GEOSBuffer");
@@ -1239,15 +911,6 @@ Datum ST_OffsetCurve(PG_FUNCTION_ARGS);
 PG_FUNCTION_INFO_V1(ST_OffsetCurve);
 Datum ST_OffsetCurve(PG_FUNCTION_ARGS)
 {
-#if POSTGIS_GEOS_VERSION < 32
-       lwpgerror("The GEOS version this PostGIS binary "
-               "was compiled against (%d) doesn't support "
-               "ST_OffsetCurve function "
-               "(needs 3.2 or higher)",
-               POSTGIS_GEOS_VERSION);
-       PG_RETURN_NULL(); /* never get here */
-#else
-
        GSERIALIZED     *gser_input;
        GSERIALIZED *gser_result;
        LWGEOM *lwgeom_input;
@@ -1379,8 +1042,6 @@ Datum ST_OffsetCurve(PG_FUNCTION_ARGS)
        lwgeom_free(lwgeom_input);
        lwgeom_free(lwgeom_result);
        PG_RETURN_POINTER(gser_result);
-
-#endif /* POSTGIS_GEOS_VERSION < 32 */
 }
 
 
@@ -1694,9 +1355,6 @@ Datum isvalid(PG_FUNCTION_ARGS)
        LWGEOM *lwgeom;
        bool result;
        GEOSGeom g1;
-#if POSTGIS_GEOS_VERSION < 33
-       GBOX box1;
-#endif
 
        geom1 = PG_GETARG_GSERIALIZED_P(0);
 
@@ -1704,20 +1362,6 @@ Datum isvalid(PG_FUNCTION_ARGS)
        if ( gserialized_is_empty(geom1) )
                PG_RETURN_BOOL(true);
 
-#if POSTGIS_GEOS_VERSION < 33
-       /* Short circuit and return FALSE if we have infinite coordinates */
-       /* GEOS 3.3+ is supposed to  handle this stuff OK */
-       if ( gserialized_get_gbox_p(geom1, &box1) )
-       {
-               if ( isinf(box1.xmax) || isinf(box1.ymax) || isinf(box1.xmin) || isinf(box1.ymin) ||
-                       isnan(box1.xmax) || isnan(box1.ymax) || isnan(box1.xmin) || isnan(box1.ymin)  )
-               {
-                       lwpgnotice("Geometry contains an Inf or NaN coordinate");
-                       PG_RETURN_BOOL(FALSE);
-               }
-       }
-#endif
-
        initGEOS(lwpgnotice, lwgeom_geos_error);
 
        lwgeom = lwgeom_from_gserialized(geom1);
@@ -1761,31 +1405,9 @@ Datum isvalidreason(PG_FUNCTION_ARGS)
        char *reason_str = NULL;
        text *result = NULL;
        const GEOSGeometry *g1 = NULL;
-#if POSTGIS_GEOS_VERSION < 33
-       GBOX box;
-#endif
 
        geom = PG_GETARG_GSERIALIZED_P(0);
 
-#if POSTGIS_GEOS_VERSION < 33
-       /* Short circuit and return if we have infinite coordinates */
-       /* GEOS 3.3+ is supposed to  handle this stuff OK */
-       if ( gserialized_get_gbox_p(geom, &box) )
-       {
-               if ( isinf(box.xmax) || isinf(box.ymax) || isinf(box.xmin) || isinf(box.ymin) ||
-                       isnan(box.xmax) || isnan(box.ymax) || isnan(box.xmin) || isnan(box.ymin)  )
-               {
-                       const char *rsn = "Geometry contains an Inf or NaN coordinate";
-                       size_t len = strlen(rsn);
-                       result = palloc(VARHDRSZ + len);
-                       SET_VARSIZE(result, VARHDRSZ + len);
-                       memcpy(VARDATA(result), rsn, len);
-                       PG_FREE_IF_COPY(geom, 0);
-                       PG_RETURN_POINTER(result);
-               }
-       }
-#endif
-
        initGEOS(lwpgnotice, lwgeom_geos_error);
 
        g1 = (GEOSGeometry *)POSTGIS2GEOS(geom);
@@ -1806,10 +1428,8 @@ Datum isvalidreason(PG_FUNCTION_ARGS)
                result = cstring2text(lwgeom_geos_errmsg);
        }
 
-
        PG_FREE_IF_COPY(geom, 0);
        PG_RETURN_POINTER(result);
-
 }
 
 /*
@@ -1819,14 +1439,6 @@ Datum isvalidreason(PG_FUNCTION_ARGS)
 PG_FUNCTION_INFO_V1(isvaliddetail);
 Datum isvaliddetail(PG_FUNCTION_ARGS)
 {
-#if POSTGIS_GEOS_VERSION < 33
-       lwpgerror("The GEOS version this PostGIS binary "
-               "was compiled against (%d) doesn't support "
-               "'isValidDetail' function (3.3.0+ required)",
-               POSTGIS_GEOS_VERSION);
-       PG_RETURN_NULL();
-#else /* POSTGIS_GEOS_VERSION >= 33 */
-
        GSERIALIZED *geom = NULL;
        const GEOSGeometry *g1 = NULL;
        char *values[3]; /* valid bool, reason text, location geometry */
@@ -1913,8 +1525,6 @@ Datum isvaliddetail(PG_FUNCTION_ARGS)
        heap_freetuple(tuple);
 
        PG_RETURN_HEAPTUPLEHEADER(result);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
 }
 
 /**
@@ -2928,9 +2538,7 @@ Datum relate_full(PG_FUNCTION_ARGS)
        GEOSGeometry *g1, *g2;
        char *relate_str;
        text *result;
-#if POSTGIS_GEOS_VERSION >= 33
        int bnr = GEOSRELATE_BNR_OGC;
-#endif
 
        POSTGIS_DEBUG(2, "in relate_full()");
 
@@ -2941,16 +2549,7 @@ Datum relate_full(PG_FUNCTION_ARGS)
 
        if ( PG_NARGS() > 2 )
        {
-#if POSTGIS_GEOS_VERSION >= 33
                bnr = PG_GETARG_INT32(2);
-#else
-               lwpgerror("The GEOS version this PostGIS binary "
-                       "was compiled against (%d) doesn't support "
-                       "specifying a boundary node rule with ST_Relate"
-                       " (3.3.0+ required)",
-                       POSTGIS_GEOS_VERSION);
-               PG_RETURN_NULL();
-#endif
        }
 
        errorIfGeometryCollection(geom1,geom2);
@@ -2980,11 +2579,7 @@ Datum relate_full(PG_FUNCTION_ARGS)
        POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g1));
        POSTGIS_DEBUGF(3, "%s", GEOSGeomToWKT(g2));
 
-#if POSTGIS_GEOS_VERSION >= 33
        relate_str = GEOSRelateBoundaryNodeRule(g1, g2, bnr);
-#else
-       relate_str = GEOSRelate(g1, g2);
-#endif
 
        GEOSGeom_destroy(g1);
        GEOSGeom_destroy(g2);
@@ -3682,13 +3277,6 @@ Datum ST_Snap(PG_FUNCTION_ARGS);
 PG_FUNCTION_INFO_V1(ST_Snap);
 Datum ST_Snap(PG_FUNCTION_ARGS)
 {
-#if POSTGIS_GEOS_VERSION < 33
-       lwpgerror("The GEOS version this PostGIS binary "
-               "was compiled against (%d) doesn't support "
-               "'ST_Snap' function (3.3.0+ required)",
-               POSTGIS_GEOS_VERSION);
-       PG_RETURN_NULL();
-#else /* POSTGIS_GEOS_VERSION >= 33 */
        GSERIALIZED *geom1, *geom2, *result;
        LWGEOM *lwgeom1, *lwgeom2, *lwresult;
        double tolerance;
@@ -3710,9 +3298,6 @@ Datum ST_Snap(PG_FUNCTION_ARGS)
        lwgeom_free(lwresult);
 
        PG_RETURN_POINTER(result);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
-
 }
 
 /*
@@ -3792,13 +3377,6 @@ Datum ST_SharedPaths(PG_FUNCTION_ARGS);
 PG_FUNCTION_INFO_V1(ST_SharedPaths);
 Datum ST_SharedPaths(PG_FUNCTION_ARGS)
 {
-#if POSTGIS_GEOS_VERSION < 33
-       lwpgerror("The GEOS version this PostGIS binary "
-               "was compiled against (%d) doesn't support "
-               "'ST_SharedPaths' function (3.3.0+ required)",
-               POSTGIS_GEOS_VERSION);
-       PG_RETURN_NULL();
-#else /* POSTGIS_GEOS_VERSION >= 33 */
        GSERIALIZED *geom1, *geom2, *out;
        LWGEOM *g1, *g2, *lwgeom_out;
 
@@ -3825,9 +3403,6 @@ Datum ST_SharedPaths(PG_FUNCTION_ARGS)
        PG_FREE_IF_COPY(geom1, 0);
        PG_FREE_IF_COPY(geom2, 1);
        PG_RETURN_POINTER(out);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
-
 }
 
 
@@ -3843,13 +3418,6 @@ Datum ST_Node(PG_FUNCTION_ARGS);
 PG_FUNCTION_INFO_V1(ST_Node);
 Datum ST_Node(PG_FUNCTION_ARGS)
 {
-#if POSTGIS_GEOS_VERSION < 33
-       lwpgerror("The GEOS version this PostGIS binary "
-               "was compiled against (%d) doesn't support "
-               "'ST_Node' function (3.3.0+ required)",
-               POSTGIS_GEOS_VERSION);
-       PG_RETURN_NULL();
-#else /* POSTGIS_GEOS_VERSION >= 33 */
        GSERIALIZED *geom1, *out;
        LWGEOM *g1, *lwgeom_out;
 
@@ -3871,8 +3439,5 @@ Datum ST_Node(PG_FUNCTION_ARGS)
 
        PG_FREE_IF_COPY(geom1, 0);
        PG_RETURN_POINTER(out);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
-
 }
 
index 7bea2206962782b276ae6966cfa95188d14e9cc0..353af40bd5474acf8d15e6270c164cb13dd562a2 100644 (file)
@@ -52,11 +52,6 @@ Datum ST_MakeValid(PG_FUNCTION_ARGS);
 PG_FUNCTION_INFO_V1(ST_MakeValid);
 Datum ST_MakeValid(PG_FUNCTION_ARGS)
 {
-#if POSTGIS_GEOS_VERSION < 33
-       elog(ERROR, "You need GEOS-3.3.0 or up for ST_MakeValid");
-       PG_RETURN_NULL();
-#else /* POSTGIS_GEOS_VERSION >= 33 */
-
        GSERIALIZED *in, *out;
        LWGEOM *lwgeom_in, *lwgeom_out;
 
@@ -91,11 +86,8 @@ Datum ST_MakeValid(PG_FUNCTION_ARGS)
        out = geometry_serialize(lwgeom_out);
 
        PG_RETURN_POINTER(out);
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
 }
 
-#if POSTGIS_GEOS_VERSION >= 33
-
 /* Uses GEOS internally */
 static LWGEOM* lwgeom_clean(LWGEOM* lwgeom_in);
 static LWGEOM*
@@ -138,18 +130,11 @@ lwgeom_clean(LWGEOM* lwgeom_in)
        return lwgeom_out;
 }
 
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
-
 
 Datum ST_CleanGeometry(PG_FUNCTION_ARGS);
 PG_FUNCTION_INFO_V1(ST_CleanGeometry);
 Datum ST_CleanGeometry(PG_FUNCTION_ARGS)
 {
-#if POSTGIS_GEOS_VERSION < 33
-       elog(ERROR, "You need GEOS-3.3.0 or up for ST_CleanGeometry");
-       PG_RETURN_NULL();
-#else /* POSTGIS_GEOS_VERSION >= 33 */
-
        GSERIALIZED *in, *out;
        LWGEOM *lwgeom_in, *lwgeom_out;
 
@@ -175,7 +160,5 @@ Datum ST_CleanGeometry(PG_FUNCTION_ARGS)
 
        out = geometry_serialize(lwgeom_out);
        PG_RETURN_POINTER(out);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
 }
 
index 3264ce4e3faedd277d77822e0cfab97cb0500c62..cf6dc531af33ffd234e54ecf2f794696f790a268 100644 (file)
@@ -40,14 +40,6 @@ Datum ST_RelateMatch(PG_FUNCTION_ARGS);
 PG_FUNCTION_INFO_V1(ST_RelateMatch);
 Datum ST_RelateMatch(PG_FUNCTION_ARGS)
 {
-#if POSTGIS_GEOS_VERSION < 33
-       lwpgerror("The GEOS version this postgis binary "
-               "was compiled against (%d) doesn't support "
-               "'ST_RelateMatch' function (3.3.0+ required)",
-               POSTGIS_GEOS_VERSION);
-       PG_RETURN_NULL();
-#else /* POSTGIS_GEOS_VERSION >= 33 */
-
        char *mat, *pat;
        text *mat_text, *pat_text;
        int result;
@@ -72,8 +64,5 @@ Datum ST_RelateMatch(PG_FUNCTION_ARGS)
 
        lwfree(mat); lwfree(pat);
        PG_RETURN_BOOL(result);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
-
 }
 
index 47d6f9ef22be7b88e54ea791808808e7a0c9118d..66d1e61482fa8214008608c8918c7840b1342ae9 100644 (file)
@@ -470,18 +470,10 @@ rt_errorstate rt_raster_surface(rt_raster raster, int nband, LWMPOLY **surface)
                rtdealloc(gv);
 
                /* create geometry collection */
-#if POSTGIS_GEOS_VERSION >= 33
                gc = GEOSGeom_createCollection(GEOS_GEOMETRYCOLLECTION, geoms, geomscount);
-#else
-               gc = GEOSGeom_createCollection(GEOS_MULTIPOLYGON, geoms, geomscount);
-#endif
 
                if (gc == NULL) {
-#if POSTGIS_GEOS_VERSION >= 33
                        rterror("rt_raster_surface: Could not create GEOS GEOMETRYCOLLECTION from set of pixel polygons");
-#else
-                       rterror("rt_raster_surface: Could not create GEOS MULTIPOLYGON from set of pixel polygons");
-#endif
 
                        for (i = 0; i < geomscount; i++)
                                GEOSGeom_destroy(geoms[i]);
@@ -490,20 +482,13 @@ rt_errorstate rt_raster_surface(rt_raster raster, int nband, LWMPOLY **surface)
                }
 
                /* run the union */
-#if POSTGIS_GEOS_VERSION >= 33
                gunion = GEOSUnaryUnion(gc);
-#else
-               gunion = GEOSUnionCascaded(gc);
-#endif
+
                GEOSGeom_destroy(gc);
                rtdealloc(geoms);
 
                if (gunion == NULL) {
-#if POSTGIS_GEOS_VERSION >= 33
                        rterror("rt_raster_surface: Could not union the pixel polygons using GEOSUnaryUnion()");
-#else
-                       rterror("rt_raster_surface: Could not union the pixel polygons using GEOSUnionCascaded()");
-#endif
                        return ES_ERROR;
                }
 
@@ -517,10 +502,6 @@ rt_errorstate rt_raster_surface(rt_raster raster, int nband, LWMPOLY **surface)
                do {
                        LWGEOM *mpolyValid = NULL;
 
-#if POSTGIS_GEOS_VERSION < 33
-                       break;
-#endif
-
                        if (GEOSisValid(gunion))
                                break;
 
@@ -1253,11 +1234,6 @@ rt_raster_gdal_polygonize(
                        if not, try to make valid
                */
                do {
-#if POSTGIS_GEOS_VERSION < 33
-                       /* nothing can be done if the geometry was invalid if GEOS < 3.3 */
-                       break;
-#endif
-
                        ggeom = (GEOSGeometry *) LWGEOM2GEOS(lwgeom, 0);
                        if (ggeom == NULL) {
                                rtwarn("Cannot test geometry for validity");
index d1309f3611dd374a76b83e49027daacd49e58e27..ccc695dce899468682d694086783f5a358c7dc51 100644 (file)
@@ -317,11 +317,9 @@ static void test_raster_surface() {
        CU_ASSERT_EQUAL(err, ES_NONE);
        CU_ASSERT(mpoly != NULL);
        wkt = lwgeom_to_text(lwmpoly_as_lwgeom(mpoly));
-#if POSTGIS_GEOS_VERSION >= 33
+
        CU_ASSERT_STRING_EQUAL(wkt, "MULTIPOLYGON(((1 -1,1 0,5 0,5 -5,4 -5,0 -5,0 -1,1 -1),(1 -1,1 -2,2 -2,2 -1,1 -1),(2 -2,2 -3,3 -3,3 -2,2 -2)))");
-#else
-       CU_ASSERT_STRING_EQUAL(wkt, "MULTIPOLYGON(((1 0,1 -1,0 -1,0 -5,4 -5,5 -5,5 0,1 0),(1 -1,1 -2,2 -2,2 -3,3 -3,3 -2,2 -2,2 -1,1 -1)))");
-#endif
+
        rtdealloc(wkt);
        lwmpoly_free(mpoly);
        mpoly = NULL;
@@ -333,11 +331,9 @@ static void test_raster_surface() {
        CU_ASSERT_EQUAL(err, ES_NONE);
        CU_ASSERT(mpoly != NULL);
        wkt = lwgeom_to_text(lwmpoly_as_lwgeom(mpoly));
-#if POSTGIS_GEOS_VERSION >= 33
+
        CU_ASSERT_STRING_EQUAL(wkt, "MULTIPOLYGON(((1 -1,1 0,5 0,5 -5,4 -5,0 -5,0 -1,1 -1),(1 -1,1 -2,2 -2,2 -1,1 -1),(2 -2,2 -3,3 -3,3 -2,2 -2),(3 -3,3 -4,4 -4,4 -3,3 -3)))");
-#else
-       CU_ASSERT_STRING_EQUAL(wkt, "MULTIPOLYGON(((1 0,1 -1,0 -1,0 -5,4 -5,5 -5,5 0,1 0),(1 -1,1 -2,2 -2,2 -3,3 -3,3 -4,4 -4,4 -3,3 -3,3 -2,2 -2,2 -1,1 -1)))");
-#endif
+
        rtdealloc(wkt);
        lwmpoly_free(mpoly);
        mpoly = NULL;