[postgis-tickets] r17648 - Use protobuf version to enable/disable mvt/geobuf
Paul Ramsey
pramsey at cleverelephant.ca
Tue Jul 30 03:27:22 PDT 2019
Author: pramsey
Date: 2019-07-30 15:27:22 -0700 (Tue, 30 Jul 2019)
New Revision: 17648
Modified:
trunk/NEWS
trunk/configure.ac
trunk/postgis/Makefile.in
trunk/postgis/geobuf.c
trunk/postgis/geobuf.h
trunk/postgis/lwgeom_out_geobuf.c
trunk/postgis_config.h.in
trunk/regress/core/Makefile.in
Log:
Use protobuf version to enable/disable mvt/geobuf
Closes #4419
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2019-07-30 22:27:11 UTC (rev 17647)
+++ trunk/NEWS 2019-07-30 22:27:22 UTC (rev 17648)
@@ -19,6 +19,7 @@
- #4403, Support for shp2pgsql ability to reproject with copy mode (-D) (Regina Obe)
- #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 3.0.0alpha3
2019/07/01
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2019-07-30 22:27:11 UTC (rev 17647)
+++ trunk/configure.ac 2019-07-30 22:27:22 UTC (rev 17648)
@@ -1044,6 +1044,21 @@
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])
@@ -1626,7 +1641,12 @@
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([ Wagyu: ${HAVE_WAGYU}])
Modified: trunk/postgis/Makefile.in
===================================================================
--- trunk/postgis/Makefile.in 2019-07-30 22:27:11 UTC (rev 17647)
+++ trunk/postgis/Makefile.in 2019-07-30 22:27:22 UTC (rev 17648)
@@ -57,7 +57,10 @@
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
UTHASH_INCLUDE = -I../deps/uthash/include
endif
@@ -220,9 +223,11 @@
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
Modified: trunk/postgis/geobuf.c
===================================================================
--- trunk/postgis/geobuf.c 2019-07-30 22:27:11 UTC (rev 17647)
+++ trunk/postgis/geobuf.c 2019-07-30 22:27:22 UTC (rev 17648)
@@ -26,7 +26,7 @@
#include "geobuf.h"
#include "pgsql_compat.h"
-#ifdef HAVE_LIBPROTOBUF
+#if defined HAVE_LIBPROTOBUF && defined HAVE_GEOBUF
#define FEATURES_CAPACITY_INITIAL 50
#define MAX_PRECISION 1e6
Modified: trunk/postgis/geobuf.h
===================================================================
--- trunk/postgis/geobuf.h 2019-07-30 22:27:11 UTC (rev 17647)
+++ trunk/postgis/geobuf.h 2019-07-30 22:27:22 UTC (rev 17648)
@@ -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"
Modified: trunk/postgis/lwgeom_out_geobuf.c
===================================================================
--- trunk/postgis/lwgeom_out_geobuf.c 2019-07-30 22:27:11 UTC (rev 17647)
+++ trunk/postgis/lwgeom_out_geobuf.c 2019-07-30 22:27:22 UTC (rev 17648)
@@ -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 @@
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;
Modified: trunk/postgis_config.h.in
===================================================================
--- trunk/postgis_config.h.in 2019-07-30 22:27:11 UTC (rev 17647)
+++ trunk/postgis_config.h.in 2019-07-30 22:27:22 UTC (rev 17648)
@@ -41,6 +41,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
Modified: trunk/regress/core/Makefile.in
===================================================================
--- trunk/regress/core/Makefile.in 2019-07-30 22:27:11 UTC (rev 17647)
+++ trunk/regress/core/Makefile.in 2019-07-30 22:27:22 UTC (rev 17648)
@@ -23,6 +23,7 @@
POSTGIS_MINOR_VERSION=@POSTGIS_MINOR_VERSION@
HAVE_JSON=@HAVE_JSON@
HAVE_PROTOBUF=@HAVE_PROTOBUF@
+PROTOCC_VERSION=@PROTOCC_VERSION@
HAVE_SPGIST=@HAVE_SPGIST@
INTERRUPTTESTS=@INTERRUPTTESTS@
@@ -207,9 +208,12 @@
# ST_AsMVT, ST_AsGeobuf
TESTS += \
mvt \
- geobuf \
mvt_jsonb
+ifeq ($(shell expr $(PROTOCC_VERSION) ">=" 10100),1)
+ TESTS += \
+ geobuf
endif
+endif
all install uninstall:
More information about the postgis-tickets
mailing list