Merge branch 'master' of github.com:mapnik/mapnik
This commit is contained in:
commit
b12e73fbc7
6 changed files with 55 additions and 50 deletions
|
@ -87,7 +87,7 @@ struct feature_collection_grammar :
|
|||
features = lit("\"features\"")
|
||||
> lit(":")
|
||||
> lit('[')
|
||||
> feature(_val) % lit(',')
|
||||
> -(feature(_val) % lit(','))
|
||||
> lit(']')
|
||||
;
|
||||
|
||||
|
|
|
@ -279,29 +279,29 @@ struct feature_grammar :
|
|||
;
|
||||
|
||||
linestring_coordinates = eps[ _a = new_<geometry_type>(LineString)]
|
||||
> (points(_a) [push_back(_r1,_a)]
|
||||
> -(points(_a) [push_back(_r1,_a)]
|
||||
| eps[cleanup_(_a)][_pass = false])
|
||||
;
|
||||
|
||||
polygon_coordinates = eps[ _a = new_<geometry_type>(Polygon) ]
|
||||
> ((lit('[')
|
||||
> points(_a) % lit(',')
|
||||
> -(points(_a) % lit(','))
|
||||
> lit(']')) [push_back(_r1,_a)]
|
||||
| eps[cleanup_(_a)][_pass = false])
|
||||
;
|
||||
|
||||
multipoint_coordinates = lit('[')
|
||||
> (point_coordinates(_r1) % lit(','))
|
||||
> -(point_coordinates(_r1) % lit(','))
|
||||
> lit(']')
|
||||
;
|
||||
|
||||
multilinestring_coordinates = lit('[')
|
||||
> (linestring_coordinates(_r1) % lit(','))
|
||||
> -(linestring_coordinates(_r1) % lit(','))
|
||||
> lit(']')
|
||||
;
|
||||
|
||||
multipolygon_coordinates = lit('[')
|
||||
> (polygon_coordinates(_r1) % lit(','))
|
||||
> -(polygon_coordinates(_r1) % lit(','))
|
||||
> lit(']')
|
||||
;
|
||||
|
||||
|
@ -309,10 +309,9 @@ struct feature_grammar :
|
|||
;
|
||||
|
||||
// point
|
||||
point = (lit('[') > double_ > lit(',') > double_ > lit(']')) [push_vertex_(_r1,_r2,_1,_2)];
|
||||
point = lit('[') > -((double_ > lit(',') > double_)[push_vertex_(_r1,_r2,_1,_2)]) > lit(']');
|
||||
// points
|
||||
points = lit('[')[_a = SEG_MOVETO] > point (_a,_r1) % lit(',') [_a = SEG_LINETO] > lit(']');
|
||||
|
||||
points = lit('[')[_a = SEG_MOVETO] > -(point (_a,_r1) % lit(',')[_a = SEG_LINETO]) > lit(']');
|
||||
on_error<fail>
|
||||
(
|
||||
feature
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
// boost
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
@ -129,11 +128,9 @@ std::map<std::string, mapnik::parameters> geojson_datasource::get_statistics() c
|
|||
return statistics_;
|
||||
}
|
||||
|
||||
// FIXME: implement
|
||||
mapnik::box2d<double> geojson_datasource::envelope() const
|
||||
{
|
||||
if (!is_bound_) bind();
|
||||
|
||||
return extent_;
|
||||
}
|
||||
|
||||
|
@ -149,9 +146,12 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons
|
|||
if (!is_bound_) bind();
|
||||
|
||||
// if the query box intersects our world extent then query for features
|
||||
if (extent_.intersects(q.get_bbox()))
|
||||
mapnik::box2d<double> const& b = q.get_bbox();
|
||||
if (extent_.intersects(b))
|
||||
{
|
||||
return boost::make_shared<geojson_featureset>(features_,tree_);
|
||||
box_type box(point_type(b.minx(),b.miny()),point_type(b.maxx(),b.maxy()));
|
||||
index_array_ = tree_.find(box);
|
||||
return boost::make_shared<geojson_featureset>(features_, index_array_.begin(), index_array_.end());
|
||||
}
|
||||
// otherwise return an empty featureset pointer
|
||||
return mapnik::featureset_ptr();
|
||||
|
|
|
@ -62,6 +62,7 @@ private:
|
|||
boost::shared_ptr<mapnik::transcoder> tr_;
|
||||
mutable std::vector<mapnik::feature_ptr> features_;
|
||||
mutable spatial_index_type tree_;
|
||||
mutable std::deque<std::size_t> index_array_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -30,22 +30,23 @@
|
|||
#include "geojson_featureset.hpp"
|
||||
|
||||
geojson_featureset::geojson_featureset(std::vector<mapnik::feature_ptr> const& features,
|
||||
geojson_datasource::spatial_index_type const& tree)
|
||||
: feature_id_(1),
|
||||
features_(features),
|
||||
tree_(tree) {}
|
||||
std::deque<std::size_t>::const_iterator index_itr,
|
||||
std::deque<std::size_t>::const_iterator index_end)
|
||||
: features_(features),
|
||||
index_itr_(index_itr),
|
||||
index_end_(index_end) {}
|
||||
|
||||
geojson_featureset::~geojson_featureset() {}
|
||||
|
||||
mapnik::feature_ptr geojson_featureset::next()
|
||||
{
|
||||
feature_id_++;
|
||||
if (feature_id_ <= features_.size())
|
||||
if (index_itr_ != index_end_)
|
||||
{
|
||||
return features_.at(feature_id_ - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return mapnik::feature_ptr();
|
||||
std::size_t index = *index_itr_++;
|
||||
if ( index < features_.size())
|
||||
{
|
||||
return features_.at(index);
|
||||
}
|
||||
}
|
||||
return mapnik::feature_ptr();
|
||||
}
|
||||
|
|
|
@ -2,22 +2,26 @@
|
|||
#define GEOJSON_FEATURESET_HPP
|
||||
|
||||
#include <mapnik/datasource.hpp>
|
||||
#include <vector>
|
||||
#include "geojson_datasource.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
|
||||
|
||||
class geojson_featureset : public mapnik::Featureset
|
||||
{
|
||||
public:
|
||||
geojson_featureset(std::vector<mapnik::feature_ptr> const& features,
|
||||
geojson_datasource::spatial_index_type const& tree);
|
||||
std::deque<std::size_t>::const_iterator index_itr,
|
||||
std::deque<std::size_t>::const_iterator index_end);
|
||||
virtual ~geojson_featureset();
|
||||
mapnik::feature_ptr next();
|
||||
|
||||
private:
|
||||
mapnik::box2d<double> box_;
|
||||
unsigned int feature_id_;
|
||||
std::vector<mapnik::feature_ptr> const& features_;
|
||||
geojson_datasource::spatial_index_type const& tree_;
|
||||
std::deque<std::size_t>::const_iterator index_itr_;
|
||||
std::deque<std::size_t>::const_iterator index_end_;
|
||||
};
|
||||
|
||||
#endif // GEOJSON_FEATURESET_HPP
|
||||
|
|
Loading…
Reference in a new issue