diff --git a/bench/vtile-encode.cpp b/bench/vtile-encode.cpp index 7689fad9..e5bce22f 100644 --- a/bench/vtile-encode.cpp +++ b/bench/vtile-encode.cpp @@ -32,7 +32,7 @@ int main(int argc, char** argv) { if (argc < 4) { - std::clog << "usage: vtile-encode /path/to/geometry.geojson z x y [iterations]\n"; + std::clog << "usage: vtile-encode /path/to/geometry.geojson z x y [-i iterations] [-l layer_count] [-o output_file] [-p epsg_code]\n"; return -1; } std::string geojson_file(argv[1]); diff --git a/src/vector_tile_geometry_clipper.hpp b/src/vector_tile_geometry_clipper.hpp index f5820efe..f23ce9ac 100644 --- a/src/vector_tile_geometry_clipper.hpp +++ b/src/vector_tile_geometry_clipper.hpp @@ -138,6 +138,9 @@ class geometry_clipper void operator() (mapnik::geometry::multi_point & geom) { + // Here we remove repeated points from multi_point + auto last = std::unique(geom.begin(), geom.end()); + geom.erase(last, geom.end()); next_(geom); } diff --git a/test/system/remove_repeated_point.cpp b/test/system/remove_repeated_point.cpp new file mode 100644 index 00000000..bf773242 --- /dev/null +++ b/test/system/remove_repeated_point.cpp @@ -0,0 +1,23 @@ +#include "catch.hpp" + +// test-utils +#include "round_trip.hpp" +#include "geom_to_wkt.hpp" + +// mapnik +#include + +TEST_CASE("vector tile multi_point encoding with repeated points should be removed") +{ + mapnik::geometry::multi_point geom; + geom.emplace_back(0,0); + geom.emplace_back(0,0); + geom.emplace_back(1,1); + geom.emplace_back(1,1); + mapnik::geometry::geometry new_geom = test_utils::round_trip(geom); + CHECK( !mapnik::geometry::is_empty(new_geom) ); + std::string wkt; + CHECK( test_utils::to_wkt(wkt, new_geom) ); + CHECK( wkt == "MULTIPOINT(128 -128,128.711 -126.578)" ); + CHECK( new_geom.is >() ); +}