Skip to content

Commit

Permalink
Remove repeated points from multipoints
Browse files Browse the repository at this point in the history
  • Loading branch information
flippmoke committed Feb 16, 2016
1 parent ba74f6c commit 3e79c5d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bench/vtile-encode.cpp
Expand Up @@ -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]);
Expand Down
3 changes: 3 additions & 0 deletions src/vector_tile_geometry_clipper.hpp
Expand Up @@ -138,6 +138,9 @@ class geometry_clipper

void operator() (mapnik::geometry::multi_point<std::int64_t> & geom)
{
// Here we remove repeated points from multi_point
auto last = std::unique(geom.begin(), geom.end());
geom.erase(last, geom.end());
next_(geom);
}

Expand Down
23 changes: 23 additions & 0 deletions 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 <mapnik/geometry_is_empty.hpp>

TEST_CASE("vector tile multi_point encoding with repeated points should be removed")
{
mapnik::geometry::multi_point<double> geom;
geom.emplace_back(0,0);
geom.emplace_back(0,0);
geom.emplace_back(1,1);
geom.emplace_back(1,1);
mapnik::geometry::geometry<double> 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<mapnik::geometry::multi_point<double> >() );
}

0 comments on commit 3e79c5d

Please sign in to comment.