[mapnik-vector-tile] 05/15: Imported Upstream version 0.8.5+dfsg

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Sat Sep 12 11:06:50 UTC 2015


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 3fa1df4173cca95bc92383252ca1ad25fd63c412
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri Sep 11 22:55:20 2015 +0200

    Imported Upstream version 0.8.5+dfsg
---
 .gitignore                              |  2 ++
 .npmignore                              | 13 ++++++-
 CHANGELOG.md                            |  5 +++
 CONTRIBUTING.md                         | 13 +++++++
 Makefile                                |  6 ++++
 bench/vtile-transform.cpp               | 14 ++++++--
 bootstrap.sh                            |  2 +-
 package.json                            |  2 +-
 src/vector_tile_datasource_pbf.ipp      |  2 +-
 src/vector_tile_processor.hpp           |  3 +-
 src/vector_tile_processor.ipp           | 37 +++++++++-----------
 src/vector_tile_strategy.hpp            | 41 +++++++++++++++++++---
 test/clipper_test.cpp                   | 12 +++++--
 test/data/linestrings_and_point.geojson | 56 ++++++++++++++++++++++++++++++
 test/test_utils.cpp                     |  9 +++++
 test/test_utils.hpp                     |  1 +
 test/vector_tile.cpp                    |  6 ++--
 test/vector_tile_pbf.cpp                | 61 +++++++++++++++++++++++++++++++++
 18 files changed, 248 insertions(+), 37 deletions(-)

diff --git a/.gitignore b/.gitignore
index 02cdd31..3e38244 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,5 @@ test/run-raster-test
 archive
 TODO.md
 examples/c++/tileinfo
+.mason
+mason_packages
diff --git a/.npmignore b/.npmignore
index d9382ea..77504b7 100644
--- a/.npmignore
+++ b/.npmignore
@@ -8,4 +8,15 @@ python/vector_tile_pb2.py
 test/run-test
 *pyc
 archive
-TODO.md
\ No newline at end of file
+TODO.md
+.mason
+mason_packages
+deps
+build
+.travis.yml
+scripts
+gyp
+test
+CONTRIBUTING.md
+bootstrap.sh
+bench
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d38b756..1226381 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
 # Changelog
 
+## 0.8.5
+
+ - Remove geometries from clipping that never intersect with the bounding box of the tile (#135)
+ - Fix indexing error in tile_datasource_pbf (#132)
+
 ## 0.8.4
 
  - Started to skip coordinates that are out of range (#121)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..d0a99ce
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,13 @@
+# Contributing
+
+General guidelines for contributing to mapnik-vector-tile
+
+## Releasing
+
+To release a new node-mapnik version:
+
+ - Make sure that all tests as passing (including travis and appveyor tests).
+ - Update the CHANGELOG.md and commit new version.
+ - Create a github tag like `git tag -a v0.8.5 -m "v0.8.5"`
+ - Ensure you have a clean checkout (no extra files in your check that are not known by git). You need to be careful, for instance, to avoid a large accidental file being packaged by npm. You can get a view of what npm will publish by running `make testpack`
+ - Then publish the module to npm repositories by running `npm publish`
diff --git a/Makefile b/Makefile
index 58085e4..c3ee347 100755
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,12 @@ libvtile: build/Makefile Makefile
 test: libvtile
 	./build/$(BUILDTYPE)/tests
 
+testpack:
+	rm -f ./*tgz
+	npm pack
+	tar -ztvf *tgz
+	rm -f ./*tgz
+
 clean:
 	rm -rf ./build
 
diff --git a/bench/vtile-transform.cpp b/bench/vtile-transform.cpp
index 772a90d..b716cc3 100644
--- a/bench/vtile-transform.cpp
+++ b/bench/vtile-transform.cpp
@@ -60,7 +60,11 @@ int main() {
     {
         mapnik::vector_tile_impl::vector_tile_strategy_proj vs(prj_trans,tr, 16);
         mapnik::progress_timer __stats__(std::clog, "transform_visitor with reserve with proj no-op");
-        mapnik::vector_tile_impl::transform_visitor<mapnik::vector_tile_impl::vector_tile_strategy_proj> transit(vs);
+        mapnik::box2d<double> clip_extent(std::numeric_limits<double>::min(),
+                                       std::numeric_limits<double>::min(),
+                                       std::numeric_limits<double>::max(),
+                                       std::numeric_limits<double>::max());
+        mapnik::vector_tile_impl::transform_visitor<mapnik::vector_tile_impl::vector_tile_strategy_proj> transit(vs, clip_extent);
         for (unsigned i=0;i<10000;++i)
         {
             mapnik::geometry::geometry<std::int64_t> new_geom = mapnik::util::apply_visitor(transit,geom);        
@@ -76,7 +80,11 @@ int main() {
     {
         mapnik::vector_tile_impl::vector_tile_strategy vs(tr, 16);
         mapnik::progress_timer __stats__(std::clog, "transform_visitor with reserve with no proj function call overhead");
-        mapnik::vector_tile_impl::transform_visitor<mapnik::vector_tile_impl::vector_tile_strategy> transit(vs);
+        mapnik::box2d<double> clip_extent(std::numeric_limits<double>::min(),
+                                       std::numeric_limits<double>::min(),
+                                       std::numeric_limits<double>::max(),
+                                       std::numeric_limits<double>::max());
+        mapnik::vector_tile_impl::transform_visitor<mapnik::vector_tile_impl::vector_tile_strategy> transit(vs, clip_extent);
         for (unsigned i=0;i<10000;++i)
         {
             mapnik::geometry::geometry<std::int64_t> new_geom = mapnik::util::apply_visitor(transit,geom);
@@ -90,4 +98,4 @@ int main() {
         }
     }
     return 0;
-}
\ No newline at end of file
+}
diff --git a/bootstrap.sh b/bootstrap.sh
index d98f431..c2c6ced 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -28,7 +28,7 @@ function install_mason_deps() {
     install harfbuzz 0.9.40
     install jpeg_turbo 1.4.0
     install libxml2 2.9.2
-    install libpng 1.6.16
+    install libpng 1.6.17
     install webp 0.4.2
     install icu 54.1
     install proj 4.8.0
diff --git a/package.json b/package.json
index 7dfbbd3..2b3124a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "mapnik-vector-tile",
-    "version": "0.8.4",
+    "version": "0.8.5",
     "description": "Mapnik vector tile API",
     "main": "./package.json",
     "repository"   :  {
diff --git a/src/vector_tile_datasource_pbf.ipp b/src/vector_tile_datasource_pbf.ipp
index 8976b4b..e3ab58d 100644
--- a/src/vector_tile_datasource_pbf.ipp
+++ b/src/vector_tile_datasource_pbf.ipp
@@ -110,10 +110,10 @@ namespace mapnik { namespace vector_tile_impl {
                                     else
                                     {
                                         val_idx = *_i;
-                                        val = layer_values_.at(val_idx);
                                         std::string name = layer_keys_.at(key_idx);
                                         if (feature->has_key(name))
                                         {
+                                            val = layer_values_.at(val_idx);
                                             if (val.is<std::string>())
                                             {
                                                 feature->put(name, tr_.transcode(val.get<std::string>().data(), val.get<std::string>().length()));
diff --git a/src/vector_tile_processor.hpp b/src/vector_tile_processor.hpp
index 2bf2808..916e2a1 100644
--- a/src/vector_tile_processor.hpp
+++ b/src/vector_tile_processor.hpp
@@ -85,7 +85,8 @@ public:
     MAPNIK_VECTOR_INLINE unsigned handle_geometry(T2 const& vs,
                                                   mapnik::feature_impl const& feature,
                                                   mapnik::geometry::geometry<double> const& geom,
-                                                  mapnik::box2d<int> const& tile_clipping_extent);
+                                                  mapnik::box2d<int> const& tile_clipping_extent,
+                                                  mapnik::box2d<double> const& target_clipping_extent);
 };
 
 }} // end ns
diff --git a/src/vector_tile_processor.ipp b/src/vector_tile_processor.ipp
index 72da363..bf820e4 100644
--- a/src/vector_tile_processor.ipp
+++ b/src/vector_tile_processor.ipp
@@ -24,7 +24,6 @@
 #include <mapnik/util/noncopyable.hpp>
 #include <mapnik/transform_path_adapter.hpp>
 #include <mapnik/geometry_is_empty.hpp>
-#include <mapnik/geometry_envelope.hpp>
 #include <mapnik/geometry_adapters.hpp>
 #include <mapnik/geometry_transform.hpp>
 
@@ -802,7 +801,8 @@ void processor<T>::apply_to_layer(mapnik::layer const& lay,
                 if (handle_geometry(vs,
                                     *feature,
                                     geom,
-                                    tile_clipping_extent) > 0)
+                                    tile_clipping_extent,
+                                    target_clipping_extent) > 0)
                 {
                     painted_ = true;
                 }
@@ -818,6 +818,7 @@ void processor<T>::apply_to_layer(mapnik::layer const& lay,
             mapnik::geometry::point<std::int64_t> p2_max = mapnik::geometry::transform<std::int64_t>(p1_max, vs);
             box2d<int> tile_clipping_extent(p2_min.x, p2_min.y, p2_max.x, p2_max.y);
             mapnik::vector_tile_impl::vector_tile_strategy_proj vs2(prj_trans,t_,backend_.get_path_multiplier());
+            prj_trans.forward(target_clipping_extent, PROJ_ENVELOPE_POINTS);
             while (feature)
             {
                 mapnik::geometry::geometry<double> const& geom = feature->get_geometry();
@@ -829,7 +830,8 @@ void processor<T>::apply_to_layer(mapnik::layer const& lay,
                 if (handle_geometry(vs2,
                                     *feature,
                                     geom,
-                                    tile_clipping_extent) > 0)
+                                    tile_clipping_extent,
+                                    target_clipping_extent) > 0)
                 {
                     painted_ = true;
                 }
@@ -912,13 +914,10 @@ struct encoder_visitor {
     unsigned operator() (mapnik::geometry::point<std::int64_t> const& geom)
     {
         unsigned path_count = 0;
-        if (tile_clipping_extent_.intersects(geom.x,geom.y))
-        {
-            backend_.start_tile_feature(feature_);
-            backend_.current_feature_->set_type(vector_tile::Tile_GeomType_POINT);
-            path_count = backend_.add_path(geom);
-            backend_.stop_tile_feature();
-        }
+        backend_.start_tile_feature(feature_);
+        backend_.current_feature_->set_type(vector_tile::Tile_GeomType_POINT);
+        path_count = backend_.add_path(geom);
+        backend_.stop_tile_feature();
         return path_count;
     }
 
@@ -928,16 +927,13 @@ struct encoder_visitor {
         bool first = true;
         for (auto const& pt : geom)
         {
-            if (tile_clipping_extent_.intersects(pt.x,pt.y))
+            if (first)
             {
-                if (first)
-                {
-                    first = false;
-                    backend_.start_tile_feature(feature_);
-                    backend_.current_feature_->set_type(vector_tile::Tile_GeomType_POINT);
-                }
-                path_count += backend_.add_path(pt);
+                first = false;
+                backend_.start_tile_feature(feature_);
+                backend_.current_feature_->set_type(vector_tile::Tile_GeomType_POINT);
             }
+            path_count += backend_.add_path(pt);
         }
         if (!first)
         {
@@ -1269,13 +1265,14 @@ template <typename T> template <typename T2>
 unsigned processor<T>::handle_geometry(T2 const& vs,
                                        mapnik::feature_impl const& feature,
                                        mapnik::geometry::geometry<double> const& geom,
-                                       mapnik::box2d<int> const& tile_clipping_extent)
+                                       mapnik::box2d<int> const& tile_clipping_extent,
+                                       mapnik::box2d<double> const& target_clipping_extent)
 {
     // TODO
     // - no need to create a new skipping_transformer per geometry
     // - write a non-skipping / zero copy transformer to be used when no projection is needed
     using vector_tile_strategy_type = T2;
-    mapnik::vector_tile_impl::transform_visitor<vector_tile_strategy_type> skipping_transformer(vs);
+    mapnik::vector_tile_impl::transform_visitor<vector_tile_strategy_type> skipping_transformer(vs, target_clipping_extent);
     mapnik::geometry::geometry<std::int64_t> new_geom = mapnik::util::apply_visitor(skipping_transformer,geom);
     encoder_visitor<T> encoder(backend_, feature, tile_clipping_extent, area_threshold_);
     if (simplify_distance_ > 0)
diff --git a/src/vector_tile_strategy.hpp b/src/vector_tile_strategy.hpp
index 27a83dc..a8f535f 100644
--- a/src/vector_tile_strategy.hpp
+++ b/src/vector_tile_strategy.hpp
@@ -6,6 +6,7 @@
 #include <mapnik/util/noncopyable.hpp>
 #include <mapnik/proj_transform.hpp>
 #include <mapnik/view_transform.hpp>
+#include <mapnik/geometry_envelope.hpp>
 
 #include "clipper.hpp"
 
@@ -17,7 +18,6 @@
 #include <boost/numeric/conversion/cast.hpp>
 #pragma GCC diagnostic pop
 
-
 namespace mapnik {
 
 namespace vector_tile_impl {
@@ -106,11 +106,13 @@ struct vector_tile_strategy_proj
 template <typename TransformType>
 struct transform_visitor {
 
-    transform_visitor(TransformType const& tr) :
-      tr_(tr) {}
+    transform_visitor(TransformType const& tr, box2d<double> const& target_clipping_extent) :
+      tr_(tr),
+      target_clipping_extent_(target_clipping_extent) {}
 
     inline mapnik::geometry::geometry<std::int64_t> operator() (mapnik::geometry::point<double> const& geom)
     {
+        if (!target_clipping_extent_.intersects(geom.x,geom.y)) return mapnik::geometry::geometry_empty(); 
         mapnik::geometry::point<std::int64_t> new_geom;
         if (!tr_.apply(geom,new_geom)) return mapnik::geometry::geometry_empty();
         return new_geom;
@@ -123,16 +125,22 @@ struct transform_visitor {
         for (auto const& pt : geom)
         {
             mapnik::geometry::point<std::int64_t> pt2;
-            if (tr_.apply(pt,pt2))
+            if (target_clipping_extent_.intersects(pt.x, pt.y) && tr_.apply(pt,pt2))
             {
                 new_geom.push_back(std::move(pt2));
             }
         }
+        if (new_geom.empty()) return mapnik::geometry::geometry_empty();
         return new_geom;
     }
 
     inline mapnik::geometry::geometry<std::int64_t> operator() (mapnik::geometry::line_string<double> const& geom)
     {
+        mapnik::box2d<double> geom_bbox = mapnik::geometry::envelope(geom);
+        if (!target_clipping_extent_.intersects(geom_bbox)) 
+        {
+            return mapnik::geometry::geometry_empty();
+        }
         mapnik::geometry::line_string<std::int64_t> new_geom;
         new_geom.reserve(geom.size());
         for (auto const& pt : geom)
@@ -152,6 +160,8 @@ struct transform_visitor {
         new_geom.reserve(geom.size());
         for (auto const& line : geom)
         {
+            mapnik::box2d<double> line_bbox = mapnik::geometry::envelope(line);
+            if (!target_clipping_extent_.intersects(line_bbox)) continue;
             mapnik::geometry::line_string<std::int64_t> new_line;
             new_line.reserve(line.size());
             for (auto const& pt : line)
@@ -164,11 +174,17 @@ struct transform_visitor {
             }
             new_geom.push_back(std::move(new_line));
         }
+        if (new_geom.empty()) return mapnik::geometry::geometry_empty();
         return new_geom;
     }
 
     inline mapnik::geometry::geometry<std::int64_t> operator() (mapnik::geometry::polygon<double> const& geom)
     {
+        mapnik::box2d<double> ext_bbox = mapnik::geometry::envelope(geom);
+        if (!target_clipping_extent_.intersects(ext_bbox))
+        {
+            return mapnik::geometry::geometry_empty();
+        }
         mapnik::geometry::polygon<std::int64_t> new_geom;
         new_geom.exterior_ring.reserve(geom.exterior_ring.size());
         for (auto const& pt : geom.exterior_ring)
@@ -181,6 +197,11 @@ struct transform_visitor {
         }
         for (auto const& ring : geom.interior_rings)
         {
+            mapnik::box2d<double> ring_bbox = mapnik::geometry::envelope(static_cast<mapnik::geometry::line_string<double> const&>(ring));
+            if (!target_clipping_extent_.intersects(ring_bbox)) 
+            {
+                continue;
+            }
             mapnik::geometry::linear_ring<std::int64_t> new_ring;
             new_ring.reserve(ring.size());
             for (auto const& pt : ring)
@@ -202,6 +223,11 @@ struct transform_visitor {
         new_geom.reserve(geom.size());
         for (auto const& poly : geom)
         {
+            mapnik::box2d<double> ext_bbox = mapnik::geometry::envelope(poly);
+            if (!target_clipping_extent_.intersects(ext_bbox)) 
+            {
+                continue;
+            }
             mapnik::geometry::polygon<std::int64_t> new_poly;
             new_poly.exterior_ring.reserve(poly.exterior_ring.size());
             for (auto const& pt : poly.exterior_ring)
@@ -214,6 +240,11 @@ struct transform_visitor {
             }
             for (auto const& ring : poly.interior_rings)
             {
+                mapnik::box2d<double> ring_bbox = mapnik::geometry::envelope(static_cast<mapnik::geometry::line_string<double> const&>(ring));
+                if (!target_clipping_extent_.intersects(ring_bbox))
+                {
+                    continue;
+                }
                 mapnik::geometry::linear_ring<std::int64_t> new_ring;
                 new_ring.reserve(ring.size());
                 for (auto const& pt : ring)
@@ -228,6 +259,7 @@ struct transform_visitor {
             }
             new_geom.push_back(std::move(new_poly));
         }
+        if (new_geom.empty()) return mapnik::geometry::geometry_empty();
         return new_geom;
     }
 
@@ -247,6 +279,7 @@ struct transform_visitor {
         return geom;
     }
     TransformType const& tr_;
+    box2d<double> const& target_clipping_extent_;
 };
 
 }
diff --git a/test/clipper_test.cpp b/test/clipper_test.cpp
index fcbdd0c..5224a98 100644
--- a/test/clipper_test.cpp
+++ b/test/clipper_test.cpp
@@ -61,7 +61,11 @@ TEST_CASE( "vector_tile_strategy", "should not overflow" ) {
         double path_multiplier = 1000000000000.0;
         mapnik::vector_tile_impl::vector_tile_strategy_proj vs(prj_trans, tr, path_multiplier);
         CHECK_THROWS( mapnik::geometry::transform<std::int64_t>(g, vs) );
-        mapnik::vector_tile_impl::transform_visitor<mapnik::vector_tile_impl::vector_tile_strategy_proj> skipping_transformer(vs);
+        mapnik::box2d<double> clip_extent(std::numeric_limits<double>::min(),
+                                       std::numeric_limits<double>::min(),
+                                       std::numeric_limits<double>::max(),
+                                       std::numeric_limits<double>::max());
+        mapnik::vector_tile_impl::transform_visitor<mapnik::vector_tile_impl::vector_tile_strategy_proj> skipping_transformer(vs, clip_extent);
         mapnik::geometry::geometry<std::int64_t> new_geom = skipping_transformer(g);
         REQUIRE( new_geom.is<mapnik::geometry::polygon<std::int64_t>>() );
         auto const& poly = mapnik::util::get<mapnik::geometry::polygon<std::int64_t>>(new_geom);
@@ -89,7 +93,11 @@ TEST_CASE( "vector_tile_strategy2", "invalid mercator coord in interior ring" )
     mapnik::view_transform tr(tile_size,tile_size,z15_extent,0,0);
     mapnik::vector_tile_impl::vector_tile_strategy_proj vs(prj_trans, tr, 16);
     CHECK_THROWS( mapnik::geometry::transform<std::int64_t>(geom, vs) );
-    mapnik::vector_tile_impl::transform_visitor<mapnik::vector_tile_impl::vector_tile_strategy_proj> skipping_transformer(vs);
+    mapnik::box2d<double> clip_extent(std::numeric_limits<double>::min(),
+                                   std::numeric_limits<double>::min(),
+                                   std::numeric_limits<double>::max(),
+                                   std::numeric_limits<double>::max());
+    mapnik::vector_tile_impl::transform_visitor<mapnik::vector_tile_impl::vector_tile_strategy_proj> skipping_transformer(vs, clip_extent);
     mapnik::geometry::geometry<std::int64_t> new_geom = mapnik::util::apply_visitor(skipping_transformer,geom);
     REQUIRE( new_geom.is<mapnik::geometry::polygon<std::int64_t>>() );
     auto const& poly = mapnik::util::get<mapnik::geometry::polygon<std::int64_t>>(new_geom);
diff --git a/test/data/linestrings_and_point.geojson b/test/data/linestrings_and_point.geojson
new file mode 100644
index 0000000..dddeef1
--- /dev/null
+++ b/test/data/linestrings_and_point.geojson
@@ -0,0 +1,56 @@
+{
+  "type": "FeatureCollection",
+  "features": [
+    {
+      "type": "Feature",
+      "id": 1,
+      "geometry": {
+        "type": "LineString",
+        "coordinates": [
+          [
+            -180,
+            60.020952153748
+          ],
+          [
+            180,
+            -60.020952153748
+          ]
+        ]
+      },
+      "properties": {}
+    },
+    {
+      "type": "Feature",
+      "id": 2,
+      "geometry": {
+        "type": "LineString",
+        "coordinates": [
+          [
+            -180,
+            -60.020952153748
+          ],
+          [
+            180,
+            60.020952153748
+          ]
+        ]
+      },
+      "properties": {}
+    },
+    {
+      "type": "Feature",
+      "id": 1,
+      "geometry": {
+        "type": "Point",
+        "coordinates": [
+          0,
+          0
+        ]
+      },
+      "properties": {
+        "x": 0,
+        "y": 0
+      }
+    }
+  ]
+}
\ No newline at end of file
diff --git a/test/test_utils.cpp b/test/test_utils.cpp
index b26b5ae..68a8d42 100644
--- a/test/test_utils.cpp
+++ b/test/test_utils.cpp
@@ -12,6 +12,7 @@
 #include <mapnik/datasource.hpp>
 #include <mapnik/load_map.hpp>
 #include <mapnik/memory_datasource.hpp>
+#include <mapnik/datasource_cache.hpp>
 #include <mapnik/image.hpp>
 #include <mapnik/image_reader.hpp>
 #include <mapnik/util/file_io.hpp>
@@ -75,6 +76,14 @@ std::shared_ptr<mapnik::memory_datasource> build_geojson_ds(std::string const& g
     return ds;
 }
 
+std::shared_ptr<mapnik::datasource> build_geojson_fs_ds(std::string const& geojson_file) {
+    mapnik::parameters params;
+    params["type"] = "geojson";
+    params["file"] = geojson_file;
+    params["cache_features"] = "false";
+    return mapnik::datasource_cache::instance().create(params);
+}
+
 mapnik::geometry::geometry<double> read_geojson(std::string const& geojson_file) {
     mapnik::util::file input(geojson_file);
     if (!input.open())
diff --git a/test/test_utils.hpp b/test/test_utils.hpp
index fe51943..96d9fbc 100644
--- a/test/test_utils.hpp
+++ b/test/test_utils.hpp
@@ -12,6 +12,7 @@ namespace testing {
 std::shared_ptr<mapnik::memory_datasource> build_ds(double x,double y, bool second=false);
 mapnik::geometry::geometry<double> read_geojson(std::string const& geojson_file);
 std::shared_ptr<mapnik::memory_datasource> build_geojson_ds(std::string const& geojson_file);
+std::shared_ptr<mapnik::memory_datasource> build_geojson_fs_ds(std::string const& geojson_file);
 
 unsigned compare_images(std::string const& src_fn,
                         std::string const& dest_fn,
diff --git a/test/vector_tile.cpp b/test/vector_tile.cpp
index d5a349a..2716cfc 100644
--- a/test/vector_tile.cpp
+++ b/test/vector_tile.cpp
@@ -614,7 +614,7 @@ mapnik::geometry::geometry<double> round_trip(mapnik::geometry::geometry<double>
     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);
     mapnik::box2d<int> clipping_extent(p2_min.x, p2_min.y, p2_max.x, p2_max.y);
-    ren.handle_geometry(vs2,*feature,geom,clipping_extent);
+    ren.handle_geometry(vs2,*feature,geom,clipping_extent, bbox);
     backend.stop_tile_layer();
     if (tile.layers_size() != 1)
     {
@@ -1021,7 +1021,7 @@ mapnik::geometry::geometry<double> round_trip2(mapnik::geometry::geometry<double
     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);
     mapnik::box2d<int> clipping_extent(p2_min.x, p2_min.y, p2_max.x, p2_max.y);
-    ren.handle_geometry(vs2,*feature,geom,clipping_extent);
+    ren.handle_geometry(vs2,*feature,geom,clipping_extent, bbox);
     backend.stop_tile_layer();
     if (tile.layers_size() != 1)
     {
@@ -1227,4 +1227,4 @@ TEST_CASE( "vector tile transform2", "should not throw reprojected data from loc
     if (diff > 0) {
         mapnik::save_to_file(im,"test/fixtures/transform-actual-2.png","png32");
     }
-}
\ No newline at end of file
+}
diff --git a/test/vector_tile_pbf.cpp b/test/vector_tile_pbf.cpp
index fb0e3c0..8f2774f 100644
--- a/test/vector_tile_pbf.cpp
+++ b/test/vector_tile_pbf.cpp
@@ -559,3 +559,64 @@ TEST_CASE("Check that we throw on various valid-but-we-don't-handle PBF encoded
    }
 
 }
+
+TEST_CASE( "pbf vector tile from linestring geojson", "should create vector tile with data" ) {
+    typedef mapnik::vector_tile_impl::backend_pbf backend_type;
+    typedef mapnik::vector_tile_impl::processor<backend_type> renderer_type;
+    typedef vector_tile::Tile tile_type;
+    tile_type tile;
+    backend_type backend(tile,1000);
+    unsigned tile_size = 256;
+    mapnik::box2d<double> bbox(-20037508.342789,-20037508.342789,20037508.342789,20037508.342789);
+    mapnik::Map map(tile_size,tile_size,"+init=epsg:3857");
+    mapnik::layer lyr("layer","+init=epsg:4326");
+    auto ds = testing::build_geojson_fs_ds("./test/data/linestrings_and_point.geojson");
+    lyr.set_datasource(ds);
+    map.add_layer(lyr);
+    map.zoom_to_box(bbox);
+    mapnik::request m_req(tile_size,tile_size,bbox);
+    renderer_type ren(backend,map,m_req);
+    ren.apply();
+    CHECK( ren.painted() == true );
+    REQUIRE(1 == tile.layers_size());
+    vector_tile::Tile_Layer const& layer = tile.layers(0);
+    CHECK(std::string("layer") == layer.name());
+    REQUIRE(3 == layer.features_size());
+    std::string buffer;
+    tile.SerializeToString(&buffer);
+    mapbox::util::pbf pbf_tile(buffer.c_str(), buffer.size());
+    pbf_tile.next();
+    mapbox::util::pbf layer3 = pbf_tile.get_message();
+    std::shared_ptr<mapnik::vector_tile_impl::tile_datasource_pbf> ds2 = std::make_shared<
+                                    mapnik::vector_tile_impl::tile_datasource_pbf>(
+                                        layer3,0,0,0,256);
+    CHECK(ds2->get_name() == "layer");
+    mapnik::query q(bbox);
+    // note: https://github.com/mapbox/mapnik-vector-tile/issues/132 does not occur
+    // if we uncomment these lines
+    //q.add_property_name("x");
+    //q.add_property_name("y");
+    std::size_t expected_num_attr_returned = q.property_names().size();
+    auto fs = ds2->features(q);
+    auto f_ptr = fs->next();
+    CHECK(f_ptr != mapnik::feature_ptr());
+    // no attributes
+    CHECK(f_ptr->context()->size() == expected_num_attr_returned);
+    CHECK(f_ptr->get_geometry().is<mapnik::geometry::line_string<double> >());
+    // second feature
+    f_ptr = fs->next();
+    CHECK(f_ptr != mapnik::feature_ptr());
+    CHECK(f_ptr->context()->size() == expected_num_attr_returned);
+    CHECK(f_ptr->get_geometry().is<mapnik::geometry::line_string<double> >());
+
+    // third feature
+    f_ptr = fs->next();
+    CHECK(f_ptr != mapnik::feature_ptr());
+    CHECK(f_ptr->context()->size() == expected_num_attr_returned);
+    CHECK(f_ptr->get_geometry().is<mapnik::geometry::point<double> >());
+
+    // only three features
+    f_ptr = fs->next();
+    CHECK(f_ptr == mapnik::feature_ptr());
+
+}

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