Metawriter: Only write features that are actually rendered.

This commit is contained in:
Hermann Kraus 2010-08-01 15:07:50 +00:00
parent 8f8903baa5
commit 0ae110015b
3 changed files with 7 additions and 0 deletions

View file

@ -94,6 +94,7 @@ public:
for (;metaItr!=metaItrEnd; ++metaItr) for (;metaItr!=metaItrEnd; ++metaItr)
{ {
metaItr->second->start(m_.metawriter_output_properties); metaItr->second->start(m_.metawriter_output_properties);
metaItr->second->set_size(m_.width(), m_.height());
} }
try try

View file

@ -80,10 +80,13 @@ class metawriter
CoordTransform const &t, CoordTransform const &t,
metawriter_properties const& properties = metawriter_properties())=0; metawriter_properties const& properties = metawriter_properties())=0;
virtual void start(metawriter_property_map const& properties) {}; virtual void start(metawriter_property_map const& properties) {};
void set_size(int width, int height) { width_ = width; height_ = height; }
virtual void stop() {}; virtual void stop() {};
metawriter_properties const& get_default_properties() const { return dflt_properties_;} metawriter_properties const& get_default_properties() const { return dflt_properties_;}
protected: protected:
metawriter_properties dflt_properties_; metawriter_properties dflt_properties_;
int width_;
int height_;
}; };
typedef boost::shared_ptr<metawriter> metawriter_ptr; typedef boost::shared_ptr<metawriter> metawriter_ptr;

View file

@ -105,6 +105,9 @@ void metawriter_json_stream::add_box(box2d<double> box, Feature const &feature,
output: WGS84 output: WGS84
*/ */
/* Check if feature is in bounds. */
if (box.maxx() < 0 || box.maxy() < 0 || box.minx() > width_ || box.miny() > height_) return;
proj_transform trans(prj_trans.source(), projection("+proj=latlong +datum=WGS84")); proj_transform trans(prj_trans.source(), projection("+proj=latlong +datum=WGS84"));
//t_ coord transform has transform for box2d combined with prj_trans //t_ coord transform has transform for box2d combined with prj_trans
box = t.backward(box, trans); box = t.backward(box, trans);