]> granicus.if.org Git - postgis/commitdiff
Added postgis_lib_version() and postgis_geos_version()
authorSandro Santilli <strk@keybit.net>
Thu, 22 Jul 2004 16:20:10 +0000 (16:20 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 22 Jul 2004 16:20:10 +0000 (16:20 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@646 b70326c6-7e19-0410-871a-916f4a2858ee

Makefile
postgis.h
postgis.sql.in
postgis_fn.c
postgis_geos.c
postgis_geos_wrapper.cpp
postgis_transform.c

index 4da03443ebd9525c799e108a149a78be460592f3..6ff0b7eb379d65fbcde4a4d07bcd7ab741f37d2f 100644 (file)
--- 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
index 2253efe315d1fe4dd96976cdfc4847a6483917b4..ab90cd97ee76746abedb53aad184366d178b6b03 100644 (file)
--- 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.
index 7d8e645d11108aba27109d3b109d227a544d35a1..2a5ae660850a7aea93a1fbe623c245857edbd6c7 100644 (file)
@@ -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';
index a15a8e871f675f1325ac862779846101318252d5..2f0c67791847c2eb6c14c654ab6b874de25dfdff 100644 (file)
@@ -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);
+}
index 4073998a13c4462ead8f358c6584976641fd819f..d83d7536e1f80df8fc908908a3767f8594482fc9 100644 (file)
@@ -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();
 }
 
index 06606fda32c9af43471d3229867758d8cbb9490a..daa1715472246e7611fabed5a2603de83491c8ee 100644 (file)
@@ -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;
+}
 
 
index b67aa3cbfeba92d80b392f68485e899c58de4468..1983a7fdc46fba75554961f069dec219e0bfecd6 100644 (file)
@@ -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);