From 6a56e2a82e2d3d8007cdc3dfb95e0fb4500437ea Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Tue, 9 Aug 2011 16:05:30 +0000 Subject: [PATCH] Add GEOS entry points in liblwgeom.h (public API) [RT-SIGTA] git-svn-id: http://svn.osgeo.org/postgis/trunk@7719 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/liblwgeom.h | 30 ++++++++++++++++++++++++++++++ liblwgeom/lwgeom_geos.c | 8 +++++++- liblwgeom/lwgeom_geos.h | 20 -------------------- postgis/lwgeom_geos.c | 7 +++---- postgis/lwgeom_geos.h | 1 + 5 files changed, 41 insertions(+), 25 deletions(-) diff --git a/liblwgeom/liblwgeom.h b/liblwgeom/liblwgeom.h index 8e1d95053..6db31a5bf 100644 --- a/liblwgeom/liblwgeom.h +++ b/liblwgeom/liblwgeom.h @@ -2164,5 +2164,35 @@ double lwcircle_center(const POINT4D *p1, const POINT4D *p2, const POINT4D *p3, LWGEOM *lwgeom_segmentize(LWGEOM *geom, uint32 perQuad); LWGEOM *lwgeom_desegmentize(LWGEOM *geom); +/******************************************************************************* + * GEOS proxy functions on LWGEOM + ******************************************************************************/ + +/** Return GEOS version string (not to be freed) */ +const char* lwgeom_geos_version(); + +/** Convert an LWGEOM to a GEOS Geometry and convert back -- for debug only */ +LWGEOM* lwgeom_geos_noop(const LWGEOM *geom) ; + +LWGEOM *lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2); +LWGEOM *lwgeom_difference(const LWGEOM *geom1, const LWGEOM *geom2); +LWGEOM *lwgeom_symdifference(const LWGEOM* geom1, const LWGEOM* geom2); +LWGEOM *lwgeom_union(const LWGEOM *geom1, const LWGEOM *geom2); + +/******************************************************************************* + * GEOS-dependent extra functions on LWGEOM + ******************************************************************************/ + +/** + * Take a geometry and return an areal geometry + * (Polygon or MultiPolygon). + * Actually a wrapper around GEOSpolygonize, + * transforming the resulting collection into + * a valid polygon Geometry. + */ +LWGEOM* lwgeom_buildarea(const LWGEOM *geom) ; + + + #endif /* !defined _LIBLWGEOM_H */ diff --git a/liblwgeom/lwgeom_geos.c b/liblwgeom/lwgeom_geos.c index ad3501953..37d607111 100644 --- a/liblwgeom/lwgeom_geos.c +++ b/liblwgeom/lwgeom_geos.c @@ -17,7 +17,7 @@ #include - +#define LWGEOM_GEOS_ERRMSG_MAXSIZE 256 char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]; extern void @@ -397,6 +397,12 @@ LWGEOM2GEOS(const LWGEOM *lwgeom) return g; } +const char* +lwgeom_geos_version() +{ + const char *ver = GEOSversion(); + return ver; +} diff --git a/liblwgeom/lwgeom_geos.h b/liblwgeom/lwgeom_geos.h index 34a655d0f..edab8eed7 100644 --- a/liblwgeom/lwgeom_geos.h +++ b/liblwgeom/lwgeom_geos.h @@ -20,25 +20,6 @@ #include "liblwgeom.h" -LWGEOM *lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2) ; -LWGEOM *lwgeom_difference(const LWGEOM *geom1, const LWGEOM *geom2) ; -LWGEOM *lwgeom_symdifference(const LWGEOM* geom1, const LWGEOM* geom2) ; -LWGEOM* lwgeom_union(const LWGEOM *geom1, const LWGEOM *geom2) ; - -/** - * Take a geometry and return an areal geometry - * (Polygon or MultiPolygon). - * Actually a wrapper around GEOSpolygonize, - * transforming the resulting collection into - * a valid polygon Geometry. - */ -LWGEOM* lwgeom_buildarea(const LWGEOM *geom) ; - -/** Convert an LWGEOM to a GEOS Geometry and convert back -- for debug only */ -LWGEOM* lwgeom_geos_noop(const LWGEOM *geom) ; - - - /* ** Public prototypes for GEOS utility functions. */ @@ -50,7 +31,6 @@ GEOSGeometry * LWGEOM_GEOS_buildArea(const GEOSGeometry* geom_in); POINTARRAY *ptarray_from_GEOSCoordSeq(const GEOSCoordSequence *cs, char want3d); -#define LWGEOM_GEOS_ERRMSG_MAXSIZE 256 extern char lwgeom_geos_errmsg[]; extern void lwgeom_geos_error(const char *fmt, ...); diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c index 946406869..73ff8543a 100644 --- a/postgis/lwgeom_geos.c +++ b/postgis/lwgeom_geos.c @@ -13,11 +13,10 @@ **********************************************************************/ #include "lwgeom_geos.h" +#include "liblwgeom_internal.h" #include "lwgeom_rtree.h" -#include "lwgeom_geos_prepared.h" +#include "lwgeom_functions_analytic.h" /* for point_in_polygon */ #include "funcapi.h" -#include "lwgeom_functions_analytic.h" -#include "liblwgeom_internal.h" #include #include @@ -82,7 +81,7 @@ Datum pgis_union_geometry_array(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(postgis_geos_version); Datum postgis_geos_version(PG_FUNCTION_ARGS) { - const char *ver = GEOSversion(); + const char *ver = lwgeom_geos_version(); text *result = cstring2text(ver); PG_RETURN_POINTER(result); } diff --git a/postgis/lwgeom_geos.h b/postgis/lwgeom_geos.h index f03b19f28..604197fb9 100644 --- a/postgis/lwgeom_geos.h +++ b/postgis/lwgeom_geos.h @@ -31,6 +31,7 @@ #include "lwgeom_pg.h" #include "liblwgeom.h" #include "profile.h" +#include "../liblwgeom/liblwgeom.h" #include "../liblwgeom/lwgeom_geos.h" #include -- 2.50.0