commit
391a9f835b
4 changed files with 46 additions and 37 deletions
|
@ -61,10 +61,10 @@ struct push_box_impl
|
||||||
template <typename T0, typename T1, typename T2, typename T3>
|
template <typename T0, typename T1, typename T2, typename T3>
|
||||||
void operator() (T0 & boxes, T1 const& begin, T2 const& box, T3 const& range) const
|
void operator() (T0 & boxes, T1 const& begin, T2 const& box, T3 const& range) const
|
||||||
{
|
{
|
||||||
if (box.valid()) boxes.emplace_back(box,
|
boxes.emplace_back(box,
|
||||||
std::make_pair(std::distance(begin,
|
std::make_pair(std::distance(begin,
|
||||||
range.begin()),
|
range.begin()),
|
||||||
std::distance(range.begin(), range.end())));
|
std::distance(range.begin(), range.end())));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5ad14e6bdf2c5e6babd8ac04aa057ed6c67ac617
|
Subproject commit 4035e34534d6f0ad7060fc4a2f5f6018c61d7a1b
|
|
@ -514,7 +514,8 @@ TEST_CASE("geojson") {
|
||||||
|
|
||||||
for (auto const& c_str : {"./test/data/json/feature-malformed-1.geojson",
|
for (auto const& c_str : {"./test/data/json/feature-malformed-1.geojson",
|
||||||
"./test/data/json/feature-malformed-2.geojson",
|
"./test/data/json/feature-malformed-2.geojson",
|
||||||
"./test/data/json/feature-malformed-3.geojson"})
|
"./test/data/json/feature-malformed-3.geojson",
|
||||||
|
"./test/data/json/feature-malformed-4.geojson"})
|
||||||
{
|
{
|
||||||
std::string filename(c_str);
|
std::string filename(c_str);
|
||||||
params["file"] = filename;
|
params["file"] = filename;
|
||||||
|
@ -554,43 +555,46 @@ TEST_CASE("geojson") {
|
||||||
|
|
||||||
SECTION("GeoJSON ensure mapnik::featureset::next() throws on malformed input")
|
SECTION("GeoJSON ensure mapnik::featureset::next() throws on malformed input")
|
||||||
{
|
{
|
||||||
std::string filename{"./test/data/json/featurecollection-malformed.json"};
|
|
||||||
mapnik::parameters params;
|
mapnik::parameters params;
|
||||||
params["type"] = "geojson";
|
params["type"] = "geojson";
|
||||||
params["file"] = filename;
|
for (auto const& c_str : {"./test/data/json/featurecollection-malformed.json",
|
||||||
|
"./test/data/json/featurecollection-malformed-2.json"})
|
||||||
// cleanup in the case of a failed previous run
|
|
||||||
if (mapnik::util::exists(filename + ".index"))
|
|
||||||
{
|
{
|
||||||
mapnik::util::remove(filename + ".index");
|
std::string filename(c_str);
|
||||||
}
|
params["file"] = filename;
|
||||||
|
// cleanup in the case of a failed previous run
|
||||||
|
if (mapnik::util::exists(filename + ".index"))
|
||||||
|
{
|
||||||
|
mapnik::util::remove(filename + ".index");
|
||||||
|
}
|
||||||
|
|
||||||
CHECK(!mapnik::util::exists(filename + ".index"));
|
CHECK(!mapnik::util::exists(filename + ".index"));
|
||||||
int ret = create_disk_index(filename);
|
int ret = create_disk_index(filename);
|
||||||
int ret_posix = (ret >> 8) & 0x000000ff;
|
int ret_posix = (ret >> 8) & 0x000000ff;
|
||||||
INFO(ret);
|
INFO(ret);
|
||||||
INFO(ret_posix);
|
INFO(ret_posix);
|
||||||
CHECK(mapnik::util::exists(filename + ".index"));
|
CHECK(mapnik::util::exists(filename + ".index"));
|
||||||
|
|
||||||
for (auto cache_features : {true,false})
|
for (auto cache_features : {true,false})
|
||||||
{
|
{
|
||||||
params["cache_features"] = cache_features;
|
params["cache_features"] = cache_features;
|
||||||
auto ds = mapnik::datasource_cache::instance().create(params);
|
auto ds = mapnik::datasource_cache::instance().create(params);
|
||||||
auto fields = ds->get_descriptor().get_descriptors();
|
auto fields = ds->get_descriptor().get_descriptors();
|
||||||
mapnik::query query(ds->envelope());
|
mapnik::query query(ds->envelope());
|
||||||
auto features = ds->features(query);
|
auto features = ds->features(query);
|
||||||
REQUIRE_THROWS(
|
REQUIRE_THROWS(
|
||||||
auto feature = features->next();
|
auto feature = features->next();
|
||||||
while (feature != nullptr)
|
while (feature != nullptr)
|
||||||
{
|
{
|
||||||
feature = features->next();
|
feature = features->next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
if (mapnik::util::exists(filename + ".index"))
|
if (mapnik::util::exists(filename + ".index"))
|
||||||
{
|
{
|
||||||
mapnik::util::remove(filename + ".index");
|
mapnik::util::remove(filename + ".index");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,11 @@ std::pair<bool,typename T::value_type::first_type> process_geojson_file(T & boxe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (validate_features)
|
||||||
|
{
|
||||||
|
if (verbose) std::clog << "Invalid bbox encountered " << item.first << std::endl;
|
||||||
|
return std::make_pair(false, extent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return std::make_pair(true, extent);
|
return std::make_pair(true, extent);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue