expose "num_features_to_query" datasource parameter (ref #3495)
This commit is contained in:
parent
1e8f471448
commit
f3252d00f4
2 changed files with 7 additions and 7 deletions
|
@ -116,7 +116,8 @@ geojson_datasource::geojson_datasource(parameters const& params)
|
||||||
inline_string_(),
|
inline_string_(),
|
||||||
extent_(),
|
extent_(),
|
||||||
features_(),
|
features_(),
|
||||||
tree_(nullptr)
|
tree_(nullptr),
|
||||||
|
num_features_to_query_(*params.get<mapnik::value_integer>("num_features_to_query",5))
|
||||||
{
|
{
|
||||||
boost::optional<std::string> inline_string = params.get<std::string>("inline");
|
boost::optional<std::string> inline_string = params.get<std::string>("inline");
|
||||||
if (inline_string)
|
if (inline_string)
|
||||||
|
@ -233,6 +234,7 @@ void geojson_datasource::initialise_disk_index(std::string const& filename)
|
||||||
|
|
||||||
mapnik::util::file file(filename_);
|
mapnik::util::file file(filename_);
|
||||||
if (!file) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + "'");
|
if (!file) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + "'");
|
||||||
|
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
||||||
for (auto const& pos : positions)
|
for (auto const& pos : positions)
|
||||||
{
|
{
|
||||||
std::fseek(file.get(), pos.first, SEEK_SET);
|
std::fseek(file.get(), pos.first, SEEK_SET);
|
||||||
|
@ -241,7 +243,6 @@ void geojson_datasource::initialise_disk_index(std::string const& filename)
|
||||||
std::fread(record.data(), pos.second, 1, file.get());
|
std::fread(record.data(), pos.second, 1, file.get());
|
||||||
auto const* start = record.data();
|
auto const* start = record.data();
|
||||||
auto const* end = start + record.size();
|
auto const* end = start + record.size();
|
||||||
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
|
||||||
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx, -1));
|
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx, -1));
|
||||||
using namespace boost::spirit;
|
using namespace boost::spirit;
|
||||||
standard::space_type space;
|
standard::space_type space;
|
||||||
|
@ -314,6 +315,7 @@ void geojson_datasource::initialise_index(Iterator start, Iterator end)
|
||||||
tree_ = std::make_unique<spatial_index_type>(boxes);
|
tree_ = std::make_unique<spatial_index_type>(boxes);
|
||||||
// calculate total extent
|
// calculate total extent
|
||||||
std::size_t feature_count = 0;
|
std::size_t feature_count = 0;
|
||||||
|
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
||||||
for (auto const& item : boxes)
|
for (auto const& item : boxes)
|
||||||
{
|
{
|
||||||
auto const& box = std::get<0>(item);
|
auto const& box = std::get<0>(item);
|
||||||
|
@ -326,7 +328,6 @@ void geojson_datasource::initialise_index(Iterator start, Iterator end)
|
||||||
// NOTE: this doesn't yield correct answer for geoJSON in general, just an indication
|
// NOTE: this doesn't yield correct answer for geoJSON in general, just an indication
|
||||||
Iterator itr2 = start + geometry_index.first;
|
Iterator itr2 = start + geometry_index.first;
|
||||||
Iterator end2 = itr2 + geometry_index.second;
|
Iterator end2 = itr2 + geometry_index.second;
|
||||||
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
|
||||||
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,-1)); // temp feature
|
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,-1)); // temp feature
|
||||||
if (!boost::spirit::qi::phrase_parse(itr2, end2,
|
if (!boost::spirit::qi::phrase_parse(itr2, end2,
|
||||||
(geojson_datasource_static_feature_grammar)(boost::phoenix::ref(*feature)), space)
|
(geojson_datasource_static_feature_grammar)(boost::phoenix::ref(*feature)), space)
|
||||||
|
@ -356,7 +357,7 @@ void geojson_datasource::parse_geojson(Iterator start, Iterator end)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool result = boost::spirit::qi::phrase_parse(itr, end, (geojson_datasource_static_fc_grammar)
|
bool result = boost::spirit::qi::phrase_parse(itr, end, (geojson_datasource_static_fc_grammar)
|
||||||
(boost::phoenix::ref(ctx),boost::phoenix::ref(start_id), boost::phoenix::ref(callback)),
|
(boost::phoenix::ref(ctx), boost::phoenix::ref(start_id), boost::phoenix::ref(callback)),
|
||||||
space);
|
space);
|
||||||
if (!result || itr != end)
|
if (!result || itr != end)
|
||||||
{
|
{
|
||||||
|
@ -458,7 +459,7 @@ boost::optional<mapnik::datasource_geometry_t> geojson_datasource::get_geometry_
|
||||||
mapnik::util::file file(filename_);
|
mapnik::util::file file(filename_);
|
||||||
|
|
||||||
if (!file) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + "'");
|
if (!file) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + "'");
|
||||||
|
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
||||||
for (auto const& pos : positions)
|
for (auto const& pos : positions)
|
||||||
{
|
{
|
||||||
std::fseek(file.get(), pos.first, SEEK_SET);
|
std::fseek(file.get(), pos.first, SEEK_SET);
|
||||||
|
@ -467,7 +468,6 @@ boost::optional<mapnik::datasource_geometry_t> geojson_datasource::get_geometry_
|
||||||
std::fread(record.data(), pos.second, 1, file.get());
|
std::fread(record.data(), pos.second, 1, file.get());
|
||||||
auto const* start = record.data();
|
auto const* start = record.data();
|
||||||
auto const* end = start + record.size();
|
auto const* end = start + record.size();
|
||||||
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
|
||||||
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx, -1)); // temp feature
|
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx, -1)); // temp feature
|
||||||
using namespace boost::spirit;
|
using namespace boost::spirit;
|
||||||
standard::space_type space;
|
standard::space_type space;
|
||||||
|
|
|
@ -104,7 +104,7 @@ private:
|
||||||
std::unique_ptr<spatial_index_type> tree_;
|
std::unique_ptr<spatial_index_type> tree_;
|
||||||
bool cache_features_ = true;
|
bool cache_features_ = true;
|
||||||
bool has_disk_index_ = false;
|
bool has_disk_index_ = false;
|
||||||
const std::size_t num_features_to_query_ = 5;
|
const std::size_t num_features_to_query_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue