[Git][debian-gis-team/mapnik-vector-tile][upstream] New upstream version 1.6.1+dfsg

Bas Couwenberg gitlab at salsa.debian.org
Tue Feb 20 19:11:59 UTC 2018


Bas Couwenberg pushed to branch upstream at Debian GIS Project / mapnik-vector-tile


Commits:
51735720 by Bas Couwenberg at 2018-02-20T19:55:36+01:00
New upstream version 1.6.1+dfsg
- - - - -


11 changed files:

- CHANGELOG.md
- package.json
- src/vector_tile_layer.hpp
- + test/data/singapore.dbf
- + test/data/singapore.prj
- + test/data/singapore.sbn
- + test/data/singapore.sbx
- + test/data/singapore.shp
- + test/data/singapore.shx
- + test/data/singapore.xml
- + test/unit/processor/reprojection_error.cpp


Changes:

=====================================
CHANGELOG.md
=====================================
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## 1.6.1
+
+- Solved problem surrounded odd reprojection issues when dealing with low zoom level tiles and projections covering small geographic areas.
+
 ## 1.6.0
 
 - Bug fix for possible massive allocations in invalid vector tiles


=====================================
package.json
=====================================
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "mapnik-vector-tile",
-    "version": "1.6.0",
+    "version": "1.6.1",
     "description": "Mapnik Vector Tile API",
     "main": "include_dirs.js",
     "repository"   :  {


=====================================
src/vector_tile_layer.hpp
=====================================
--- a/src/vector_tile_layer.hpp
+++ b/src/vector_tile_layer.hpp
@@ -106,7 +106,7 @@ public:
           name_(lay.name()),
           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()),
+          source_buffered_extent_(calc_source_buffered_extent(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),
@@ -208,13 +208,20 @@ public:
         return ext;
     }
     
-    mapnik::box2d<double> calc_source_buffered_extent()
+    mapnik::box2d<double> calc_source_buffered_extent(mapnik::layer const& lay)
     {
         mapnik::box2d<double> new_extent(target_buffered_extent_);
         if (!prj_trans_.forward(new_extent, PROJ_ENVELOPE_POINTS))
         {
-            // this modifies the layer_ext by clipping to the buffered_ext
-            valid_ = false;
+            if (!ds_ || ds_->type() != datasource::Vector)
+            {
+                throw std::runtime_error("vector_tile_processor: can not project target projection to an extent in the source projection, reproject source data prior to processing");
+            }
+            else
+            {
+                new_extent = lay.envelope();
+            }
+
         }
         return new_extent;
     }
@@ -239,13 +246,6 @@ 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 reproject back to map projection");
-            }
-        }
 
         // first, try intersection of map extent forward projected into layer srs
         if (source_buffered_extent_.intersects(query_extent))
@@ -265,7 +265,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: query extent did not reproject back to map projection");
+                throw std::runtime_error("vector_tile_processor: query extent did not reproject back to source projection");
             }
         }
         else
@@ -273,8 +273,22 @@ public:
             // if no intersection then nothing to do for layer
             valid_ = false;    
         }
-        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 (!prj_trans_.equal())
+        {
+            if (!prj_trans_.forward(unbuffered_query_extent, PROJ_ENVELOPE_POINTS))
+            {
+                if (!ds_ || ds_->type() != datasource::Vector)
+                {
+                    throw std::runtime_error("vector_tile_processor: can not project target projection to an extent in the source projection, reproject source data prior to processing");
+                }
+                else
+                {
+                    unbuffered_query_extent = lay.envelope();
+                }
+            }
+        }
+        double qw = unbuffered_query_extent.width() > 0 ? unbuffered_query_extent.width() : 1.0;
+        double qh = unbuffered_query_extent.height() > 0 ? unbuffered_query_extent.height() : 1.0;
         if (!ds_ || ds_->type() == datasource::Vector)
         {
             qw = VT_LEGACY_IMAGE_SIZE / qw;
@@ -285,6 +299,7 @@ public:
             qw = static_cast<double>(layer_extent_) / qw;
             qh = static_cast<double>(layer_extent_) / qh;
         }
+
         mapnik::query::resolution_type res(qw, qh);
         mapnik::query q(query_extent, res, scale_denom, unbuffered_query_extent);
         if (ds_)


=====================================
test/data/singapore.dbf
=====================================
Binary files /dev/null and b/test/data/singapore.dbf differ


=====================================
test/data/singapore.prj
=====================================
--- /dev/null
+++ b/test/data/singapore.prj
@@ -0,0 +1 @@
+PROJCS["SVY21",GEOGCS["SVY21[WGS84]",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",28001.642],PARAMETER["False_Northing",38744.572],PARAMETER["Central_Meridian",103.8333333333333],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",1.366666666666667],UNIT["Meter",1.0]]
\ No newline at end of file


=====================================
test/data/singapore.sbn
=====================================
Binary files /dev/null and b/test/data/singapore.sbn differ


=====================================
test/data/singapore.sbx
=====================================
Binary files /dev/null and b/test/data/singapore.sbx differ


=====================================
test/data/singapore.shp
=====================================
Binary files /dev/null and b/test/data/singapore.shp differ


=====================================
test/data/singapore.shx
=====================================
Binary files /dev/null and b/test/data/singapore.shx differ


=====================================
test/data/singapore.xml
=====================================
--- /dev/null
+++ b/test/data/singapore.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE Map[]>
+<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over" maximum-extent="-20037508.34,-20037508.34,20037508.34,20037508.34">
+  <Parameters>
+    <Parameter name="center">103.92383995989066,1.3312732063470314,0</Parameter>
+    <Parameter name="bounds">103.92116959172444,1.3293149668842956,103.92651032805688,1.3332314458097674</Parameter>
+    <Parameter name="format">pbf</Parameter>
+    <Parameter name="json"><![CDATA[{"vector_layers":[{"id":"zika_cluster","description":"","minzoom":0,"maxzoom":22,"fields":{"OBJECTID":"Number","LOCALITY":"String","CASE_SIZE":"Number","NAME":"String","HYPERLINK":"String","CLUSTER_ID":"String","INC_CRC":"String","FMEL_UPD_D":"String","X_ADDR":"Number","Y_ADDR":"Number","SHAPE_Leng":"Number","SHAPE_Area":"Number"}}]}]]></Parameter>
+    <Parameter name="maxzoom">15</Parameter>
+    <Parameter name="minzoom">0</Parameter>
+  </Parameters>
+
+  <Layer name="zika_cluster" buffer-size="8" srs="+proj=tmerc +lat_0=1.366666666666667 +lon_0=103.8333333333333 +k=1 +x_0=28001.642 +y_0=38744.572 +ellps=WGS84 +units=m +no_defs">
+    <Datasource>
+      <Parameter name="type">shape</Parameter>
+      <Parameter name="file">singapore.shp</Parameter>
+      <Parameter name="layer">zika_cluster</Parameter>
+    </Datasource>
+  </Layer>
+</Map>


=====================================
test/unit/processor/reprojection_error.cpp
=====================================
--- /dev/null
+++ b/test/unit/processor/reprojection_error.cpp
@@ -0,0 +1,46 @@
+#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 - handle strange projection issues")
+{
+    mapnik::Map map(256, 256);
+    mapnik::load_map(map, "test/data/singapore.xml");
+    mapnik::vector_tile_impl::processor ren(map);
+
+    {
+        mapnik::vector_tile_impl::tile out_tile = ren.create_tile(1, 0, 1);
+        vector_tile::Tile tile;
+        REQUIRE(tile.ParseFromString(out_tile.get_buffer()));
+        // Should be empty due to simplification
+        REQUIRE(0 == tile.layers_size());
+    }
+    {
+        mapnik::vector_tile_impl::tile out_tile = ren.create_tile(1, 0, 1, 4096 * 1024);
+        vector_tile::Tile tile;
+        REQUIRE(tile.ParseFromString(out_tile.get_buffer()));
+        // Expanding the extent here we get some data as simplification doesn't occur
+        REQUIRE(1 == tile.layers_size());
+        CHECK(1 == tile.layers(0).features_size());
+    }
+    {
+        mapnik::vector_tile_impl::tile out_tile = ren.create_tile(50, 31, 6);
+        vector_tile::Tile tile;
+        REQUIRE(tile.ParseFromString(out_tile.get_buffer()));
+        // Slightly more zoomed in we get data.
+        REQUIRE(1 == tile.layers_size());
+        CHECK(1 == tile.layers(0).features_size());
+    }
+}



View it on GitLab: https://salsa.debian.org/debian-gis-team/mapnik-vector-tile/commit/517357203950d7f2912d2681a79aa58a8e13fefa

---
View it on GitLab: https://salsa.debian.org/debian-gis-team/mapnik-vector-tile/commit/517357203950d7f2912d2681a79aa58a8e13fefa
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-grass-devel/attachments/20180220/11448277/attachment-0001.html>


More information about the Pkg-grass-devel mailing list