[mapnik-vector-tile] 01/05: New upstream version 1.6.1+dfsg

Bas Couwenberg sebastic at debian.org
Tue Feb 20 19:11:28 UTC 2018


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 517357203950d7f2912d2681a79aa58a8e13fefa
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Tue Feb 20 19:55:36 2018 +0100

    New upstream version 1.6.1+dfsg
---
 CHANGELOG.md                               |   4 +++
 package.json                               |   2 +-
 src/vector_tile_layer.hpp                  |  43 ++++++++++++++++++---------
 test/data/singapore.dbf                    | Bin 0 -> 1582 bytes
 test/data/singapore.prj                    |   1 +
 test/data/singapore.sbn                    | Bin 0 -> 132 bytes
 test/data/singapore.sbx                    | Bin 0 -> 116 bytes
 test/data/singapore.shp                    | Bin 0 -> 636 bytes
 test/data/singapore.shx                    | Bin 0 -> 108 bytes
 test/data/singapore.xml                    |  20 +++++++++++++
 test/unit/processor/reprojection_error.cpp |  46 +++++++++++++++++++++++++++++
 11 files changed, 101 insertions(+), 15 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2fad2b9..8389381 100644
--- 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
diff --git a/package.json b/package.json
index 144ee69..19e3572 100644
--- 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"   :  {
diff --git a/src/vector_tile_layer.hpp b/src/vector_tile_layer.hpp
index af512e6..d2a1d08 100644
--- 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_)
diff --git a/test/data/singapore.dbf b/test/data/singapore.dbf
new file mode 100644
index 0000000..c78f80e
Binary files /dev/null and b/test/data/singapore.dbf differ
diff --git a/test/data/singapore.prj b/test/data/singapore.prj
new file mode 100644
index 0000000..b848068
--- /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
diff --git a/test/data/singapore.sbn b/test/data/singapore.sbn
new file mode 100644
index 0000000..816ad90
Binary files /dev/null and b/test/data/singapore.sbn differ
diff --git a/test/data/singapore.sbx b/test/data/singapore.sbx
new file mode 100644
index 0000000..385b00a
Binary files /dev/null and b/test/data/singapore.sbx differ
diff --git a/test/data/singapore.shp b/test/data/singapore.shp
new file mode 100644
index 0000000..9117769
Binary files /dev/null and b/test/data/singapore.shp differ
diff --git a/test/data/singapore.shx b/test/data/singapore.shx
new file mode 100644
index 0000000..82089a9
Binary files /dev/null and b/test/data/singapore.shx differ
diff --git a/test/data/singapore.xml b/test/data/singapore.xml
new file mode 100644
index 0000000..ea5c40a
--- /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>
diff --git a/test/unit/processor/reprojection_error.cpp b/test/unit/processor/reprojection_error.cpp
new file mode 100644
index 0000000..231f80d
--- /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());
+    }
+}

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