remove index_array from datasource and implement move semantics in featureset

fixes #2048 for topojson.input
This commit is contained in:
artemp 2013-10-23 15:01:29 +01:00
parent 710d558218
commit 116706fd1c
4 changed files with 8 additions and 9 deletions

View File

@ -145,8 +145,7 @@ mapnik::featureset_ptr topojson_datasource::features(mapnik::query const& q) con
if (extent_.intersects(b))
{
box_type box(point_type(b.minx(),b.miny()),point_type(b.maxx(),b.maxy()));
index_array_ = tree_.find(box);
return std::make_shared<topojson_featureset>(topo_, *tr_, index_array_.begin(), index_array_.end());
return std::make_shared<topojson_featureset>(topo_, *tr_, tree_.find(box));
}
// otherwise return an empty featureset pointer
return mapnik::featureset_ptr();

View File

@ -74,7 +74,6 @@ private:
std::shared_ptr<mapnik::transcoder> tr_;
mapnik::topojson::topology topo_;
spatial_index_type tree_;
mutable std::deque<std::size_t> index_array_;
};

View File

@ -353,13 +353,13 @@ struct feature_generator : public boost::static_visitor<mapnik::feature_ptr>
topojson_featureset::topojson_featureset(mapnik::topojson::topology const& topo,
mapnik::transcoder const& tr,
std::deque<std::size_t>::const_iterator index_itr,
std::deque<std::size_t>::const_iterator index_end)
std::deque<std::size_t> && index_array)
: ctx_(std::make_shared<mapnik::context_type>()),
topo_(topo),
tr_(tr),
index_itr_(index_itr),
index_end_(index_end),
index_array_(std::move(index_array)),
index_itr_(index_array_.begin()),
index_end_(index_array_.end()),
feature_id_ (0) {}
topojson_featureset::~topojson_featureset() {}

View File

@ -34,8 +34,8 @@ class topojson_featureset : public mapnik::Featureset
public:
topojson_featureset(mapnik::topojson::topology const& topo,
mapnik::transcoder const& tr,
std::deque<std::size_t>::const_iterator index_itr,
std::deque<std::size_t>::const_iterator index_end);
std::deque<std::size_t> && index_array);
virtual ~topojson_featureset();
mapnik::feature_ptr next();
@ -44,6 +44,7 @@ private:
mapnik::box2d<double> box_;
mapnik::topojson::topology const& topo_;
mapnik::transcoder const& tr_;
const std::deque<std::size_t> index_array_;
std::deque<std::size_t>::const_iterator index_itr_;
std::deque<std::size_t>::const_iterator index_end_;
std::size_t feature_id_;