1.removed map width/height from query interface
2.small cleanups
This commit is contained in:
parent
93740b5dec
commit
2f360a6549
9 changed files with 136 additions and 171 deletions
|
@ -27,7 +27,7 @@
|
|||
void export_query()
|
||||
{
|
||||
using mapnik::query;
|
||||
|
||||
//class_<query>("Query",init<
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,26 +34,26 @@ namespace mapnik
|
|||
{
|
||||
template <typename T>
|
||||
class MAPNIK_DECL agg_renderer : public feature_style_processor<agg_renderer<T> >,
|
||||
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<freetype_engine> font_manager_;
|
||||
label_collision_detector2 detector_;
|
||||
T & pixmap_;
|
||||
CoordTransform t_;
|
||||
face_manager<freetype_engine> font_manager_;
|
||||
label_collision_detector2 detector_;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace mapnik
|
|||
const std::vector<rule_type>& rules=style.get_rules();
|
||||
std::vector<rule_type>::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))
|
||||
|
|
|
@ -36,96 +36,74 @@ namespace mapnik
|
|||
class query
|
||||
{
|
||||
private:
|
||||
Envelope<double> bbox_;
|
||||
unsigned width_;
|
||||
unsigned height_;
|
||||
filter<Feature>* filter_;
|
||||
std::set<std::string> names_;
|
||||
Envelope<double> bbox_;
|
||||
filter<Feature>* filter_;
|
||||
std::set<std::string> names_;
|
||||
public:
|
||||
query(unsigned width,unsigned height)
|
||||
: bbox_(std::numeric_limits<double>::min(),
|
||||
std::numeric_limits<double>::min(),
|
||||
std::numeric_limits<double>::max(),
|
||||
std::numeric_limits<double>::max()),
|
||||
width_(width),
|
||||
height_(height),
|
||||
filter_(new all_filter<Feature>)
|
||||
{}
|
||||
|
||||
query(const Envelope<double>& bbox,unsigned width,unsigned height)
|
||||
: bbox_(bbox),
|
||||
width_(width),
|
||||
height_(height),
|
||||
filter_(new all_filter<Feature>)
|
||||
{}
|
||||
|
||||
query(const Envelope<double>& bbox,unsigned width,unsigned height,const filter<Feature>& 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<Feature>* tmp=other.filter_->clone();
|
||||
delete filter_;
|
||||
filter_=tmp;
|
||||
bbox_=other.bbox_;
|
||||
width_=other.width_;
|
||||
height_=other.height_;
|
||||
names_=other.names_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const filter<Feature>* get_filter() const
|
||||
{
|
||||
return filter_;
|
||||
}
|
||||
|
||||
const Envelope<double>& get_bbox() const
|
||||
{
|
||||
return bbox_;
|
||||
}
|
||||
|
||||
unsigned get_width() const
|
||||
{
|
||||
return width_;
|
||||
}
|
||||
|
||||
unsigned get_height() const
|
||||
{
|
||||
return height_;
|
||||
}
|
||||
|
||||
void set_filter(const filter<Feature>& f)
|
||||
{
|
||||
filter<Feature>* tmp=f.clone();
|
||||
delete filter_;
|
||||
filter_=tmp;
|
||||
}
|
||||
query()
|
||||
: bbox_(std::numeric_limits<double>::min(),
|
||||
std::numeric_limits<double>::min(),
|
||||
std::numeric_limits<double>::max(),
|
||||
std::numeric_limits<double>::max()),
|
||||
filter_(new all_filter<Feature>)
|
||||
{}
|
||||
|
||||
void add_property_name(const std::string& name)
|
||||
{
|
||||
names_.insert(name);
|
||||
}
|
||||
query(const Envelope<double>& bbox)
|
||||
: bbox_(bbox),
|
||||
filter_(new all_filter<Feature>)
|
||||
{}
|
||||
|
||||
const std::set<std::string>& property_names() const
|
||||
{
|
||||
return names_;
|
||||
}
|
||||
query(const Envelope<double>& bbox, const filter<Feature>& 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<Feature>* tmp=other.filter_->clone();
|
||||
delete filter_;
|
||||
filter_=tmp;
|
||||
bbox_=other.bbox_;
|
||||
names_=other.names_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const filter<Feature>* get_filter() const
|
||||
{
|
||||
return filter_;
|
||||
}
|
||||
|
||||
const Envelope<double>& get_bbox() const
|
||||
{
|
||||
return bbox_;
|
||||
}
|
||||
|
||||
void set_filter(const filter<Feature>& f)
|
||||
{
|
||||
filter<Feature>* tmp=f.clone();
|
||||
delete filter_;
|
||||
filter_=tmp;
|
||||
}
|
||||
|
||||
void add_property_name(const std::string& name)
|
||||
{
|
||||
names_.insert(name);
|
||||
}
|
||||
|
||||
const std::set<std::string>& property_names() const
|
||||
{
|
||||
return names_;
|
||||
}
|
||||
|
||||
~query()
|
||||
{
|
||||
delete filter_;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -30,12 +30,10 @@ namespace mapnik
|
|||
{
|
||||
struct raster
|
||||
{
|
||||
int x_;
|
||||
int y_;
|
||||
Envelope<double> ext_;
|
||||
ImageData32 data_;
|
||||
raster(int x,int y,ImageData32& data)
|
||||
: x_(x),
|
||||
y_(y),
|
||||
raster(Envelope<double> const ext,ImageData32& data)
|
||||
: ext_(ext),
|
||||
data_(data) {}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -24,14 +24,13 @@
|
|||
#include "image_util.hpp"
|
||||
|
||||
template <typename LookupPolicy>
|
||||
raster_featureset<LookupPolicy>::raster_featureset(LookupPolicy const& policy,query const& q)
|
||||
raster_featureset<LookupPolicy>::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 <typename LookupPolicy>
|
||||
|
@ -42,13 +41,13 @@ feature_ptr raster_featureset<LookupPolicy>::next()
|
|||
{
|
||||
if (curIter_!=endIter_)
|
||||
{
|
||||
feature_ptr feature(new Feature(+id_));
|
||||
feature_ptr feature(new Feature(+id_));
|
||||
try
|
||||
{
|
||||
std::clog<<"raster_featureset "<<curIter_->format()<<" "<<curIter_->file()<<std::endl;
|
||||
std::clog<<"raster_featureset "<<curIter_->format()<<" "<<curIter_->file()<<std::endl;
|
||||
std::auto_ptr<ImageReader> reader(get_image_reader(curIter_->format(),curIter_->file()));
|
||||
std::clog<<reader.get()<<std::endl;
|
||||
if (reader.get())
|
||||
std::clog<<reader.get()<<std::endl;
|
||||
if (reader.get())
|
||||
{
|
||||
int image_width=reader->width();
|
||||
int image_height=reader->height();
|
||||
|
@ -58,14 +57,9 @@ feature_ptr raster_featureset<LookupPolicy>::next()
|
|||
Envelope<double> intersect=extent_.intersect(curIter_->envelope());
|
||||
Envelope<double> ext=t.forward(intersect);
|
||||
|
||||
Envelope<double> 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<ImageData32>(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<LookupPolicy>::next()
|
|||
{
|
||||
}
|
||||
++curIter_;
|
||||
return feature;
|
||||
return feature;
|
||||
}
|
||||
return feature_ptr();
|
||||
}
|
||||
|
||||
|
||||
template class raster_featureset<single_file_policy>;
|
||||
//template raster_featureset<os_name_policy>;
|
||||
|
|
|
@ -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<double>& 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 <typename LookupPolicy>
|
||||
class raster_featureset : public Featureset
|
||||
{
|
||||
|
@ -106,7 +101,6 @@ class raster_featureset : public Featureset
|
|||
LookupPolicy policy_;
|
||||
size_t id_;
|
||||
Envelope<double> extent_;
|
||||
CoordTransform t_;
|
||||
iterator_type curIter_;
|
||||
iterator_type endIter_;
|
||||
public:
|
||||
|
|
|
@ -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_;
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
|
||||
#include <boost/utility.hpp>
|
||||
#include <iostream>
|
||||
#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<double> ext=t_.forward(raster->ext_);
|
||||
ImageData32 target((int)(ext.width() + 0.5),(int)(ext.height() + 0.5));
|
||||
scale_image<ImageData32>(target,raster->data_);
|
||||
pixmap_.set_rectangle(int(ext.minx()),int(ext.miny()),target);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue