fix feature-cache for rasters - TODO: no intersection check option for memory_featureset
This commit is contained in:
parent
f7bd53c0d3
commit
9040d2ac9d
4 changed files with 23 additions and 16 deletions
|
@ -458,7 +458,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
|
|||
}
|
||||
else if (cache_features)
|
||||
{
|
||||
memory_datasource cache;
|
||||
memory_datasource cache(ds->type());
|
||||
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();
|
||||
memory_datasource(datasource::datasource_t type=datasource::Vector);
|
||||
virtual ~memory_datasource();
|
||||
void push(feature_ptr feature);
|
||||
datasource::datasource_t type() const;
|
||||
|
@ -50,6 +50,7 @@ public:
|
|||
private:
|
||||
std::vector<feature_ptr> features_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
datasource::datasource_t type_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#define MAPNIK_MEMORY_FEATURESET_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/memory_datasource.hpp>
|
||||
|
||||
// boost
|
||||
|
@ -38,13 +37,15 @@ public:
|
|||
memory_featureset(box2d<double> const& bbox, memory_datasource const& ds)
|
||||
: bbox_(bbox),
|
||||
pos_(ds.features_.begin()),
|
||||
end_(ds.features_.end())
|
||||
end_(ds.features_.end()),
|
||||
type_(ds.type())
|
||||
{}
|
||||
|
||||
memory_featureset(box2d<double> const& bbox, std::vector<feature_ptr> const& features)
|
||||
: bbox_(bbox),
|
||||
pos_(features.begin()),
|
||||
end_(features.end())
|
||||
end_(features.end()),
|
||||
type_(datasource::Vector)
|
||||
{}
|
||||
|
||||
virtual ~memory_featureset() {}
|
||||
|
@ -52,21 +53,24 @@ public:
|
|||
feature_ptr next()
|
||||
{
|
||||
while (pos_ != end_)
|
||||
{
|
||||
if (type_ == datasource::Raster)
|
||||
{
|
||||
return *pos_++;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned i=0; i<(*pos_)->num_geometries();++i)
|
||||
{
|
||||
geometry_type & geom = (*pos_)->get_geometry(i);
|
||||
|
||||
MAPNIK_LOG_DEBUG(memory_featureset) << "memory_featureset: BBox=" << bbox_ << ",Envelope=" << geom.envelope();
|
||||
|
||||
if (bbox_.intersects(geom.envelope()))
|
||||
{
|
||||
return *pos_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
++pos_;
|
||||
}
|
||||
|
||||
return feature_ptr();
|
||||
}
|
||||
|
||||
|
@ -74,6 +78,7 @@ private:
|
|||
box2d<double> bbox_;
|
||||
std::vector<feature_ptr>::const_iterator pos_;
|
||||
std::vector<feature_ptr>::const_iterator end_;
|
||||
datasource::datasource_t type_;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -62,9 +62,10 @@ struct accumulate_extent
|
|||
bool first_;
|
||||
};
|
||||
|
||||
memory_datasource::memory_datasource()
|
||||
memory_datasource::memory_datasource(datasource::datasource_t type)
|
||||
: datasource(parameters()),
|
||||
desc_("in-memory datasource","utf-8") {}
|
||||
desc_("in-memory datasource","utf-8"),
|
||||
type_(type) {}
|
||||
|
||||
memory_datasource::~memory_datasource() {}
|
||||
|
||||
|
@ -77,7 +78,7 @@ void memory_datasource::push(feature_ptr feature)
|
|||
|
||||
datasource::datasource_t memory_datasource::type() const
|
||||
{
|
||||
return datasource::Vector;
|
||||
return type_;
|
||||
}
|
||||
|
||||
featureset_ptr memory_datasource::features(const query& q) const
|
||||
|
|
Loading…
Reference in a new issue