Relax bounding box extracting grammar (ref #4140) + unit test

This commit is contained in:
Artem Pavlenko 2020-05-07 11:35:53 +01:00
parent 9bfe888cef
commit d0b40f62dc
3 changed files with 56 additions and 4 deletions

View file

@ -143,9 +143,7 @@ auto const coordinates_rule_def = lit("\"coordinates\"") >> lit(':') >> position
auto const bounding_box_def = raw[lit('{')[open_bracket]
>> *(eps[check_brackets] >>
((lit("\"FeatureCollection\"") > eps(false))
|
lit('{')[open_bracket]
(lit('{')[open_bracket]
|
lit('}')[close_bracket]
|

@ -1 +1 @@
Subproject commit eaf64519e4aecc0b1f689aa96d4d741b22a75a87
Subproject commit ce8acb4a3940e4f269a9f834ef20da2ff81b5b5e

View file

@ -543,7 +543,61 @@ TEST_CASE("geojson") {
{
mapnik::util::remove(filename + ".index");
}
}
}
SECTION("GeoJSON \"type\":\"FeatureCollection\" in Feature properties (#4140)")
{
// Create datasource
mapnik::parameters params;
params["type"] = "geojson";
std::string filename("./test/data/json/feature_collection_issue_4140.json");
params["file"] = filename;
// cleanup in the case of a failed previous run
if (mapnik::util::exists(filename + ".index"))
{
mapnik::util::remove(filename + ".index");
}
for (auto create_index : { true, false })
{
if (create_index)
{
int ret = create_disk_index(filename);
int ret_posix = (ret >> 8) & 0x000000ff;
INFO(ret);
INFO(ret_posix);
CHECK(mapnik::util::exists(filename + ".index"));
}
for (auto cache_features : {true, false})
{
params["cache_features"] = cache_features;
auto ds = mapnik::datasource_cache::instance().create(params);
CHECK(ds->get_geometry_type() == mapnik::datasource_geometry_t::Point);
REQUIRE(bool(ds));
auto fields = ds->get_descriptor().get_descriptors();
mapnik::query query(ds->envelope());
for (auto const& field : fields)
{
query.add_property_name(field.get_name());
}
auto features = ds->features(query);
auto feature1 = features->next();
REQUIRE(feature1 != nullptr);
REQUIRE(feature1->envelope() == mapnik::box2d<double>(-122.0,48.0,-122.0,48.0));
auto feature2 = features->next();
REQUIRE(feature2 != nullptr);
REQUIRE(feature2->envelope() == mapnik::box2d<double>(0.0,51.0,0.0,51.0));
REQUIRE(ds->envelope() == mapnik::box2d<double>(-122.0,48.0,0.0,51.0));
}
// cleanup
if (create_index && mapnik::util::exists(filename + ".index"))
{
mapnik::util::remove(filename + ".index");
}
}
}