[mapnik-vector-tile] 10/15: Imported Upstream version 0.10.0+dfsg

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Sat Sep 12 11:06:52 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 ec8da7160e817050d279e0c7ee57c49e59ec3bf2
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri Sep 11 22:56:20 2015 +0200

    Imported Upstream version 0.10.0+dfsg
---
 CHANGELOG.md                         |   4 +
 package.json                         |   2 +-
 src/vector_tile_backend_pbf.hpp      |   5 +-
 src/vector_tile_geometry_encoder.hpp |  82 ++++++++++---------
 src/vector_tile_processor.hpp        |  10 +--
 src/vector_tile_processor.ipp        | 149 +++++++++++++++++++++--------------
 test/vector_tile_pbf.cpp             |  39 ++++-----
 7 files changed, 162 insertions(+), 129 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d1ed0ca..aaadafc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## 0.10.0
+
+ - Changed the way painted is determined. Painted could not be marked as true but a vector tile would still be empty.
+
 ## 0.9.3
 
  - Improvements to zlib compression API
diff --git a/package.json b/package.json
index cb09d04..132131c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "mapnik-vector-tile",
-    "version": "0.9.3",
+    "version": "0.10.0",
     "description": "Mapnik vector tile API",
     "main": "./package.json",
     "repository"   :  {
diff --git a/src/vector_tile_backend_pbf.hpp b/src/vector_tile_backend_pbf.hpp
index 0090663..510a323 100644
--- a/src/vector_tile_backend_pbf.hpp
+++ b/src/vector_tile_backend_pbf.hpp
@@ -48,7 +48,7 @@ namespace mapnik { namespace vector_tile_impl {
         inline void stop_tile_layer() {}
 
         template <typename T>
-        inline unsigned add_path(T const& path)
+        inline bool add_path(T const& path)
         {
             if (current_feature_)
             {
@@ -57,7 +57,8 @@ namespace mapnik { namespace vector_tile_impl {
                                        x_,
                                        y_);
             }
-            return 0;
+            // no path was added return false
+            return false;
         }
     };
 
diff --git a/src/vector_tile_geometry_encoder.hpp b/src/vector_tile_geometry_encoder.hpp
index ea6edd1..42cdbdd 100644
--- a/src/vector_tile_geometry_encoder.hpp
+++ b/src/vector_tile_geometry_encoder.hpp
@@ -19,7 +19,7 @@
 
 namespace mapnik { namespace vector_tile_impl {
 
-inline unsigned encode_geometry(mapnik::geometry::point<std::int64_t> const& pt,
+inline bool encode_geometry(mapnik::geometry::point<std::int64_t> const& pt,
                         vector_tile::Tile_Feature & current_feature,
                         int32_t & start_x,
                         int32_t & start_y)
@@ -32,7 +32,7 @@ inline unsigned encode_geometry(mapnik::geometry::point<std::int64_t> const& pt,
     current_feature.add_geometry(protozero::encode_zigzag32(dy));
     start_x = pt.x;
     start_y = pt.y;
-    return 1;
+    return true;
 }
 
 inline unsigned encode_length(unsigned len)
@@ -40,7 +40,7 @@ inline unsigned encode_length(unsigned len)
     return (len << 3u) | 2u;
 }
 
-inline unsigned encode_geometry(mapnik::geometry::line_string<std::int64_t> const& line,
+inline bool encode_geometry(mapnik::geometry::line_string<std::int64_t> const& line,
                         vector_tile::Tile_Feature & current_feature,
                         int32_t & start_x,
                         int32_t & start_y)
@@ -48,7 +48,7 @@ inline unsigned encode_geometry(mapnik::geometry::line_string<std::int64_t> cons
     std::size_t line_size = line.size();
     if (line_size <= 0)
     {
-        return 0;
+        return false;
     }
     unsigned line_to_length = static_cast<unsigned>(line_size) - 1;
 
@@ -78,10 +78,10 @@ inline unsigned encode_geometry(mapnik::geometry::line_string<std::int64_t> cons
         start_x = pt.x;
         start_y = pt.y;
     }
-    return line.size();
+    return true;
 }
 
-inline unsigned encode_geometry(mapnik::geometry::linear_ring<std::int64_t> const& ring,
+inline bool encode_geometry(mapnik::geometry::linear_ring<std::int64_t> const& ring,
                         vector_tile::Tile_Feature & current_feature,
                         int32_t & start_x,
                         int32_t & start_y)
@@ -89,7 +89,7 @@ inline unsigned encode_geometry(mapnik::geometry::linear_ring<std::int64_t> cons
     std::size_t ring_size = ring.size();
     if (ring_size < 3)
     {
-        return 0;
+        return false;
     }
     unsigned line_to_length = static_cast<unsigned>(ring_size) - 1;
     unsigned count = 0;
@@ -105,7 +105,7 @@ inline unsigned encode_geometry(mapnik::geometry::linear_ring<std::int64_t> cons
         line_to_length -= 1;
         if (line_to_length < 2)
         {
-            return 0;
+            return false;
         }
     }
 
@@ -135,36 +135,34 @@ inline unsigned encode_geometry(mapnik::geometry::linear_ring<std::int64_t> cons
         ++count;
     }
     current_feature.add_geometry(15); // close_path
-    return line_to_length;
+    return true;
 }
 
-inline unsigned encode_geometry(mapnik::geometry::polygon<std::int64_t> const& poly,
-                                vector_tile::Tile_Feature & current_feature,
-                                int32_t & start_x,
-                                int32_t & start_y)
+inline bool encode_geometry(mapnik::geometry::polygon<std::int64_t> const& poly,
+                            vector_tile::Tile_Feature & current_feature,
+                            int32_t & start_x,
+                            int32_t & start_y)
 {
-    unsigned count = 0;
-    count += encode_geometry(poly.exterior_ring, current_feature, start_x, start_y);
-    if (count == 0)
+    if (!encode_geometry(poly.exterior_ring, current_feature, start_x, start_y))
     {
-        return count;
+        return false;
     }
     for (auto const& ring : poly.interior_rings)
     {
-        count += encode_geometry(ring, current_feature, start_x, start_y);
+        encode_geometry(ring, current_feature, start_x, start_y);
     }
-    return count;
+    return true;
 }
 
-inline unsigned encode_geometry(mapnik::geometry::multi_point<std::int64_t> const& geom,
-                                vector_tile::Tile_Feature & current_feature,
-                                int32_t & start_x,
-                                int32_t & start_y)
+inline bool encode_geometry(mapnik::geometry::multi_point<std::int64_t> const& geom,
+                            vector_tile::Tile_Feature & current_feature,
+                            int32_t & start_x,
+                            int32_t & start_y)
 {
     std::size_t geom_size = geom.size();
     if (geom_size <= 0)
     {
-        return 0;
+        return false;
     }
     current_feature.add_geometry(1u | (geom_size << 3)); // move_to | (len << 3)
     for (auto const& pt : geom)
@@ -177,33 +175,39 @@ inline unsigned encode_geometry(mapnik::geometry::multi_point<std::int64_t> cons
         start_x = pt.x;
         start_y = pt.y;
     }
-    return geom_size;
+    return true;
 }
 
-inline unsigned encode_geometry(mapnik::geometry::multi_line_string<std::int64_t> const& geom,
-                                vector_tile::Tile_Feature & current_feature,
-                                int32_t & start_x,
-                                int32_t & start_y)
+inline bool encode_geometry(mapnik::geometry::multi_line_string<std::int64_t> const& geom,
+                            vector_tile::Tile_Feature & current_feature,
+                            int32_t & start_x,
+                            int32_t & start_y)
 {
-    unsigned count = 0;
+    bool success = false;
     for (auto const& poly : geom)
     {
-        count += encode_geometry(poly, current_feature, start_x, start_y);
+        if (encode_geometry(poly, current_feature, start_x, start_y))
+        {
+            success = true;
+        }
     }
-    return count;
+    return success;
 }
 
-inline unsigned encode_geometry(mapnik::geometry::multi_polygon<std::int64_t> const& geom,
-                                vector_tile::Tile_Feature & current_feature,
-                                int32_t & start_x,
-                                int32_t & start_y)
+inline bool encode_geometry(mapnik::geometry::multi_polygon<std::int64_t> const& geom,
+                            vector_tile::Tile_Feature & current_feature,
+                            int32_t & start_x,
+                            int32_t & start_y)
 {
-    unsigned count = 0;
+    bool success = false;
     for (auto const& poly : geom)
     {
-        count += encode_geometry(poly, current_feature, start_x, start_y);
+        if (encode_geometry(poly, current_feature, start_x, start_y))
+        {
+            success = true;
+        }
     }
-    return count;
+    return success;
 }
 
 }} // end ns
diff --git a/src/vector_tile_processor.hpp b/src/vector_tile_processor.hpp
index 916e2a1..89cf4ce 100644
--- a/src/vector_tile_processor.hpp
+++ b/src/vector_tile_processor.hpp
@@ -82,11 +82,11 @@ public:
                         int buffer_size);
 
     template <typename T2>
-    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<double> const& target_clipping_extent);
+    MAPNIK_VECTOR_INLINE bool 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<double> const& target_clipping_extent);
 };
 
 }} // end ns
diff --git a/src/vector_tile_processor.ipp b/src/vector_tile_processor.ipp
index 08554fb..220cfeb 100644
--- a/src/vector_tile_processor.ipp
+++ b/src/vector_tile_processor.ipp
@@ -802,7 +802,7 @@ void processor<T>::apply_to_layer(mapnik::layer const& lay,
                                     *feature,
                                     geom,
                                     tile_clipping_extent,
-                                    target_clipping_extent) > 0)
+                                    target_clipping_extent))
                 {
                     painted_ = true;
                 }
@@ -896,48 +896,54 @@ struct encoder_visitor {
       tile_clipping_extent_(tile_clipping_extent),
       area_threshold_(area_threshold) {}
 
-    unsigned operator() (mapnik::geometry::geometry_empty const&)
+    bool operator() (mapnik::geometry::geometry_empty const&)
     {
-        return 0;
+        return false;
     }
 
-    unsigned operator() (mapnik::geometry::geometry_collection<std::int64_t> & geom)
+    bool operator() (mapnik::geometry::geometry_collection<std::int64_t> & geom)
     {
-        unsigned count = 0;
+        bool painted = false;
         for (auto & g : geom)
         {
-            count += mapnik::util::apply_visitor((*this), g);
+            if (mapnik::util::apply_visitor((*this), g))
+            {
+                painted = true;
+            }
         }
-        return count;
+        return painted;
     }
 
-    unsigned operator() (mapnik::geometry::point<std::int64_t> const& geom)
+    bool operator() (mapnik::geometry::point<std::int64_t> const& geom)
     {
-        unsigned path_count = 0;
         backend_.start_tile_feature(feature_);
         backend_.current_feature_->set_type(vector_tile::Tile_GeomType_POINT);
-        path_count = backend_.add_path(geom);
+        bool painted = backend_.add_path(geom);
         backend_.stop_tile_feature();
-        return path_count;
+        return painted;
     }
 
-    unsigned operator() (mapnik::geometry::multi_point<std::int64_t> const& geom)
+    bool operator() (mapnik::geometry::multi_point<std::int64_t> const& geom)
     {
-        unsigned path_count = 0;
+        bool painted = false;
         if (!geom.empty())
         {
             backend_.start_tile_feature(feature_);
             backend_.current_feature_->set_type(vector_tile::Tile_GeomType_POINT);
-            path_count = backend_.add_path(geom);
+            painted = backend_.add_path(geom);
             backend_.stop_tile_feature();
         }
-        return path_count;
+        return painted;
     }
 
-    unsigned operator() (mapnik::geometry::line_string<std::int64_t> & geom)
+    bool operator() (mapnik::geometry::line_string<std::int64_t> & geom)
     {
-        unsigned path_count = 0;
-        if (geom.size() < 2) return 0;
+        bool painted = false;
+        if (geom.size() < 2)
+        {
+            // This is false because it means the original data was invalid
+            return false;
+        }
         std::deque<mapnik::geometry::line_string<int64_t>> result;
         mapnik::geometry::linear_ring<std::int64_t> clip_box;
         clip_box.emplace_back(tile_clipping_extent_.minx(),tile_clipping_extent_.miny());
@@ -948,20 +954,23 @@ struct encoder_visitor {
         boost::geometry::intersection(clip_box,geom,result);
         if (!result.empty())
         {
+            // Found some data in tile so painted is now true
+            painted = true;
+            // Add the data to the tile
             backend_.start_tile_feature(feature_);
             backend_.current_feature_->set_type(vector_tile::Tile_GeomType_LINESTRING);
             for (auto const& ls : result)
             {
-                path_count += backend_.add_path(ls);
+                backend_.add_path(ls);
             }
             backend_.stop_tile_feature();
         }
-        return path_count;
+        return painted;
     }
 
-    unsigned operator() (mapnik::geometry::multi_line_string<std::int64_t> & geom)
+    bool operator() (mapnik::geometry::multi_line_string<std::int64_t> & geom)
     {
-        unsigned path_count = 0;
+        bool painted = false;
         mapnik::geometry::linear_ring<std::int64_t> clip_box;
         clip_box.emplace_back(tile_clipping_extent_.minx(),tile_clipping_extent_.miny());
         clip_box.emplace_back(tile_clipping_extent_.maxx(),tile_clipping_extent_.miny());
@@ -975,19 +984,21 @@ struct encoder_visitor {
             {
                continue;
             }
+            // If any line reaches here painted is now true because
             std::deque<mapnik::geometry::line_string<int64_t>> result;
             boost::geometry::intersection(clip_box,line,result);
             if (!result.empty())
             {
                 if (first)
                 {
+                    painted = true;
                     first = false;
                     backend_.start_tile_feature(feature_);
                     backend_.current_feature_->set_type(vector_tile::Tile_GeomType_LINESTRING);
                 }
                 for (auto const& ls : result)
                 {
-                    path_count += backend_.add_path(ls);
+                    backend_.add_path(ls);
                 }
             }
         }
@@ -995,13 +1006,20 @@ struct encoder_visitor {
         {
             backend_.stop_tile_feature();
         }
-        return path_count;
+        return painted;
     }
 
-    unsigned operator() (mapnik::geometry::polygon<std::int64_t> & geom)
+    bool operator() (mapnik::geometry::polygon<std::int64_t> & geom)
     {
-        unsigned path_count = 0;
-        if (geom.exterior_ring.size() < 3) return 0;
+        bool painted = false;
+        if (geom.exterior_ring.size() < 3)
+        {
+            // Invalid geometry so will be false
+            return false;
+        }
+        // Because of geometry cleaning and other methods
+        // we automatically call this tile painted even if there is no intersections.
+        painted = true;
         double clean_distance = 1.415;
         mapnik::geometry::linear_ring<std::int64_t> clip_box;
         clip_box.emplace_back(tile_clipping_extent_.minx(),tile_clipping_extent_.miny());
@@ -1014,7 +1032,7 @@ struct encoder_visitor {
         double outer_area = ClipperLib::Area(geom.exterior_ring);
         if (std::abs(outer_area) < area_threshold_)
         {
-            return 0;
+            return painted;
         }
         // The view transform inverts the y axis so this should be positive still despite now
         // being clockwise for the exterior ring. If it is not lets invert it.
@@ -1026,11 +1044,14 @@ struct encoder_visitor {
         //poly_clipper.StrictlySimple(true);
         if (!poly_clipper.AddPath(geom.exterior_ring, ClipperLib::ptSubject, true))
         {
-            return 0;
+            return painted;
         }
         for (auto & ring : geom.interior_rings)
         {
-            if (ring.size() < 3) continue;
+            if (ring.size() < 3) 
+            {
+                continue;
+            }
             ClipperLib::CleanPolygon(ring, clean_distance);
             double inner_area = ClipperLib::Area(ring);
             if (std::abs(inner_area) < area_threshold_) continue;
@@ -1047,7 +1068,7 @@ struct encoder_visitor {
         }
         if (!poly_clipper.AddPath( clip_box, ClipperLib::ptClip, true ))
         {
-            return 0;
+            return painted;
         }
         mapnik::geometry::multi_line_string<std::int64_t> output_paths;
         poly_clipper.Execute(ClipperLib::ctIntersection, output_paths, ClipperLib::pftNonZero);
@@ -1055,7 +1076,7 @@ struct encoder_visitor {
         ClipperLib::CleanPolygons(output_paths, clean_distance);
         if (!clipper.AddPaths(output_paths, ClipperLib::ptSubject, true))
         {
-            return 0;
+            return painted;
         }
         
         ClipperLib::PolyTree polygons;
@@ -1072,7 +1093,7 @@ struct encoder_visitor {
 
         if (mp.empty())
         {
-            return 0;
+            return painted;
         }
 
         backend_.start_tile_feature(feature_);
@@ -1080,18 +1101,23 @@ struct encoder_visitor {
         
         for (auto const& poly : mp)
         {
-            path_count += backend_.add_path(poly);
+            backend_.add_path(poly);
         }
         backend_.stop_tile_feature();
-        return path_count;
+        return painted;
     }
 
-    unsigned operator() (mapnik::geometry::multi_polygon<std::int64_t> & geom)
+    bool operator() (mapnik::geometry::multi_polygon<std::int64_t> & geom)
     {
-        unsigned path_count = 0;
+        bool painted = false;
         //mapnik::box2d<std::int64_t> bbox = mapnik::geometry::envelope(geom);
-        if (geom.empty()) return 0;
-            
+        if (geom.empty())
+        {
+            return painted;
+        }
+        // From this point on due to polygon cleaning etc, we just assume that the tile has some sort
+        // of intersection and is painted.
+        painted = true;   
         double clean_distance = 1.415;
         mapnik::geometry::linear_ring<std::int64_t> clip_box;
         clip_box.emplace_back(tile_clipping_extent_.minx(),tile_clipping_extent_.miny());
@@ -1140,7 +1166,7 @@ struct encoder_visitor {
             }
             if (!poly_clipper.AddPath( clip_box, ClipperLib::ptClip, true ))
             {
-                return 0;
+                return painted;
             }
             mapnik::geometry::multi_line_string<std::int64_t> output_paths;
             poly_clipper.Execute(ClipperLib::ctIntersection, output_paths);//, ClipperLib::pftNonZero);
@@ -1167,7 +1193,7 @@ struct encoder_visitor {
         
         if (mp.empty())
         {
-            return 0;
+            return painted;
         }
 
         backend_.start_tile_feature(feature_);
@@ -1175,10 +1201,10 @@ struct encoder_visitor {
         
         for (auto const& poly : mp)
         {
-            path_count += backend_.add_path(poly);
+            backend_.add_path(poly);
         }
         backend_.stop_tile_feature();
-        return path_count;
+        return painted;
     }
 
     backend_type & backend_;
@@ -1195,57 +1221,60 @@ struct simplify_visitor {
       encoder_(encoder),
       simplify_distance_(simplify_distance) {}
 
-    unsigned operator() (mapnik::geometry::point<std::int64_t> const& geom)
+    bool operator() (mapnik::geometry::point<std::int64_t> const& geom)
     {
         return encoder_(geom);
     }
 
-    unsigned operator() (mapnik::geometry::multi_point<std::int64_t> const& geom)
+    bool operator() (mapnik::geometry::multi_point<std::int64_t> const& geom)
     {
         return encoder_(geom);
     }
 
-    unsigned operator() (mapnik::geometry::line_string<std::int64_t> const& geom)
+    bool operator() (mapnik::geometry::line_string<std::int64_t> const& geom)
     {
         mapnik::geometry::line_string<std::int64_t> simplified;
         boost::geometry::simplify(geom,simplified,simplify_distance_);
         return encoder_(simplified);
     }
 
-    unsigned operator() (mapnik::geometry::multi_line_string<std::int64_t> const& geom)
+    bool operator() (mapnik::geometry::multi_line_string<std::int64_t> const& geom)
     {
         mapnik::geometry::multi_line_string<std::int64_t> simplified;
         boost::geometry::simplify(geom,simplified,simplify_distance_);
         return encoder_(simplified);
     }
 
-    unsigned operator() (mapnik::geometry::polygon<std::int64_t> const& geom)
+    bool operator() (mapnik::geometry::polygon<std::int64_t> const& geom)
     {
         mapnik::geometry::polygon<std::int64_t> simplified;
         boost::geometry::simplify(geom,simplified,simplify_distance_);
         return encoder_(simplified);
     }
 
-    unsigned operator() (mapnik::geometry::multi_polygon<std::int64_t> const& geom)
+    bool operator() (mapnik::geometry::multi_polygon<std::int64_t> const& geom)
     {
         mapnik::geometry::multi_polygon<std::int64_t> simplified;
         boost::geometry::simplify(geom,simplified,simplify_distance_);
         return encoder_(simplified);
     }
 
-    unsigned operator() (mapnik::geometry::geometry_collection<std::int64_t> const& geom)
+    bool operator() (mapnik::geometry::geometry_collection<std::int64_t> const& geom)
     {
-        unsigned count = 0;
+        bool painted = false;
         for (auto const& g : geom)
         {
-            count += mapnik::util::apply_visitor((*this), g);
+            if (mapnik::util::apply_visitor((*this), g))
+            {
+                painted = true;
+            }
         }
-        return count;
+        return painted;
     }
 
-    unsigned operator() (mapnik::geometry::geometry_empty const&)
+    bool operator() (mapnik::geometry::geometry_empty const&)
     {
-        return 0;
+        return false;
     }
 
     encoder_visitor<backend_type> & encoder_;
@@ -1254,11 +1283,11 @@ struct simplify_visitor {
 
 
 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<double> const& target_clipping_extent)
+bool 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<double> const& target_clipping_extent)
 {
     // TODO
     // - no need to create a new skipping_transformer per geometry
diff --git a/test/vector_tile_pbf.cpp b/test/vector_tile_pbf.cpp
index fb33e4b..a45c500 100644
--- a/test/vector_tile_pbf.cpp
+++ b/test/vector_tile_pbf.cpp
@@ -424,29 +424,24 @@ TEST_CASE( "pbf vector tile from simplified geojson", "should create vector tile
     protozero::pbf_reader pbf_layer = pbf_tile.get_message();
     // Need to loop because they could be encoded in any order
     bool found = false;
-    while (!found && pbf_layer.next()) {
+    while (!found && pbf_layer.next(2)) {
       // But there will be only one in our tile, so we'll break out of loop once we find it
-      if (pbf_layer.tag() == 2) {
-          protozero::pbf_reader pbf_feature = pbf_layer.get_message();
-          while (!found && pbf_feature.next()) {
-              if (pbf_feature.tag() == 4) {
-                  found = true;
-                  std::pair< protozero::pbf_reader::const_uint32_iterator, protozero::pbf_reader::const_uint32_iterator > geom_itr = pbf_feature.get_packed_uint32();
-                  mapnik::vector_tile_impl::GeometryPBF geoms(geom_itr, tile_x,tile_y,scale,-1*scale);
-                  auto geom = mapnik::vector_tile_impl::decode_geometry(geoms, f.type());
-
-                  unsigned int n_err = 0;
-                  mapnik::projection wgs84("+init=epsg:4326",true);
-                  mapnik::projection merc("+init=epsg:3857",true);
-                  mapnik::proj_transform prj_trans(merc,wgs84);
-                  mapnik::geometry::geometry<double> projected_geom = mapnik::geometry::reproject_copy(geom,prj_trans,n_err);
-                  CHECK( n_err == 0 );
-                  std::string geojson_string;
-                  CHECK( mapnik::util::to_geojson(geojson_string,projected_geom) );
-                  CHECK( geojson_string == "{\"type\":\"Polygon\",\"coordinates\":[[[160.42359375,11.422482415387],[160.40671875,11.3976701817587],[160.396875,11.3935345987523],[160.39828125,11.4018057045895],[160.39265625,11.4004272036667],[160.38984375,11.3811274888866],[160.3940625,11.3838846711709],[160.3771875,11.3521754635814],[160.33921875,11.3590690696413],[160.35046875,11.3645838345287],[160.3575,11.3645838345287],[160.3575,11.3756130442004],[160.28859375,11.3480392200085],[160. [...]
-                  break;
-              }
-          }
+      protozero::pbf_reader pbf_feature = pbf_layer.get_message();
+      while (!found && pbf_feature.next(4)) {
+          found = true;
+          std::pair< protozero::pbf_reader::const_uint32_iterator, protozero::pbf_reader::const_uint32_iterator > geom_itr = pbf_feature.get_packed_uint32();
+          mapnik::vector_tile_impl::GeometryPBF geoms(geom_itr, tile_x,tile_y,scale,-1*scale);
+          auto geom = mapnik::vector_tile_impl::decode_geometry(geoms, f.type());
+              unsigned int n_err = 0;
+          mapnik::projection wgs84("+init=epsg:4326",true);
+          mapnik::projection merc("+init=epsg:3857",true);
+          mapnik::proj_transform prj_trans(merc,wgs84);
+          mapnik::geometry::geometry<double> projected_geom = mapnik::geometry::reproject_copy(geom,prj_trans,n_err);
+          CHECK( n_err == 0 );
+          std::string geojson_string;
+          CHECK( mapnik::util::to_geojson(geojson_string,projected_geom) );
+          CHECK( geojson_string == "{\"type\":\"Polygon\",\"coordinates\":[[[160.42359375,11.422482415387],[160.40671875,11.3976701817587],[160.396875,11.3935345987523],[160.39828125,11.4018057045895],[160.39265625,11.4004272036667],[160.38984375,11.3811274888866],[160.3940625,11.3838846711709],[160.3771875,11.3521754635814],[160.33921875,11.3590690696413],[160.35046875,11.3645838345287],[160.3575,11.3645838345287],[160.3575,11.3756130442004],[160.28859375,11.3480392200085],[160.295625,1 [...]
+          break;
       }
     }
     REQUIRE( found );

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