diff --git a/bindings/python/mapnik_query.cpp b/bindings/python/mapnik_query.cpp index 83a3aec30..becc48ef3 100644 --- a/bindings/python/mapnik_query.cpp +++ b/bindings/python/mapnik_query.cpp @@ -27,7 +27,7 @@ void export_query() { using mapnik::query; - + //class_("Query",init< } diff --git a/include/agg_renderer.hpp b/include/agg_renderer.hpp index cb35e90d6..31c655938 100644 --- a/include/agg_renderer.hpp +++ b/include/agg_renderer.hpp @@ -34,26 +34,26 @@ namespace mapnik { template class MAPNIK_DECL agg_renderer : public feature_style_processor >, - private boost::noncopyable + private boost::noncopyable { public: - agg_renderer(Map const& m, T & pixmap); - void start_map_processing(Map const& map); - void end_map_processing(Map const& map); - void start_layer_processing(Layer const& lay); - void end_layer_processing(Layer const& lay); - void process(point_symbolizer const& sym,Feature const& feature); - void process(line_symbolizer const& sym,Feature const& feature); - void process(line_pattern_symbolizer const& sym,Feature const& feature); - void process(polygon_symbolizer const& sym,Feature const& feature); - void process(polygon_pattern_symbolizer const& sym,Feature const& feature); - void process(raster_symbolizer const& sym,Feature const& feature); - void process(text_symbolizer const& sym,Feature const& feature); + agg_renderer(Map const& m, T & pixmap); + void start_map_processing(Map const& map); + void end_map_processing(Map const& map); + void start_layer_processing(Layer const& lay); + void end_layer_processing(Layer const& lay); + void process(point_symbolizer const& sym,Feature const& feature); + void process(line_symbolizer const& sym,Feature const& feature); + void process(line_pattern_symbolizer const& sym,Feature const& feature); + void process(polygon_symbolizer const& sym,Feature const& feature); + void process(polygon_pattern_symbolizer const& sym,Feature const& feature); + void process(raster_symbolizer const& sym,Feature const& feature); + void process(text_symbolizer const& sym,Feature const& feature); private: - T & pixmap_; - CoordTransform t_; - face_manager font_manager_; - label_collision_detector2 detector_; + T & pixmap_; + CoordTransform t_; + face_manager font_manager_; + label_collision_detector2 detector_; }; } diff --git a/include/feature_style_processor.hpp b/include/feature_style_processor.hpp index ce790280d..3b38f4cf8 100644 --- a/include/feature_style_processor.hpp +++ b/include/feature_style_processor.hpp @@ -103,7 +103,7 @@ namespace mapnik const std::vector& rules=style.get_rules(); std::vector::const_iterator ruleIter=rules.begin(); - query q(bbox,m_.getWidth(),m_.getHeight()); + query q(bbox); //BBOX query while (ruleIter!=rules.end()) { if (ruleIter->active(scale)) diff --git a/include/query.hpp b/include/query.hpp index c76c85b65..7cfdf7a8f 100644 --- a/include/query.hpp +++ b/include/query.hpp @@ -36,96 +36,74 @@ namespace mapnik class query { private: - Envelope bbox_; - unsigned width_; - unsigned height_; - filter* filter_; - std::set names_; + Envelope bbox_; + filter* filter_; + std::set names_; public: - query(unsigned width,unsigned height) - : bbox_(std::numeric_limits::min(), - std::numeric_limits::min(), - std::numeric_limits::max(), - std::numeric_limits::max()), - width_(width), - height_(height), - filter_(new all_filter) - {} - - query(const Envelope& bbox,unsigned width,unsigned height) - : bbox_(bbox), - width_(width), - height_(height), - filter_(new all_filter) - {} - - query(const Envelope& bbox,unsigned width,unsigned height,const filter& f) - : bbox_(bbox), - width_(width), - height_(height), - filter_(f.clone()) - {} - - query(const query& other) - : bbox_(other.bbox_), - width_(other.width_), - height_(other.height_), - filter_(other.filter_->clone()) - {} - - query& operator=(const query& other) - { - filter* tmp=other.filter_->clone(); - delete filter_; - filter_=tmp; - bbox_=other.bbox_; - width_=other.width_; - height_=other.height_; - names_=other.names_; - return *this; - } - - const filter* get_filter() const - { - return filter_; - } - - const Envelope& get_bbox() const - { - return bbox_; - } - - unsigned get_width() const - { - return width_; - } - - unsigned get_height() const - { - return height_; - } - - void set_filter(const filter& f) - { - filter* tmp=f.clone(); - delete filter_; - filter_=tmp; - } + query() + : bbox_(std::numeric_limits::min(), + std::numeric_limits::min(), + std::numeric_limits::max(), + std::numeric_limits::max()), + filter_(new all_filter) + {} - void add_property_name(const std::string& name) - { - names_.insert(name); - } + query(const Envelope& bbox) + : bbox_(bbox), + filter_(new all_filter) + {} - const std::set& property_names() const - { - return names_; - } + query(const Envelope& bbox, const filter& f) + : bbox_(bbox), + filter_(f.clone()) + {} - ~query() - { - delete filter_; - } + query(const query& other) + : bbox_(other.bbox_), + filter_(other.filter_->clone()) + {} + + query& operator=(const query& other) + { + filter* tmp=other.filter_->clone(); + delete filter_; + filter_=tmp; + bbox_=other.bbox_; + names_=other.names_; + return *this; + } + + const filter* get_filter() const + { + return filter_; + } + + const Envelope& get_bbox() const + { + return bbox_; + } + + void set_filter(const filter& f) + { + filter* tmp=f.clone(); + delete filter_; + filter_=tmp; + } + + void add_property_name(const std::string& name) + { + names_.insert(name); + } + + const std::set& property_names() const + { + return names_; + } + + ~query() + { + delete filter_; + } }; } diff --git a/include/raster.hpp b/include/raster.hpp index 8bdab4087..8a975f45b 100644 --- a/include/raster.hpp +++ b/include/raster.hpp @@ -30,12 +30,10 @@ namespace mapnik { struct raster { - int x_; - int y_; + Envelope ext_; ImageData32 data_; - raster(int x,int y,ImageData32& data) - : x_(x), - y_(y), + raster(Envelope const ext,ImageData32& data) + : ext_(ext), data_(data) {} }; } diff --git a/plugins/input/raster/raster_featureset.cpp b/plugins/input/raster/raster_featureset.cpp index d3b9c6499..479f9d141 100644 --- a/plugins/input/raster/raster_featureset.cpp +++ b/plugins/input/raster/raster_featureset.cpp @@ -24,14 +24,13 @@ #include "image_util.hpp" template -raster_featureset::raster_featureset(LookupPolicy const& policy,query const& q) +raster_featureset::raster_featureset(LookupPolicy const& policy, + query const& q) : policy_(policy), id_(1), extent_(q.get_bbox()), - t_(q.get_width(),q.get_height(),extent_), curIter_(policy_.query(extent_)), endIter_(policy_.end()) - {} template @@ -42,13 +41,13 @@ feature_ptr raster_featureset::next() { if (curIter_!=endIter_) { - feature_ptr feature(new Feature(+id_)); + feature_ptr feature(new Feature(+id_)); try { - std::clog<<"raster_featureset "<format()<<" "<file()<format()<<" "<file()< reader(get_image_reader(curIter_->format(),curIter_->file())); - std::clog<width(); int image_height=reader->height(); @@ -58,14 +57,9 @@ feature_ptr raster_featureset::next() Envelope intersect=extent_.intersect(curIter_->envelope()); Envelope ext=t.forward(intersect); - Envelope image_ext=t_.forward(intersect); - - ImageData32 image((int)ext.width(),(int)ext.height()); + ImageData32 image((int)ext.width(),(int)ext.height()); reader->read((int)ext.minx(),(int)ext.miny(),image); - - ImageData32 target((int)(image_ext.width()+0.5),(int)(image_ext.height()+0.5)); - scale_image(target,image); - feature->set_raster(raster_ptr(new raster(int(image_ext.minx()+0.5),int(image_ext.miny()+0.5),target))); + feature->set_raster(raster_ptr(new raster(intersect,image))); } } } @@ -73,11 +67,9 @@ feature_ptr raster_featureset::next() { } ++curIter_; - return feature; + return feature; } return feature_ptr(); } - template class raster_featureset; -//template raster_featureset; diff --git a/plugins/input/raster/raster_featureset.hpp b/plugins/input/raster/raster_featureset.hpp index 4f4b4f66b..fe3b6cea1 100644 --- a/plugins/input/raster/raster_featureset.hpp +++ b/plugins/input/raster/raster_featureset.hpp @@ -34,71 +34,66 @@ class single_file_policy public: class const_iterator { - enum {start,end}; - bool status_; - const single_file_policy* p_; + enum {start,end}; + bool status_; + const single_file_policy* p_; public: - explicit const_iterator(const single_file_policy* p) - :status_(start), - p_(p) {} + explicit const_iterator(const single_file_policy* p) + :status_(start), + p_(p) {} - const_iterator() - :status_(end){} + const_iterator() + :status_(end){} - const_iterator(const const_iterator& other) - :status_(other.status_), - p_(other.p_) {} + const_iterator(const const_iterator& other) + :status_(other.status_), + p_(other.p_) {} - const_iterator& operator++() - { - status_=end; - return *this; - } + const_iterator& operator++() + { + status_=end; + return *this; + } - const raster_info& operator*() const - { - return p_->info_; - } + const raster_info& operator*() const + { + return p_->info_; + } - const raster_info* operator->() const - { - return &(p_->info_); - } + const raster_info* operator->() const + { + return &(p_->info_); + } - bool operator!=(const const_iterator& itr) - { - return status_!=itr.status_; - } + bool operator!=(const const_iterator& itr) + { + return status_!=itr.status_; + } }; explicit single_file_policy(const raster_info& info) - :info_(info) {} + :info_(info) {} const_iterator begin() { - return const_iterator(this); + return const_iterator(this); } const_iterator query(const Envelope& box) { - if (box.intersects(info_.envelope())) - { - return begin(); - } - return end(); + if (box.intersects(info_.envelope())) + { + return begin(); + } + return end(); } const_iterator end() { - return const_iterator(); + return const_iterator(); } }; -class os_name_policy -{ - //TODO -}; - template class raster_featureset : public Featureset { @@ -106,7 +101,6 @@ class raster_featureset : public Featureset LookupPolicy policy_; size_t id_; Envelope extent_; - CoordTransform t_; iterator_type curIter_; iterator_type endIter_; public: diff --git a/plugins/input/shape/shape.cpp b/plugins/input/shape/shape.cpp index 99454efdd..f50748418 100644 --- a/plugins/input/shape/shape.cpp +++ b/plugins/input/shape/shape.cpp @@ -124,7 +124,6 @@ void shape_datasource::init(shape_io& shape) std::clog << "shape_type=" << shape_type << std::endl; } - int shape_datasource::type() const { return type_; diff --git a/src/agg_renderer.cpp b/src/agg_renderer.cpp index cd60dfcbe..f2c94bc28 100644 --- a/src/agg_renderer.cpp +++ b/src/agg_renderer.cpp @@ -55,6 +55,7 @@ #include #include +#include "image_util.hpp" namespace mapnik { @@ -389,7 +390,10 @@ namespace mapnik raster_ptr const& raster=feature.get_raster(); if (raster) { - pixmap_.set_rectangle(raster->x_,raster->y_,raster->data_); + Envelope ext=t_.forward(raster->ext_); + ImageData32 target((int)(ext.width() + 0.5),(int)(ext.height() + 0.5)); + scale_image(target,raster->data_); + pixmap_.set_rectangle(int(ext.minx()),int(ext.miny()),target); } }