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<
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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))
|
||||||
|
|
|
@ -37,39 +37,29 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Envelope<double> bbox_;
|
Envelope<double> bbox_;
|
||||||
unsigned width_;
|
|
||||||
unsigned height_;
|
|
||||||
filter<Feature>* filter_;
|
filter<Feature>* filter_;
|
||||||
std::set<std::string> names_;
|
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),
|
|
||||||
height_(height),
|
|
||||||
filter_(new all_filter<Feature>)
|
filter_(new all_filter<Feature>)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
query(const Envelope<double>& bbox,unsigned width,unsigned height)
|
query(const Envelope<double>& bbox)
|
||||||
: bbox_(bbox),
|
: bbox_(bbox),
|
||||||
width_(width),
|
|
||||||
height_(height),
|
|
||||||
filter_(new all_filter<Feature>)
|
filter_(new all_filter<Feature>)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
query(const Envelope<double>& bbox,unsigned width,unsigned height,const filter<Feature>& f)
|
query(const Envelope<double>& bbox, const filter<Feature>& f)
|
||||||
: bbox_(bbox),
|
: bbox_(bbox),
|
||||||
width_(width),
|
|
||||||
height_(height),
|
|
||||||
filter_(f.clone())
|
filter_(f.clone())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
query(const query& other)
|
query(const query& other)
|
||||||
: bbox_(other.bbox_),
|
: bbox_(other.bbox_),
|
||||||
width_(other.width_),
|
|
||||||
height_(other.height_),
|
|
||||||
filter_(other.filter_->clone())
|
filter_(other.filter_->clone())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -79,8 +69,6 @@ namespace mapnik
|
||||||
delete filter_;
|
delete filter_;
|
||||||
filter_=tmp;
|
filter_=tmp;
|
||||||
bbox_=other.bbox_;
|
bbox_=other.bbox_;
|
||||||
width_=other.width_;
|
|
||||||
height_=other.height_;
|
|
||||||
names_=other.names_;
|
names_=other.names_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -95,16 +83,6 @@ namespace mapnik
|
||||||
return bbox_;
|
return bbox_;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned get_width() const
|
|
||||||
{
|
|
||||||
return width_;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned get_height() const
|
|
||||||
{
|
|
||||||
return height_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_filter(const filter<Feature>& f)
|
void set_filter(const filter<Feature>& f)
|
||||||
{
|
{
|
||||||
filter<Feature>* tmp=f.clone();
|
filter<Feature>* tmp=f.clone();
|
||||||
|
|
|
@ -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>
|
||||||
|
@ -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)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,6 +72,4 @@ feature_ptr raster_featureset<LookupPolicy>::next()
|
||||||
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>;
|
|
||||||
|
|
|
@ -94,11 +94,6 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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