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()
|
void export_query()
|
||||||
{
|
{
|
||||||
using mapnik::query;
|
using mapnik::query;
|
||||||
|
//class_<query>("Query",init<
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,26 +34,26 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class MAPNIK_DECL agg_renderer : public feature_style_processor<agg_renderer<T> >,
|
class MAPNIK_DECL agg_renderer : public feature_style_processor<agg_renderer<T> >,
|
||||||
private boost::noncopyable
|
private boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
agg_renderer(Map const& m, T & pixmap);
|
agg_renderer(Map const& m, T & pixmap);
|
||||||
void start_map_processing(Map const& map);
|
void start_map_processing(Map const& map);
|
||||||
void end_map_processing(Map const& map);
|
void end_map_processing(Map const& map);
|
||||||
void start_layer_processing(Layer const& lay);
|
void start_layer_processing(Layer const& lay);
|
||||||
void end_layer_processing(Layer const& lay);
|
void end_layer_processing(Layer const& lay);
|
||||||
void process(point_symbolizer const& sym,Feature const& feature);
|
void process(point_symbolizer const& sym,Feature const& feature);
|
||||||
void process(line_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(line_pattern_symbolizer const& sym,Feature const& feature);
|
||||||
void process(polygon_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(polygon_pattern_symbolizer const& sym,Feature const& feature);
|
||||||
void process(raster_symbolizer const& sym,Feature const& feature);
|
void process(raster_symbolizer const& sym,Feature const& feature);
|
||||||
void process(text_symbolizer const& sym,Feature const& feature);
|
void process(text_symbolizer const& sym,Feature const& feature);
|
||||||
private:
|
private:
|
||||||
T & pixmap_;
|
T & pixmap_;
|
||||||
CoordTransform t_;
|
CoordTransform t_;
|
||||||
face_manager<freetype_engine> font_manager_;
|
face_manager<freetype_engine> font_manager_;
|
||||||
label_collision_detector2 detector_;
|
label_collision_detector2 detector_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ namespace mapnik
|
||||||
const std::vector<rule_type>& rules=style.get_rules();
|
const std::vector<rule_type>& rules=style.get_rules();
|
||||||
std::vector<rule_type>::const_iterator ruleIter=rules.begin();
|
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())
|
while (ruleIter!=rules.end())
|
||||||
{
|
{
|
||||||
if (ruleIter->active(scale))
|
if (ruleIter->active(scale))
|
||||||
|
|
|
@ -36,96 +36,74 @@ namespace mapnik
|
||||||
class query
|
class query
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Envelope<double> bbox_;
|
Envelope<double> bbox_;
|
||||||
unsigned width_;
|
filter<Feature>* filter_;
|
||||||
unsigned height_;
|
std::set<std::string> names_;
|
||||||
filter<Feature>* filter_;
|
|
||||||
std::set<std::string> names_;
|
|
||||||
public:
|
public:
|
||||||
query(unsigned width,unsigned height)
|
query()
|
||||||
: bbox_(std::numeric_limits<double>::min(),
|
: bbox_(std::numeric_limits<double>::min(),
|
||||||
std::numeric_limits<double>::min(),
|
std::numeric_limits<double>::min(),
|
||||||
std::numeric_limits<double>::max(),
|
std::numeric_limits<double>::max(),
|
||||||
std::numeric_limits<double>::max()),
|
std::numeric_limits<double>::max()),
|
||||||
width_(width),
|
filter_(new all_filter<Feature>)
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void add_property_name(const std::string& name)
|
query(const Envelope<double>& bbox)
|
||||||
{
|
: bbox_(bbox),
|
||||||
names_.insert(name);
|
filter_(new all_filter<Feature>)
|
||||||
}
|
{}
|
||||||
|
|
||||||
const std::set<std::string>& property_names() const
|
query(const Envelope<double>& bbox, const filter<Feature>& f)
|
||||||
{
|
: bbox_(bbox),
|
||||||
return names_;
|
filter_(f.clone())
|
||||||
}
|
{}
|
||||||
|
|
||||||
~query()
|
query(const query& other)
|
||||||
{
|
: bbox_(other.bbox_),
|
||||||
delete filter_;
|
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
|
struct raster
|
||||||
{
|
{
|
||||||
int x_;
|
Envelope<double> ext_;
|
||||||
int y_;
|
|
||||||
ImageData32 data_;
|
ImageData32 data_;
|
||||||
raster(int x,int y,ImageData32& data)
|
raster(Envelope<double> const ext,ImageData32& data)
|
||||||
: x_(x),
|
: ext_(ext),
|
||||||
y_(y),
|
|
||||||
data_(data) {}
|
data_(data) {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,13 @@
|
||||||
#include "image_util.hpp"
|
#include "image_util.hpp"
|
||||||
|
|
||||||
template <typename LookupPolicy>
|
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),
|
: policy_(policy),
|
||||||
id_(1),
|
id_(1),
|
||||||
extent_(q.get_bbox()),
|
extent_(q.get_bbox()),
|
||||||
t_(q.get_width(),q.get_height(),extent_),
|
|
||||||
curIter_(policy_.query(extent_)),
|
curIter_(policy_.query(extent_)),
|
||||||
endIter_(policy_.end())
|
endIter_(policy_.end())
|
||||||
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <typename LookupPolicy>
|
template <typename LookupPolicy>
|
||||||
|
@ -42,13 +41,13 @@ feature_ptr raster_featureset<LookupPolicy>::next()
|
||||||
{
|
{
|
||||||
if (curIter_!=endIter_)
|
if (curIter_!=endIter_)
|
||||||
{
|
{
|
||||||
feature_ptr feature(new Feature(+id_));
|
feature_ptr feature(new Feature(+id_));
|
||||||
try
|
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::auto_ptr<ImageReader> reader(get_image_reader(curIter_->format(),curIter_->file()));
|
||||||
std::clog<<reader.get()<<std::endl;
|
std::clog<<reader.get()<<std::endl;
|
||||||
if (reader.get())
|
if (reader.get())
|
||||||
{
|
{
|
||||||
int image_width=reader->width();
|
int image_width=reader->width();
|
||||||
int image_height=reader->height();
|
int image_height=reader->height();
|
||||||
|
@ -58,14 +57,9 @@ feature_ptr raster_featureset<LookupPolicy>::next()
|
||||||
Envelope<double> intersect=extent_.intersect(curIter_->envelope());
|
Envelope<double> intersect=extent_.intersect(curIter_->envelope());
|
||||||
Envelope<double> ext=t.forward(intersect);
|
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);
|
reader->read((int)ext.minx(),(int)ext.miny(),image);
|
||||||
|
feature->set_raster(raster_ptr(new raster(intersect,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)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,11 +67,9 @@ feature_ptr raster_featureset<LookupPolicy>::next()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
++curIter_;
|
++curIter_;
|
||||||
return feature;
|
return feature;
|
||||||
}
|
}
|
||||||
return feature_ptr();
|
return feature_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template class raster_featureset<single_file_policy>;
|
template class raster_featureset<single_file_policy>;
|
||||||
//template raster_featureset<os_name_policy>;
|
|
||||||
|
|
|
@ -34,71 +34,66 @@ class single_file_policy
|
||||||
public:
|
public:
|
||||||
class const_iterator
|
class const_iterator
|
||||||
{
|
{
|
||||||
enum {start,end};
|
enum {start,end};
|
||||||
bool status_;
|
bool status_;
|
||||||
const single_file_policy* p_;
|
const single_file_policy* p_;
|
||||||
public:
|
public:
|
||||||
explicit const_iterator(const single_file_policy* p)
|
explicit const_iterator(const single_file_policy* p)
|
||||||
:status_(start),
|
:status_(start),
|
||||||
p_(p) {}
|
p_(p) {}
|
||||||
|
|
||||||
const_iterator()
|
const_iterator()
|
||||||
:status_(end){}
|
:status_(end){}
|
||||||
|
|
||||||
const_iterator(const const_iterator& other)
|
const_iterator(const const_iterator& other)
|
||||||
:status_(other.status_),
|
:status_(other.status_),
|
||||||
p_(other.p_) {}
|
p_(other.p_) {}
|
||||||
|
|
||||||
const_iterator& operator++()
|
const_iterator& operator++()
|
||||||
{
|
{
|
||||||
status_=end;
|
status_=end;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
const raster_info& operator*() const
|
const raster_info& operator*() const
|
||||||
{
|
{
|
||||||
return p_->info_;
|
return p_->info_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const raster_info* operator->() const
|
const raster_info* operator->() const
|
||||||
{
|
{
|
||||||
return &(p_->info_);
|
return &(p_->info_);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const const_iterator& itr)
|
bool operator!=(const const_iterator& itr)
|
||||||
{
|
{
|
||||||
return status_!=itr.status_;
|
return status_!=itr.status_;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit single_file_policy(const raster_info& info)
|
explicit single_file_policy(const raster_info& info)
|
||||||
:info_(info) {}
|
:info_(info) {}
|
||||||
|
|
||||||
const_iterator begin()
|
const_iterator begin()
|
||||||
{
|
{
|
||||||
return const_iterator(this);
|
return const_iterator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator query(const Envelope<double>& box)
|
const_iterator query(const Envelope<double>& box)
|
||||||
{
|
{
|
||||||
if (box.intersects(info_.envelope()))
|
if (box.intersects(info_.envelope()))
|
||||||
{
|
{
|
||||||
return begin();
|
return begin();
|
||||||
}
|
}
|
||||||
return end();
|
return end();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator end()
|
const_iterator end()
|
||||||
{
|
{
|
||||||
return const_iterator();
|
return const_iterator();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class os_name_policy
|
|
||||||
{
|
|
||||||
//TODO
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename LookupPolicy>
|
template <typename LookupPolicy>
|
||||||
class raster_featureset : public Featureset
|
class raster_featureset : public Featureset
|
||||||
{
|
{
|
||||||
|
@ -106,7 +101,6 @@ class raster_featureset : public Featureset
|
||||||
LookupPolicy policy_;
|
LookupPolicy policy_;
|
||||||
size_t id_;
|
size_t id_;
|
||||||
Envelope<double> extent_;
|
Envelope<double> extent_;
|
||||||
CoordTransform t_;
|
|
||||||
iterator_type curIter_;
|
iterator_type curIter_;
|
||||||
iterator_type endIter_;
|
iterator_type endIter_;
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -124,7 +124,6 @@ void shape_datasource::init(shape_io& shape)
|
||||||
std::clog << "shape_type=" << shape_type << std::endl;
|
std::clog << "shape_type=" << shape_type << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int shape_datasource::type() const
|
int shape_datasource::type() const
|
||||||
{
|
{
|
||||||
return type_;
|
return type_;
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
|
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "image_util.hpp"
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
@ -389,7 +390,10 @@ namespace mapnik
|
||||||
raster_ptr const& raster=feature.get_raster();
|
raster_ptr const& raster=feature.get_raster();
|
||||||
if (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