[postgis-tickets] r17646 - Use protobuf version to enable/disable mvt/geobuf
Paul Ramsey
pramsey at cleverelephant.ca
Tue Jul 30 03:27:06 PDT 2019
Author: pramsey
Date: 2019-07-30 15:27:06 -0700 (Tue, 30 Jul 2019)
New Revision: 17646
Modified:
branches/2.4/NEWS
branches/2.4/configure.ac
branches/2.4/postgis/Makefile.in
branches/2.4/postgis/geobuf.c
branches/2.4/postgis/geobuf.h
branches/2.4/postgis/lwgeom_out_geobuf.c
branches/2.4/postgis_config.h.in
branches/2.4/regress/Makefile.in
Log:
Use protobuf version to enable/disable mvt/geobuf
References #4419
Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS 2019-07-29 17:36:47 UTC (rev 17645)
+++ branches/2.4/NEWS 2019-07-30 22:27:06 UTC (rev 17646)
@@ -12,6 +12,7 @@
- #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.4.7
Modified: branches/2.4/configure.ac
===================================================================
--- branches/2.4/configure.ac 2019-07-29 17:36:47 UTC (rev 17645)
+++ branches/2.4/configure.ac 2019-07-30 22:27:06 UTC (rev 17646)
@@ -995,6 +995,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])
@@ -1497,7 +1512,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()
Modified: branches/2.4/postgis/Makefile.in
===================================================================
--- branches/2.4/postgis/Makefile.in 2019-07-29 17:36:47 UTC (rev 17645)
+++ branches/2.4/postgis/Makefile.in 2019-07-30 22:27:06 UTC (rev 17646)
@@ -51,8 +51,11 @@
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
SQLPP = @SQLPP@
@@ -197,9 +200,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: branches/2.4/postgis/geobuf.c
===================================================================
--- branches/2.4/postgis/geobuf.c 2019-07-29 17:36:47 UTC (rev 17645)
+++ branches/2.4/postgis/geobuf.c 2019-07-30 22:27:06 UTC (rev 17646)
@@ -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
Modified: branches/2.4/postgis/geobuf.h
===================================================================
--- branches/2.4/postgis/geobuf.h 2019-07-29 17:36:47 UTC (rev 17645)
+++ branches/2.4/postgis/geobuf.h 2019-07-30 22:27:06 UTC (rev 17646)
@@ -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: branches/2.4/postgis/lwgeom_out_geobuf.c
===================================================================
--- branches/2.4/postgis/lwgeom_out_geobuf.c 2019-07-29 17:36:47 UTC (rev 17645)
+++ branches/2.4/postgis/lwgeom_out_geobuf.c 2019-07-30 22:27:06 UTC (rev 17646)
@@ -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: branches/2.4/postgis_config.h.in
===================================================================
--- branches/2.4/postgis_config.h.in 2019-07-29 17:36:47 UTC (rev 17645)
+++ branches/2.4/postgis_config.h.in 2019-07-30 22:27:06 UTC (rev 17646)
@@ -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
Modified: branches/2.4/regress/Makefile.in
===================================================================
--- branches/2.4/regress/Makefile.in 2019-07-29 17:36:47 UTC (rev 17645)
+++ branches/2.4/regress/Makefile.in 2019-07-30 22:27:06 UTC (rev 17646)
@@ -23,6 +23,7 @@
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@
MINGWBUILD=@MINGWBUILD@
@@ -251,8 +252,11 @@
# 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
More information about the postgis-tickets
mailing list