mirror of
https://github.com/mapnik/mapnik.git
synced 2025-12-08 20:13:09 +00:00
disable bbox intersection testing when caching features on the fly during rendering - closes #1543
This commit is contained in:
parent
53922be94e
commit
52c3f8ff6e
@ -427,7 +427,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
|
||||
featureset_ptr features = ds->features(q);
|
||||
if (features) {
|
||||
// Cache all features into the memory_datasource before rendering.
|
||||
memory_datasource cache;
|
||||
memory_datasource cache(ds->type(),false);
|
||||
feature_ptr feature, prev;
|
||||
|
||||
while ((feature = features->next()))
|
||||
@ -458,7 +458,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
|
||||
}
|
||||
else if (cache_features)
|
||||
{
|
||||
memory_datasource cache(ds->type());
|
||||
memory_datasource cache(ds->type(),false);
|
||||
featureset_ptr features = ds->features(q);
|
||||
if (features) {
|
||||
// Cache all features into the memory_datasource before rendering.
|
||||
|
||||
@ -36,7 +36,7 @@ class MAPNIK_DECL memory_datasource : public datasource
|
||||
{
|
||||
friend class memory_featureset;
|
||||
public:
|
||||
memory_datasource(datasource::datasource_t type=datasource::Vector);
|
||||
memory_datasource(datasource::datasource_t type=datasource::Vector, bool bbox_check=true);
|
||||
virtual ~memory_datasource();
|
||||
void push(feature_ptr feature);
|
||||
datasource::datasource_t type() const;
|
||||
@ -51,6 +51,7 @@ private:
|
||||
std::vector<feature_ptr> features_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
datasource::datasource_t type_;
|
||||
bool bbox_check_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -34,18 +34,20 @@ namespace mapnik {
|
||||
class memory_featureset : public Featureset
|
||||
{
|
||||
public:
|
||||
memory_featureset(box2d<double> const& bbox, memory_datasource const& ds)
|
||||
memory_featureset(box2d<double> const& bbox, memory_datasource const& ds, bool bbox_check = true)
|
||||
: bbox_(bbox),
|
||||
pos_(ds.features_.begin()),
|
||||
end_(ds.features_.end()),
|
||||
type_(ds.type())
|
||||
type_(ds.type()),
|
||||
bbox_check_(bbox_check)
|
||||
{}
|
||||
|
||||
memory_featureset(box2d<double> const& bbox, std::vector<feature_ptr> const& features)
|
||||
memory_featureset(box2d<double> const& bbox, std::vector<feature_ptr> const& features, bool bbox_check = true)
|
||||
: bbox_(bbox),
|
||||
pos_(features.begin()),
|
||||
end_(features.end()),
|
||||
type_(datasource::Vector)
|
||||
type_(datasource::Vector),
|
||||
bbox_check_(bbox_check)
|
||||
{}
|
||||
|
||||
virtual ~memory_featureset() {}
|
||||
@ -54,22 +56,33 @@ public:
|
||||
{
|
||||
while (pos_ != end_)
|
||||
{
|
||||
if (type_ == datasource::Raster)
|
||||
if (bbox_check_)
|
||||
{
|
||||
return *pos_++;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned i=0; i<(*pos_)->num_geometries();++i)
|
||||
if (type_ == datasource::Raster)
|
||||
{
|
||||
geometry_type & geom = (*pos_)->get_geometry(i);
|
||||
if (bbox_.intersects(geom.envelope()))
|
||||
raster_ptr const& source = (*pos_)->get_raster();
|
||||
if (source && bbox_.intersects(source->ext_))
|
||||
{
|
||||
return *pos_++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned i=0; i<(*pos_)->num_geometries();++i)
|
||||
{
|
||||
geometry_type & geom = (*pos_)->get_geometry(i);
|
||||
if (bbox_.intersects(geom.envelope()))
|
||||
{
|
||||
return *pos_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
++pos_;
|
||||
}
|
||||
++pos_;
|
||||
}
|
||||
return feature_ptr();
|
||||
}
|
||||
@ -79,6 +92,7 @@ private:
|
||||
std::vector<feature_ptr>::const_iterator pos_;
|
||||
std::vector<feature_ptr>::const_iterator end_;
|
||||
datasource::datasource_t type_;
|
||||
bool bbox_check_;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -62,10 +62,11 @@ struct accumulate_extent
|
||||
bool first_;
|
||||
};
|
||||
|
||||
memory_datasource::memory_datasource(datasource::datasource_t type)
|
||||
memory_datasource::memory_datasource(datasource::datasource_t type, bool bbox_check)
|
||||
: datasource(parameters()),
|
||||
desc_("in-memory datasource","utf-8"),
|
||||
type_(type) {}
|
||||
type_(type),
|
||||
bbox_check_(bbox_check) {}
|
||||
|
||||
memory_datasource::~memory_datasource() {}
|
||||
|
||||
@ -83,7 +84,7 @@ datasource::datasource_t memory_datasource::type() const
|
||||
|
||||
featureset_ptr memory_datasource::features(const query& q) const
|
||||
{
|
||||
return boost::make_shared<memory_featureset>(q.get_bbox(),*this);
|
||||
return boost::make_shared<memory_featureset>(q.get_bbox(),*this,bbox_check_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user