]> granicus.if.org Git - postgis/commitdiff
Adds postgis_gdal_version() function as per ticket #1225.
authorBborie Park <bkpark at ucdavis.edu>
Tue, 4 Oct 2011 22:38:46 +0000 (22:38 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Tue, 4 Oct 2011 22:38:46 +0000 (22:38 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7945 b70326c6-7e19-0410-871a-916f4a2858ee

configure.ac
postgis/postgis.sql.in.c
raster/raster_config.h.in
raster/rt_core/rt_api.c
raster/rt_core/rt_api.h
raster/rt_pg/rt_pg.c
raster/rt_pg/rtpostgis.sql.in.c
regress/run_test

index 4da3889f468b84d82ec776f15d424ddfb76042ea..3d5bf5641cdf86dfdbf77020a51ea61aa9ad955c 100644 (file)
@@ -851,8 +851,10 @@ if test "x$RASTER" = "xraster"; then dnl # {
        if test ! "$GDAL_VERSION_NUMBER" -ge "$GDAL_MIN_VERSION_NUMBER" ; then
                  AC_MSG_RESULT([not found])
                  AC_MSG_ERROR([PostGIS requires GDAL >= $GDAL_MIN_VERSION])
-          fi
+       fi
 
+       AC_DEFINE_UNQUOTED([POSTGIS_GDAL_VERSION], [$POSTGIS_GDAL_VERSION], [GDAL library version])     
+       AC_SUBST([POSTGIS_GDAL_VERSION])
        else
                AC_MSG_RESULT([not found])
                AC_MSG_ERROR([gdal-config not found. Try --with-gdalconfig=<path to gdal-config>])
index 2b8835fc7064106c2f5f2153e7e5edad96407c83..ea40a451ec70bca4288dbb0e53d6299a24623f75 100644 (file)
@@ -2207,6 +2207,7 @@ DECLARE
        libver text;\r
        projver text;\r
        geosver text;\r
+       gdalver text;\r
        libxmlver text;\r
        usestats bool;\r
        dbproc text;\r
@@ -2216,6 +2217,7 @@ BEGIN
        SELECT postgis_lib_version() INTO libver;\r
        SELECT postgis_proj_version() INTO projver;\r
        SELECT postgis_geos_version() INTO geosver;\r
+       SELECT postgis_gdal_version() INTO gdalver;\r
        SELECT postgis_libxml_version() INTO libxmlver;\r
        SELECT postgis_uses_stats() INTO usestats;\r
        SELECT postgis_scripts_installed() INTO dbproc;\r
@@ -2231,6 +2233,10 @@ BEGIN
                fullver = fullver || ' PROJ="' || projver || '"';\r
        END IF;\r
 \r
+       IF  gdalver IS NOT NULL THEN\r
+               fullver = fullver || ' GDAL="' || gdalver || '"';\r
+       END IF;\r
+\r
        IF  libxmlver IS NOT NULL THEN\r
                fullver = fullver || ' LIBXML="' || libxmlver || '"';\r
        END IF;\r
index b29526ac1ea6ca435feaa95d5d22eaa9bb76c855..5c02e61b75faf6c7da96d06341cc4afad2c94408 100644 (file)
@@ -63,6 +63,9 @@
 /* PostGIS Raster version */
 #undef POSTGIS_RASTER_VERSION
 
+/* GDAL library version */
+#undef POSTGIS_GDAL_VERSION
+
 /* Define to 1 if GDAL has GDALFPolygonize function. */
 #undef GDALFPOLYGONIZE
 
index 886274312996d792fd6b5e87c21c0996bbfe2f71..b30695039ebd533d20a18c6d75c296ed94835dcd 100644 (file)
@@ -185,6 +185,9 @@ static void quicksort(double *left, double *right) {
        }
 }
 
+/*
+       convert name to GDAL Resample Algorithm
+*/
 GDALResampleAlg
 rt_util_gdal_resample_alg(const char *algname) {
        if (!algname || !strlen(algname))       return GRA_NearestNeighbour;
@@ -205,6 +208,9 @@ rt_util_gdal_resample_alg(const char *algname) {
        return GRA_NearestNeighbour;
 }
 
+/*
+       convert rt_pixtype to GDALDataType
+*/
 GDALDataType
 rt_util_pixtype_to_gdal_datatype(rt_pixtype pt) {
        switch (pt) {
@@ -236,6 +242,17 @@ rt_util_pixtype_to_gdal_datatype(rt_pixtype pt) {
        return GDT_Unknown;
 }
 
+/*
+       get GDAL runtime version information
+*/
+const char*
+rt_util_gdal_version(const char *request) {
+       if (NULL == request || !strlen(request))
+               return GDALVersionInfo("RELEASE_NAME");
+       else
+               return GDALVersionInfo(request);
+}
+
 /*- rt_context -------------------------------------------------------*/
 
 /* Functions definitions */
index d6692dff8062867155f8c2ddba96e6ca8a0c4e3b..6f5d7b439ddd748b96131c15e13f8c030725b159 100644 (file)
@@ -1144,6 +1144,12 @@ rt_util_gdal_resample_alg(const char *algname);
 GDALDataType
 rt_util_pixtype_to_gdal_datatype(rt_pixtype pt);
 
+/*
+       get GDAL runtime version information
+*/
+const char*
+rt_util_gdal_version(const char *request);
+
 /*
        helper macros for consistent floating point equality checks
 */
index 20d74b5c5d01cf1c90bf53a3a63da6081ec7381a..9eda96cab9cd03626017198bd7aa70bf0b36d3f9 100644 (file)
@@ -135,6 +135,7 @@ static char *getSRTextSPI(int srid);
 /* Utility functions */
 Datum RASTER_lib_version(PG_FUNCTION_ARGS);
 Datum RASTER_lib_build_date(PG_FUNCTION_ARGS);
+Datum RASTER_gdal_version(PG_FUNCTION_ARGS);
 
 /* Input/output and format conversions */
 Datum RASTER_in(PG_FUNCTION_ARGS);
@@ -538,6 +539,14 @@ Datum RASTER_lib_build_date(PG_FUNCTION_ARGS)
     PG_RETURN_POINTER(result);
 }
 
+PG_FUNCTION_INFO_V1(RASTER_gdal_version);
+Datum RASTER_gdal_version(PG_FUNCTION_ARGS)
+{
+       const char *ver = rt_util_gdal_version("--version");
+       text *result = cstring2text(ver);
+       PG_RETURN_POINTER(result);
+}
+
 /**
  * Input is a string with hex chars in it.
  * Convert to binary and put in the result
index f7fddc8b11bd36bc9283a480183c2cf037e5f8f9..cc8dd1a04cffd152019c8787373936cfd4094463 100644 (file)
@@ -51,7 +51,7 @@ CREATE TYPE raster (
 ------------------------------------------------------------------------------
 
 -----------------------------------------------------------------------
--- RasterLib Version
+-- Raster Version
 -----------------------------------------------------------------------
 
 CREATE OR REPLACE FUNCTION postgis_raster_lib_version()
@@ -64,6 +64,11 @@ CREATE OR REPLACE FUNCTION postgis_raster_lib_build_date()
     AS 'MODULE_PATHNAME', 'RASTER_lib_build_date'
     LANGUAGE 'C' IMMUTABLE; -- a new lib will require a new session
 
+CREATE OR REPLACE FUNCTION postgis_gdal_version()
+    RETURNS text
+    AS 'MODULE_PATHNAME', 'RASTER_gdal_version'
+    LANGUAGE 'C' IMMUTABLE;
+
 -----------------------------------------------------------------------
 -- Raster Accessors
 -----------------------------------------------------------------------
index a079b6265cbe209869e3174037c492bc326c4797..f7a081158fa5f6e915848f9df1f46c29154933e2 100755 (executable)
@@ -525,6 +525,7 @@ fi
 
 geosver=`${PSQL} -tAc "select postgis_geos_version()" "${DB}"`
 projver=`${PSQL} -tAc "select postgis_proj_version()" "${DB}"`
+gdalver=`${PSQL} -tAc "select postgis_gdal_version()" "${DB}"`
 libbuilddate=`${PSQL} -tAc "select postgis_lib_build_date()" "${DB}"`
 pgsqlver=`${PSQL} -tAc "select version()" "${DB}"`
 
@@ -540,6 +541,9 @@ fi
 if [ -n "$projver" ]; then
        echo "   PROJ: $projver"
 fi
+if [ -n "$gdalver" ]; then
+       echo "   GDAL: $gdalver"
+fi
 
 ###################################################
 #