+ update to new feature_impl

This commit is contained in:
Artem Pavlenko 2012-01-17 13:41:37 -05:00
parent b89aee13fd
commit 48fb4e675b

View file

@ -38,28 +38,22 @@ using mapnik::Feature;
using mapnik::metawriter_properties;
// intersect a set of properties with those in the feature descriptor
map<string,value> intersect_properties(const Feature &feature, const metawriter_properties &properties) {
map<string,value> intersect_properties(Feature const& feature, metawriter_properties const& properties) {
// FIXME
//const map<string, value> &fprops = feature.props();
map<string,value> nprops;
/*
BOOST_FOREACH(string p, properties) {
map<string, value>::const_iterator itr = fprops.find(p);
if (itr != fprops.end()) {
nprops.insert(*itr);
}
BOOST_FOREACH(string p, properties)
{
if (feature.has_key(p))
nprops.insert(std::make_pair(p,feature.get(p)));
}
*/
return nprops;
}
} // end anonymous namespace
return nprops;
}} // end anonymous namespace
namespace mapnik {
metawriter_inmem::metawriter_inmem(metawriter_properties dflt_properties)
: metawriter(dflt_properties) {
: metawriter(dflt_properties) {
}
metawriter_inmem::~metawriter_inmem() {
@ -69,10 +63,10 @@ void
metawriter_inmem::add_box(box2d<double> const& box, Feature const& feature,
CoordTransform const& /*t*/,
metawriter_properties const& properties) {
meta_instance inst;
inst.box = box;
inst.properties = intersect_properties(feature, properties);
instances_.push_back(inst);
meta_instance inst;
inst.box = box;
inst.properties = intersect_properties(feature, properties);
instances_.push_back(inst);
}
void
@ -81,12 +75,12 @@ metawriter_inmem::add_text(placement const& p,
Feature const& feature,
CoordTransform const& /*t*/,
metawriter_properties const& properties) {
if (p.extents.valid()) {
meta_instance inst;
inst.properties = intersect_properties(feature, properties);
inst.box = p.extents;
instances_.push_back(inst);
}
if (p.extents.valid()) {
meta_instance inst;
inst.properties = intersect_properties(feature, properties);
inst.box = p.extents;
instances_.push_back(inst);
}
}
void
@ -94,7 +88,7 @@ metawriter_inmem::add_polygon(path_type & path,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties) {
add_vertices(path, feature, t, properties);
add_vertices(path, feature, t, properties);
}
void
@ -102,7 +96,7 @@ metawriter_inmem::add_line(path_type & path,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties) {
add_vertices(path, feature, t, properties);
add_vertices(path, feature, t, properties);
}
void
@ -110,41 +104,41 @@ metawriter_inmem::add_vertices(path_type & path,
Feature const& feature,
CoordTransform const& /*t*/,
metawriter_properties const& properties) {
box2d<double> box;
unsigned cmd;
double x = 0.0, y = 0.0;
box2d<double> box;
unsigned cmd;
double x = 0.0, y = 0.0;
path.rewind(0);
while ((cmd = path.vertex(&x, &y)) != SEG_END) {
box.expand_to_include(x, y);
}
path.rewind(0);
while ((cmd = path.vertex(&x, &y)) != SEG_END) {
box.expand_to_include(x, y);
}
if ((box.width() >= 0.0) && (box.height() >= 0.0)) {
meta_instance inst;
inst.properties = intersect_properties(feature, properties);
inst.box = box;
instances_.push_back(inst);
}
if ((box.width() >= 0.0) && (box.height() >= 0.0)) {
meta_instance inst;
inst.properties = intersect_properties(feature, properties);
inst.box = box;
instances_.push_back(inst);
}
}
void
metawriter_inmem::start(metawriter_property_map const& /*properties*/) {
instances_.clear();
instances_.clear();
}
const std::list<metawriter_inmem::meta_instance> &
metawriter_inmem::instances() const {
return instances_;
return instances_;
}
metawriter_inmem::meta_instance_list::const_iterator
metawriter_inmem::inst_begin() const {
return instances_.begin();
return instances_.begin();
}
metawriter_inmem::meta_instance_list::const_iterator
metawriter_inmem::inst_end() const {
return instances_.end();
return instances_.end();
}