[postgis-tickets] r14466 - #3365, remove code paths for POSTGIS_GEOS_VERSION < 33
Daniel Baston
dbaston at gmail.com
Tue Dec 1 15:16:41 PST 2015
Author: dbaston
Date: 2015-12-01 15:16:41 -0800 (Tue, 01 Dec 2015)
New Revision: 14466
Modified:
trunk/liblwgeom/cunit/cu_clean.c
trunk/liblwgeom/cunit/cu_node.c
trunk/liblwgeom/cunit/cu_split.c
trunk/liblwgeom/lwgeom_geos.c
trunk/liblwgeom/lwgeom_geos_clean.c
trunk/liblwgeom/lwgeom_geos_node.c
trunk/postgis/lwgeom_geos.c
trunk/postgis/lwgeom_geos_clean.c
trunk/postgis/lwgeom_geos_relatematch.c
trunk/raster/rt_core/rt_geometry.c
trunk/raster/test/cunit/cu_raster_geometry.c
Log:
#3365, remove code paths for POSTGIS_GEOS_VERSION < 33
Modified: trunk/liblwgeom/cunit/cu_clean.c
===================================================================
--- trunk/liblwgeom/cunit/cu_clean.c 2015-12-01 10:52:02 UTC (rev 14465)
+++ trunk/liblwgeom/cunit/cu_clean.c 2015-12-01 23:16:41 UTC (rev 14466)
@@ -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 @@
lwgeom_free(gout);
lwgeom_free(gin);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
}
/* TODO: add more tests ! */
Modified: trunk/liblwgeom/cunit/cu_node.c
===================================================================
--- trunk/liblwgeom/cunit/cu_node.c 2015-12-01 10:52:02 UTC (rev 14465)
+++ trunk/liblwgeom/cunit/cu_node.c 2015-12-01 23:16:41 UTC (rev 14466)
@@ -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 @@
"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 */
}
/*
Modified: trunk/liblwgeom/cunit/cu_split.c
===================================================================
--- trunk/liblwgeom/cunit/cu_split.c 2015-12-01 10:52:02 UTC (rev 14465)
+++ trunk/liblwgeom/cunit/cu_split.c 2015-12-01 23:16:41 UTC (rev 14466)
@@ -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 @@
lwcollection_free((LWCOLLECTION*)coll);
lwline_free(line);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
}
static void test_lwgeom_split(void)
Modified: trunk/liblwgeom/lwgeom_geos.c
===================================================================
--- trunk/liblwgeom/lwgeom_geos.c 2015-12-01 10:52:02 UTC (rev 14465)
+++ trunk/liblwgeom/lwgeom_geos.c 2015-12-01 23:16:41 UTC (rev 14466)
@@ -227,15 +227,6 @@
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 @@
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 @@
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*
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 @@
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 @@
}
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 @@
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 @@
}
return lwgeom_result;
-
-#endif /* POSTGIS_GEOS_VERSION < 32 */
}
LWTIN *lwtin_from_geos(const GEOSGeometry *geom, int want3d) {
Modified: trunk/liblwgeom/lwgeom_geos_clean.c
===================================================================
--- trunk/liblwgeom/lwgeom_geos_clean.c 2015-12-01 10:52:02 UTC (rev 14465)
+++ trunk/liblwgeom/lwgeom_geos_clean.c 2015-12-01 23:16:41 UTC (rev 14466)
@@ -381,7 +381,6 @@
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 @@
return lwgeom_out;
}
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
-
Modified: trunk/liblwgeom/lwgeom_geos_node.c
===================================================================
--- trunk/liblwgeom/lwgeom_geos_node.c 2015-12-01 10:52:02 UTC (rev 14465)
+++ trunk/liblwgeom/lwgeom_geos_node.c 2015-12-01 23:16:41 UTC (rev 14466)
@@ -85,13 +85,6 @@
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 @@
}
return ret;
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
}
/* exported */
@@ -128,13 +120,6 @@
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 @@
lines->srid = lwgeom_in->srid;
return (LWGEOM*)lines;
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
}
Modified: trunk/postgis/lwgeom_geos.c
===================================================================
--- trunk/postgis/lwgeom_geos.c 2015-12-01 10:52:02 UTC (rev 14465)
+++ trunk/postgis/lwgeom_geos.c 2015-12-01 23:16:41 UTC (rev 14466)
@@ -116,13 +116,6 @@
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 @@
PG_FREE_IF_COPY(geom2, 1);
PG_RETURN_FLOAT8(result);
-#endif
}
/**
@@ -182,13 +174,6 @@
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 @@
PG_FREE_IF_COPY(geom2, 1);
PG_RETURN_FLOAT8(result);
-#endif
}
@@ -250,7 +234,6 @@
*/
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 @@
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 @@
}
-#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 @@
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 @@
lwgeom_free(lwgeom_input);
lwgeom_free(lwgeom_result);
PG_RETURN_POINTER(gser_result);
-
-#endif /* POSTGIS_GEOS_VERSION < 32 */
}
@@ -1694,9 +1355,6 @@
LWGEOM *lwgeom;
bool result;
GEOSGeom g1;
-#if POSTGIS_GEOS_VERSION < 33
- GBOX box1;
-#endif
geom1 = PG_GETARG_GSERIALIZED_P(0);
@@ -1704,20 +1362,6 @@
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 @@
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 @@
result = cstring2text(lwgeom_geos_errmsg);
}
-
PG_FREE_IF_COPY(geom, 0);
PG_RETURN_POINTER(result);
-
}
/*
@@ -1819,14 +1439,6 @@
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 @@
heap_freetuple(tuple);
PG_RETURN_HEAPTUPLEHEADER(result);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
}
/**
@@ -2928,9 +2538,7 @@
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 @@
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 @@
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 @@
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 @@
lwgeom_free(lwresult);
PG_RETURN_POINTER(result);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
-
}
/*
@@ -3792,13 +3377,6 @@
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 @@
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 @@
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 @@
PG_FREE_IF_COPY(geom1, 0);
PG_RETURN_POINTER(out);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
-
}
Modified: trunk/postgis/lwgeom_geos_clean.c
===================================================================
--- trunk/postgis/lwgeom_geos_clean.c 2015-12-01 10:52:02 UTC (rev 14465)
+++ trunk/postgis/lwgeom_geos_clean.c 2015-12-01 23:16:41 UTC (rev 14466)
@@ -52,11 +52,6 @@
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 @@
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 @@
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 @@
out = geometry_serialize(lwgeom_out);
PG_RETURN_POINTER(out);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
}
Modified: trunk/postgis/lwgeom_geos_relatematch.c
===================================================================
--- trunk/postgis/lwgeom_geos_relatematch.c 2015-12-01 10:52:02 UTC (rev 14465)
+++ trunk/postgis/lwgeom_geos_relatematch.c 2015-12-01 23:16:41 UTC (rev 14466)
@@ -40,14 +40,6 @@
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 @@
lwfree(mat); lwfree(pat);
PG_RETURN_BOOL(result);
-
-#endif /* POSTGIS_GEOS_VERSION >= 33 */
-
}
Modified: trunk/raster/rt_core/rt_geometry.c
===================================================================
--- trunk/raster/rt_core/rt_geometry.c 2015-12-01 10:52:02 UTC (rev 14465)
+++ trunk/raster/rt_core/rt_geometry.c 2015-12-01 23:16:41 UTC (rev 14466)
@@ -470,18 +470,10 @@
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 @@
}
/* 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 @@
do {
LWGEOM *mpolyValid = NULL;
-#if POSTGIS_GEOS_VERSION < 33
- break;
-#endif
-
if (GEOSisValid(gunion))
break;
@@ -1253,11 +1234,6 @@
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");
Modified: trunk/raster/test/cunit/cu_raster_geometry.c
===================================================================
--- trunk/raster/test/cunit/cu_raster_geometry.c 2015-12-01 10:52:02 UTC (rev 14465)
+++ trunk/raster/test/cunit/cu_raster_geometry.c 2015-12-01 23:16:41 UTC (rev 14466)
@@ -317,11 +317,9 @@
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 @@
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;
More information about the postgis-tickets
mailing list