wkb_reader/json input grammar - correct polygons to have CCW exterioir/CW interior

This commit is contained in:
artemp 2015-03-04 12:09:08 +01:00
parent 9e35540b50
commit f4a1e9368b
2 changed files with 10 additions and 1 deletions

View file

@ -24,6 +24,9 @@
#define MAPNIK_JSON_GEOMETRY_UTIL_HPP #define MAPNIK_JSON_GEOMETRY_UTIL_HPP
#include <mapnik/geometry_impl.hpp> #include <mapnik/geometry_impl.hpp>
#include <mapnik/geometry_adapters.hpp>
// boost.geometry
#include <boost/geometry/algorithms/correct.hpp>
namespace mapnik { namespace json { namespace mapnik { namespace json {
@ -97,7 +100,8 @@ struct create_polygon
if (i == 0) poly.set_exterior_ring(std::move(ring)); if (i == 0) poly.set_exterior_ring(std::move(ring));
else poly.add_hole(std::move(ring)); else poly.add_hole(std::move(ring));
} }
// correct oriantations etc
boost::geometry::correct(poly);
geom_ = std::move(poly); geom_ = std::move(poly);
} }

View file

@ -27,6 +27,9 @@
#include <mapnik/wkb.hpp> #include <mapnik/wkb.hpp>
#include <mapnik/feature.hpp> #include <mapnik/feature.hpp>
#include <mapnik/util/noncopyable.hpp> #include <mapnik/util/noncopyable.hpp>
#include <mapnik/geometry_adapters.hpp>
// boost.geometry
#include <boost/geometry/algorithms/correct.hpp>
namespace mapnik namespace mapnik
{ {
@ -318,6 +321,8 @@ private:
if ( i == 0) poly.set_exterior_ring(std::move(ring)); if ( i == 0) poly.set_exterior_ring(std::move(ring));
else poly.add_hole(std::move(ring)); else poly.add_hole(std::move(ring));
} }
// correct orientations etc
boost::geometry::correct(poly);
return poly; return poly;
} }