GeoJSON test - add empty geometries tests.

This commit is contained in:
artemp 2017-03-22 14:41:08 +00:00
parent a1084e0c09
commit dbbf18c752

View file

@ -28,6 +28,7 @@
#include <mapnik/datasource_cache.hpp> #include <mapnik/datasource_cache.hpp>
#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/util/fs.hpp> #include <mapnik/util/fs.hpp>
#include <cstdlib> #include <cstdlib>
@ -115,6 +116,25 @@ TEST_CASE("geojson") {
} }
} }
SECTION("GeoJSON empty Geometries handling")
{
auto valid_empty_geometries =
{
"null", // Point can't be empty
"{ \"type\": \"LineString\", \"coordinates\": [] }}",
"{ \"type\": \"Polygon\", \"coordinates\": [ [ ] ] } }",
"{ \"type\": \"MultiPoint\", \"coordinates\": [ ] }}",
"{ \"type\": \"MultiLineString\", \"coordinates\": [ [] ] }}",
"{ \"type\": \"MultiPolygon\", \"coordinates\": [[ []] ] }}"
};
for (auto const& json : valid_empty_geometries)
{
mapnik::geometry::geometry<double> geom;
CHECK(mapnik::json::from_geojson(json, geom));
}
}
SECTION("GeoJSON num_features_to_query") SECTION("GeoJSON num_features_to_query")
{ {
std::string filename = "./test/data/json/featurecollection-multipleprops.geojson"; std::string filename = "./test/data/json/featurecollection-multipleprops.geojson";
@ -557,8 +577,7 @@ TEST_CASE("geojson") {
{ {
mapnik::parameters params; mapnik::parameters params;
params["type"] = "geojson"; params["type"] = "geojson";
for (auto const& c_str : {"./test/data/json/featurecollection-malformed.json", for (auto const& c_str : {"./test/data/json/featurecollection-malformed.json"})
"./test/data/json/featurecollection-malformed-2.json"})
{ {
std::string filename(c_str); std::string filename(c_str);
params["file"] = filename; params["file"] = filename;