GeoJSON IO test - ensure geometries round-trip.
This commit is contained in:
parent
60d891f094
commit
fa549b380a
1 changed files with 12 additions and 2 deletions
|
@ -29,9 +29,10 @@
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
#include <mapnik/geometry_type.hpp>
|
#include <mapnik/geometry_type.hpp>
|
||||||
#include <mapnik/json/geometry_parser.hpp> // from_geojson
|
#include <mapnik/json/geometry_parser.hpp> // from_geojson
|
||||||
|
#include <mapnik/util/geometry_to_geojson.hpp>
|
||||||
#include <mapnik/util/fs.hpp>
|
#include <mapnik/util/fs.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <algorithm>
|
||||||
#include <boost/optional/optional_io.hpp>
|
#include <boost/optional/optional_io.hpp>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -128,10 +129,19 @@ TEST_CASE("geojson") {
|
||||||
"{ \"type\": \"MultiPolygon\", \"coordinates\": [[ []] ] }"
|
"{ \"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;
|
mapnik::geometry::geometry<double> geom;
|
||||||
CHECK(mapnik::json::from_geojson(json, 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 =
|
auto invalid_empty_geometries =
|
||||||
|
|
Loading…
Reference in a new issue