[mapnik-vector-tile] 07/14: New upstream version 1.5.0+dfsg

Bas Couwenberg sebastic at debian.org
Tue Sep 26 20:15:07 UTC 2017


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository mapnik-vector-tile.

commit bd83bcf52f20ea163f78f70af55bcad3f0cd125e
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Tue Sep 26 21:25:40 2017 +0200

    New upstream version 1.5.0+dfsg
---
 .travis.yml                              | 21 ++++------
 CHANGELOG.md                             |  5 +++
 Makefile                                 | 54 +++++++++++++++++++------
 README.md                                | 39 ++++++++-----------
 bootstrap.sh                             | 32 +++++++++------
 examples/c++/tileinfo.cpp                |  6 ++-
 gyp/build.gyp                            | 32 +++++++--------
 install_mason.sh                         | 17 ++++----
 package.json                             |  2 +-
 scripts/build.sh                         | 11 +++++-
 src/vector_tile_layer.hpp                | 14 +++++--
 src/vector_tile_processor.hpp            | 12 +++++-
 src/vector_tile_processor.ipp            |  4 +-
 test/geometry_visual_test.cpp            |  1 -
 test/run.sh                              | 10 +++++
 test/system/processor_and_datasource.cpp | 36 +++++++++++++++++
 test/unit/layer_impl/layer.cpp           | 67 ++++++++++++++++++++++++++++++++
 test/unit/processor/variables.cpp        | 33 ++++++++++++++++
 18 files changed, 303 insertions(+), 93 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 91a6e69..42f2bce 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,7 +17,7 @@ matrix:
     - os: linux
       sudo: false
       compiler: ": gcc5"
-      env: JOBS=10 CXX="ccache g++-5" CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"
+      env: JOBS=10 CXX="ccache g++-5"
       addons:
         apt:
           sources: ['ubuntu-toolchain-r-test']
@@ -25,7 +25,7 @@ matrix:
     - os: linux
       sudo: false
       compiler: ": clang"
-      env: JOBS=10 CXX="ccache clang++-3.9 -Qunused-arguments"
+      env: JOBS=10 CXX="ccache clang++-4.0 -Qunused-arguments"
       addons:
         apt:
           sources: ['ubuntu-toolchain-r-test']
@@ -33,7 +33,7 @@ matrix:
     - os: linux
       sudo: false
       compiler: ": clang-coverage"
-      env: JOBS=10 CXX="ccache clang++-3.9 -Qunused-arguments" COVERAGE=true BUILDTYPE=Debug
+      env: JOBS=10 CXX="ccache clang++-4.0 -Qunused-arguments" COVERAGE=true
       addons:
         apt:
           sources: ['ubuntu-toolchain-r-test']
@@ -45,15 +45,14 @@ matrix:
       osx_image: xcode8.3 # upgrades clang from 6 -> 7
 
 before_install:
- - source ./bootstrap.sh
  - ./install_mason.sh
  - |
    if [[ $(uname -s) == 'Linux' ]]; then
-     ./mason/mason install llvm-cov 3.9.1
-     ./mason/mason install clang++ 3.9.1
-     export PATH=$(./mason/mason prefix clang++ 3.9.1)/bin:${PATH}
+     ./mason/mason install llvm-cov 4.0.1
+     ./mason/mason install clang++ 4.0.1
+     export PATH=$(./mason/mason prefix clang++ 4.0.1)/bin:${PATH}
      which clang++
-     export PATH=$(./mason/mason prefix llvm-cov 3.9.1)/bin:${PATH}
+     export PATH=$(./mason/mason prefix llvm-cov 4.0.1)/bin:${PATH}
      which llvm-cov
    fi
 
@@ -65,8 +64,4 @@ before_script:
 
 script:
  # make sure tileinfo command works
- - ./build/${BUILDTYPE:-Release}/tileinfo examples/data/14_2620_6331.vector.mvt.z
-
-notifications:
-  slack:
-    secure: eP79cXpZ3zyVarMooLYi75C5XBS65SJkf12h25hLDmoaQD+aX0u3+/hivE3jxi8KI8v1Izpzf06aCGHL1lx/xXGg2uuiM6dtZTou1mJJ4oFsxzOJFfLXhsUO1+qXkJJG1xoaLpbSdX/y+2dfe0xKTm4zAlluj2DvwZO+R9djLGM=
+ - ./build/Debug/tileinfo examples/data/14_2620_6331.vector.mvt.z
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3a5c72c..93eae1b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
 # Changelog
 
+## 1.5.0
+
+- Added back ability to build against external mapnik (see docs for instructions)
+- Added support for variables @rafatower: https://github.com/mapbox/mapnik-vector-tile/pull/248
+
 ## 1.4.0
 
 - Fixed a bug associated with image height and width when reading from an image resulting in a size of zero causing exceptions.
diff --git a/Makefile b/Makefile
index 1af04da..669d90f 100755
--- a/Makefile
+++ b/Makefile
@@ -1,27 +1,53 @@
-MAPNIK_PLUGINDIR = $(shell mason_packages/.link/bin/mapnik-config --input-plugins)
-BUILDTYPE ?= Release
-
 GYP_REVISION=3464008
 
-all: libvtile
+default: release
+
+mason_packages/.link/bin:
+	SKIP_MAPNIK_INSTALL=YES ./install_mason.sh
 
 mason_packages/.link/bin/mapnik-config:
 	./install_mason.sh
 
+pre_build_check:
+	@echo "Looking for mapnik-config on your PATH..."
+	mapnik-config -v
+
 ./deps/gyp:
 	git clone https://chromium.googlesource.com/external/gyp.git ./deps/gyp && cd ./deps/gyp && git checkout $(GYP_REVISION)
 
-build/Makefile: mason_packages/.link/bin/mapnik-config ./deps/gyp gyp/build.gyp test/*
-	deps/gyp/gyp gyp/build.gyp --depth=. -DMAPNIK_PLUGINDIR=\"$(MAPNIK_PLUGINDIR)\" -Goutput_dir=. --generator-output=./build -f make
+build/Makefile: pre_build_check ./deps/gyp gyp/build.gyp test/*
+	deps/gyp/gyp gyp/build.gyp --depth=. -DMAPNIK_PLUGINDIR=\"$(shell mapnik-config --input-plugins)\" -Goutput_dir=. --generator-output=./build -f make
+	$(MAKE) -C build/ V=$(V)
+
+release: mason_packages/.link/bin/mapnik-config Makefile
+	CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0 $(CXXFLAGS)" $(MAKE) release_base
 
-libvtile: build/Makefile Makefile
-	@$(MAKE) -C build/ BUILDTYPE=$(BUILDTYPE) V=$(V)
+debug: mason_packages/.link/bin/mapnik-config Makefile
+	CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0 $(CXXFLAGS)" $(MAKE) debug_base
 
-test/geometry-test-data:
+# note: we set PATH to the mason bins to pick up protoc
+# and CXXFLAGS/LDFLAGS to find protobuf headers/libs
+# This will only find mason installed mapnik-config if run via the `release` or `debug` targets
+release_base: mason_packages/.link/bin Makefile
+	CXXFLAGS="-isystem `pwd`/mason_packages/.link/include $(CXXFLAGS)" \
+	 LDFLAGS="-L`pwd`/mason_packages/.link/lib $(LDFLAGS)" \
+	 PATH="`pwd`/mason_packages/.link/bin/:${PATH}" \
+	 BUILDTYPE=Release $(MAKE) build/Makefile
+
+debug_base: mason_packages/.link/bin Makefile
+	CXXFLAGS="-isystem `pwd`/mason_packages/.link/include $(CXXFLAGS)" \
+	 LDFLAGS="-L`pwd`/mason_packages/.link/lib $(LDFLAGS)" \
+	 PATH="`pwd`/mason_packages/.link/bin/:${PATH}" \
+	 BUILDTYPE=Debug $(MAKE) build/Makefile
+
+test/geometry-test-data/README.md:
 	git submodule update --init
 
-test: libvtile test/geometry-test-data
-	DYLD_LIBRARY_PATH=$(MVT_LIBRARY_PATH) ./build/$(BUILDTYPE)/tests
+test: test/geometry-test-data/README.md
+	BUILDTYPE=Release ./test/run.sh
+
+test-debug: test/geometry-test-data/README.md
+	BUILDTYPE=Debug ./test/run.sh
 
 testpack:
 	rm -f ./*tgz
@@ -31,8 +57,12 @@ testpack:
 
 clean:
 	rm -rf ./build
+
+distclean: clean
+	rm -rf ./mason
+	rm -rf ./deps/gyp
 	rm -rf ./mason_packages
 
-.PHONY: test
+.PHONY: test build/Makefile
 
 
diff --git a/README.md b/README.md
index 3baf062..5e8354a 100644
--- a/README.md
+++ b/README.md
@@ -11,42 +11,37 @@ Provides C++ headers that support rendering geodata into vector tiles and render
 
 ## Depends
 
-Mapnik Vector Tile does not currently support Mapnik 3.1.x.
-
- - mapnik-vector-tile >=1.4.x depends on Mapnik >=v3.0.14
- - mapnik-vector-tile >=1.0.x depends on Mapnik >=v3.0.11
- - mapnik-vector-tile 1.0.0 to 0.7.x depends on Mapnik v3.0.x (until 3.0.0 is released this means latest mapnik HEAD)
- - mapnik-vector-tile 0.6.x and previous work with Mapnik v2.2.x or v2.3.x
- - You will need `libmapnik` and `mapnik-config` available
- - Protobuf: `libprotobuf` and `protoc`
-
 ## Implementation details
 
 Vector tiles in this code represent a direct serialization of Mapnik layers optimized for space efficient storage and fast deserialization. For those familiar with the Mapnik API vector tiles here can be considered a named array of `mapnik::featureset_ptr` whose geometries have been pre-tiled.
 
 For more details see [vector-tile-spec](https://github.com/mapbox/vector-tile-spec).
 
-### Ubuntu Dependencies Installation
+## Building from source
+
+If you do not need to build against an external mapnik, just type:
 
-    sudo apt-get install -y libprotobuf7 libprotobuf-dev protobuf-compiler
-    sudo apt-add-repository --yes ppa:mapnik/nightly-2.3
-    sudo apt-get update -y
-    sudo apt-get -y install libmapnik=2.3.0* mapnik-utils=2.3.0* libmapnik-dev=2.3.0* mapnik-input-plugin*=2.3.0*
+    make
 
-### OS X Dependencies Installation
+This will download all deps (including Mapnik) and compile against them.
 
-    brew install protobuf
-    brew install mapnik
+To build and test in debug mode do:
 
-## Building
+    make debug test-debug
 
-Just type:
+If you have Mapnik, libprotobuf, and all the Mapnik deps already installed on your system then you can build against them with:
 
-    make
+    make release_base
+
+If building against an external Mapnik please know that Mapnik Vector Tile does not currently support Mapnik 3.1.x.
 
-This builds the protobuf C++ wrappers: `vector_tile.pb.cc` and `vector_tile.pb.h`
+ - mapnik-vector-tile >=1.4.x depends on Mapnik >=v3.0.14
+ - mapnik-vector-tile >=1.0.x depends on Mapnik >=v3.0.11
+ - mapnik-vector-tile 1.0.0 to 0.7.x depends on Mapnik v3.0.x (until 3.0.0 is released this means latest mapnik HEAD)
+ - mapnik-vector-tile 0.6.x and previous work with Mapnik v2.2.x or v2.3.x
+ - You will need `libmapnik` and `mapnik-config` available
+ - Protobuf: `libprotobuf` and `protoc`
 
-Then include `vector_tile.pb.cc` in your code. The rest is header only.
 
 ## Tests
 
diff --git a/bootstrap.sh b/bootstrap.sh
index 522514a..bf125c4 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,19 +1,27 @@
 #!/usr/bin/env bash
 
+# if built against mason package fix dynamic data locations
 function setup_runtime_settings() {
-    local MASON_LINKED_ABS=$(pwd)/mason_packages/.link
-    export PROJ_LIB=${MASON_LINKED_ABS}/share/proj
-    export ICU_DATA=${MASON_LINKED_ABS}/share/icu/${ICU_VERSION}
-    export GDAL_DATA=${MASON_LINKED_ABS}/share/gdal
-    if [[ $(uname -s) == 'Darwin' ]]; then
-        export DYLD_LIBRARY_PATH=$(pwd)/mason_packages/.link/lib:${DYLD_LIBRARY_PATH}
-        # OS X > 10.11 blocks DYLD_LIBRARY_PATH so we pass along using a
-        # differently named variable
-        export MVT_LIBRARY_PATH=${DYLD_LIBRARY_PATH}
-    else
-        export LD_LIBRARY_PATH=$(pwd)/mason_packages/.link/lib:${LD_LIBRARY_PATH}
+    if [[ -f $(pwd)/mason_packages/.link/bin/mapnik-config ]]; then
+        # TODO: use --proj-lib, --gdal-data, etc after https://github.com/mapnik/mapnik/pull/3759 is fixed
+        #export PROJ_LIB=$(mapnik-config --proj-lib)
+        #export GDAL_DATA=$(mapnik-config --gdal-data)
+        #export ICU_DATA=$(mapnik-config --icu-data)
+        local MASON_LINKED_ABS=$(pwd)/mason_packages/.link
+        export PROJ_LIB=${MASON_LINKED_ABS}/share/proj
+        ICU_VERSION=$(ls ${MASON_LINKED_ABS}/share/icu/)
+        export ICU_DATA=${MASON_LINKED_ABS}/share/icu/${ICU_VERSION}
+        export GDAL_DATA=${MASON_LINKED_ABS}/share/gdal
+        if [[ $(uname -s) == 'Darwin' ]]; then
+            export DYLD_LIBRARY_PATH=$(pwd)/mason_packages/.link/lib:${DYLD_LIBRARY_PATH:-}
+            # OS X > 10.11 blocks DYLD_LIBRARY_PATH so we pass along using a
+            # differently named variable
+            export MVT_LIBRARY_PATH=${DYLD_LIBRARY_PATH}
+        else
+            export LD_LIBRARY_PATH=$(pwd)/mason_packages/.link/lib:${LD_LIBRARY_PATH:-}
+        fi
+        export PATH=$(pwd)/mason_packages/.link/bin:${PATH}
     fi
-    export PATH=$(pwd)/mason_packages/.link/bin:${PATH}
 }
 
 function main() {
diff --git a/examples/c++/tileinfo.cpp b/examples/c++/tileinfo.cpp
index b4e3959..253fa7d 100644
--- a/examples/c++/tileinfo.cpp
+++ b/examples/c++/tileinfo.cpp
@@ -209,7 +209,11 @@ int main(int argc, char** argv)
                  for (std::size_t l=0;l<static_cast<std::size_t>(layer.features_size());++l)
                  {
                      vector_tile::Tile_Feature const & feat = layer.features(l);
-                     std::cout << "  feature: " << feat.id() << "\n";
+                     if (feat.has_id()) {
+                         std::cout << "  feature: " << feat.id() << "\n";
+                     } else {
+                         std::cout << "  feature: (no id set)\n";
+                     }
                      std::cout << "    type: ";
                      unsigned feat_type = feat.type();
                      if (feat_type == 0) {
diff --git a/gyp/build.gyp b/gyp/build.gyp
index 5a22717..7ab392a 100644
--- a/gyp/build.gyp
+++ b/gyp/build.gyp
@@ -37,25 +37,25 @@
         "<(SHARED_INTERMEDIATE_DIR)/vector_tile.pb.cc"
       ],
       'include_dirs': [
-        '<(SHARED_INTERMEDIATE_DIR)/',
+        '<(SHARED_INTERMEDIATE_DIR)/'
       ],
       'cflags_cc' : [
           '-D_THREAD_SAFE',
-          '<!@(../mason_packages/.link/bin/mapnik-config --cflags)', # assume protobuf headers are here
+          '<!@(mapnik-config --cflags)',
           '-Wno-sign-compare',
           '-Wno-sign-conversion'
       ],
       'xcode_settings': {
         'OTHER_CPLUSPLUSFLAGS':[
            '-D_THREAD_SAFE',
-           '<!@(../mason_packages/.link/bin/mapnik-config --cflags)', # assume protobuf headers are here
+           '<!@(mapnik-config --cflags)',
            '-Wno-sign-compare',
            '-Wno-sign-conversion'
         ],
       },
       'direct_dependent_settings': {
         'include_dirs': [
-          '<(SHARED_INTERMEDIATE_DIR)/',
+          '<(SHARED_INTERMEDIATE_DIR)/'
         ],
         'libraries':[
           '-lprotobuf-lite'
@@ -82,34 +82,34 @@
         "<@(common_defines)"
       ],
       'cflags_cc' : [
-          '<!@(../mason_packages/.link/bin/mapnik-config --cflags)'
+          '<!@(mapnik-config --cflags)'
       ],
       'xcode_settings': {
         'OTHER_CPLUSPLUSFLAGS':[
-           '<!@(../mason_packages/.link/bin/mapnik-config --cflags)'
+           '<!@(mapnik-config --cflags)'
         ],
       },
       'direct_dependent_settings': {
         'include_dirs': [
-          '<(SHARED_INTERMEDIATE_DIR)/',
+          '<(SHARED_INTERMEDIATE_DIR)/'
         ],
         'defines' : [
           "<@(common_defines)"
         ],
         'cflags_cc' : [
-            '<!@(../mason_packages/.link/bin/mapnik-config --cflags)'
+            '<!@(mapnik-config --cflags)'
         ],
         'xcode_settings': {
           'OTHER_CPLUSPLUSFLAGS':[
-             '<!@(../mason_packages/.link/bin/mapnik-config --cflags)'
+             '<!@(mapnik-config --cflags)'
           ],
         },
         'libraries':[
-          '<!@(../mason_packages/.link/bin/mapnik-config --libs)',
-          '<!@(../mason_packages/.link/bin/mapnik-config --ldflags)',
+          '<!@(mapnik-config --libs)',
+          '<!@(mapnik-config --ldflags)',
           '-lmapnik-wkt',
           '-lmapnik-json',
-          '<!@(../mason_packages/.link/bin/mapnik-config --dep-libs)',
+          '<!@(mapnik-config --dep-libs)',
           '-lprotobuf-lite',
           '-lz'
         ],
@@ -203,18 +203,18 @@
         "../src"
       ],
       'libraries':[
-        '-L<!@(../mason_packages/.link/bin/mapnik-config --prefix)/lib',
-        '<!@(../mason_packages/.link/bin/mapnik-config --ldflags)',
+        '-L<!@(mapnik-config --prefix)/lib',
+        '<!@(mapnik-config --ldflags)',
         '-lz'
       ],
       'cflags_cc' : [
           '-D_THREAD_SAFE',
-          '<!@(../mason_packages/.link/bin/mapnik-config --cflags)' # assume protobuf headers are here
+          '<!@(mapnik-config --cflags)'
       ],
       'xcode_settings': {
         'OTHER_CPLUSPLUSFLAGS':[
            '-D_THREAD_SAFE',
-           '<!@(../mason_packages/.link/bin/mapnik-config --cflags)' # assume protobuf headers are here
+           '<!@(mapnik-config --cflags)'
         ],
       }
     }    
diff --git a/install_mason.sh b/install_mason.sh
index c20d294..f20aea3 100755
--- a/install_mason.sh
+++ b/install_mason.sh
@@ -9,13 +9,21 @@ function install() {
 }
 
 ICU_VERSION="57.1"
+MASON_VERSION="v0.14.2"
 
 if [ ! -f ./mason/mason.sh ]; then
     mkdir -p ./mason
-    curl -sSfL https://github.com/mapbox/mason/archive/9eac60614fda7cfeb8a9e81d18e8cca5c1ae8fbc.tar.gz | tar --gunzip --extract --strip-components=1 --exclude="*md" --exclude="test*" --directory=./mason
+    curl -sSfL https://github.com/mapbox/mason/archive/${MASON_VERSION}.tar.gz | tar --gunzip --extract --strip-components=1 --exclude="*md" --exclude="test*" --directory=./mason
 fi
 
-if [ ! -f ./mason_packages/.link/bin/mapnik-config ]; then
+# core deps
+install protozero 1.5.2
+install geometry 0.9.2
+install wagyu 0.4.3
+install protobuf 3.3.0
+
+# mapnik
+if [[ ${SKIP_MAPNIK_INSTALL:-} != 'YES' ]] && [[ ! -f ./mason_packages/.link/bin/mapnik-config ]]; then
 
     # mapnik deps
     install jpeg_turbo 1.5.1
@@ -37,9 +45,4 @@ if [ ! -f ./mason_packages/.link/bin/mapnik-config ]; then
     # mapnik
     install mapnik 3.0.14
 
-    # other deps
-    install protozero 1.5.1
-    install geometry 0.9.1
-    install wagyu 0.4.2
-    install protobuf 2.6.1
 fi
diff --git a/package.json b/package.json
index dc2e6b0..e19a8d9 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "mapnik-vector-tile",
-    "version": "1.4.0",
+    "version": "1.5.0",
     "description": "Mapnik Vector Tile API",
     "main": "include_dirs.js",
     "repository"   :  {
diff --git a/scripts/build.sh b/scripts/build.sh
index 3248157..1564098 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -2,10 +2,17 @@ set -e -u
 set -o pipefail
 
 if [[ ${COVERAGE:-false} == true ]]; then
+    # test only debug version
     export LDFLAGS="--coverage"
     export CXXFLAGS="--coverage"
+    make debug -j${JOBS:-1} V=1
+    make test-debug
+else
+    # test both release and debug
+    make release -j${JOBS:-1} V=1
+    make test
+    make debug -j${JOBS:-1} V=1
+    make test-debug
 fi
 
-make -j${JOBS:-1} test BUILDTYPE=${BUILDTYPE:-Release} V=1
-
 set +e +u
diff --git a/src/vector_tile_layer.hpp b/src/vector_tile_layer.hpp
index 1ab7509..532b0f6 100644
--- a/src/vector_tile_layer.hpp
+++ b/src/vector_tile_layer.hpp
@@ -95,7 +95,8 @@ public:
                double scale_factor,
                double scale_denom,
                int offset_x,
-               int offset_y)
+               int offset_y,
+               mapnik::attributes const& vars)
         : valid_(true),
           ds_(lay.datasource()),
           target_proj_(map.srs(), true),
@@ -106,7 +107,7 @@ public:
           layer_extent_(calc_extent(tile_size)),
           target_buffered_extent_(calc_target_buffered_extent(tile_extent_bbox, buffer_size, lay, map)),
           source_buffered_extent_(calc_source_buffered_extent()),
-          query_(calc_query(scale_factor, scale_denom, tile_extent_bbox, lay)),
+          query_(calc_query(scale_factor, scale_denom, tile_extent_bbox, lay, vars)),
           view_trans_(layer_extent_, layer_extent_, tile_extent_bbox, offset_x, offset_y),
           empty_(true),
           painted_(false)
@@ -221,7 +222,8 @@ public:
     mapnik::query calc_query(double scale_factor,
                              double scale_denom,
                              mapnik::box2d<double> const& tile_extent_bbox,
-                             mapnik::layer const& lay)
+                             mapnik::layer const& lay,
+                             mapnik::attributes const& vars)
     {
         // Adjust the scale denominator if required
         if (scale_denom <= 0.0)
@@ -293,6 +295,7 @@ public:
                 q.add_property_name(desc.get_name());
             }
         }
+        q.set_variables(vars);
         return q;
     }
 
@@ -306,6 +309,11 @@ public:
         return ds_->features(query_);
     }
 
+    mapnik::query const& get_query() const
+    {
+        return query_;
+    }
+
     mapnik::view_transform const& get_view_transform() const
     {
         return view_trans_;
diff --git a/src/vector_tile_processor.hpp b/src/vector_tile_processor.hpp
index 0868010..5a77fc5 100644
--- a/src/vector_tile_processor.hpp
+++ b/src/vector_tile_processor.hpp
@@ -6,6 +6,7 @@
 #include <mapnik/image_scaling.hpp>
 #include <mapnik/layer.hpp>
 #include <mapnik/map.hpp>
+#include <mapnik/attribute.hpp>
 #include <mapnik/request.hpp>
 #include <mapnik/util/noncopyable.hpp>
 
@@ -46,9 +47,10 @@ private:
     bool multi_polygon_union_;
     bool process_all_rings_;
     std::launch threading_mode_;
+    mapnik::attributes vars_;
 
 public:
-    processor(mapnik::Map const& map)
+    processor(mapnik::Map const& map, mapnik::attributes const& vars = mapnik::attributes())
         : m_(map),
           image_format_("webp"),
           scale_factor_(1.0),
@@ -59,7 +61,8 @@ public:
           strictly_simple_(true),
           multi_polygon_union_(false),
           process_all_rings_(false),
-          threading_mode_(std::launch::deferred) {}
+          threading_mode_(std::launch::deferred),
+          vars_(vars) {}
 
     MAPNIK_VECTOR_INLINE void update_tile(tile & t,
                                           double scale_denom = 0.0,
@@ -182,6 +185,11 @@ public:
         return image_format_;
     }
 
+    mapnik::attributes const& get_variables() const
+    {
+        return vars_;
+    }
+
     void set_threading_mode(std::launch mode)
     {
         threading_mode_ = mode;
diff --git a/src/vector_tile_processor.ipp b/src/vector_tile_processor.ipp
index fecc5bc..ad9a21a 100644
--- a/src/vector_tile_processor.ipp
+++ b/src/vector_tile_processor.ipp
@@ -15,6 +15,7 @@
 #include <mapnik/layer.hpp>
 #include <mapnik/map.hpp>
 #include <mapnik/version.hpp>
+#include <mapnik/attribute.hpp>
 
 #if MAPNIK_VERSION >= 300100
 #include <mapnik/geometry/transform.hpp>
@@ -258,7 +259,8 @@ MAPNIK_VECTOR_INLINE void processor::update_tile(tile & t,
                              scale_factor_,
                              scale_denom,
                              offset_x,
-                             offset_y);
+                             offset_y,
+                             vars_);
         if (!tile_layers.back().is_valid())
         {
             t.add_empty_layer(lay.name());
diff --git a/test/geometry_visual_test.cpp b/test/geometry_visual_test.cpp
index ccdbbbf..b2f8196 100644
--- a/test/geometry_visual_test.cpp
+++ b/test/geometry_visual_test.cpp
@@ -162,7 +162,6 @@ void clip_geometry(mapnik::Map const& map,
         }
         std::string expected_string(input.data().get(), input.size());
         mapnik::geometry::geometry<double> geom_expected;
-        CHECK(expected_string == geojson_string);
         if (mapnik::json::from_geojson(expected_string, geom_expected))
         {
             assert_g_equal(geom_expected, geom4326_pbf);
diff --git a/test/run.sh b/test/run.sh
new file mode 100755
index 0000000..3c003de
--- /dev/null
+++ b/test/run.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+set -eu
+set -o pipefail
+
+source ./bootstrap.sh
+
+BUILDTYPE=${BUILDTYPE:-Release}
+
+./build/${BUILDTYPE}/tests
\ No newline at end of file
diff --git a/test/system/processor_and_datasource.cpp b/test/system/processor_and_datasource.cpp
index 6af58ce..ac60ed9 100644
--- a/test/system/processor_and_datasource.cpp
+++ b/test/system/processor_and_datasource.cpp
@@ -64,6 +64,42 @@ TEST_CASE("vector tile output -- simple two points")
     CHECK(190 == buffer.size());
 }
 
+TEST_CASE("processor -- can deal with (optional) variables")
+{
+    // Build Map
+    mapnik::Map map(256, 256, "+init=epsg:3857");
+    mapnik::layer lyr("layer",map.srs());
+    lyr.set_datasource(testing::build_ds(0,0,true));
+    map.add_layer(lyr);
+
+    // Create processor
+    const mapnik::attributes vars { {"zoom_level", 20} };
+    mapnik::vector_tile_impl::processor ren(map, vars);
+
+    // Request Tile
+    mapnik::vector_tile_impl::merc_tile out_tile = ren.create_tile(0,0,0);
+    CHECK(out_tile.is_painted() == true);
+    CHECK(out_tile.is_empty() == false);
+
+    // Now check that the tile is correct.
+    vector_tile::Tile tile;
+    tile.ParseFromString(out_tile.get_buffer());
+    REQUIRE(1 == tile.layers_size());
+    vector_tile::Tile_Layer const& layer = tile.layers(0);
+    CHECK(std::string("layer") == layer.name());
+    REQUIRE(2 == layer.features_size());
+    vector_tile::Tile_Feature const& f = layer.features(0);
+    CHECK(static_cast<mapnik::value_integer>(1) == static_cast<mapnik::value_integer>(f.id()));
+    REQUIRE(3 == f.geometry_size());
+    CHECK(9 == f.geometry(0));
+    CHECK(4096 == f.geometry(1));
+    CHECK(4096 == f.geometry(2));
+    CHECK(190 == tile.ByteSize());
+    std::string buffer;
+    CHECK(tile.SerializeToString(&buffer));
+    CHECK(190 == buffer.size());
+}
+
 TEST_CASE("vector tile output -- empty tile")
 {
     // test adding empty layers should result in empty tile
diff --git a/test/unit/layer_impl/layer.cpp b/test/unit/layer_impl/layer.cpp
new file mode 100644
index 0000000..6de5762
--- /dev/null
+++ b/test/unit/layer_impl/layer.cpp
@@ -0,0 +1,67 @@
+#include "catch.hpp"
+
+// mapnik
+#include <mapnik/map.hpp>
+#include <mapnik/attribute.hpp>
+#include <mapnik/memory_datasource.hpp>
+
+// mapnik vector tile layer class
+#include "vector_tile_layer.hpp"
+
+TEST_CASE("Vector tile layer class")
+{
+    SECTION("The constructor can produce a valid tile_layer with empty vars")
+    {
+        mapnik::Map map(256, 256);
+
+        // Create memory datasource
+        mapnik::parameters params;
+        params["type"] = "memory";
+        auto ds = std::make_shared<mapnik::memory_datasource>(params);
+
+        mapnik::layer layer("layer", "+init=epsg:3857");
+        layer.set_datasource(ds);
+        mapnik::box2d<double> extent(-20037508.342789,-20037508.342789,20037508.342789,20037508.342789);
+        const mapnik::attributes empty_vars;
+
+        mapnik::vector_tile_impl::tile_layer some_layer(map,
+                                                        layer,
+                                                        extent,
+                                                        256, // tile_size
+                                                        10, // buffer_size
+                                                        1.0, // scale_factor
+                                                        0, // scale_denom
+                                                        0, // offset_x
+                                                        0, // offset_y
+                                                        empty_vars);
+        CHECK(some_layer.is_valid());
+    }
+
+    SECTION("The query has the variables passed to the constructor")
+    {
+        mapnik::Map map(256, 256);
+
+        // Create memory datasource
+        mapnik::parameters params;
+        params["type"] = "memory";
+        auto ds = std::make_shared<mapnik::memory_datasource>(params);
+
+        mapnik::layer layer("layer", "+init=epsg:3857");
+        layer.set_datasource(ds);
+        mapnik::box2d<double> extent(-20037508.342789,-20037508.342789,20037508.342789,20037508.342789);
+        const mapnik::attributes vars { {"zoom_level", 20} };
+
+        mapnik::vector_tile_impl::tile_layer some_layer(map,
+                                                        layer,
+                                                        extent,
+                                                        256, // tile_size
+                                                        10, // buffer_size
+                                                        1.0, // scale_factor
+                                                        0, // scale_denom
+                                                        0, // offset_x
+                                                        0, // offset_y
+                                                        vars);
+        CHECK(some_layer.is_valid());
+        CHECK( ( vars == some_layer.get_query().variables() ) );
+    }
+}
diff --git a/test/unit/processor/variables.cpp b/test/unit/processor/variables.cpp
new file mode 100644
index 0000000..57bfb49
--- /dev/null
+++ b/test/unit/processor/variables.cpp
@@ -0,0 +1,33 @@
+#include "catch.hpp"
+
+// mapnik
+#include <mapnik/map.hpp>
+#include <mapnik/attribute.hpp>
+#include <mapnik/memory_datasource.hpp>
+#include <mapnik/feature_factory.hpp>
+
+// mapnik-vector-tile
+#include "vector_tile_processor.hpp"
+#include "vector_tile_tile.hpp"
+
+
+TEST_CASE("feature processor - can pass variables down to layers")
+{
+    SECTION("variables are optional")
+    {
+        mapnik::Map map(256, 256);
+        mapnik::attributes empty_vars;
+
+        mapnik::vector_tile_impl::processor some_processor(map);
+        CHECK( ( empty_vars == some_processor.get_variables() ) );
+    }
+
+    SECTION("variables can be passed down to the processor")
+    {
+        mapnik::Map map(256, 256);
+        const mapnik::attributes vars { {"zoom_level", 20} };
+
+        mapnik::vector_tile_impl::processor some_processor(map, vars);
+        CHECK( ( vars == some_processor.get_variables() ) );
+    }
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mapnik-vector-tile.git



More information about the Pkg-grass-devel mailing list