[mapnik-vector-tile] 01/04: Imported Upstream version 1.1.2+dfsg
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Mon Apr 18 20:36:03 UTC 2016
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 0959cd6de412580cff386c96030d6c91fa79c6a9
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Mon Apr 18 22:22:32 2016 +0200
Imported Upstream version 1.1.2+dfsg
---
CHANGELOG.md | 4 ++++
package.json | 2 +-
src/vector_tile_geometry_decoder.hpp | 1 -
src/vector_tile_geometry_decoder.ipp | 14 ++++++++++--
src/vector_tile_layer.hpp | 9 +++++++-
test/data/image.mvt | Bin 0 -> 146098 bytes
test/unit/encoding/geometry_to_feature_pbf.cpp | 1 -
test/unit/load/merge.cpp | 29 ++++++++++++++++++++++++-
8 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 15ba151..fd0bd71 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## 1.1.2
+
+- Fix performance regression when passing raster through vector tile
+
## 1.1.1
- Corrected for numerical precision issue when using decoder where it was incorrectly considering very small triangles as having zero area.
diff --git a/package.json b/package.json
index baf5931..1412ab0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "mapnik-vector-tile",
- "version": "1.1.1",
+ "version": "1.1.2",
"description": "Mapnik Vector Tile API",
"main": "./package.json",
"repository" : {
diff --git a/src/vector_tile_geometry_decoder.hpp b/src/vector_tile_geometry_decoder.hpp
index a7a2254..998cba7 100644
--- a/src/vector_tile_geometry_decoder.hpp
+++ b/src/vector_tile_geometry_decoder.hpp
@@ -10,7 +10,6 @@
//mapnik
#include <mapnik/box2d.hpp>
#include <mapnik/geometry.hpp>
-#include <mapnik/util/is_clockwise.hpp>
#if defined(DEBUG)
#include <mapnik/debug.hpp>
#endif
diff --git a/src/vector_tile_geometry_decoder.ipp b/src/vector_tile_geometry_decoder.ipp
index b876387..56120fa 100644
--- a/src/vector_tile_geometry_decoder.ipp
+++ b/src/vector_tile_geometry_decoder.ipp
@@ -25,13 +25,23 @@ namespace detail
template <typename T>
bool ring_is_clockwise(T const& ring)
{
- long double area = 0.0;
std::size_t num_points = ring.size();
+ if (num_points < 3)
+ {
+ return false;
+ }
+ double area = 0.0;
+ double orig_x = ring[0].x;
+ double orig_y = ring[0].y;
for (std::size_t i = 0; i < num_points; ++i)
{
auto const& p0 = ring[i];
auto const& p1 = ring[(i + 1) % num_points];
- area += static_cast<long double>(p0.x) * static_cast<long double>(p1.y) - static_cast<long double>(p0.y) * static_cast<long double>(p1.x);
+ double x0 = p0.x - orig_x;
+ double y0 = p0.y - orig_y;
+ double x1 = p1.x - orig_x;
+ double y1 = p1.y - orig_y;
+ area += x0 * y1 - x1 * y0;
}
return (area < 0.0) ? true : false;
}
diff --git a/src/vector_tile_layer.hpp b/src/vector_tile_layer.hpp
index d70663d..4cfde5a 100644
--- a/src/vector_tile_layer.hpp
+++ b/src/vector_tile_layer.hpp
@@ -145,7 +145,14 @@ public:
auto ds_extent = ds_->params().template get<mapnik::value_integer>("vector_layer_extent");
if (ds_extent)
{
- layer_extent = *ds_extent;
+ if (ds_->type() == datasource::Vector)
+ {
+ layer_extent = *ds_extent;
+ }
+ else
+ {
+ layer_extent = 256;
+ }
}
if (layer_extent == 0)
{
diff --git a/test/data/image.mvt b/test/data/image.mvt
new file mode 100644
index 0000000..74e5b85
Binary files /dev/null and b/test/data/image.mvt differ
diff --git a/test/unit/encoding/geometry_to_feature_pbf.cpp b/test/unit/encoding/geometry_to_feature_pbf.cpp
index 66741ee..fb3e7e3 100644
--- a/test/unit/encoding/geometry_to_feature_pbf.cpp
+++ b/test/unit/encoding/geometry_to_feature_pbf.cpp
@@ -2,7 +2,6 @@
// mapnik vector tile
#include "vector_tile_geometry_feature.hpp"
-#include "vector_tile_layer.hpp"
// mapnik
#include <mapnik/geometry.hpp>
diff --git a/test/unit/load/merge.cpp b/test/unit/load/merge.cpp
index f5f825f..6579b88 100644
--- a/test/unit/load/merge.cpp
+++ b/test/unit/load/merge.cpp
@@ -10,7 +10,7 @@
#include <fstream>
#include <string>
-TEST_CASE( "merge_from_compressed_buffer" )
+TEST_CASE( "merge_from_compressed_buffer - vector" )
{
std::ifstream stream("./test/data/0.0.0.vector.mvt",std::ios_base::in|std::ios_base::binary);
REQUIRE(stream.is_open());
@@ -64,5 +64,32 @@ TEST_CASE( "merge_from_compressed_buffer" )
CHECK(errors.size() == 0);
}
}
+}
+TEST_CASE( "merge_from_compressed_buffer - raster" )
+{
+ std::ifstream stream("./test/data/image.mvt",std::ios_base::in|std::ios_base::binary);
+ REQUIRE(stream.is_open());
+ std::string buffer(std::istreambuf_iterator<char>(stream.rdbuf()),(std::istreambuf_iterator<char>()));
+ REQUIRE(buffer.size() == 146098);
+ mapnik::vector_tile_impl::merc_tile tile(0,0,0);
+ mapnik::vector_tile_impl::merge_from_compressed_buffer(tile, buffer.data(), buffer.size(), true, true);
+ CHECK(tile.get_layers().size() == 1);
+ {
+ protozero::pbf_reader tile_msg(tile.get_buffer());
+ while (tile_msg.next(mapnik::vector_tile_impl::Tile_Encoding::LAYERS))
+ {
+ auto layer_data = tile_msg.get_data();
+ protozero::pbf_reader layer_props_msg(layer_data);
+ auto layer_info = mapnik::vector_tile_impl::get_layer_name_and_version(layer_props_msg);
+ std::string const& layer_name = layer_info.first;
+ std::uint32_t version = layer_info.second;
+ CHECK(layer_name == "layer");
+ CHECK(version == 2);
+ std::set<mapnik::vector_tile_impl::validity_error> errors;
+ protozero::pbf_reader layer_valid_msg(layer_data);
+ layer_is_valid(layer_valid_msg, errors);
+ CHECK(errors.size() == 0);
+ }
+ }
}
--
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