diff --git a/src/json/extract_bounding_boxes_x3.cpp b/src/json/extract_bounding_boxes_x3.cpp index 819832fde..ac62b4b8a 100644 --- a/src/json/extract_bounding_boxes_x3.cpp +++ b/src/json/extract_bounding_boxes_x3.cpp @@ -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] | diff --git a/test/data b/test/data index eaf64519e..ce8acb4a3 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit eaf64519e4aecc0b1f689aa96d4d741b22a75a87 +Subproject commit ce8acb4a3940e4f269a9f834ef20da2ff81b5b5e diff --git a/test/unit/datasource/geojson.cpp b/test/unit/datasource/geojson.cpp index 2b09f1443..551fae432 100644 --- a/test/unit/datasource/geojson.cpp +++ b/test/unit/datasource/geojson.cpp @@ -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(-122.0,48.0,-122.0,48.0)); + auto feature2 = features->next(); + REQUIRE(feature2 != nullptr); + REQUIRE(feature2->envelope() == mapnik::box2d(0.0,51.0,0.0,51.0)); + REQUIRE(ds->envelope() == mapnik::box2d(-122.0,48.0,0.0,51.0)); + } + + // cleanup + if (create_index && mapnik::util::exists(filename + ".index")) + { + mapnik::util::remove(filename + ".index"); + } } }