From: Sandro Santilli Date: Thu, 22 Jul 2004 16:20:10 +0000 (+0000) Subject: Added postgis_lib_version() and postgis_geos_version() X-Git-Tag: pgis_0_9_1~148 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b7511706aeaccc599ba41517d3654782b659e6e;p=postgis Added postgis_lib_version() and postgis_geos_version() git-svn-id: http://svn.osgeo.org/postgis/trunk@646 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/Makefile b/Makefile index 4da03443e..6ff0b7eb3 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,7 @@ endif NAME=postgis SO_MAJOR_VERSION=0 SO_MINOR_VERSION=8 +SO_MICRO_VERSION=2 ifeq (${USE_VERSION}, 71) MODULE_FILENAME = $(LPATH)/$(shlib) MODULE_INSTALLDIR = $(libdir) @@ -97,6 +98,7 @@ endif # Postgis version #--------------------------------------------------------------- +POSTGIS_LIB_VERSION = $(SO_MAJOR_VERSION).$(SO_MINOR_VERSION).$(SO_MICRO_VERSION) POSTGIS_VERSION = $(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) USE_GEOS=$(USE_GEOS) USE_PROJ=$(USE_PROJ) USE_STATS=$(USE_STATS) #--------------------------------------------------------------- @@ -104,6 +106,7 @@ POSTGIS_VERSION = $(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) USE_GEOS=$(USE_GEOS) U override CFLAGS += -g -fexceptions override CFLAGS += -I$(srcdir) -DFRONTEND -DSYSCONFDIR='"$(sysconfdir)"' override CFLAGS += -DUSE_VERSION=$(USE_VERSION) +override CFLAGS += -DPOSTGIS_LIB_VERSION='"$(POSTGIS_LIB_VERSION)"' ifeq ($(USE_GEOS),1) override CFLAGS += -I$(GEOS_DIR)/include -DUSE_GEOS diff --git a/postgis.h b/postgis.h index 2253efe31..ab90cd97e 100644 --- a/postgis.h +++ b/postgis.h @@ -11,6 +11,9 @@ * ********************************************************************** * $Log$ + * Revision 1.47 2004/07/22 16:20:09 strk + * Added postgis_lib_version() and postgis_geos_version() + * * Revision 1.46 2004/06/09 09:06:55 strk * Added Romi's Win32 patches. * @@ -669,6 +672,8 @@ Datum simplify(PG_FUNCTION_ARGS); Datum line_interpolate_point(PG_FUNCTION_ARGS); Datum fluffType(PG_FUNCTION_ARGS); +Datum postgis_lib_version(PG_FUNCTION_ARGS); +Datum postgis_geos_version(PG_FUNCTION_ARGS); /*-------------------------------------------------------------------- * Useful floating point utilities and constants. diff --git a/postgis.sql.in b/postgis.sql.in index 7d8e645d1..2a5ae6608 100644 --- a/postgis.sql.in +++ b/postgis.sql.in @@ -295,6 +295,14 @@ CREATE TABLE geometry_columns ( ----------------------------------------------------------------------- -- POSTGIS_VERSION() ----------------------------------------------------------------------- +CREATEFUNCTION postgis_lib_version() RETURNS cstring + AS '@MODULE_FILENAME@' + LANGUAGE 'C'; + +CREATEFUNCTION postgis_geos_version() RETURNS cstring + AS '@MODULE_FILENAME@' + LANGUAGE 'C'; + CREATEFUNCTION postgis_version() RETURNS text AS 'SELECT \'@POSTGIS_VERSION@\'::text AS version' LANGUAGE 'sql'; diff --git a/postgis_fn.c b/postgis_fn.c index a15a8e871..2f0c67791 100644 --- a/postgis_fn.c +++ b/postgis_fn.c @@ -11,6 +11,9 @@ * ********************************************************************** * $Log$ + * Revision 1.37 2004/07/22 16:20:10 strk + * Added postgis_lib_version() and postgis_geos_version() + * * Revision 1.36 2004/06/03 16:44:56 strk * Added expand_geometry - expand(geometry, int8) * @@ -3136,3 +3139,10 @@ Datum fluffType(PG_FUNCTION_ARGS) PG_FREE_IF_COPY(geom1,0); PG_RETURN_POINTER(g); } + +PG_FUNCTION_INFO_V1(postgis_lib_version); +Datum postgis_lib_version(PG_FUNCTION_ARGS) +{ + char *result = pstrdup(POSTGIS_LIB_VERSION); + PG_RETURN_CSTRING(result); +} diff --git a/postgis_geos.c b/postgis_geos.c index 4073998a1..d83d7536e 100644 --- a/postgis_geos.c +++ b/postgis_geos.c @@ -10,6 +10,9 @@ * ********************************************************************** * $Log$ + * Revision 1.33 2004/07/22 16:20:10 strk + * Added postgis_lib_version() and postgis_geos_version() + * * Revision 1.32 2004/07/01 17:02:05 strk * Updated to support latest GEOS (actually removed all geos-version related * switches). @@ -181,6 +184,7 @@ extern char *GEOSasText(Geometry *g1); extern char GEOSisEmpty(Geometry *g1); extern char *GEOSGeometryType(Geometry *g1); extern int GEOSGeometryTypeId(Geometry *g1); +extern char *GEOSversion(); extern void GEOSdeleteChar(char *a); @@ -1831,6 +1835,15 @@ Datum GEOSnoop(PG_FUNCTION_ARGS) PG_RETURN_POINTER(result); } +PG_FUNCTION_INFO_V1(postgis_geos_version); +Datum postgis_geos_version(PG_FUNCTION_ARGS) +{ + char *ver = GEOSversion(); + char *result = pstrdup(ver); + free(ver); + PG_RETURN_CSTRING(result); +} + //---------------------------------------------------------------------------- // NULL implementation here // --------------------------------------------------------------------------- @@ -2016,10 +2029,10 @@ Datum GEOSnoop(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } -PG_FUNCTION_INFO_V1(GEOSversion); -Datum GEOSversion(PG_FUNCTION_ARGS) +PG_FUNCTION_INFO_V1(postgis_geos_version); +Datum postgis_geos_version(PG_FUNCTION_ARGS) { - elog(ERROR,"GEOSversion:: operation not implemented - compile PostGIS with GEOS support"); + //elog(ERROR,"GEOSversion:: operation not implemented - compile PostGIS with GEOS support"); PG_RETURN_NULL(); } diff --git a/postgis_geos_wrapper.cpp b/postgis_geos_wrapper.cpp index 06606fda3..daa171547 100644 --- a/postgis_geos_wrapper.cpp +++ b/postgis_geos_wrapper.cpp @@ -2,6 +2,9 @@ /* * $Log$ +* Revision 1.26 2004/07/22 16:20:10 strk +* Added postgis_lib_version() and postgis_geos_version() +* * Revision 1.25 2004/07/17 09:52:48 strk * GEOS multi-version support switches implemented with GEOS_LAST_INTERFACE * @@ -74,8 +77,6 @@ using namespace geos; - - //WARNING THIS *MUST* BE SET CORRECTLY. int MAXIMUM_ALIGNOF = -999999; // to be set during initialization - this will be either 4 (intel) or 8 (sparc) @@ -138,7 +139,7 @@ extern "C" char GEOSrelateCrosses(Geometry *g1, Geometry*g2); extern "C" char GEOSrelateWithin(Geometry *g1, Geometry*g2); extern "C" char GEOSrelateContains(Geometry *g1, Geometry*g2); extern "C" char GEOSrelateOverlaps(Geometry *g1, Geometry*g2); - +extern "C" char *GEOSversion(); extern "C" Geometry *PostGIS2GEOS_point(POINT3D *point,int SRID, bool is3d); extern "C" Geometry *PostGIS2GEOS_linestring(const LINE3D *line,int SRID, bool is3d); @@ -1508,5 +1509,20 @@ int GEOSGetSRID(Geometry *g1) } } +char * +GEOSversion() +{ +#if GEOS_LAST_INTERFACE < 2 + /* + * GEOS upgrade needs postgis re-build, so this static + * assignment is not going to be a problem + */ + char *res = strdup("GEOS 1.0.0 ported from JTS-1.3"); +#else + string version = geos::version(); + char *res = strdup(version.c_str()); +#endif + return res; +} diff --git a/postgis_transform.c b/postgis_transform.c index b67aa3cbf..1983a7fdc 100644 --- a/postgis_transform.c +++ b/postgis_transform.c @@ -11,6 +11,9 @@ * ********************************************************************** * $Log$ + * Revision 1.17 2004/07/22 16:20:10 strk + * Added postgis_lib_version() and postgis_geos_version() + * * Revision 1.16 2004/04/28 22:26:02 pramsey * Fixed spelling mistake in header text. * @@ -456,7 +459,7 @@ Datum transform_geom(PG_FUNCTION_ARGS) } -#else +#else // ! defined USE_PROJ // return the original geometry PG_FUNCTION_INFO_V1(transform_geom);