[mapnik-vector-tile] 01/06: Imported Upstream version 1.1.1+dfsg
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Sat Apr 16 17:19:57 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 9a932629a129643ef26172267b5557ad2fbfd80d
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Sat Apr 16 18:53:23 2016 +0200
Imported Upstream version 1.1.1+dfsg
---
CHANGELOG.md | 3 ++
Makefile | 2 +-
bin/vtile-fuzz.cpp | 83 ++++++++++++++++++++++++++++++++++++
gyp/build.gyp | 16 +++++++
gyp/common.gypi | 17 ++++++++
package.json | 2 +-
src/vector_tile_geometry_decoder.ipp | 25 ++++++++---
test/utils/encoding_util.cpp | 4 ++
test/utils/round_trip.cpp | 4 ++
test/vector_tile.cpp | 4 ++
test/vector_tile_pbf.cpp | 10 +++++
11 files changed, 162 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9f9343d..15ba151 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog
+## 1.1.1
+
+- Corrected for numerical precision issue when using decoder where it was incorrectly considering very small triangles as having zero area.
## 1.1.0
diff --git a/Makefile b/Makefile
index 497457c..5d2d335 100755
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
MAPNIK_PLUGINDIR := $(shell mapnik-config --input-plugins)
BUILDTYPE ?= Release
-CLIPPER_REVISION=68c49e9a9adaff1ddddb008eaf49f71bf259c4e8
+CLIPPER_REVISION=381c817fd13e819e90006ed1f3c26ea6f1e6e343
PROTOZERO_REVISION=v1.3.0
GYP_REVISION=3464008
diff --git a/bin/vtile-fuzz.cpp b/bin/vtile-fuzz.cpp
new file mode 100644
index 0000000..243ecf2
--- /dev/null
+++ b/bin/vtile-fuzz.cpp
@@ -0,0 +1,83 @@
+#include "vector_tile_geometry_clipper.hpp"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <vector>
+#include <iostream>
+#include <limits>
+
+
+/*
+
+https://github.com/mapnik/clipper/issues/3
+
+*/
+
+class noop_process {
+public:
+ noop_process() {}
+ template <typename T>
+ void operator() (T &)
+ {
+ return;
+ }
+};
+
+int main() {
+
+ noop_process no_op;
+ using clipping_process = mapnik::vector_tile_impl::geometry_clipper<noop_process>;
+ double area_threshold = 0;
+ bool strictly_simple = true;
+ bool multi_polygon_union = true;
+ mapnik::vector_tile_impl::polygon_fill_type fill_type = mapnik::vector_tile_impl::even_odd_fill;
+ bool process_all_rings = true;
+ mapnik::box2d<int> tile_clipping_extent(std::numeric_limits<int>::min(),
+ std::numeric_limits<int>::min(),
+ std::numeric_limits<int>::max(),
+ std::numeric_limits<int>::max());
+ clipping_process clipper(tile_clipping_extent,
+ area_threshold,
+ strictly_simple,
+ multi_polygon_union,
+ fill_type,
+ process_all_rings,
+ no_op);
+
+ srand(time(NULL));
+
+ while (1) {
+
+ std::size_t len = rand() % 700 + 3;
+
+ mapnik::geometry::polygon<std::int64_t> poly;
+ mapnik::geometry::linear_ring<std::int64_t> ring;
+
+ bool added_exterior = false;
+
+ for (std::size_t i = 0; i < len; ++i) {
+ std::int64_t x = rand() % 4096;
+ std::int64_t y = rand() % 4096;
+ //std::clog << x << "," << y;
+
+ ring.add_coord(x,y);
+
+ if (!added_exterior && i > 100) {
+ poly.set_exterior_ring(std::move(ring));
+ ring = mapnik::geometry::linear_ring<std::int64_t>();
+ //std::clog << "added exterior\n";
+ added_exterior = true;
+ }
+
+ if (added_exterior && rand() % 50 == 0 && ring.size() >= 3) {
+ poly.add_hole(std::move(ring));
+ ring = mapnik::geometry::linear_ring<std::int64_t>();
+ //std::clog << "added hole\n";
+ }
+ }
+
+ std::clog << "size: " << poly.num_rings() << "\n";
+ clipper(poly);
+ }
+}
\ No newline at end of file
diff --git a/gyp/build.gyp b/gyp/build.gyp
index 5e579ea..98db069 100644
--- a/gyp/build.gyp
+++ b/gyp/build.gyp
@@ -211,6 +211,22 @@
]
},
{
+ "target_name": "vtile-fuzz",
+ 'dependencies': [ 'mapnik_vector_tile_impl' ],
+ "type": "executable",
+ "defines": [
+ "<@(common_defines)",
+ "MAPNIK_PLUGINDIR=<(MAPNIK_PLUGINDIR)"
+ ],
+ "sources": [
+ "../bin/vtile-fuzz.cpp"
+ ],
+ "include_dirs": [
+ "../src",
+ '../deps/protozero/include'
+ ]
+ },
+ {
"target_name": "tileinfo",
'dependencies': [ 'vector_tile' ],
"type": "executable",
diff --git a/gyp/common.gypi b/gyp/common.gypi
index 491252b..49940ef 100644
--- a/gyp/common.gypi
+++ b/gyp/common.gypi
@@ -117,7 +117,24 @@
"defines": [
"DEBUG"
],
+ 'defines!': [
+ 'NDEBUG'
+ ],
+ 'cflags_cc!': [
+ '-O3',
+ '-O2',
+ '-O1',
+ '-Os',
+ '-DNDEBUG'
+ ],
"xcode_settings": {
+ 'OTHER_CPLUSPLUSFLAGS!': [
+ '-O3',
+ '-O2',
+ '-O1',
+ '-Os',
+ '-DNDEBUG'
+ ],
"GCC_OPTIMIZATION_LEVEL": "0",
"GCC_GENERATE_DEBUGGING_SYMBOLS": "YES",
"OTHER_CPLUSPLUSFLAGS": [ "-Wall", "-Wextra", "-pedantic", "-g", "-O0" ]
diff --git a/package.json b/package.json
index fe9c7b0..baf5931 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "mapnik-vector-tile",
- "version": "1.1.0",
+ "version": "1.1.1",
"description": "Mapnik Vector Tile API",
"main": "./package.json",
"repository" : {
diff --git a/src/vector_tile_geometry_decoder.ipp b/src/vector_tile_geometry_decoder.ipp
index 6023952..b876387 100644
--- a/src/vector_tile_geometry_decoder.ipp
+++ b/src/vector_tile_geometry_decoder.ipp
@@ -4,7 +4,6 @@
//mapnik
#include <mapnik/box2d.hpp>
#include <mapnik/geometry.hpp>
-#include <mapnik/util/is_clockwise.hpp>
#if defined(DEBUG)
#include <mapnik/debug.hpp>
#endif
@@ -23,6 +22,20 @@ namespace vector_tile_impl
namespace detail
{
+template <typename T>
+bool ring_is_clockwise(T const& ring)
+{
+ long double area = 0.0;
+ std::size_t num_points = ring.size();
+ 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);
+ }
+ return (area < 0.0) ? true : false;
+}
+
template <typename value_type>
inline void move_cursor(value_type & x, value_type & y, std::int32_t dx, std::int32_t dy, double scale_x_, double scale_y_)
{
@@ -425,7 +438,7 @@ void decode_polygons(mapnik::geometry::geometry<T1> & geom,
// We are going to check if the current ring is clockwise, keeping in mind that
// the orientation could have flipped due to scaling.
- if (mapnik::util::is_clockwise(*rings_itr))
+ if (ring_is_clockwise(*rings_itr))
{
if (scaling_reversed_orientation)
{
@@ -483,7 +496,7 @@ void decode_polygons(mapnik::geometry::geometry<T1> & geom,
}
if (first)
{
- first_is_clockwise = mapnik::util::is_clockwise(*rings_itr);
+ first_is_clockwise = ring_is_clockwise(*rings_itr);
// first ring always exterior and sets all future winding order
multi_poly.emplace_back();
if (first_is_clockwise)
@@ -494,7 +507,7 @@ void decode_polygons(mapnik::geometry::geometry<T1> & geom,
multi_poly.back().set_exterior_ring(std::move(*rings_itr));
first = false;
}
- else if (first_is_clockwise == mapnik::util::is_clockwise(*rings_itr))
+ else if (first_is_clockwise == ring_is_clockwise(*rings_itr))
{
// hit a new exterior ring, so start a new polygon
multi_poly.emplace_back(); // start new polygon
@@ -544,7 +557,7 @@ void decode_polygons(mapnik::geometry::geometry<T1> & geom,
if (first)
{
- if (mapnik::util::is_clockwise(*rings_itr))
+ if (ring_is_clockwise(*rings_itr))
{
if (scaling_reversed_orientation)
{
@@ -565,7 +578,7 @@ void decode_polygons(mapnik::geometry::geometry<T1> & geom,
multi_poly.back().set_exterior_ring(std::move(*rings_itr));
first = false;
}
- else if (mapnik::util::is_clockwise(*rings_itr)) // interior ring
+ else if (ring_is_clockwise(*rings_itr)) // interior ring
{
if (scaling_reversed_orientation)
{
diff --git a/test/utils/encoding_util.cpp b/test/utils/encoding_util.cpp
index 60521f6..563092a 100644
--- a/test/utils/encoding_util.cpp
+++ b/test/utils/encoding_util.cpp
@@ -76,6 +76,10 @@ std::string compare_pbf(mapnik::geometry::geometry<std::int64_t> const& g, unsig
{
geometry_type = feature_reader.get_enum();
}
+ else
+ {
+ feature_reader.skip();
+ }
}
mapnik::vector_tile_impl::GeometryPBF<double> geoms(geom_itr, 0.0, 0.0, 1.0, 1.0);
auto g2 = mapnik::vector_tile_impl::decode_geometry(geoms, geometry_type, version);
diff --git a/test/utils/round_trip.cpp b/test/utils/round_trip.cpp
index 420a2b2..9166014 100644
--- a/test/utils/round_trip.cpp
+++ b/test/utils/round_trip.cpp
@@ -81,6 +81,10 @@ mapnik::geometry::geometry<double> round_trip(mapnik::geometry::geometry<double>
{
geometry_type = feature_reader.get_enum();
}
+ else
+ {
+ feature_reader.skip();
+ }
}
mapnik::vector_tile_impl::GeometryPBF<double> geoms(geom_itr, 0, 0, 1000, -1000);
return mapnik::vector_tile_impl::decode_geometry(geoms, geometry_type, 2);
diff --git a/test/vector_tile.cpp b/test/vector_tile.cpp
index d3175cf..a250271 100644
--- a/test/vector_tile.cpp
+++ b/test/vector_tile.cpp
@@ -82,6 +82,10 @@ TEST_CASE("vector tile from simplified geojson")
{
geometry_type = feature_reader.get_enum();
}
+ else
+ {
+ feature_reader.skip();
+ }
}
mapnik::vector_tile_impl::GeometryPBF<double> geoms(geom_itr, tile_x, tile_y, scale, -1*scale);
auto geom = mapnik::vector_tile_impl::decode_geometry(geoms, geometry_type, 2);
diff --git a/test/vector_tile_pbf.cpp b/test/vector_tile_pbf.cpp
index e6b7764..d9034ab 100644
--- a/test/vector_tile_pbf.cpp
+++ b/test/vector_tile_pbf.cpp
@@ -292,7 +292,12 @@ TEST_CASE( "pbf decoding empty buffer", "should throw exception" ) {
protozero::pbf_reader pbf_tile(buffer);
pbf_tile.next();
protozero::pbf_reader layer2;
+#if defined(DNDEBUG)
+ // throws in release mode
REQUIRE_THROWS(layer2 = pbf_tile.get_message());
+#else
+ // aborts in protozero in debug mode
+#endif
}
TEST_CASE( "pbf decoding garbage buffer", "should throw exception" ) {
@@ -300,7 +305,12 @@ TEST_CASE( "pbf decoding garbage buffer", "should throw exception" ) {
protozero::pbf_reader pbf_tile(buffer);
REQUIRE_THROWS_AS(pbf_tile.next(), protozero::unknown_pbf_wire_type_exception);
protozero::pbf_reader layer2;
+#if defined(DNDEBUG)
+ // throws in release mode
REQUIRE_THROWS(layer2 = pbf_tile.get_message());
+#else
+ // aborts in protozero in debug mode
+#endif
}
--
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