From 0f73b8b795bfd7b2adc9a452760674dde41c284d Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Mon, 25 Mar 2019 15:19:44 +0000 Subject: [PATCH] GeJSON - allow empty FeatureCollections (#4035) --- plugins/input/geojson/geojson_datasource.cpp | 4 ++-- test/unit/datasource/geojson.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index 614621102..a4edc7782 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -274,7 +274,7 @@ void geojson_datasource::initialise_index(Iterator start, Iterator end) try { mapnik::json::extract_bounding_boxes(itr, end, boxes); - if (itr != end || boxes.empty()) throw std::exception(); + if (itr != end) throw std::exception(); // bulk insert initialise r-tree tree_ = std::make_unique(boxes); // calculate total extent @@ -366,7 +366,7 @@ void geojson_datasource::parse_geojson(Iterator start, Iterator end) { boxes_type boxes; mapnik::json::extract_bounding_boxes(itr, end, boxes); - if (itr != end || boxes.empty()) throw std::exception(); //ensure we've consumed all input and we extracted at least one bbox; + if (itr != end) throw std::exception(); //ensure we've consumed all input for (auto const& item : boxes) { auto const& geometry_index = std::get<1>(item); diff --git a/test/unit/datasource/geojson.cpp b/test/unit/datasource/geojson.cpp index 2b09f1443..574274546 100644 --- a/test/unit/datasource/geojson.cpp +++ b/test/unit/datasource/geojson.cpp @@ -108,7 +108,7 @@ TEST_CASE("geojson") { params["type"] = "geojson"; params["file"] = "./test/data/json/empty_featurecollection.json"; params["cache_features"] = cache_features; - REQUIRE_THROWS(mapnik::datasource_cache::instance().create(params)); + REQUIRE(mapnik::datasource_cache::instance().create(params)); } }