only run geojson unit test if plugin was built
This commit is contained in:
parent
b54b2753a0
commit
0145476ff7
1 changed files with 42 additions and 40 deletions
|
@ -26,50 +26,52 @@
|
||||||
#include <mapnik/datasource.hpp>
|
#include <mapnik/datasource.hpp>
|
||||||
#include <mapnik/datasource_cache.hpp>
|
#include <mapnik/datasource_cache.hpp>
|
||||||
#include <mapnik/geometry.hpp>
|
#include <mapnik/geometry.hpp>
|
||||||
|
#include <mapnik/util/fs.hpp>
|
||||||
|
|
||||||
static const std::string geojson_plugin("./plugins/input/geojson.input");
|
|
||||||
const bool registered = mapnik::datasource_cache::instance().register_datasources(geojson_plugin);
|
|
||||||
|
|
||||||
TEST_CASE("geojson") {
|
TEST_CASE("geojson") {
|
||||||
|
|
||||||
SECTION("json feature cache-feature=\"true\"")
|
std::string geojson_plugin("./plugins/input/geojson.input");
|
||||||
{
|
if (mapnik::util::exists(geojson_plugin))
|
||||||
// Create datasource
|
|
||||||
mapnik::parameters params;
|
|
||||||
params["type"] = "geojson";
|
|
||||||
params["file"] = "./test/data/json/feature.json";
|
|
||||||
params["cache-features"] = true;
|
|
||||||
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());
|
mapnik::datasource_cache::instance().register_datasources("plugins/input/geojson.input");
|
||||||
}
|
SECTION("json feature cache-feature=\"true\"")
|
||||||
auto features = ds->features(query);
|
{
|
||||||
auto feature = features->next();
|
// Create datasource
|
||||||
REQUIRE(feature != nullptr);
|
mapnik::parameters params;
|
||||||
}
|
params["type"] = "geojson";
|
||||||
|
params["file"] = "./test/data/json/feature.json";
|
||||||
|
params["cache-features"] = true;
|
||||||
|
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();
|
||||||
|
REQUIRE(feature != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("json feature cache-feature=\"false\"")
|
SECTION("json feature cache-feature=\"false\"")
|
||||||
{
|
{
|
||||||
mapnik::parameters params;
|
mapnik::parameters params;
|
||||||
params["type"] = "geojson";
|
params["type"] = "geojson";
|
||||||
params["file"] = "./test/data/json/feature.json";
|
params["file"] = "./test/data/json/feature.json";
|
||||||
params["cache-features"] = false;
|
params["cache-features"] = false;
|
||||||
auto ds = mapnik::datasource_cache::instance().create(params);
|
auto ds = mapnik::datasource_cache::instance().create(params);
|
||||||
REQUIRE(bool(ds));
|
REQUIRE(bool(ds));
|
||||||
auto fields = ds->get_descriptor().get_descriptors();
|
auto fields = ds->get_descriptor().get_descriptors();
|
||||||
mapnik::query query(ds->envelope());
|
mapnik::query query(ds->envelope());
|
||||||
for (auto const &field : fields)
|
for (auto const &field : fields)
|
||||||
{
|
{
|
||||||
query.add_property_name(field.get_name());
|
query.add_property_name(field.get_name());
|
||||||
}
|
}
|
||||||
auto features = ds->features(query);
|
auto features = ds->features(query);
|
||||||
auto feature = features->next();
|
auto feature = features->next();
|
||||||
REQUIRE(feature != nullptr);
|
REQUIRE(feature != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue