Merge remote-tracking branch 'origin/master'

This commit is contained in:
Artem Pavlenko 2012-06-17 15:21:27 -04:00
commit dc89f6fac4
32 changed files with 322 additions and 254 deletions

View file

@ -220,9 +220,7 @@ static void write_features(T const& grid_type,
boost::optional<std::string> join_value; boost::optional<std::string> join_value;
if (key == grid_type.key_name()) if (key == grid_type.key_name())
{ {
std::stringstream s; join_value = feat_itr->first;
s << feature->id();
join_value = s.str();
} }
else if (feature->has_key(key)) else if (feature->has_key(key))
{ {

View file

@ -75,38 +75,38 @@ public:
double opacity, composite_mode_e comp_op); double opacity, composite_mode_e comp_op);
void process(point_symbolizer const& sym, void process(point_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(line_symbolizer const& sym, void process(line_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(line_pattern_symbolizer const& sym, void process(line_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(polygon_symbolizer const& sym, void process(polygon_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(polygon_pattern_symbolizer const& sym, void process(polygon_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(raster_symbolizer const& sym, void process(raster_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(shield_symbolizer const& sym, void process(shield_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(text_symbolizer const& sym, void process(text_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(building_symbolizer const& sym, void process(building_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(markers_symbolizer const& sym, void process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
inline bool process(rule::symbolizers const& /*syms*/, inline bool process(rule::symbolizers const& /*syms*/,
mapnik::feature_ptr const& /*feature*/, mapnik::feature_impl & /*feature*/,
proj_transform const& /*prj_trans*/) proj_transform const& /*prj_trans*/)
{ {
// agg renderer doesn't support processing of multiple symbolizers. // agg renderer doesn't support processing of multiple symbolizers.

View file

@ -83,37 +83,37 @@ public:
void start_style_processing(feature_type_style const& st); void start_style_processing(feature_type_style const& st);
void end_style_processing(feature_type_style const& st); void end_style_processing(feature_type_style const& st);
void process(point_symbolizer const& sym, void process(point_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(line_symbolizer const& sym, void process(line_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(line_pattern_symbolizer const& sym, void process(line_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(polygon_symbolizer const& sym, void process(polygon_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(polygon_pattern_symbolizer const& sym, void process(polygon_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(raster_symbolizer const& sym, void process(raster_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(shield_symbolizer const& sym, void process(shield_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(text_symbolizer const& sym, void process(text_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(building_symbolizer const& sym, void process(building_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(markers_symbolizer const& sym, void process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
inline bool process(rule::symbolizers const& /*syms*/, inline bool process(rule::symbolizers const& /*syms*/,
mapnik::feature_ptr const& /*feature*/, mapnik::feature_impl & /*feature*/,
proj_transform const& /*prj_trans*/) proj_transform const& /*prj_trans*/)
{ {
// cairo renderer doesn't support processing of multiple symbolizers. // cairo renderer doesn't support processing of multiple symbolizers.

View file

@ -187,6 +187,16 @@ public:
return data_.size(); return data_.size();
} }
cont_type const& get_data() const
{
return data_;
}
void set_data(cont_type const& data)
{
data_ = data;
}
context_ptr context() context_ptr context()
{ {
return ctx_; return ctx_;

View file

@ -32,6 +32,7 @@
#include <mapnik/global.hpp> #include <mapnik/global.hpp>
#include <mapnik/value.hpp> #include <mapnik/value.hpp>
#include <mapnik/feature.hpp> #include <mapnik/feature.hpp>
#include <mapnik/feature_factory.hpp>
// boost // boost
#include <boost/cstdint.hpp> #include <boost/cstdint.hpp>
@ -57,7 +58,7 @@ public:
// mapping between pixel id and key // mapping between pixel id and key
typedef std::map<value_type, lookup_type> feature_key_type; typedef std::map<value_type, lookup_type> feature_key_type;
typedef std::map<lookup_type, value_type> key_type; typedef std::map<lookup_type, value_type> key_type;
typedef std::map<std::string, mapnik::feature_ptr> feature_type; typedef std::map<lookup_type, mapnik::feature_ptr> feature_type;
private: private:
unsigned width_; unsigned width_;
@ -70,6 +71,7 @@ private:
std::set<std::string> names_; std::set<std::string> names_;
feature_key_type f_keys_; feature_key_type f_keys_;
feature_type features_; feature_type features_;
mapnik::context_ptr ctx_;
public: public:
@ -83,7 +85,8 @@ public:
painted_(false), painted_(false),
names_(), names_(),
f_keys_(), f_keys_(),
features_() features_(),
ctx_(boost::make_shared<mapnik::context_type>())
{ {
// this only works if each datasource's // this only works if each datasource's
// feature count starts at 1 // feature count starts at 1
@ -100,7 +103,8 @@ public:
painted_(rhs.painted_), painted_(rhs.painted_),
names_(rhs.names_), names_(rhs.names_),
f_keys_(rhs.f_keys_), f_keys_(rhs.f_keys_),
features_(rhs.features_) features_(rhs.features_),
ctx_(rhs.ctx_)
{ {
f_keys_[0] = ""; f_keys_[0] = "";
} }
@ -122,23 +126,37 @@ public:
return id_name_; return id_name_;
} }
inline void add_feature(mapnik::feature_ptr const& feature) inline void add_feature(mapnik::feature_impl & feature)
{ {
// avoid adding duplicate features (e.g. in the case of both a line symbolizer and a polygon symbolizer)
typename feature_key_type::const_iterator feature_pos = f_keys_.find(feature.id());
if (feature_pos != f_keys_.end())
{
return;
}
if (ctx_->size() == 0) {
mapnik::feature_impl::iterator itr = feature.begin();
mapnik::feature_impl::iterator end = feature.end();
for ( ;itr!=end; ++itr)
{
ctx_->push(boost::get<0>(*itr));
}
}
// NOTE: currently lookup keys must be strings, // NOTE: currently lookup keys must be strings,
// but this should be revisited // but this should be revisited
boost::optional<lookup_type> lookup_value; boost::optional<lookup_type> lookup_value;
if (key_ == id_name_) if (key_ == id_name_)
{ {
std::stringstream s; std::stringstream s;
s << feature->id(); s << feature.id();
lookup_value = s.str(); lookup_value = s.str();
} }
else else
{ {
if (feature->has_key(key_)) if (feature.has_key(key_))
{ {
lookup_value = feature->get(key_).to_string(); lookup_value = feature.get(key_).to_string();
} }
else else
{ {
@ -150,16 +168,21 @@ public:
{ {
// TODO - consider shortcutting f_keys if feature_id == lookup_value // TODO - consider shortcutting f_keys if feature_id == lookup_value
// create a mapping between the pixel id and the feature key // create a mapping between the pixel id and the feature key
f_keys_.insert(std::make_pair(feature->id(),*lookup_value)); f_keys_.insert(std::make_pair(feature.id(),*lookup_value));
// if extra fields have been supplied, push them into grid memory // if extra fields have been supplied, push them into grid memory
if (!names_.empty()) if (!names_.empty())
{ {
features_.insert(std::make_pair(*lookup_value,feature)); // it is ~ 2x faster to copy feature attributes compared
// to building up a in-memory cache of feature_ptrs
// https://github.com/mapnik/mapnik/issues/1198
mapnik::feature_ptr feature2(mapnik::feature_factory::create(ctx_,feature.id()));
feature2->set_data(feature.get_data());
features_.insert(std::make_pair(*lookup_value,feature2));
} }
} }
else else
{ {
MAPNIK_LOG_DEBUG(grid) << "hit_grid: Warning - key '" << key_ << "' was blank for " << *feature; MAPNIK_LOG_DEBUG(grid) << "hit_grid: Warning - key '" << key_ << "' was blank for " << feature;
} }
} }

View file

@ -65,40 +65,40 @@ public:
void end_layer_processing(layer const& lay); void end_layer_processing(layer const& lay);
void start_style_processing(feature_type_style const& st) {} void start_style_processing(feature_type_style const& st) {}
void end_style_processing(feature_type_style const& st) {} void end_style_processing(feature_type_style const& st) {}
void render_marker(mapnik::feature_ptr const& feature, unsigned int step, pixel_position const& pos, marker const& marker, const agg::trans_affine & tr, double opacity); void render_marker(mapnik::feature_impl & feature, unsigned int step, pixel_position const& pos, marker const& marker, const agg::trans_affine & tr, double opacity);
void process(point_symbolizer const& sym, void process(point_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(line_symbolizer const& sym, void process(line_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(line_pattern_symbolizer const& sym, void process(line_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(polygon_symbolizer const& sym, void process(polygon_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(polygon_pattern_symbolizer const& sym, void process(polygon_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(raster_symbolizer const& sym, void process(raster_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(shield_symbolizer const& sym, void process(shield_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(text_symbolizer const& sym, void process(text_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(building_symbolizer const& sym, void process(building_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
void process(markers_symbolizer const& sym, void process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
inline bool process(rule::symbolizers const& /*syms*/, inline bool process(rule::symbolizers const& /*syms*/,
mapnik::feature_ptr const& /*feature*/, mapnik::feature_impl & /*feature*/,
proj_transform const& /*prj_trans*/) proj_transform const& /*prj_trans*/)
{ {
// grid renderer doesn't support processing of multiple symbolizers. // grid renderer doesn't support processing of multiple symbolizers.

View file

@ -44,7 +44,7 @@ namespace mapnik
template <typename T> template <typename T>
void agg_renderer<T>::process(building_symbolizer const& sym, void agg_renderer<T>::process(building_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
@ -70,13 +70,13 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
expression_ptr height_expr = sym.height(); expression_ptr height_expr = sym.height();
if (height_expr) if (height_expr)
{ {
value_type result = boost::apply_visitor(evaluate<Feature,value_type>(*feature), *height_expr); value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature), *height_expr);
height = result.to_double() * scale_factor_; height = result.to_double() * scale_factor_;
} }
for (unsigned i=0;i<feature->num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)
{ {
geometry_type const& geom = feature->get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
boost::scoped_ptr<geometry_type> frame(new geometry_type(LineString)); boost::scoped_ptr<geometry_type> frame(new geometry_type(LineString));
@ -158,7 +158,7 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
} }
template void agg_renderer<image_32>::process(building_symbolizer const&, template void agg_renderer<image_32>::process(building_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -51,7 +51,7 @@ namespace mapnik {
template <typename T> template <typename T>
void agg_renderer<T>::process(line_pattern_symbolizer const& sym, void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef agg::rgba8 color; typedef agg::rgba8 color;
@ -65,7 +65,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
typedef agg::renderer_outline_image<renderer_base, pattern_type> renderer_type; typedef agg::renderer_outline_image<renderer_base, pattern_type> renderer_type;
typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type; typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type;
std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<marker_ptr> mark = marker_cache::instance()->find(filename,true); boost::optional<marker_ptr> mark = marker_cache::instance()->find(filename,true);
if (!mark) return; if (!mark) return;
@ -95,7 +95,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
rasterizer_type ras(ren); rasterizer_type ras(ren);
agg::trans_affine tr; agg::trans_affine tr;
evaluate_transform(tr, *feature, sym.get_transform()); evaluate_transform(tr, feature, sym.get_transform());
typedef boost::mpl::vector<clip_line_tag,transform_tag,smooth_tag> conv_types; typedef boost::mpl::vector<clip_line_tag,transform_tag,smooth_tag> conv_types;
vertex_converter<box2d<double>, rasterizer_type, line_pattern_symbolizer, vertex_converter<box2d<double>, rasterizer_type, line_pattern_symbolizer,
@ -106,7 +106,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
converter.set<transform_tag>(); //always transform converter.set<transform_tag>(); //always transform
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH(geometry_type & geom, feature->paths()) BOOST_FOREACH(geometry_type & geom, feature.paths())
{ {
if (geom.num_points() > 1) if (geom.num_points() > 1)
{ {
@ -116,7 +116,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
} }
template void agg_renderer<image_32>::process(line_pattern_symbolizer const&, template void agg_renderer<image_32>::process(line_pattern_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -50,7 +50,7 @@ namespace mapnik {
template <typename T> template <typename T>
void agg_renderer<T>::process(line_symbolizer const& sym, void agg_renderer<T>::process(line_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
@ -77,7 +77,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
renderer_base renb(pixf); renderer_base renb(pixf);
agg::trans_affine tr; agg::trans_affine tr;
evaluate_transform(tr, *feature, sym.get_transform()); evaluate_transform(tr, feature, sym.get_transform());
box2d<double> ext = query_extent_ * 1.1; box2d<double> ext = query_extent_ * 1.1;
@ -106,7 +106,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
if (stroke_.has_dash()) converter.set<dash_tag>(); if (stroke_.has_dash()) converter.set<dash_tag>();
converter.set<stroke_tag>(); //always stroke converter.set<stroke_tag>(); //always stroke
BOOST_FOREACH( geometry_type & geom, feature->paths()) BOOST_FOREACH( geometry_type & geom, feature.paths())
{ {
if (geom.num_points() > 1) if (geom.num_points() > 1)
{ {
@ -129,7 +129,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
if (stroke_.has_dash()) converter.set<dash_tag>(); if (stroke_.has_dash()) converter.set<dash_tag>();
converter.set<stroke_tag>(); //always stroke converter.set<stroke_tag>(); //always stroke
BOOST_FOREACH( geometry_type & geom, feature->paths()) BOOST_FOREACH( geometry_type & geom, feature.paths())
{ {
if (geom.num_points() > 1) if (geom.num_points() > 1)
{ {
@ -149,7 +149,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
template void agg_renderer<image_32>::process(line_symbolizer const&, template void agg_renderer<image_32>::process(line_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -50,7 +50,7 @@ namespace mapnik {
template <typename T> template <typename T>
void agg_renderer<T>::process(markers_symbolizer const& sym, void agg_renderer<T>::process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type; typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
@ -73,9 +73,9 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
renderer_base renb(pixf); renderer_base renb(pixf);
renderer_type ren(renb); renderer_type ren(renb);
agg::trans_affine tr; agg::trans_affine tr;
evaluate_transform(tr, *feature, sym.get_image_transform()); evaluate_transform(tr, feature, sym.get_image_transform());
tr = agg::trans_affine_scaling(scale_factor_) * tr; tr = agg::trans_affine_scaling(scale_factor_) * tr;
std::string filename = path_processor_type::evaluate(*sym.get_filename(), *feature); std::string filename = path_processor_type::evaluate(*sym.get_filename(), feature);
marker_placement_e placement_method = sym.get_marker_placement(); marker_placement_e placement_method = sym.get_marker_placement();
marker_type_e marker_type = sym.get_marker_type(); marker_type_e marker_type = sym.get_marker_type();
metawriter_with_properties writer = sym.get_metawriter(); metawriter_with_properties writer = sym.get_metawriter();
@ -108,9 +108,9 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
renderer_type, renderer_type,
agg::pixfmt_rgba32 > svg_renderer(svg_path,(*marker)->attributes()); agg::pixfmt_rgba32 > svg_renderer(svg_path,(*marker)->attributes());
for (unsigned i=0; i<feature->num_geometries(); ++i) for (unsigned i=0; i<feature.num_geometries(); ++i)
{ {
geometry_type & geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
// TODO - merge this code with point_symbolizer rendering // TODO - merge this code with point_symbolizer rendering
if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1) if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1)
{ {
@ -136,7 +136,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
//if (!sym.get_ignore_placement()) //if (!sym.get_ignore_placement())
// detector_->insert(label_ext); // detector_->insert(label_ext);
metawriter_with_properties writer = sym.get_metawriter(); metawriter_with_properties writer = sym.get_metawriter();
if (writer.first) writer.first->add_box(extent, *feature, t_, writer.second); if (writer.first) writer.first->add_box(extent, feature, t_, writer.second);
} }
} }
else else
@ -237,9 +237,9 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
agg::path_storage marker; agg::path_storage marker;
for (unsigned i=0; i<feature->num_geometries(); ++i) for (unsigned i=0; i<feature.num_geometries(); ++i)
{ {
geometry_type & geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
//if (geom.num_points() <= 1) continue; //if (geom.num_points() <= 1) continue;
if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1) if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1)
{ {
@ -274,7 +274,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
} }
if (!sym.get_ignore_placement()) if (!sym.get_ignore_placement())
detector_->insert(label_ext); detector_->insert(label_ext);
if (writer.first) writer.first->add_box(label_ext, *feature, t_, writer.second); if (writer.first) writer.first->add_box(label_ext, feature, t_, writer.second);
} }
} }
else else
@ -347,6 +347,6 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
} }
template void agg_renderer<image_32>::process(markers_symbolizer const&, template void agg_renderer<image_32>::process(markers_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -46,10 +46,10 @@ namespace mapnik {
template <typename T> template <typename T>
void agg_renderer<T>::process(point_symbolizer const& sym, void agg_renderer<T>::process(point_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
std::string filename = path_processor_type::evaluate(*sym.get_filename(), *feature); std::string filename = path_processor_type::evaluate(*sym.get_filename(), feature);
boost::optional<mapnik::marker_ptr> marker; boost::optional<mapnik::marker_ptr> marker;
if ( !filename.empty() ) if ( !filename.empty() )
@ -67,15 +67,15 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
coord2d const center = bbox.center(); coord2d const center = bbox.center();
agg::trans_affine tr; agg::trans_affine tr;
evaluate_transform(tr, *feature, sym.get_image_transform()); evaluate_transform(tr, feature, sym.get_image_transform());
agg::trans_affine_translation const recenter(-center.x, -center.y); agg::trans_affine_translation const recenter(-center.x, -center.y);
agg::trans_affine const recenter_tr = recenter * tr; agg::trans_affine const recenter_tr = recenter * tr;
box2d<double> label_ext = bbox * recenter_tr; box2d<double> label_ext = bbox * recenter_tr;
for (unsigned i=0; i<feature->num_geometries(); ++i) for (unsigned i=0; i<feature.num_geometries(); ++i)
{ {
geometry_type const& geom = feature->get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
double x; double x;
double y; double y;
double z=0; double z=0;
@ -101,7 +101,7 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
if (!sym.get_ignore_placement()) if (!sym.get_ignore_placement())
detector_->insert(label_ext); detector_->insert(label_ext);
metawriter_with_properties writer = sym.get_metawriter(); metawriter_with_properties writer = sym.get_metawriter();
if (writer.first) writer.first->add_box(label_ext, *feature, t_, writer.second); if (writer.first) writer.first->add_box(label_ext, feature, t_, writer.second);
} }
} }
} }
@ -109,7 +109,7 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
} }
template void agg_renderer<image_32>::process(point_symbolizer const&, template void agg_renderer<image_32>::process(point_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -49,7 +49,7 @@ namespace mapnik {
template <typename T> template <typename T>
void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym, void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type; typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
@ -59,7 +59,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
ras_ptr->reset(); ras_ptr->reset();
set_gamma_method(sym,ras_ptr); set_gamma_method(sym,ras_ptr);
std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<mapnik::marker_ptr> marker; boost::optional<mapnik::marker_ptr> marker;
if ( !filename.empty() ) if ( !filename.empty() )
{ {
@ -120,9 +120,9 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
{ {
double x0 = 0; double x0 = 0;
double y0 = 0; double y0 = 0;
if (feature->num_geometries() > 0) if (feature.num_geometries() > 0)
{ {
clipped_geometry_type clipped(feature->get_geometry(0)); clipped_geometry_type clipped(feature.get_geometry(0));
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy()); clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
path_type path(t_,clipped,prj_trans); path_type path(t_,clipped,prj_trans);
path.vertex(&x0,&y0); path.vertex(&x0,&y0);
@ -137,7 +137,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
renderer_type rp(renb,sa, sg); renderer_type rp(renb,sa, sg);
agg::trans_affine tr; agg::trans_affine tr;
evaluate_transform(tr, *feature, sym.get_transform()); evaluate_transform(tr, feature, sym.get_transform());
box2d<double> inflated_extent = query_extent_ * 1.0; box2d<double> inflated_extent = query_extent_ * 1.0;
typedef boost::mpl::vector<clip_poly_tag,transform_tag,smooth_tag> conv_types; typedef boost::mpl::vector<clip_poly_tag,transform_tag,smooth_tag> conv_types;
@ -149,7 +149,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
converter.set<transform_tag>(); //always transform converter.set<transform_tag>(); //always transform
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature->paths()) BOOST_FOREACH( geometry_type & geom, feature.paths())
{ {
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
@ -162,7 +162,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
template void agg_renderer<image_32>::process(polygon_pattern_symbolizer const&, template void agg_renderer<image_32>::process(polygon_pattern_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -41,7 +41,7 @@ namespace mapnik {
template <typename T> template <typename T>
void agg_renderer<T>::process(polygon_symbolizer const& sym, void agg_renderer<T>::process(polygon_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
@ -51,7 +51,7 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
box2d<double> inflated_extent = query_extent_ * 1.0; box2d<double> inflated_extent = query_extent_ * 1.0;
agg::trans_affine tr; agg::trans_affine tr;
evaluate_transform(tr, *feature, sym.get_transform()); evaluate_transform(tr, feature, sym.get_transform());
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag> conv_types; typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag> conv_types;
vertex_converter<box2d<double>, rasterizer, polygon_symbolizer, vertex_converter<box2d<double>, rasterizer, polygon_symbolizer,
@ -63,7 +63,7 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
converter.set<affine_transform_tag>(); converter.set<affine_transform_tag>();
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature->paths()) BOOST_FOREACH( geometry_type & geom, feature.paths())
{ {
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
@ -97,7 +97,7 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
} }
template void agg_renderer<image_32>::process(polygon_symbolizer const&, template void agg_renderer<image_32>::process(polygon_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -41,16 +41,16 @@ namespace mapnik {
template <typename T> template <typename T>
void agg_renderer<T>::process(raster_symbolizer const& sym, void agg_renderer<T>::process(raster_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
raster_ptr const& source=feature->get_raster(); raster_ptr const& source=feature.get_raster();
if (source) if (source)
{ {
// If there's a colorizer defined, use it to color the raster in-place // If there's a colorizer defined, use it to color the raster in-place
raster_colorizer_ptr colorizer = sym.get_colorizer(); raster_colorizer_ptr colorizer = sym.get_colorizer();
if (colorizer) if (colorizer)
colorizer->colorize(source,*feature); colorizer->colorize(source,feature);
box2d<double> target_ext = box2d<double>(source->ext_); box2d<double> target_ext = box2d<double>(source->ext_);
prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS); prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS);
@ -83,7 +83,7 @@ void agg_renderer<T>::process(raster_symbolizer const& sym,
} }
template void agg_renderer<image_32>::process(raster_symbolizer const&, template void agg_renderer<image_32>::process(raster_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -36,12 +36,12 @@ namespace mapnik {
template <typename T> template <typename T>
void agg_renderer<T>::process(shield_symbolizer const& sym, void agg_renderer<T>::process(shield_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
shield_symbolizer_helper<face_manager<freetype_engine>, shield_symbolizer_helper<face_manager<freetype_engine>,
label_collision_detector4> helper( label_collision_detector4> helper(
sym, *feature, prj_trans, sym, feature, prj_trans,
width_, height_, width_, height_,
scale_factor_, scale_factor_,
t_, font_manager_, *detector_, query_extent_); t_, font_manager_, *detector_, query_extent_);
@ -74,7 +74,7 @@ void agg_renderer<T>::process(shield_symbolizer const& sym,
template void agg_renderer<image_32>::process(shield_symbolizer const&, template void agg_renderer<image_32>::process(shield_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -29,12 +29,12 @@ namespace mapnik {
template <typename T> template <typename T>
void agg_renderer<T>::process(text_symbolizer const& sym, void agg_renderer<T>::process(text_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
text_symbolizer_helper<face_manager<freetype_engine>, text_symbolizer_helper<face_manager<freetype_engine>,
label_collision_detector4> helper( label_collision_detector4> helper(
sym, *feature, prj_trans, sym, feature, prj_trans,
detector_->extent().width(), detector_->extent().height(), detector_->extent().width(), detector_->extent().height(),
scale_factor_, scale_factor_,
t_, font_manager_, *detector_, query_extent_); t_, font_manager_, *detector_, query_extent_);
@ -53,7 +53,7 @@ void agg_renderer<T>::process(text_symbolizer const& sym,
} }
template void agg_renderer<image_32>::process(text_symbolizer const&, template void agg_renderer<image_32>::process(text_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -830,7 +830,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
void cairo_renderer_base::process(polygon_symbolizer const& sym, void cairo_renderer_base::process(polygon_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
cairo_context context(context_); cairo_context context(context_);
@ -838,7 +838,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
context.set_color(sym.get_fill(), sym.get_opacity()); context.set_color(sym.get_fill(), sym.get_opacity());
agg::trans_affine tr; agg::trans_affine tr;
evaluate_transform(tr, *feature, sym.get_transform()); evaluate_transform(tr, feature, sym.get_transform());
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag> conv_types; typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag> conv_types;
vertex_converter<box2d<double>, cairo_context, polygon_symbolizer, vertex_converter<box2d<double>, cairo_context, polygon_symbolizer,
@ -850,7 +850,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
converter.set<affine_transform_tag>(); converter.set<affine_transform_tag>();
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature->paths()) BOOST_FOREACH( geometry_type & geom, feature.paths())
{ {
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
@ -862,7 +862,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
void cairo_renderer_base::process(building_symbolizer const& sym, void cairo_renderer_base::process(building_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
@ -874,13 +874,13 @@ void cairo_renderer_base::start_map_processing(Map const& map)
expression_ptr height_expr = sym.height(); expression_ptr height_expr = sym.height();
if (height_expr) if (height_expr)
{ {
value_type result = boost::apply_visitor(evaluate<Feature,value_type>(*feature), *height_expr); value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature), *height_expr);
height = result.to_double(); //scale_factor is always 1.0 atm height = result.to_double(); //scale_factor is always 1.0 atm
} }
for (unsigned i = 0; i < feature->num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {
geometry_type const& geom = feature->get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
@ -971,7 +971,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
void cairo_renderer_base::process(line_symbolizer const& sym, void cairo_renderer_base::process(line_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
cairo_context context(context_); cairo_context context(context_);
@ -989,7 +989,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
agg::trans_affine tr; agg::trans_affine tr;
evaluate_transform(tr, *feature, sym.get_transform()); evaluate_transform(tr, feature, sym.get_transform());
typedef boost::mpl::vector<clip_line_tag,transform_tag, offset_transform_tag, affine_transform_tag, smooth_tag> conv_types; typedef boost::mpl::vector<clip_line_tag,transform_tag, offset_transform_tag, affine_transform_tag, smooth_tag> conv_types;
vertex_converter<box2d<double>, cairo_context, line_symbolizer, vertex_converter<box2d<double>, cairo_context, line_symbolizer,
@ -1003,7 +1003,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
converter.set<affine_transform_tag>(); // optional affine transform converter.set<affine_transform_tag>(); // optional affine transform
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature->paths()) BOOST_FOREACH( geometry_type & geom, feature.paths())
{ {
if (geom.num_points() > 1) if (geom.num_points() > 1)
{ {
@ -1127,10 +1127,10 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
void cairo_renderer_base::process(point_symbolizer const& sym, void cairo_renderer_base::process(point_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<marker_ptr> marker; boost::optional<marker_ptr> marker;
if ( !filename.empty() ) if ( !filename.empty() )
@ -1143,13 +1143,13 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
agg::trans_affine mtx; agg::trans_affine mtx;
evaluate_transform(mtx, *feature, sym.get_image_transform()); evaluate_transform(mtx, feature, sym.get_image_transform());
if (marker) if (marker)
{ {
for (unsigned i = 0; i < feature->num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {
geometry_type const& geom = feature->get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
double x; double x;
double y; double y;
double z = 0; double z = 0;
@ -1178,7 +1178,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
metawriter_with_properties writer = sym.get_metawriter(); metawriter_with_properties writer = sym.get_metawriter();
if (writer.first) if (writer.first)
{ {
writer.first->add_box(label_ext, *feature, t_, writer.second); writer.first->add_box(label_ext, feature, t_, writer.second);
} }
} }
} }
@ -1186,12 +1186,12 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
void cairo_renderer_base::process(shield_symbolizer const& sym, void cairo_renderer_base::process(shield_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
shield_symbolizer_helper<face_manager<freetype_engine>, shield_symbolizer_helper<face_manager<freetype_engine>,
label_collision_detector4> helper( label_collision_detector4> helper(
sym, *feature, prj_trans, sym, feature, prj_trans,
detector_.extent().width(), detector_.extent().height(), detector_.extent().width(), detector_.extent().height(),
1.0 /*scale_factor*/, 1.0 /*scale_factor*/,
t_, font_manager_, detector_, query_extent_); t_, font_manager_, detector_, query_extent_);
@ -1213,13 +1213,13 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
void cairo_renderer_base::process(line_pattern_symbolizer const& sym, void cairo_renderer_base::process(line_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type; typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
typedef coord_transform<CoordTransform,clipped_geometry_type> path_type; typedef coord_transform<CoordTransform,clipped_geometry_type> path_type;
std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<mapnik::marker_ptr> marker = mapnik::marker_cache::instance()->find(filename,true); boost::optional<mapnik::marker_ptr> marker = mapnik::marker_cache::instance()->find(filename,true);
if (!marker && !(*marker)->is_bitmap()) return; if (!marker && !(*marker)->is_bitmap()) return;
@ -1234,9 +1234,9 @@ void cairo_renderer_base::start_map_processing(Map const& map)
pattern.set_filter(Cairo::FILTER_BILINEAR); pattern.set_filter(Cairo::FILTER_BILINEAR);
context.set_line_width(height); context.set_line_width(height);
for (unsigned i = 0; i < feature->num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {
geometry_type & geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
if (geom.num_points() > 1) if (geom.num_points() > 1)
{ {
@ -1287,13 +1287,13 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym, void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
cairo_context context(context_); cairo_context context(context_);
context.set_operator(sym.comp_op()); context.set_operator(sym.comp_op());
std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<mapnik::marker_ptr> marker = mapnik::marker_cache::instance()->find(filename,true); boost::optional<mapnik::marker_ptr> marker = mapnik::marker_cache::instance()->find(filename,true);
if (!marker && !(*marker)->is_bitmap()) return; if (!marker && !(*marker)->is_bitmap()) return;
@ -1304,7 +1304,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
context.set_pattern(pattern); context.set_pattern(pattern);
agg::trans_affine tr; agg::trans_affine tr;
evaluate_transform(tr, *feature, sym.get_transform()); evaluate_transform(tr, feature, sym.get_transform());
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag> conv_types; typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag> conv_types;
vertex_converter<box2d<double>, cairo_context, polygon_pattern_symbolizer, vertex_converter<box2d<double>, cairo_context, polygon_pattern_symbolizer,
@ -1316,7 +1316,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
converter.set<affine_transform_tag>(); converter.set<affine_transform_tag>();
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH( geometry_type & geom, feature->paths()) BOOST_FOREACH( geometry_type & geom, feature.paths())
{ {
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
@ -1329,16 +1329,16 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
void cairo_renderer_base::process(raster_symbolizer const& sym, void cairo_renderer_base::process(raster_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
raster_ptr const& source = feature->get_raster(); raster_ptr const& source = feature.get_raster();
if (source) if (source)
{ {
// If there's a colorizer defined, use it to color the raster in-place // If there's a colorizer defined, use it to color the raster in-place
raster_colorizer_ptr colorizer = sym.get_colorizer(); raster_colorizer_ptr colorizer = sym.get_colorizer();
if (colorizer) if (colorizer)
colorizer->colorize(source,*feature); colorizer->colorize(source,feature);
box2d<double> target_ext = box2d<double>(source->ext_); box2d<double> target_ext = box2d<double>(source->ext_);
prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS); prj_trans.backward(target_ext, PROJ_ENVELOPE_POINTS);
@ -1374,7 +1374,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
void cairo_renderer_base::process(markers_symbolizer const& sym, void cairo_renderer_base::process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
cairo_context context(context_); cairo_context context(context_);
@ -1385,11 +1385,11 @@ void cairo_renderer_base::start_map_processing(Map const& map)
typedef coord_transform<CoordTransform,clipped_geometry_type> path_type; typedef coord_transform<CoordTransform,clipped_geometry_type> path_type;
agg::trans_affine tr; agg::trans_affine tr;
evaluate_transform(tr, *feature, sym.get_image_transform()); evaluate_transform(tr, feature, sym.get_image_transform());
// TODO - use this? // TODO - use this?
//tr = agg::trans_affine_scaling(scale_factor_) * tr; //tr = agg::trans_affine_scaling(scale_factor_) * tr;
std::string filename = path_processor_type::evaluate(*sym.get_filename(), *feature); std::string filename = path_processor_type::evaluate(*sym.get_filename(), feature);
marker_placement_e placement_method = sym.get_marker_placement(); marker_placement_e placement_method = sym.get_marker_placement();
marker_type_e marker_type = sym.get_marker_type(); marker_type_e marker_type = sym.get_marker_type();
metawriter_with_properties writer = sym.get_metawriter(); metawriter_with_properties writer = sym.get_metawriter();
@ -1420,9 +1420,9 @@ void cairo_renderer_base::start_map_processing(Map const& map)
box2d<double> extent(x1,y1,x2,y2); box2d<double> extent(x1,y1,x2,y2);
using namespace mapnik::svg; using namespace mapnik::svg;
for (unsigned i=0; i<feature->num_geometries(); ++i) for (unsigned i=0; i<feature.num_geometries(); ++i)
{ {
geometry_type & geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
// TODO - merge this code with point_symbolizer rendering // TODO - merge this code with point_symbolizer rendering
if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1) if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1)
{ {
@ -1443,7 +1443,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
//if (!sym.get_ignore_placement()) //if (!sym.get_ignore_placement())
// detector_.insert(label_ext); // detector_.insert(label_ext);
metawriter_with_properties writer = sym.get_metawriter(); metawriter_with_properties writer = sym.get_metawriter();
if (writer.first) writer.first->add_box(extent, *feature, t_, writer.second); if (writer.first) writer.first->add_box(extent, feature, t_, writer.second);
} }
} }
else else
@ -1518,9 +1518,9 @@ void cairo_renderer_base::start_map_processing(Map const& map)
agg::path_storage marker; agg::path_storage marker;
for (unsigned i=0; i<feature->num_geometries(); ++i) for (unsigned i=0; i<feature.num_geometries(); ++i)
{ {
geometry_type & geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1) if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1)
{ {
geom.label_position(&x,&y); geom.label_position(&x,&y);
@ -1552,7 +1552,7 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
if (!sym.get_ignore_placement()) if (!sym.get_ignore_placement())
detector_.insert(label_ext); detector_.insert(label_ext);
if (writer.first) writer.first->add_box(label_ext, *feature, t_, writer.second); if (writer.first) writer.first->add_box(label_ext, feature, t_, writer.second);
} }
} }
else else
@ -1618,10 +1618,10 @@ void cairo_renderer_base::start_map_processing(Map const& map)
} }
void cairo_renderer_base::process(text_symbolizer const& sym, void cairo_renderer_base::process(text_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
text_symbolizer_helper<face_manager<freetype_engine>, label_collision_detector4> helper(sym, *feature, prj_trans, detector_.extent().width(), detector_.extent().height(), 1.0 /*scale_factor*/, t_, font_manager_, detector_, query_extent_); text_symbolizer_helper<face_manager<freetype_engine>, label_collision_detector4> helper(sym, feature, prj_trans, detector_.extent().width(), detector_.extent().height(), 1.0 /*scale_factor*/, t_, font_manager_, detector_, query_extent_);
cairo_context context(context_); cairo_context context(context_);
context.set_operator(sym.comp_op()); context.set_operator(sym.comp_op());

View file

@ -62,7 +62,7 @@ template <bool>
struct process_impl struct process_impl
{ {
template <typename T0, typename T1, typename T2, typename T3> template <typename T0, typename T1, typename T2, typename T3>
static void process(T0 & ren, T1 const& sym, T2 const& f, T3 const& tr) static void process(T0 & ren, T1 const& sym, T2 & f, T3 const& tr)
{ {
ren.process(sym,f,tr); ren.process(sym,f,tr);
} }
@ -72,7 +72,7 @@ template <> // No-op specialization
struct process_impl<false> struct process_impl<false>
{ {
template <typename T0, typename T1, typename T2, typename T3> template <typename T0, typename T1, typename T2, typename T3>
static void process(T0 & ren, T1 const& sym, T2 const& f, T3 const& tr) static void process(T0 & ren, T1 const& sym, T2 & f, T3 const& tr)
{ {
boost::ignore_unused_variable_warning(ren); boost::ignore_unused_variable_warning(ren);
boost::ignore_unused_variable_warning(f); boost::ignore_unused_variable_warning(f);
@ -93,7 +93,7 @@ template <typename Processor>
struct feature_style_processor<Processor>::symbol_dispatch : public boost::static_visitor<> struct feature_style_processor<Processor>::symbol_dispatch : public boost::static_visitor<>
{ {
symbol_dispatch (Processor & output, symbol_dispatch (Processor & output,
mapnik::feature_ptr const& f, mapnik::feature_impl & f,
proj_transform const& prj_trans) proj_transform const& prj_trans)
: output_(output), : output_(output),
f_(f), f_(f),
@ -106,14 +106,14 @@ struct feature_style_processor<Processor>::symbol_dispatch : public boost::stati
} }
Processor & output_; Processor & output_;
mapnik::feature_ptr const& f_; mapnik::feature_impl & f_;
proj_transform const& prj_trans_; proj_transform const& prj_trans_;
}; };
typedef char (&no_tag)[1]; typedef char (&no_tag)[1];
typedef char (&yes_tag)[2]; typedef char (&yes_tag)[2];
template <typename T0, typename T1, void (T0::*)(T1 const&, mapnik::feature_ptr const&, proj_transform const&) > template <typename T0, typename T1, void (T0::*)(T1 const&, mapnik::feature_impl &, proj_transform const&) >
struct process_memfun_helper {}; struct process_memfun_helper {};
template <typename T0, typename T1> no_tag has_process_helper(...); template <typename T0, typename T1> no_tag has_process_helper(...);
@ -556,12 +556,12 @@ void feature_style_processor<Processor>::render_style(
// if the underlying renderer is not able to process the complete set of symbolizers, // if the underlying renderer is not able to process the complete set of symbolizers,
// process one by one. // process one by one.
if(!p.process(symbols,feature,prj_trans)) if(!p.process(symbols,*feature,prj_trans))
{ {
BOOST_FOREACH (symbolizer const& sym, symbols) BOOST_FOREACH (symbolizer const& sym, symbols)
{ {
boost::apply_visitor(symbol_dispatch(p,feature,prj_trans),sym); boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym);
} }
} }
if (style->get_filter_mode() == FILTER_FIRST) if (style->get_filter_mode() == FILTER_FIRST)
@ -584,11 +584,11 @@ void feature_style_processor<Processor>::render_style(
rule::symbolizers const& symbols = r->get_symbolizers(); rule::symbolizers const& symbols = r->get_symbolizers();
// if the underlying renderer is not able to process the complete set of symbolizers, // if the underlying renderer is not able to process the complete set of symbolizers,
// process one by one. // process one by one.
if(!p.process(symbols,feature,prj_trans)) if(!p.process(symbols,*feature,prj_trans))
{ {
BOOST_FOREACH (symbolizer const& sym, symbols) BOOST_FOREACH (symbolizer const& sym, symbols)
{ {
boost::apply_visitor(symbol_dispatch(p,feature,prj_trans),sym); boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym);
} }
} }
} }
@ -606,11 +606,11 @@ void feature_style_processor<Processor>::render_style(
rule::symbolizers const& symbols = r->get_symbolizers(); rule::symbolizers const& symbols = r->get_symbolizers();
// if the underlying renderer is not able to process the complete set of symbolizers, // if the underlying renderer is not able to process the complete set of symbolizers,
// process one by one. // process one by one.
if(!p.process(symbols,feature,prj_trans)) if(!p.process(symbols,*feature,prj_trans))
{ {
BOOST_FOREACH (symbolizer const& sym, symbols) BOOST_FOREACH (symbolizer const& sym, symbols)
{ {
boost::apply_visitor(symbol_dispatch(p,feature,prj_trans),sym); boost::apply_visitor(symbol_dispatch(p,*feature,prj_trans),sym);
} }
} }
} }

View file

@ -100,7 +100,7 @@ void grid_renderer<T>::end_layer_processing(layer const&)
} }
template <typename T> template <typename T>
void grid_renderer<T>::render_marker(mapnik::feature_ptr const& feature, unsigned int step, pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity) void grid_renderer<T>::render_marker(mapnik::feature_impl & feature, unsigned int step, pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity)
{ {
if (marker.is_vector()) if (marker.is_vector())
{ {
@ -135,7 +135,7 @@ void grid_renderer<T>::render_marker(mapnik::feature_ptr const& feature, unsigne
mapnik::pixfmt_gray32> svg_renderer(svg_path, mapnik::pixfmt_gray32> svg_renderer(svg_path,
(*marker.get_vector_data())->attributes()); (*marker.get_vector_data())->attributes());
svg_renderer.render_id(*ras_ptr, sl, renb, feature->id(), mtx, opacity, bbox); svg_renderer.render_id(*ras_ptr, sl, renb, feature.id(), mtx, opacity, bbox);
} }
else else
@ -143,7 +143,7 @@ void grid_renderer<T>::render_marker(mapnik::feature_ptr const& feature, unsigne
image_data_32 const& data = **marker.get_bitmap_data(); image_data_32 const& data = **marker.get_bitmap_data();
if (step == 1 && scale_factor_ == 1.0) if (step == 1 && scale_factor_ == 1.0)
{ {
pixmap_.set_rectangle(feature->id(), data, pixmap_.set_rectangle(feature.id(), data,
boost::math::iround(pos.x), boost::math::iround(pos.x),
boost::math::iround(pos.y)); boost::math::iround(pos.y));
} }
@ -153,7 +153,7 @@ void grid_renderer<T>::render_marker(mapnik::feature_ptr const& feature, unsigne
image_data_32 target(ratio * data.width(), ratio * data.height()); image_data_32 target(ratio * data.width(), ratio * data.height());
mapnik::scale_image_agg<image_data_32>(target,data, SCALING_NEAR, mapnik::scale_image_agg<image_data_32>(target,data, SCALING_NEAR,
scale_factor_, 0.0, 0.0, 1.0, ratio); scale_factor_, 0.0, 0.0, 1.0, ratio);
pixmap_.set_rectangle(feature->id(), target, pixmap_.set_rectangle(feature.id(), target,
boost::math::iround(pos.x), boost::math::iround(pos.x),
boost::math::iround(pos.y)); boost::math::iround(pos.y));
} }

View file

@ -43,7 +43,7 @@ namespace mapnik
template <typename T> template <typename T>
void grid_renderer<T>::process(building_symbolizer const& sym, void grid_renderer<T>::process(building_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
@ -63,13 +63,13 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
expression_ptr height_expr = sym.height(); expression_ptr height_expr = sym.height();
if (height_expr) if (height_expr)
{ {
value_type result = boost::apply_visitor(evaluate<Feature,value_type>(*feature), *height_expr); value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature), *height_expr);
height = result.to_double() * scale_factor_; height = result.to_double() * scale_factor_;
} }
for (unsigned i=0;i<feature->num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)
{ {
geometry_type const& geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
boost::scoped_ptr<geometry_type> frame(new geometry_type(LineString)); boost::scoped_ptr<geometry_type> frame(new geometry_type(LineString));
@ -108,7 +108,7 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
path_type faces_path (t_,*faces,prj_trans); path_type faces_path (t_,*faces,prj_trans);
ras_ptr->add_path(faces_path); ras_ptr->add_path(faces_path);
ren.color(mapnik::gray32(feature->id())); ren.color(mapnik::gray32(feature.id()));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
ras_ptr->reset(); ras_ptr->reset();
@ -135,13 +135,13 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
path_type path(t_,*frame,prj_trans); path_type path(t_,*frame,prj_trans);
agg::conv_stroke<path_type> stroke(path); agg::conv_stroke<path_type> stroke(path);
ras_ptr->add_path(stroke); ras_ptr->add_path(stroke);
ren.color(mapnik::gray32(feature->id())); ren.color(mapnik::gray32(feature.id()));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
ras_ptr->reset(); ras_ptr->reset();
path_type roof_path (t_,*roof,prj_trans); path_type roof_path (t_,*roof,prj_trans);
ras_ptr->add_path(roof_path); ras_ptr->add_path(roof_path);
ren.color(mapnik::gray32(feature->id())); ren.color(mapnik::gray32(feature.id()));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
} }
} }
@ -149,7 +149,7 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
} }
template void grid_renderer<grid>::process(building_symbolizer const&, template void grid_renderer<grid>::process(building_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -42,7 +42,7 @@ namespace mapnik {
template <typename T> template <typename T>
void grid_renderer<T>::process(line_pattern_symbolizer const& sym, void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
@ -61,9 +61,9 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
// TODO - actually handle image dimensions // TODO - actually handle image dimensions
int stroke_width = 2; int stroke_width = 2;
for (unsigned i=0;i<feature->num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)
{ {
geometry_type & geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
if (geom.num_points() > 1) if (geom.num_points() > 1)
{ {
path_type path(t_,geom,prj_trans); path_type path(t_,geom,prj_trans);
@ -75,7 +75,7 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
} }
// render id // render id
ren.color(mapnik::gray32(feature->id())); ren.color(mapnik::gray32(feature.id()));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
// add feature properties to grid cache // add feature properties to grid cache
@ -85,7 +85,7 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
template void grid_renderer<grid>::process(line_pattern_symbolizer const&, template void grid_renderer<grid>::process(line_pattern_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -42,7 +42,7 @@ namespace mapnik {
template <typename T> template <typename T>
void grid_renderer<T>::process(line_symbolizer const& sym, void grid_renderer<T>::process(line_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
@ -60,9 +60,9 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
stroke const& stroke_ = sym.get_stroke(); stroke const& stroke_ = sym.get_stroke();
for (unsigned i=0;i<feature->num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)
{ {
geometry_type & geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
if (geom.num_points() > 1) if (geom.num_points() > 1)
{ {
path_type path(t_,geom,prj_trans); path_type path(t_,geom,prj_trans);
@ -134,7 +134,7 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
} }
// render id // render id
ren.color(mapnik::gray32(feature->id())); ren.color(mapnik::gray32(feature.id()));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
// add feature properties to grid cache // add feature properties to grid cache
@ -144,7 +144,7 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
template void grid_renderer<grid>::process(line_symbolizer const&, template void grid_renderer<grid>::process(line_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -52,7 +52,7 @@ namespace mapnik {
template <typename T> template <typename T>
void grid_renderer<T>::process(markers_symbolizer const& sym, void grid_renderer<T>::process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
@ -69,10 +69,10 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
ras_ptr->reset(); ras_ptr->reset();
agg::trans_affine tr; agg::trans_affine tr;
evaluate_transform(tr, *feature, sym.get_image_transform()); evaluate_transform(tr, feature, sym.get_image_transform());
unsigned int res = pixmap_.get_resolution(); unsigned int res = pixmap_.get_resolution();
tr = agg::trans_affine_scaling(scale_factor_*(1.0/res)) * tr; tr = agg::trans_affine_scaling(scale_factor_*(1.0/res)) * tr;
std::string filename = path_processor_type::evaluate(*sym.get_filename(), *feature); std::string filename = path_processor_type::evaluate(*sym.get_filename(), feature);
marker_placement_e placement_method = sym.get_marker_placement(); marker_placement_e placement_method = sym.get_marker_placement();
marker_type_e marker_type = sym.get_marker_type(); marker_type_e marker_type = sym.get_marker_type();
@ -106,9 +106,9 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
mapnik::pixfmt_gray32 > svg_renderer(svg_path,(*marker)->attributes()); mapnik::pixfmt_gray32 > svg_renderer(svg_path,(*marker)->attributes());
bool placed = false; bool placed = false;
for (unsigned i=0; i<feature->num_geometries(); ++i) for (unsigned i=0; i<feature.num_geometries(); ++i)
{ {
geometry_type & geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1) if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1)
{ {
double x; double x;
@ -143,7 +143,7 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
{ {
placed = true; placed = true;
agg::trans_affine matrix = recenter * tr *agg::trans_affine_rotation(angle) * agg::trans_affine_translation(x, y); agg::trans_affine matrix = recenter * tr *agg::trans_affine_rotation(angle) * agg::trans_affine_translation(x, y);
svg_renderer.render_id(*ras_ptr, sl, renb, feature->id(), matrix, sym.get_opacity(),bbox); svg_renderer.render_id(*ras_ptr, sl, renb, feature.id(), matrix, sym.get_opacity(),bbox);
} }
} }
if (placed) if (placed)
@ -203,9 +203,9 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
double y; double y;
double z=0; double z=0;
for (unsigned i=0; i<feature->num_geometries(); ++i) for (unsigned i=0; i<feature.num_geometries(); ++i)
{ {
geometry_type & geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1) if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1)
{ {
geom.label_position(&x,&y); geom.label_position(&x,&y);
@ -284,13 +284,13 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
} }
} }
ren.color(mapnik::gray32(feature->id())); ren.color(mapnik::gray32(feature.id()));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
pixmap_.add_feature(feature); pixmap_.add_feature(feature);
} }
} }
template void grid_renderer<grid>::process(markers_symbolizer const&, template void grid_renderer<grid>::process(markers_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -38,10 +38,10 @@ namespace mapnik {
template <typename T> template <typename T>
void grid_renderer<T>::process(point_symbolizer const& sym, void grid_renderer<T>::process(point_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
std::string filename = path_processor_type::evaluate(*sym.get_filename(), *feature); std::string filename = path_processor_type::evaluate(*sym.get_filename(), feature);
boost::optional<mapnik::marker_ptr> marker; boost::optional<mapnik::marker_ptr> marker;
if ( !filename.empty() ) if ( !filename.empty() )
@ -56,11 +56,11 @@ void grid_renderer<T>::process(point_symbolizer const& sym,
if (marker) if (marker)
{ {
agg::trans_affine tr; agg::trans_affine tr;
evaluate_transform(tr, *feature, sym.get_image_transform()); evaluate_transform(tr, feature, sym.get_image_transform());
for (unsigned i=0; i<feature->num_geometries(); ++i) for (unsigned i=0; i<feature.num_geometries(); ++i)
{ {
geometry_type const& geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
double x; double x;
double y; double y;
double z=0; double z=0;
@ -95,7 +95,7 @@ void grid_renderer<T>::process(point_symbolizer const& sym,
} }
template void grid_renderer<grid>::process(point_symbolizer const&, template void grid_renderer<grid>::process(point_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -41,7 +41,7 @@ namespace mapnik {
template <typename T> template <typename T>
void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym, void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
@ -57,9 +57,9 @@ void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
ras_ptr->reset(); ras_ptr->reset();
for (unsigned i=0;i<feature->num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)
{ {
geometry_type & geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
path_type path(t_,geom,prj_trans); path_type path(t_,geom,prj_trans);
@ -68,7 +68,7 @@ void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
} }
// render id // render id
ren.color(mapnik::gray32(feature->id())); ren.color(mapnik::gray32(feature.id()));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
// add feature properties to grid cache // add feature properties to grid cache
@ -77,7 +77,7 @@ void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
template void grid_renderer<grid>::process(polygon_pattern_symbolizer const&, template void grid_renderer<grid>::process(polygon_pattern_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -41,7 +41,7 @@ namespace mapnik {
template <typename T> template <typename T>
void grid_renderer<T>::process(polygon_symbolizer const& sym, void grid_renderer<T>::process(polygon_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform<CoordTransform,geometry_type> path_type; typedef coord_transform<CoordTransform,geometry_type> path_type;
@ -56,9 +56,9 @@ void grid_renderer<T>::process(polygon_symbolizer const& sym,
renderer ren(renb); renderer ren(renb);
ras_ptr->reset(); ras_ptr->reset();
for (unsigned i=0;i<feature->num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)
{ {
geometry_type & geom = feature->get_geometry(i); geometry_type & geom = feature.get_geometry(i);
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
path_type path(t_,geom,prj_trans); path_type path(t_,geom,prj_trans);
@ -67,7 +67,7 @@ void grid_renderer<T>::process(polygon_symbolizer const& sym,
} }
// render id // render id
ren.color(mapnik::gray32(feature->id())); ren.color(mapnik::gray32(feature.id()));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
// add feature properties to grid cache // add feature properties to grid cache
@ -76,7 +76,7 @@ void grid_renderer<T>::process(polygon_symbolizer const& sym,
template void grid_renderer<grid>::process(polygon_symbolizer const&, template void grid_renderer<grid>::process(polygon_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -29,14 +29,14 @@ namespace mapnik {
template <typename T> template <typename T>
void grid_renderer<T>::process(raster_symbolizer const& sym, void grid_renderer<T>::process(raster_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
MAPNIK_LOG_WARN(grid_renderer) << "grid_renderer: raster_symbolizer is not yet supported"; MAPNIK_LOG_WARN(grid_renderer) << "grid_renderer: raster_symbolizer is not yet supported";
} }
template void grid_renderer<grid>::process(raster_symbolizer const&, template void grid_renderer<grid>::process(raster_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -38,13 +38,13 @@ namespace mapnik {
template <typename T> template <typename T>
void grid_renderer<T>::process(shield_symbolizer const& sym, void grid_renderer<T>::process(shield_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
box2d<double> query_extent; box2d<double> query_extent;
shield_symbolizer_helper<face_manager<freetype_engine>, shield_symbolizer_helper<face_manager<freetype_engine>,
label_collision_detector4> helper( label_collision_detector4> helper(
sym, *feature, prj_trans, sym, feature, prj_trans,
width_, height_, width_, height_,
scale_factor_, scale_factor_,
t_, font_manager_, detector_, query_extent); t_, font_manager_, detector_, query_extent);
@ -65,7 +65,7 @@ void grid_renderer<T>::process(shield_symbolizer const& sym,
sym.get_opacity()); sym.get_opacity());
ren.prepare_glyphs(&(placements[ii])); ren.prepare_glyphs(&(placements[ii]));
ren.render_id(feature->id(), placements[ii].center, 2); ren.render_id(feature.id(), placements[ii].center, 2);
} }
} }
if (placement_found) if (placement_found)
@ -73,7 +73,7 @@ void grid_renderer<T>::process(shield_symbolizer const& sym,
} }
template void grid_renderer<grid>::process(shield_symbolizer const&, template void grid_renderer<grid>::process(shield_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -28,13 +28,13 @@ namespace mapnik {
template <typename T> template <typename T>
void grid_renderer<T>::process(text_symbolizer const& sym, void grid_renderer<T>::process(text_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_impl & feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
box2d<double> query_extent; box2d<double> query_extent;
text_symbolizer_helper<face_manager<freetype_engine>, text_symbolizer_helper<face_manager<freetype_engine>,
label_collision_detector4> helper( label_collision_detector4> helper(
sym, *feature, prj_trans, sym, feature, prj_trans,
detector_.extent().width(), detector_.extent().height(), detector_.extent().width(), detector_.extent().height(),
scale_factor_ * (1.0/pixmap_.get_resolution()), scale_factor_ * (1.0/pixmap_.get_resolution()),
t_, font_manager_, detector_, t_, font_manager_, detector_,
@ -49,7 +49,7 @@ void grid_renderer<T>::process(text_symbolizer const& sym,
for (unsigned int ii = 0; ii < placements.size(); ++ii) for (unsigned int ii = 0; ii < placements.size(); ++ii)
{ {
ren.prepare_glyphs(&(placements[ii])); ren.prepare_glyphs(&(placements[ii]));
ren.render_id(feature->id(), placements[ii].center, 2); ren.render_id(feature.id(), placements[ii].center, 2);
} }
} }
if (placement_found) pixmap_.add_feature(feature); if (placement_found) pixmap_.add_feature(feature);
@ -57,7 +57,7 @@ void grid_renderer<T>::process(text_symbolizer const& sym,
} }
template void grid_renderer<grid>::process(text_symbolizer const&, template void grid_renderer<grid>::process(text_symbolizer const&,
mapnik::feature_ptr const&, mapnik::feature_impl &,
proj_transform const&); proj_transform const&);
} }

View file

@ -72,6 +72,16 @@ png_reader::png_reader(const std::string& fileName)
png_reader::~png_reader() {} png_reader::~png_reader() {}
void user_error_fn(png_structp png_ptr, png_const_charp error_msg)
{
throw image_reader_exception("failed to read invalid png");
}
void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg)
{
MAPNIK_LOG_DEBUG(png_reader) << "libpng warning: '" << warning_msg << "'";
}
static void static void
png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
@ -85,7 +95,6 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
} }
} }
void png_reader::init() void png_reader::init()
{ {
FILE *fp=fopen(fileName_.c_str(),"rb"); FILE *fp=fopen(fileName_.c_str(),"rb");
@ -111,19 +120,26 @@ void png_reader::init()
fclose(fp); fclose(fp);
throw image_reader_exception("failed to allocate png_ptr"); throw image_reader_exception("failed to allocate png_ptr");
} }
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
png_destroy_read_struct(&png_ptr,0,0);
fclose(fp);
throw image_reader_exception("failed to create info_ptr");
}
if (setjmp(png_jmpbuf(png_ptr))) // catch errors in a custom way to avoid the need for setjmp
png_set_error_fn(png_ptr, png_get_error_ptr(png_ptr), user_error_fn, user_warning_fn);
png_infop info_ptr;
try
{
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
png_destroy_read_struct(&png_ptr,0,0);
fclose(fp);
throw image_reader_exception("failed to create info_ptr");
}
}
catch (std::exception const& ex)
{ {
png_destroy_read_struct(&png_ptr,0,0); png_destroy_read_struct(&png_ptr,0,0);
fclose(fp); fclose(fp);
throw image_reader_exception("failed to read"); throw;
} }
png_set_read_fn(png_ptr, (png_voidp)fp, png_read_data); png_set_read_fn(png_ptr, (png_voidp)fp, png_read_data);
@ -167,19 +183,25 @@ void png_reader::read(unsigned x0, unsigned y0,image_data_32& image)
throw image_reader_exception("failed to allocate png_ptr"); throw image_reader_exception("failed to allocate png_ptr");
} }
png_infop info_ptr = png_create_info_struct(png_ptr); // catch errors in a custom way to avoid the need for setjmp
if (!info_ptr) png_set_error_fn(png_ptr, png_get_error_ptr(png_ptr), user_error_fn, user_warning_fn);
{
png_destroy_read_struct(&png_ptr,0,0);
fclose(fp);
throw image_reader_exception("failed to create info_ptr");
}
if (setjmp(png_jmpbuf(png_ptr))) png_infop info_ptr;
try
{
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
png_destroy_read_struct(&png_ptr,0,0);
fclose(fp);
throw image_reader_exception("failed to create info_ptr");
}
}
catch (std::exception const& ex)
{ {
png_destroy_read_struct(&png_ptr,0,0); png_destroy_read_struct(&png_ptr,0,0);
fclose(fp); fclose(fp);
throw image_reader_exception("failed to read"); throw;
} }
png_set_read_fn(png_ptr, (png_voidp)fp, png_read_data); png_set_read_fn(png_ptr, (png_voidp)fp, png_read_data);

View file

@ -139,10 +139,17 @@ void svg_parser::parse(std::string const& filename)
if (reader != 0) if (reader != 0)
{ {
int ret = xmlTextReaderRead(reader); int ret = xmlTextReaderRead(reader);
while (ret == 1) try {
while (ret == 1)
{
process_node(reader);
ret = xmlTextReaderRead(reader);
}
}
catch (std::exception const& ex)
{ {
process_node(reader); xmlFreeTextReader(reader);
ret = xmlTextReaderRead(reader); throw;
} }
xmlFreeTextReader(reader); xmlFreeTextReader(reader);
if (ret != 0) if (ret != 0)
@ -428,26 +435,34 @@ void svg_parser::parse_path(xmlTextReaderPtr reader)
value = xmlTextReaderGetAttribute(reader, BAD_CAST "d"); value = xmlTextReaderGetAttribute(reader, BAD_CAST "d");
if (value) if (value)
{ {
path_.begin_path(); // d="" (empty paths) are valid
if (strlen((const char*)value) < 1)
if (!mapnik::svg::parse_path((const char*) value, path_))
{ {
xmlFree(value); xmlFree(value);
xmlChar *id_value;
id_value = xmlTextReaderGetAttribute(reader, BAD_CAST "id");
if (id_value)
{
std::string id_string((const char *) id_value);
xmlFree(id_value);
throw std::runtime_error(std::string("unable to parse invalid svg <path> with id '") + id_string + "'");
}
else
{
throw std::runtime_error("unable to parse invalid svg <path>");
}
} }
path_.end_path(); else
xmlFree(value); {
path_.begin_path();
if (!mapnik::svg::parse_path((const char*) value, path_))
{
xmlFree(value);
xmlChar *id_value;
id_value = xmlTextReaderGetAttribute(reader, BAD_CAST "id");
if (id_value)
{
std::string id_string((const char *) id_value);
xmlFree(id_value);
throw std::runtime_error(std::string("unable to parse invalid svg <path> with id '") + id_string + "'");
}
else
{
throw std::runtime_error("unable to parse invalid svg <path>");
}
}
path_.end_path();
xmlFree(value);
}
} }
} }

View file

@ -27,13 +27,13 @@ def compare(fn1, fn2):
try: try:
im2 = Image.open(fn2) im2 = Image.open(fn2)
except IOError: except IOError:
errors.append((fn1, None, fn2)) errors.append((None, fn1, fn2))
return -1 return -1
diff = 0 diff = 0
pixels = im1.size[0] * im1.size[1] pixels = im1.size[0] * im1.size[1]
delta_pixels = im2.size[0] * im2.size[1] - pixels delta_pixels = im2.size[0] * im2.size[1] - pixels
if delta_pixels != 0: if delta_pixels != 0:
errors.append((fn1, delta_pixels, fn2)) errors.append((delta_pixels, fn1, fn2))
return delta_pixels return delta_pixels
im1 = im1.getdata() im1 = im1.getdata()
im2 = im2.getdata() im2 = im2.getdata()
@ -41,7 +41,7 @@ def compare(fn1, fn2):
if(compare_pixels(im1[i], im2[i])): if(compare_pixels(im1[i], im2[i])):
diff = diff + 1 diff = diff + 1
if diff != 0: if diff != 0:
errors.append((fn1, diff, fn2)) errors.append((diff, fn1, fn2))
passed += 1 passed += 1
return diff return diff
@ -52,10 +52,10 @@ def summary():
print "Visual text rendering summary:", print "Visual text rendering summary:",
if len(errors) != 0: if len(errors) != 0:
for error in errors: for error in errors:
if (error[1] is None): if (error[0] is None):
print "Could not verify %s: No reference image found!" % error[0] print "Could not verify %s: No reference image found!" % error[1]
else: else:
print "%s failed: %d different pixels \n\t%s (expected)" % error print "Failed: %d different pixels:\n\t%s (actual)\n\t%s (expected)" % error
sys.exit(1) sys.exit(1)
else: else:
print 'All %s tests passed: \x1b[1;32m✓ \x1b[0m' % passed print 'All %s tests passed: \x1b[1;32m✓ \x1b[0m' % passed