[mapnik-vector-tile] 06/15: Imported Upstream version 1.4.0+dfsg

Bas Couwenberg sebastic at debian.org
Tue Aug 29 11:46:05 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 bc27443eccf53299ce30fc17f18181153dfc769f
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri Jun 9 11:03:21 2017 +0200

    Imported Upstream version 1.4.0+dfsg
---
 .travis.yml                                |  21 ++++--
 CHANGELOG.md                               |   8 ++
 README.md                                  |   5 +-
 bin/vtile-fuzz.cpp                         | 113 -----------------------------
 codecov.yml                                |   5 ++
 gyp/build.gyp                              |  15 ----
 install_mason.sh                           |   4 +-
 package.json                               |   2 +-
 scripts/coverage.sh                        |  29 ++------
 src/vector_tile_featureset_pbf.ipp         |  34 +++++----
 src/vector_tile_layer.hpp                  |  16 +++-
 src/vector_tile_processor.ipp              |  57 ++++-----------
 test/data/layer_scale_denom_style.xml      |  21 ++++++
 test/fixtures/expected-2.jpeg              | Bin 42943 -> 45612 bytes
 test/fixtures/expected-2.png               | Bin 419393 -> 423118 bytes
 test/raster_tile.cpp                       |   2 +-
 test/unit/processor/scale_denom_filter.cpp |  42 +++++++++++
 17 files changed, 147 insertions(+), 227 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index bbf20b7..91a6e69 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,7 +25,15 @@ matrix:
     - os: linux
       sudo: false
       compiler: ": clang"
-      env: JOBS=10 CXX="ccache clang++-3.8 -Qunused-arguments"
+      env: JOBS=10 CXX="ccache clang++-3.9 -Qunused-arguments"
+      addons:
+        apt:
+          sources: ['ubuntu-toolchain-r-test']
+          packages: [ 'libstdc++-5-dev', 'xutils-dev']
+    - os: linux
+      sudo: false
+      compiler: ": clang-coverage"
+      env: JOBS=10 CXX="ccache clang++-3.9 -Qunused-arguments" COVERAGE=true BUILDTYPE=Debug
       addons:
         apt:
           sources: ['ubuntu-toolchain-r-test']
@@ -34,18 +42,19 @@ matrix:
       compiler: clang
       env: JOBS=10
       # https://docs.travis-ci.com/user/languages/objective-c/#Supported-OS-X-iOS-SDK-versions
-      osx_image: xcode7 # upgrades clang from 6 -> 7
+      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.8.1
-     ./mason/mason install clang++ 3.8.1
-     export PATH=$(./mason/mason prefix clang++ 3.8.1)/bin:${PATH}
+     ./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}
      which clang++
-     export LLVM_COV="$(./mason/mason prefix llvm-cov 3.8.1)/bin/llvm-cov"
+     export PATH=$(./mason/mason prefix llvm-cov 3.9.1)/bin:${PATH}
+     which llvm-cov
    fi
 
 install:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ab37c09..3a5c72c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,13 @@
 # Changelog
 
+## 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.
+- Updated to use mapnik 3.0.14, previous version of mapnik will not work properly with this newest version.
+- Corrected issues with resolution associated with mapnik queries that was allowing the buffer size of the vector tile to affect the resolution.
+- Removed some duplicate code
+- Removed fuzzer from library
+
 ## 1.3.0
 
 - Updated protozero to 1.5.1
diff --git a/README.md b/README.md
index f0eaeec..3baf062 100644
--- a/README.md
+++ b/README.md
@@ -7,10 +7,13 @@ Provides C++ headers that support rendering geodata into vector tiles and render
  - Master: [![Build Status](https://travis-ci.org/mapbox/mapnik-vector-tile.svg?branch=master)](https://travis-ci.org/mapbox/mapnik-vector-tile)
  - 0.6.x series: [![Build Status](https://secure.travis-ci.org/mapbox/mapnik-vector-tile.svg?branch=0.6.x)](http://travis-ci.org/mapbox/mapnik-vector-tile)
 
-[![Coverage Status](https://coveralls.io/repos/mapbox/mapnik-vector-tile/badge.svg?branch=master&service=github)](https://coveralls.io/github/mapbox/mapnik-vector-tile?branch=master)
+[![codecov](https://codecov.io/gh/mapbox/mapnik-vector-tile/branch/master/graph/badge.svg)](https://codecov.io/gh/mapbox/mapnik-vector-tile)
 
 ## 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
diff --git a/bin/vtile-fuzz.cpp b/bin/vtile-fuzz.cpp
deleted file mode 100644
index ee6136c..0000000
--- a/bin/vtile-fuzz.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-#include "vector_tile_geometry_clipper.hpp"
-
-#include <vector>
-#include <iostream>
-#include <limits>
-#include <cstdlib>
-
-
-/*
-
-https://github.com/mapnik/clipper/issues/3
-
-*/
-
-class noop_process {
-public:
-    noop_process() {}
-    template <typename T>
-    void operator() (T &)
-    {
-        return;
-    }
-};
-
-int main() {
-
-    noop_process no_op;
-    using clipping_process = mapnik::vector_tile_impl::geometry_clipper<noop_process>;
-    mapnik::box2d<int> no_op_max_extent(std::numeric_limits<int>::min(),
-                                            std::numeric_limits<int>::min(),
-                                            std::numeric_limits<int>::max(),
-                                            std::numeric_limits<int>::max());
-    while (1)
-    {
-
-        std::size_t len = std::rand() % 700 + 3;
-
-        for (auto strictly_simple : { true, false })
-        {
-            for (auto multi_polygon_union : { true, false })
-            {
-                for (auto process_all_rings : { true, false })
-                {
-                    for (auto area_threshold : { 0.0, 0.5 })
-                    {
-                        for (auto fill_type : { mapnik::vector_tile_impl::even_odd_fill,
-                                                mapnik::vector_tile_impl::non_zero_fill,
-                                                mapnik::vector_tile_impl::positive_fill,
-                                                mapnik::vector_tile_impl::negative_fill })
-                        {
-                            mapbox::geometry::polygon<std::int64_t> poly;
-                            mapbox::geometry::linear_ring<std::int64_t> ring;
-                            mapnik::box2d<int> geom_extent;
-
-                            bool added_exterior = false;
-                            bool first = true;
-
-                            for (std::size_t i = 0; i < len; ++i) {
-                                std::int64_t x = std::rand() % 4096;
-                                std::int64_t y = std::rand() % 4096;
-
-                                ring.emplace_back(x,y);
-                                if (first) {
-                                    first = false;
-                                    geom_extent.init(x,y,x,y);
-                                } else {
-                                    geom_extent.expand_to_include(x,y);
-                                }
-
-                                if (!added_exterior && i > 100) {
-                                    poly.push_back(ring);
-                                    ring.clear();
-                                    added_exterior = true;
-                                }
-
-                                if (added_exterior && std::rand() % 50 == 0 && ring.size() >= 3) {
-                                    poly.push_back(ring);
-                                    ring.clear();
-                                }
-                            }
-                            std::clog << "size: " << poly.size() << "\n";
-                            // clip with max extent: should result in nothing being clipped
-                            {
-                                clipping_process clipper(no_op_max_extent,
-                                                         area_threshold,
-                                                         strictly_simple,
-                                                         multi_polygon_union,
-                                                         fill_type,
-                                                         process_all_rings,
-                                                         no_op);
-                                clipper(poly);
-                            }
-                            // clip with the extent of geometries minus a bit
-                            {
-                                // TODO - mapnik core needs support for ints
-                                //mapnik::box2d<int> geom_extent = mapnik::geometry::envelope(poly);
-                                geom_extent.pad(-100);
-                                clipping_process clipper(geom_extent,
-                                                         area_threshold,
-                                                         strictly_simple,
-                                                         multi_polygon_union,
-                                                         fill_type,
-                                                         process_all_rings,
-                                                         no_op);
-                                clipper(poly);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-}
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 0000000..d06f00a
--- /dev/null
+++ b/codecov.yml
@@ -0,0 +1,5 @@
+ignore:
+  - "bin"
+  - "bench"
+  - "examples"
+  - "test"
\ No newline at end of file
diff --git a/gyp/build.gyp b/gyp/build.gyp
index 4da8b20..5a22717 100644
--- a/gyp/build.gyp
+++ b/gyp/build.gyp
@@ -193,21 +193,6 @@
       ]
     },
     {
-      "target_name": "vtile-fuzz",
-      'dependencies': [ 'mapnik_vector_tile_impl' ],
-      "type": "executable",
-      "defines": [
-        "<@(common_defines)",
-        "MAPNIK_PLUGINDIR=<(MAPNIK_PLUGINDIR)"
-      ],
-      "sources": [
-        "../bin/vtile-fuzz.cpp"
-      ],
-      "include_dirs": [
-        "../src",
-      ]
-    },
-    {
       "target_name": "tileinfo",
       'dependencies': [ 'vector_tile' ],
       "type": "executable",
diff --git a/install_mason.sh b/install_mason.sh
index 6954b4c..c20d294 100755
--- a/install_mason.sh
+++ b/install_mason.sh
@@ -12,7 +12,7 @@ ICU_VERSION="57.1"
 
 if [ ! -f ./mason/mason.sh ]; then
     mkdir -p ./mason
-    curl -sSfL https://github.com/mapbox/mason/archive/0ba3b42.tar.gz | tar --gunzip --extract --strip-components=1 --exclude="*md" --exclude="test*" --directory=./mason
+    curl -sSfL https://github.com/mapbox/mason/archive/9eac60614fda7cfeb8a9e81d18e8cca5c1ae8fbc.tar.gz | tar --gunzip --extract --strip-components=1 --exclude="*md" --exclude="test*" --directory=./mason
 fi
 
 if [ ! -f ./mason_packages/.link/bin/mapnik-config ]; then
@@ -35,7 +35,7 @@ if [ ! -f ./mason_packages/.link/bin/mapnik-config ]; then
     install harfbuzz 1.4.2-ft
 
     # mapnik
-    install mapnik 3.0.13
+    install mapnik 3.0.14
 
     # other deps
     install protozero 1.5.1
diff --git a/package.json b/package.json
index 117511e..dc2e6b0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "mapnik-vector-tile",
-    "version": "1.3.0",
+    "version": "1.4.0",
     "description": "Mapnik Vector Tile API",
     "main": "include_dirs.js",
     "repository"   :  {
diff --git a/scripts/coverage.sh b/scripts/coverage.sh
index b82e565..14bfc83 100755
--- a/scripts/coverage.sh
+++ b/scripts/coverage.sh
@@ -3,27 +3,8 @@
 set -e -u
 set -o pipefail
 
-COVERAGE=${COVERAGE:-false}
-
-if [[ ${COVERAGE} == true ]]; then
-
-    PYTHONUSERBASE=$(pwd)/mason_packages/.link pip install --user cpp-coveralls
-    if [[ $(uname -s) == 'Linux' ]]; then
-        export PYTHONPATH=$(pwd)/mason_packages/.link/lib/python2.7/site-packages
-    else
-        export PYTHONPATH=$(pwd)/mason_packages/.link/lib/python/site-packages
-    fi
-    ./mason_packages/.link/bin/cpp-coveralls \
-        --gcov ${LLVM_COV} \
-        --build-root build \
-        --gcov-options '\-lp' \
-        --exclude examples \
-        --exclude deps \
-        --exclude test \
-        --exclude bench \
-        --exclude build/Debug/obj/gen/ \
-        --exclude mason_packages \
-        --exclude scripts > /dev/null
-fi
-
-set +e +u
+if [[ ${COVERAGE:-false} != false ]]; then
+    curl -S -f https://codecov.io/bash -o codecov
+    chmod +x codecov
+    ./codecov -x "llvm-cov gcov" -Z
+fi
\ No newline at end of file
diff --git a/src/vector_tile_featureset_pbf.ipp b/src/vector_tile_featureset_pbf.ipp
index d19a463..5121134 100644
--- a/src/vector_tile_featureset_pbf.ipp
+++ b/src/vector_tile_featureset_pbf.ipp
@@ -218,34 +218,36 @@ feature_ptr tile_featureset_pbf<Filter>::next()
                     mapnik::view_transform t(image_width, image_height, tile_extent_, 0, 0);
                     box2d<double> intersect = tile_extent_.intersect(unbuffered_query_);
                     box2d<double> ext = t.forward(intersect);
-                    if (ext.width() > 0.5 && ext.height() > 0.5 )
+                    if (ext.width() > std::numeric_limits<double>::epsilon() * 5.0
+                        && ext.height() > std::numeric_limits<double>::epsilon() * 5.0)
                     {
                         // select minimum raster containing whole ext
-                        int x_off = static_cast<int>(std::floor(ext.minx() +.5));
-                        int y_off = static_cast<int>(std::floor(ext.miny() +.5));
-                        int end_x = static_cast<int>(std::floor(ext.maxx() +.5));
-                        int end_y = static_cast<int>(std::floor(ext.maxy() +.5));
+                        int x_off = static_cast<int>(std::floor(ext.minx()));
+                        int y_off = static_cast<int>(std::floor(ext.miny()));
+                        int end_x = static_cast<int>(std::ceil(ext.maxx()));
+                        int end_y = static_cast<int>(std::ceil(ext.maxy()));
 
                         // clip to available data
-                        if (x_off < 0)
-                            x_off = 0;
-                        if (y_off < 0)
-                            y_off = 0;
-                        if (end_x > image_width)
-                            end_x = image_width;
-                        if (end_y > image_height)
-                            end_y = image_height;
+                        if (x_off >= image_width) x_off = image_width - 1;
+                        if (y_off >= image_height) y_off = image_height - 1;
+                        if (x_off < 0) x_off = 0;
+                        if (y_off < 0) y_off = 0;
+                        if (end_x > image_width) end_x = image_width;
+                        if (end_y > image_height) end_y = image_height;
                         int width = end_x - x_off;
                         int height = end_y - y_off;
+                        if (width < 1) width = 1;
+                        if (height < 1) height = 1;
                         box2d<double> feature_raster_extent(x_off,
                                                             y_off,
                                                             x_off + width,
                                                             y_off + height);
-                        intersect = t.backward(feature_raster_extent);
+                        feature_raster_extent = t.backward(feature_raster_extent);
                         double filter_factor = 1.0;
                         mapnik::image_any data = reader->read(x_off, y_off, width, height);
-                        mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(intersect,
-                                                      data,
+                        mapnik::raster_ptr raster = std::make_shared<mapnik::raster>(feature_raster_extent,
+                                                      intersect,
+                                                      std::move(data),
                                                       filter_factor
                                                       );
                         feature->set_raster(raster);
diff --git a/src/vector_tile_layer.hpp b/src/vector_tile_layer.hpp
index 07e4c8b..1ab7509 100644
--- a/src/vector_tile_layer.hpp
+++ b/src/vector_tile_layer.hpp
@@ -236,6 +236,14 @@ public:
         }
 
         mapnik::box2d<double> query_extent(lay.envelope()); // source projection
+        mapnik::box2d<double> unbuffered_query_extent(tile_extent_bbox);
+        if (!prj_trans_.equal())
+        {
+            if (!prj_trans_.forward(unbuffered_query_extent, PROJ_ENVELOPE_POINTS))
+            {
+                throw std::runtime_error("vector_tile_processor: unbuffered query extent did not repoject back to map projection");
+            }
+        }
 
         // first, try intersection of map extent forward projected into layer srs
         if (source_buffered_extent_.intersects(query_extent))
@@ -255,7 +263,7 @@ public:
             // forward project layer extent back into native projection
             if (!prj_trans_.forward(query_extent, PROJ_ENVELOPE_POINTS))
             {
-                throw std::runtime_error("vector_tile_processor: layer extent did not repoject back to map projection");
+                throw std::runtime_error("vector_tile_processor: query extent did not repoject back to map projection");
             }
         }
         else
@@ -263,8 +271,8 @@ public:
             // if no intersection then nothing to do for layer
             valid_ = false;    
         }
-        double qw = query_extent.width() > 0 ? query_extent.width() : 1;
-        double qh = query_extent.height() > 0 ? query_extent.height() : 1;
+        double qw = unbuffered_query_extent.width() > 0 ? unbuffered_query_extent.width() : 1;
+        double qh = unbuffered_query_extent.height() > 0 ? unbuffered_query_extent.height() : 1;
         if (!ds_ || ds_->type() == datasource::Vector)
         {
             qw = VT_LEGACY_IMAGE_SIZE / qw;
@@ -276,7 +284,7 @@ public:
             qh = static_cast<double>(layer_extent_) / qh;
         }
         mapnik::query::resolution_type res(qw, qh);
-        mapnik::query q(query_extent, res, scale_denom, tile_extent_bbox);
+        mapnik::query q(query_extent, res, scale_denom, unbuffered_query_extent);
         if (ds_)
         {
             mapnik::layer_descriptor lay_desc = ds_->get_descriptor();
diff --git a/src/vector_tile_processor.ipp b/src/vector_tile_processor.ipp
index 679048e..fecc5bc 100644
--- a/src/vector_tile_processor.ipp
+++ b/src/vector_tile_processor.ipp
@@ -64,6 +64,19 @@ inline void create_geom_layer(tile_layer & layer,
     
     using encoding_process = mapnik::vector_tile_impl::geometry_to_feature_pbf_visitor;
     using clipping_process = mapnik::vector_tile_impl::geometry_clipper<encoding_process>;
+
+    mapnik::vector_tile_impl::vector_tile_strategy vs(layer.get_view_transform());
+    mapnik::box2d<double> const& buffered_extent = layer.get_target_buffered_extent();
+    const mapnik::geometry::point<double> p1_min(buffered_extent.minx(), buffered_extent.miny());
+    const mapnik::geometry::point<double> p1_max(buffered_extent.maxx(), buffered_extent.maxy());
+    const mapnik::geometry::point<std::int64_t> p2_min = mapnik::geometry::transform<std::int64_t>(p1_min, vs);
+    const mapnik::geometry::point<std::int64_t> p2_max = mapnik::geometry::transform<std::int64_t>(p1_max, vs);
+    const double minx = std::min(p2_min.x, p2_max.x);
+    const double maxx = std::max(p2_min.x, p2_max.x);
+    const double miny = std::min(p2_min.y, p2_max.y);
+    const double maxy = std::max(p2_min.y, p2_max.y);
+    const mapnik::box2d<int> tile_clipping_extent(minx, miny, maxx, maxy);
+
     if (simplify_distance > 0)
     {
         using simplifier_process = mapnik::vector_tile_impl::geometry_simplifier<clipping_process>;
@@ -71,17 +84,6 @@ inline void create_geom_layer(tile_layer & layer,
         {
             using strategy_type = mapnik::vector_tile_impl::vector_tile_strategy;
             using transform_type = mapnik::vector_tile_impl::transform_visitor<strategy_type, simplifier_process>;
-            strategy_type vs(layer.get_view_transform());
-            mapnik::box2d<double> const& buffered_extent = layer.get_target_buffered_extent();
-            mapnik::geometry::point<double> p1_min(buffered_extent.minx(), buffered_extent.miny());
-            mapnik::geometry::point<double> p1_max(buffered_extent.maxx(), buffered_extent.maxy());
-            mapnik::geometry::point<std::int64_t> p2_min = mapnik::geometry::transform<std::int64_t>(p1_min, vs);
-            mapnik::geometry::point<std::int64_t> p2_max = mapnik::geometry::transform<std::int64_t>(p1_max, vs);
-            double minx = std::min(p2_min.x, p2_max.x);
-            double maxx = std::max(p2_min.x, p2_max.x);
-            double miny = std::min(p2_min.y, p2_max.y);
-            double maxy = std::max(p2_min.y, p2_max.y);
-            mapnik::box2d<int> tile_clipping_extent(minx, miny, maxx, maxy);
             while (feature)
             {
                 mapnik::geometry::geometry<double> const& geom = feature->get_geometry();
@@ -103,17 +105,6 @@ inline void create_geom_layer(tile_layer & layer,
         {
             using strategy_type = mapnik::vector_tile_impl::vector_tile_strategy_proj;
             using transform_type = mapnik::vector_tile_impl::transform_visitor<strategy_type, simplifier_process>;
-            mapnik::vector_tile_impl::vector_tile_strategy vs(layer.get_view_transform());
-            mapnik::box2d<double> const& buffered_extent = layer.get_target_buffered_extent();
-            mapnik::geometry::point<double> p1_min(buffered_extent.minx(), buffered_extent.miny());
-            mapnik::geometry::point<double> p1_max(buffered_extent.maxx(), buffered_extent.maxy());
-            mapnik::geometry::point<std::int64_t> p2_min = mapnik::geometry::transform<std::int64_t>(p1_min, vs);
-            mapnik::geometry::point<std::int64_t> p2_max = mapnik::geometry::transform<std::int64_t>(p1_max, vs);
-            double minx = std::min(p2_min.x, p2_max.x);
-            double maxx = std::max(p2_min.x, p2_max.x);
-            double miny = std::min(p2_min.y, p2_max.y);
-            double maxy = std::max(p2_min.y, p2_max.y);
-            mapnik::box2d<int> tile_clipping_extent(minx, miny, maxx, maxy);
             strategy_type vs2(layer.get_proj_transform(), layer.get_view_transform());
             mapnik::box2d<double> const& trans_buffered_extent = layer.get_source_buffered_extent();
             while (feature)
@@ -140,17 +131,6 @@ inline void create_geom_layer(tile_layer & layer,
         {
             using strategy_type = mapnik::vector_tile_impl::vector_tile_strategy;
             using transform_type = mapnik::vector_tile_impl::transform_visitor<strategy_type, clipping_process>;
-            strategy_type vs(layer.get_view_transform());
-            mapnik::box2d<double> const& buffered_extent = layer.get_target_buffered_extent();
-            mapnik::geometry::point<double> p1_min(buffered_extent.minx(), buffered_extent.miny());
-            mapnik::geometry::point<double> p1_max(buffered_extent.maxx(), buffered_extent.maxy());
-            mapnik::geometry::point<std::int64_t> p2_min = mapnik::geometry::transform<std::int64_t>(p1_min, vs);
-            mapnik::geometry::point<std::int64_t> p2_max = mapnik::geometry::transform<std::int64_t>(p1_max, vs);
-            double minx = std::min(p2_min.x, p2_max.x);
-            double maxx = std::max(p2_min.x, p2_max.x);
-            double miny = std::min(p2_min.y, p2_max.y);
-            double maxy = std::max(p2_min.y, p2_max.y);
-            mapnik::box2d<int> tile_clipping_extent(minx, miny, maxx, maxy);
             while (feature)
             {
                 mapnik::geometry::geometry<double> const& geom = feature->get_geometry();
@@ -171,17 +151,6 @@ inline void create_geom_layer(tile_layer & layer,
         {
             using strategy_type = mapnik::vector_tile_impl::vector_tile_strategy_proj;
             using transform_type = mapnik::vector_tile_impl::transform_visitor<strategy_type, clipping_process>;
-            mapnik::vector_tile_impl::vector_tile_strategy vs(layer.get_view_transform());
-            mapnik::box2d<double> const& buffered_extent = layer.get_target_buffered_extent();
-            mapnik::geometry::point<double> p1_min(buffered_extent.minx(), buffered_extent.miny());
-            mapnik::geometry::point<double> p1_max(buffered_extent.maxx(), buffered_extent.maxy());
-            mapnik::geometry::point<std::int64_t> p2_min = mapnik::geometry::transform<std::int64_t>(p1_min, vs);
-            mapnik::geometry::point<std::int64_t> p2_max = mapnik::geometry::transform<std::int64_t>(p1_max, vs);
-            double minx = std::min(p2_min.x, p2_max.x);
-            double maxx = std::max(p2_min.x, p2_max.x);
-            double miny = std::min(p2_min.y, p2_max.y);
-            double maxy = std::max(p2_min.y, p2_max.y);
-            mapnik::box2d<int> tile_clipping_extent(minx, miny, maxx, maxy);
             strategy_type vs2(layer.get_proj_transform(), layer.get_view_transform());
             mapnik::box2d<double> const& trans_buffered_extent = layer.get_source_buffered_extent();
             while (feature)
diff --git a/test/data/layer_scale_denom_style.xml b/test/data/layer_scale_denom_style.xml
new file mode 100644
index 0000000..9e4d663
--- /dev/null
+++ b/test/data/layer_scale_denom_style.xml
@@ -0,0 +1,21 @@
+<Map srs="+init=epsg:3857">
+    <Layer name="1" srs="+init=epsg:3857">
+        <Datasource>
+            <Parameter name="type">csv</Parameter>
+            <Parameter name="inline">
+                x, y
+                1, 2
+            </Parameter>
+        </Datasource>
+    </Layer>
+    <Layer name="2" srs="+init=epsg:3857" maximum-scale-denominator="200000">
+        <Datasource>
+            <Parameter name="type">csv</Parameter>
+            <Parameter name="inline">
+                x, y
+                3, 4
+                1, 4
+            </Parameter>
+        </Datasource>
+    </Layer>
+</Map>
diff --git a/test/fixtures/expected-2.jpeg b/test/fixtures/expected-2.jpeg
index 6af9c26..9d9840d 100644
Binary files a/test/fixtures/expected-2.jpeg and b/test/fixtures/expected-2.jpeg differ
diff --git a/test/fixtures/expected-2.png b/test/fixtures/expected-2.png
index 1162082..bf28d86 100644
Binary files a/test/fixtures/expected-2.png and b/test/fixtures/expected-2.png differ
diff --git a/test/raster_tile.cpp b/test/raster_tile.cpp
index 6e6437a..466773b 100644
--- a/test/raster_tile.cpp
+++ b/test/raster_tile.cpp
@@ -99,7 +99,7 @@ TEST_CASE("raster tile output 1")
         mapnik::save_to_file(im_data,"test/fixtures/actual-2.jpeg","jpeg");
     }
 
-    std::size_t expected_image_size = 42977;
+    std::size_t expected_image_size = 45660;
     std::size_t expected_vtile_size = expected_image_size + 26;
     if (!debug)
     {
diff --git a/test/unit/processor/scale_denom_filter.cpp b/test/unit/processor/scale_denom_filter.cpp
new file mode 100644
index 0000000..e200753
--- /dev/null
+++ b/test/unit/processor/scale_denom_filter.cpp
@@ -0,0 +1,42 @@
+#include "catch.hpp"
+
+// mapnik
+#include <mapnik/load_map.hpp>
+
+// mapnik-vector-tile
+#include "vector_tile_processor.hpp"
+
+// libprotobuf
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#include "vector_tile.pb.h"
+#pragma GCC diagnostic pop
+
+
+TEST_CASE("feature processor - filtering by scale denominator on layer level")
+{
+    mapnik::Map map(256, 256);
+    mapnik::load_map(map, "test/data/layer_scale_denom_style.xml");
+    mapnik::vector_tile_impl::processor ren(map);
+    const double scale_denom = 200000;
+
+    {
+        mapnik::vector_tile_impl::tile out_tile = ren.create_tile(
+            2048, 2047, 12, 4096, 0, scale_denom);
+        vector_tile::Tile tile;
+        REQUIRE(tile.ParseFromString(out_tile.get_buffer()));
+        REQUIRE(2 == tile.layers_size());
+        CHECK(1 == tile.layers(0).features_size());
+        CHECK(2 == tile.layers(1).features_size());
+    }
+    {
+        // One layer is filtered out after change of scale denominator.
+        mapnik::vector_tile_impl::tile out_tile = ren.create_tile(
+            2048, 2047, 12, 4096, 0, scale_denom * 2.0);
+        vector_tile::Tile tile;
+        REQUIRE(tile.ParseFromString(out_tile.get_buffer()));
+        REQUIRE(1 == tile.layers_size());
+        CHECK(1 == tile.layers(0).features_size());
+    }
+}

-- 
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