unit tests - add 'ensure original ordering in geojson.input' test ref #3182
This commit is contained in:
parent
d288ea0af6
commit
e2cf79260f
2 changed files with 58 additions and 2 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 3161747e4a47aea0a5f968caf3443e8fdf298772
|
||||
Subproject commit 94fa33e08b81686d85d712afee0b12d4e78f7a0a
|
|
@ -503,7 +503,7 @@ TEST_CASE("geojson") {
|
|||
|
||||
for (auto cache_features : {true,false})
|
||||
{
|
||||
params["cache_features"] = false;
|
||||
params["cache_features"] = cache_features;
|
||||
auto ds = mapnik::datasource_cache::instance().create(params);
|
||||
auto fields = ds->get_descriptor().get_descriptors();
|
||||
mapnik::query query(ds->envelope());
|
||||
|
@ -573,5 +573,61 @@ TEST_CASE("geojson") {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("GeoJSON ensure original feature ordering is preserved")
|
||||
{
|
||||
mapnik::parameters params;
|
||||
params["type"] = "geojson";
|
||||
|
||||
std::string filename("./test/data/json/ordered.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)
|
||||
{
|
||||
CHECK(!mapnik::util::exists(filename + ".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);
|
||||
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 feature = features->next();
|
||||
mapnik::value_integer count = 0;
|
||||
while (feature != nullptr)
|
||||
{
|
||||
// ids are in ascending order, starting from 1
|
||||
mapnik::value val= feature->get("id");
|
||||
REQUIRE(val.get<mapnik::value_integer>() == ++count);
|
||||
feature = features->next();
|
||||
}
|
||||
}
|
||||
// cleanup
|
||||
if (create_index && mapnik::util::exists(filename + ".index"))
|
||||
{
|
||||
mapnik::util::remove(filename + ".index");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue