GeoJSON IO test - ensure geometries round-trip.

This commit is contained in:
artemp 2017-03-23 14:58:39 +00:00
parent 60d891f094
commit fa549b380a

View file

@ -29,9 +29,10 @@
#include <mapnik/geometry.hpp>
#include <mapnik/geometry_type.hpp>
#include <mapnik/json/geometry_parser.hpp> // from_geojson
#include <mapnik/util/geometry_to_geojson.hpp>
#include <mapnik/util/fs.hpp>
#include <cstdlib>
#include <algorithm>
#include <boost/optional/optional_io.hpp>
/*
@ -128,10 +129,19 @@ TEST_CASE("geojson") {
"{ \"type\": \"MultiPolygon\", \"coordinates\": [[ []] ] }"
};
for (auto const& json : valid_empty_geometries)
for (auto const& in : valid_empty_geometries)
{
std::string json(in);
mapnik::geometry::geometry<double> geom;
CHECK(mapnik::json::from_geojson(json, geom));
// round trip
std::string json_out;
CHECK(mapnik::util::to_geojson(json_out, geom));
json.erase(std::remove_if(
std::begin(json), std::end(json),
[l = std::locale{}](auto ch) { return std::isspace(ch, l); }
), std::end(json));
REQUIRE(json == json_out);
}
auto invalid_empty_geometries =