use mapnik geometry!

This commit is contained in:
artemp 2015-05-21 15:00:20 +01:00
parent 4debc817b5
commit 2e832586ab
2 changed files with 5 additions and 9 deletions

View file

@ -33,6 +33,7 @@
#include <mapnik/unicode.hpp> #include <mapnik/unicode.hpp>
#include <mapnik/value_types.hpp> #include <mapnik/value_types.hpp>
#include <mapnik/box2d.hpp> #include <mapnik/box2d.hpp>
#include <mapnik/geometry_adapters.hpp>
#include <mapnik/json/topojson_grammar.hpp> #include <mapnik/json/topojson_grammar.hpp>
#include <mapnik/json/topojson_utils.hpp> #include <mapnik/json/topojson_utils.hpp>
#include <mapnik/util/variant.hpp> #include <mapnik/util/variant.hpp>
@ -218,7 +219,7 @@ void topojson_datasource::parse_topojson(T const& buffer)
{ {
extent_.expand_to_include(box); extent_.expand_to_include(box);
} }
values.emplace_back(box_type(point_type(box.minx(),box.miny()),point_type(box.maxx(),box.maxy())), geometry_index); values.emplace_back(box, geometry_index);
++geometry_index; ++geometry_index;
} }
} }
@ -278,10 +279,9 @@ mapnik::layer_descriptor topojson_datasource::get_descriptor() const
mapnik::featureset_ptr topojson_datasource::features(mapnik::query const& q) const mapnik::featureset_ptr topojson_datasource::features(mapnik::query const& q) const
{ {
// if the query box intersects our world extent then query for features // if the query box intersects our world extent then query for features
mapnik::box2d<double> const& b = q.get_bbox(); mapnik::box2d<double> const& box = q.get_bbox();
if (extent_.intersects(b)) if (extent_.intersects(box))
{ {
box_type box(point_type(b.minx(),b.miny()),point_type(b.maxx(),b.maxy()));
topojson_featureset::array_type index_array; topojson_featureset::array_type index_array;
if (tree_) if (tree_)
{ {

View file

@ -39,8 +39,6 @@
#pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-local-typedef" #pragma GCC diagnostic ignored "-Wunused-local-typedef"
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/geometries/geometries.hpp> #include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry.hpp> #include <boost/geometry.hpp>
#include <boost/version.hpp> #include <boost/version.hpp>
@ -57,9 +55,7 @@
class topojson_datasource : public mapnik::datasource class topojson_datasource : public mapnik::datasource
{ {
public: public:
using point_type = boost::geometry::model::d2::point_xy<double>; using box_type = mapnik::box2d<double>;
using box_type = boost::geometry::model::box<point_type>;
using item_type = std::pair<box_type,std::size_t>; using item_type = std::pair<box_type,std::size_t>;
using linear_type = boost::geometry::index::linear<16,4>; using linear_type = boost::geometry::index::linear<16,4>;
using spatial_index_type = boost::geometry::index::rtree<item_type,linear_type>; using spatial_index_type = boost::geometry::index::rtree<item_type,linear_type>;