]> granicus.if.org Git - postgis/commitdiff
Use protobuf version to enable/disable mvt/geobuf
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 30 Jul 2019 22:27:11 +0000 (22:27 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 30 Jul 2019 22:27:11 +0000 (22:27 +0000)
References #4419

git-svn-id: http://svn.osgeo.org/postgis/branches/2.5@17647 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
configure.ac
postgis/Makefile.in
postgis/geobuf.c
postgis/geobuf.h
postgis/lwgeom_out_geobuf.c
postgis_config.h.in
regress/Makefile.in

diff --git a/NEWS b/NEWS
index 06062eb5b2c7bac0f911896a0dad69642efb326e..d59cb84600393a0b39fa1fdc794886b2b6b7aaf5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ PostGIS 2.5.3
   - #4445, Fix bug in lwgeom_le (Raúl Marín)
   - #4466, Fix undefined behaviour in _postgis_gserialized_stats (Raúl Marín)
   - #4209, Handle NULL geometry values in pgsql2shp (Paul Ramsey)
+  - #4419, Use protobuf version to enable/disable mvt/geobuf (Paul Ramsey)
 
 
 PostGIS 2.5.2
index 1a1afb266d002df72487d4e59791d461827a3821..05ab984924c21ed11a93f22d81fcbfd35a0a61d0 100644 (file)
@@ -1010,6 +1010,21 @@ if test "$CHECK_PROTOBUF" != "no"; then
        fi
     fi
 
+    dnl Get version number for protoc-c
+    if test "$HAVE_PROTOBUF" = "yes"; then
+        AC_PATH_PROG(PROTOCC, protoc-c)
+        PROTOCC_SEMVER=$($PROTOCC --version | grep protobuf-c | awk '{print $2}')
+        AC_MSG_RESULT([checking protoc-c version... $PROTOCC_SEMVER])
+        PROTOCC_VERSION_MAJOR=$(echo "$PROTOCC_SEMVER" | tr '.' ' ' | awk '{print $1}')
+        PROTOCC_VERSION_MINOR=$(echo "$PROTOCC_SEMVER" | tr '.' ' ' | awk '{print $2}')
+        PROTOCC_VERSION_PATCH=$(echo "$PROTOCC_SEMVER" | tr '.' ' ' | awk '{print $3}')
+        PROTOCC_VERSION=$(expr 10000 \* $PROTOCC_VERSION_MAJOR + 100 \* $PROTOCC_VERSION_MINOR + $PROTOCC_VERSION_PATCH)
+        if test $PROTOCC_VERSION -ge 10100; then
+            AC_DEFINE([HAVE_GEOBUF], [1], [Define to 1 if libprotobuf-c is >= 1.1])
+        fi
+    fi
+
+    AC_SUBST([PROTOCC_VERSION])
     AC_SUBST([PROTOBUF_CPPFLAGS])
     AC_SUBST([PROTOBUF_LDFLAGS])
     AC_SUBST([HAVE_PROTOBUF])
@@ -1506,7 +1521,12 @@ AC_MSG_RESULT([  PROJ4 version:        ${POSTGIS_PROJ_VERSION}])
 AC_MSG_RESULT([  Libxml2 config:       ${XML2CONFIG}])
 AC_MSG_RESULT([  Libxml2 version:      ${POSTGIS_LIBXML2_VERSION}])
 AC_MSG_RESULT([  JSON-C support:       ${HAVE_JSON}])
+
 AC_MSG_RESULT([  protobuf-c support:   ${HAVE_PROTOBUF}])
+if test "x$HAVE_PROTOBUF" = "xyes"; then
+  AC_MSG_RESULT([  protobuf-c version:   ${PROTOCC_SEMVER}])
+fi
+
 AC_MSG_RESULT([  PCRE support:         ${HAVE_PCRE}])
 AC_MSG_RESULT([  Perl:                 ${PERL}])
 AC_MSG_RESULT()
index d960b2d1329cf3085c20bde098a65bd176ce8b07..fc3afc3dd36b06c76eff224af7ba034fc15761d3 100644 (file)
@@ -55,7 +55,10 @@ SPGIST_OBJ= gserialized_spgist_2d.o gserialized_spgist_3d.o
 endif
 
 ifeq (@HAVE_PROTOBUF@,yes)
-PROTOBUF_OBJ=vector_tile.pb-c.o geobuf.pb-c.o
+PROTOBUF_OBJ = vector_tile.pb-c.o
+ifeq ($(shell expr @PROTOCC_VERSION@ ">=" 10100),1)
+PROTOBUF_OBJ += geobuf.pb-c.o
+endif
 endif
 
 # SQL preprocessor
@@ -203,9 +206,11 @@ geobuf.pb-c.c geobuf.pb-c.h: geobuf.proto
 ifeq (@HAVE_PROTOBUF@,yes)
 lwgeom_out_mvt.o: vector_tile.pb-c.h
 mvt.o: vector_tile.pb-c.h
+ifeq ($(shell expr $(PROTOCC_VERSION) ">=" 10100),1)
 lwgeom_out_geobuf.o: geobuf.pb-c.h
 geobuf.o: geobuf.pb-c.h
 endif
+endif
 
 # Borrow the $libdir substitution from PGXS but customise by running the preprocessor
 # and adding the version number
index f504e2e77518ec669a553aad190b3354e9a3ec05..6fcb34866cde50f2e959723587545d06e0fb5600 100644 (file)
@@ -25,7 +25,7 @@
 #include <math.h>
 #include "geobuf.h"
 
-#ifdef HAVE_LIBPROTOBUF
+#if defined HAVE_LIBPROTOBUF && defined HAVE_GEOBUF
 
 #define FEATURES_CAPACITY_INITIAL 50
 #define MAX_PRECISION 1e6
index 6614139d342da157316e31000538647ef4bbca0d..2e0ae5f062c4a6f8d6dbbe957ab0d597fb20e703 100644 (file)
@@ -42,7 +42,7 @@
 #include "lwgeom_pg.h"
 #include "lwgeom_log.h"
 
-#ifdef HAVE_LIBPROTOBUF
+#if defined HAVE_LIBPROTOBUF && defined HAVE_GEOBUF
 
 #include "geobuf.pb-c.h"
 
index 88bf47b690ade0be75132f05897c52a87a3e26b3..1221fab5ac945e7001a5c5fb1193b702a41258dc 100644 (file)
@@ -45,8 +45,8 @@
 PG_FUNCTION_INFO_V1(pgis_asgeobuf_transfn);
 Datum pgis_asgeobuf_transfn(PG_FUNCTION_ARGS)
 {
-#ifndef HAVE_LIBPROTOBUF
-       elog(ERROR, "Missing libprotobuf-c");
+#if ! (defined HAVE_LIBPROTOBUF && defined HAVE_GEOBUF)
+       elog(ERROR, "Missing libprotobuf-c >= version 1.1");
        PG_RETURN_NULL();
 #else
        MemoryContext aggcontext;
@@ -82,8 +82,8 @@ Datum pgis_asgeobuf_transfn(PG_FUNCTION_ARGS)
 PG_FUNCTION_INFO_V1(pgis_asgeobuf_finalfn);
 Datum pgis_asgeobuf_finalfn(PG_FUNCTION_ARGS)
 {
-#ifndef HAVE_LIBPROTOBUF
-       elog(ERROR, "Missing libprotobuf-c");
+#if ! (defined HAVE_LIBPROTOBUF && defined HAVE_GEOBUF)
+       elog(ERROR, "Missing libprotobuf-c >= version 1.1");
        PG_RETURN_NULL();
 #else
        uint8_t *buf;
index a84f482dc3c1fd674d6f00d65333a854ecfb5a29..da60dffa59c7fdc70f1e235d8160305dd746ac83 100644 (file)
@@ -61,6 +61,9 @@
 /* Define to 1 if libprotobuf-c is present */
 #undef HAVE_LIBPROTOBUF
 
+/* Define to 1 if libprotobuf-c is >= version 1.1 */
+#undef HAVE_GEOBUF
+
 /* Define to 1 if libjson is present */
 #undef HAVE_LIBJSON
 
index 5f896be1139ebd25429ffdf9d2f3a94ee46d4a88..d3b8087926f13c2bc3611ad1fe0e38e6d41ba3a7 100644 (file)
@@ -23,6 +23,7 @@ POSTGIS_MAJOR_VERSION=@POSTGIS_MAJOR_VERSION@
 POSTGIS_MINOR_VERSION=@POSTGIS_MINOR_VERSION@
 HAVE_JSON=@HAVE_JSON@
 HAVE_PROTOBUF=@HAVE_PROTOBUF@
+PROTOCC_VERSION=@PROTOCC_VERSION@
 HAVE_SFCGAL=@HAVE_SFCGAL@
 HAVE_BRIN=@HAVE_BRIN@
 HAVE_SPGIST=@HAVE_SPGIST@
@@ -250,8 +251,11 @@ ifeq ($(HAVE_PROTOBUF),yes)
        # protobuf-c adds:
        # ST_AsMVT, ST_AsGeobuf
        TESTS += \
-               mvt \
+               mvt
+ifeq ($(shell expr $(PROTOCC_VERSION) ">=" 10100),1)
+       TESTS += \
                geobuf
+endif
 ifeq ($(shell expr $(POSTGIS_PGSQL_VERSION) ">=" 94),1)
        TESTS += \
                mvt_jsonb