add valid/invalid empty GeoJSON geometry tests

This commit is contained in:
artemp 2017-03-23 13:44:51 +00:00
parent 60e6f5a9ff
commit 69e5340ceb

View file

@ -28,6 +28,7 @@
#include <mapnik/datasource_cache.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/geometry/geometry_type.hpp>
#include <mapnik/json/geometry_parser.hpp>
#include <mapnik/util/fs.hpp>
#include <cstdlib>
@ -115,6 +116,41 @@ 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));
}
auto invalid_empty_geometries =
{
"{ \"type\": \"Point\", \"coordinates\": [] }",
"{ \"type\": \"LineString\", \"coordinates\": [[]] }"
"{ \"type\": \"Polygon\", \"coordinates\": [[[]]] }",
"{ \"type\": \"MultiPoint\", \"coordinates\": [[]] }",
"{ \"type\": \"MultiLineString\", \"coordinates\": [[[]]] }",
"{ \"type\": \"MultiPolygon\", \"coordinates\": [[[[]]]] }"
};
for (auto const& json : invalid_empty_geometries)
{
mapnik::geometry::geometry<double> geom;
CHECK(!mapnik::json::from_geojson(json, geom));
}
}
SECTION("GeoJSON num_features_to_query")
{
std::string filename = "./test/data/json/featurecollection-multipleprops.geojson";