Compare commits
5 commits
master
...
mapnik-ind
Author | SHA1 | Date | |
---|---|---|---|
|
ae6b65d25b | ||
|
43d44da147 | ||
|
6e170a2e75 | ||
|
3b14da1210 | ||
|
af5e196d5f |
19 changed files with 110 additions and 102 deletions
|
@ -20,7 +20,7 @@ public:
|
|||
std::random_device rd;
|
||||
std::default_random_engine engine(rd());
|
||||
std::uniform_int_distribution<int> uniform_dist(0, 2048);
|
||||
quad_tree_type tree(mapnik::box2d<double>(0,0,2048,2048));
|
||||
quad_tree_type tree(mapnik::box2d<float>(0,0,2048,2048));
|
||||
//populate
|
||||
for (size_t i = 0; i < iterations_; ++i)
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ public:
|
|||
int cy = uniform_dist(engine);
|
||||
int sx = 0.2 * uniform_dist(engine);
|
||||
int sy = 0.2 * uniform_dist(engine);
|
||||
mapnik::box2d<double> box(cx - sx,cy - sy, cx + sx, cy + sy);
|
||||
mapnik::box2d<float> box(cx - sx,cy - sy, cx + sx, cy + sy);
|
||||
tree.insert(i, box);
|
||||
}
|
||||
// bounding box query
|
||||
|
@ -39,7 +39,7 @@ public:
|
|||
int cy = uniform_dist(engine);
|
||||
int sx = 0.4 * uniform_dist(engine);
|
||||
int sy = 0.4 * uniform_dist(engine);
|
||||
mapnik::box2d<double> box(cx - sx,cy - sy, cx + sx, cy + sy);
|
||||
mapnik::box2d<float> box(cx - sx,cy - sy, cx + sx, cy + sy);
|
||||
auto itr = tree.query_in_box(box);
|
||||
auto end = tree.query_end();
|
||||
for ( ;itr != end; ++itr)
|
||||
|
|
|
@ -196,28 +196,32 @@ inline bool point_on_path(double x,double y,Iter start,Iter end, double tol)
|
|||
}
|
||||
|
||||
// filters
|
||||
template <typename T = double>
|
||||
struct filter_in_box
|
||||
{
|
||||
box2d<double> box_;
|
||||
explicit filter_in_box(box2d<double> const& box)
|
||||
using value_type = T;
|
||||
box2d<value_type> box_;
|
||||
explicit filter_in_box(box2d<value_type> const& box)
|
||||
: box_(box) {}
|
||||
|
||||
bool pass(box2d<double> const& extent) const
|
||||
bool pass(box2d<value_type> const& extent) const
|
||||
{
|
||||
return extent.intersects(box_);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T = double>
|
||||
struct filter_at_point
|
||||
{
|
||||
box2d<double> box_;
|
||||
using value_type = T;
|
||||
box2d<value_type> box_;
|
||||
explicit filter_at_point(coord2d const& pt, double tol=0)
|
||||
: box_(pt,pt)
|
||||
{
|
||||
box_.pad(tol);
|
||||
}
|
||||
|
||||
bool pass(box2d<double> const& extent) const
|
||||
bool pass(box2d<value_type> const& extent) const
|
||||
{
|
||||
return extent.intersects(box_);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ private:
|
|||
// quad_tree based label collision detector
|
||||
class label_collision_detector2 : util::noncopyable
|
||||
{
|
||||
using tree_t = quad_tree<box2d<double> >;
|
||||
using tree_t = quad_tree<box2d<double>, box2d<double> >;
|
||||
tree_t tree_;
|
||||
public:
|
||||
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
// quad_tree based label collision detector with seperate check/insert
|
||||
class label_collision_detector3 : util::noncopyable
|
||||
{
|
||||
using tree_t = quad_tree< box2d<double> >;
|
||||
using tree_t = quad_tree< box2d<double>, box2d<double>>;
|
||||
tree_t tree_;
|
||||
public:
|
||||
|
||||
|
@ -141,7 +141,7 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
using tree_t = quad_tree< label >;
|
||||
using tree_t = quad_tree< label, box2d<double>>;
|
||||
tree_t tree_;
|
||||
|
||||
public:
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
namespace mapnik
|
||||
{
|
||||
template <typename T0, typename T1 = box2d<double>>
|
||||
template <typename T0, typename T1 = box2d<float>>
|
||||
class quad_tree : util::noncopyable
|
||||
{
|
||||
using value_type = T0;
|
||||
|
|
|
@ -47,7 +47,7 @@ bool check_spatial_index(InputStream& in)
|
|||
return (std::strncmp(header, "mapnik-index",12) == 0);
|
||||
}
|
||||
|
||||
template <typename Value, typename Filter, typename InputStream, typename BBox = box2d<double> >
|
||||
template <typename Value, typename Filter, typename InputStream, typename BBox = box2d<float> >
|
||||
class spatial_index
|
||||
{
|
||||
using bbox_type = BBox;
|
||||
|
|
|
@ -156,9 +156,10 @@ csv_datasource::csv_datasource(parameters const& params)
|
|||
using value_type = std::pair<std::size_t, std::size_t>;
|
||||
std::ifstream index(filename_ + ".index", std::ios::binary);
|
||||
if (!index) throw mapnik::datasource_exception("CSV Plugin: could not open: '" + filename_ + ".index'");
|
||||
extent_ = mapnik::util::spatial_index<value_type,
|
||||
mapnik::filter_in_box,
|
||||
std::ifstream>::bounding_box(index);
|
||||
auto extent = mapnik::util::spatial_index<value_type,
|
||||
mapnik::filter_in_box<float>,
|
||||
std::ifstream>::bounding_box(index);
|
||||
extent_ = mapnik::box2d<double>(extent); //conversion
|
||||
}
|
||||
//in.close(); no need to call close, rely on dtor
|
||||
}
|
||||
|
@ -320,10 +321,10 @@ csv_datasource::get_geometry_type_impl(std::istream & stream) const
|
|||
std::ifstream index(filename_ + ".index", std::ios::binary);
|
||||
if (!index) throw mapnik::datasource_exception("CSV Plugin: could not open: '" + filename_ + ".index'");
|
||||
|
||||
mapnik::filter_in_box filter(extent_);
|
||||
mapnik::filter_in_box<float> filter((mapnik::box2d<float>(extent_)));
|
||||
std::vector<value_type> positions;
|
||||
mapnik::util::spatial_index<value_type,
|
||||
mapnik::filter_in_box,
|
||||
mapnik::filter_in_box<float>,
|
||||
std::ifstream>::query_first_n(filter, index, positions, 5);
|
||||
int multi_type = 0;
|
||||
for (auto const& val : positions)
|
||||
|
@ -427,7 +428,7 @@ mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const
|
|||
}
|
||||
else if (has_disk_index_)
|
||||
{
|
||||
mapnik::filter_in_box filter(q.get_bbox());
|
||||
mapnik::filter_in_box<float> filter(mapnik::box2d<float>(q.get_bbox()));
|
||||
return std::make_shared<csv_index_featureset>(filename_, filter, locator_, separator_, quote_, headers_, ctx_);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <fstream>
|
||||
|
||||
csv_index_featureset::csv_index_featureset(std::string const& filename,
|
||||
mapnik::filter_in_box const& filter,
|
||||
mapnik::filter_in_box<float> const& filter,
|
||||
locator_type const& locator,
|
||||
char separator,
|
||||
char quote,
|
||||
|
@ -76,8 +76,9 @@ csv_index_featureset::csv_index_featureset(std::string const& filename,
|
|||
std::ifstream index(indexname.c_str(), std::ios::binary);
|
||||
if (!index) throw mapnik::datasource_exception("CSV Plugin: can't open index file " + indexname);
|
||||
mapnik::util::spatial_index<value_type,
|
||||
mapnik::filter_in_box,
|
||||
std::ifstream>::query(filter, index, positions_);
|
||||
mapnik::filter_in_box<float>,
|
||||
std::ifstream,
|
||||
mapnik::box2d<float>>::query(filter, index, positions_);
|
||||
|
||||
std::sort(positions_.begin(), positions_.end(),
|
||||
[](value_type const& lhs, value_type const& rhs) { return lhs.first < rhs.first;});
|
||||
|
|
|
@ -45,7 +45,7 @@ class csv_index_featureset : public mapnik::Featureset
|
|||
public:
|
||||
|
||||
csv_index_featureset(std::string const& filename,
|
||||
mapnik::filter_in_box const& filter,
|
||||
mapnik::filter_in_box<float> const& filter,
|
||||
locator_type const& locator,
|
||||
char separator,
|
||||
char quote,
|
||||
|
|
|
@ -222,14 +222,16 @@ void geojson_datasource::initialise_disk_index(std::string const& filename)
|
|||
using value_type = std::pair<std::size_t, std::size_t>;
|
||||
std::ifstream index(filename_ + ".index", std::ios::binary);
|
||||
if (!index) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + ".index'");
|
||||
extent_ = mapnik::util::spatial_index<value_type,
|
||||
mapnik::filter_in_box,
|
||||
std::ifstream>::bounding_box(index);
|
||||
mapnik::filter_in_box filter(extent_);
|
||||
extent_ = mapnik::box2d<double>(mapnik::util::spatial_index<value_type,
|
||||
mapnik::filter_in_box<float>,
|
||||
std::ifstream,
|
||||
mapnik::box2d<float>>::bounding_box(index));
|
||||
mapnik::filter_in_box<float> filter((mapnik::box2d<float>(extent_)));
|
||||
std::vector<value_type> positions;
|
||||
mapnik::util::spatial_index<value_type,
|
||||
mapnik::filter_in_box,
|
||||
std::ifstream>::query_first_n(filter, index, positions, num_features_to_query_);
|
||||
mapnik::filter_in_box<float>,
|
||||
std::ifstream,
|
||||
mapnik::box2d<float>>::query_first_n(filter, index, positions, num_features_to_query_);
|
||||
|
||||
mapnik::util::file file(filename_);
|
||||
if (!file) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + "'");
|
||||
|
@ -448,11 +450,12 @@ boost::optional<mapnik::datasource_geometry_t> geojson_datasource::get_geometry_
|
|||
using value_type = std::pair<std::size_t, std::size_t>;
|
||||
std::ifstream index(filename_ + ".index", std::ios::binary);
|
||||
if (!index) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + ".index'");
|
||||
mapnik::filter_in_box filter(extent_);
|
||||
mapnik::filter_in_box<float> filter((mapnik::box2d<float>(extent_)));
|
||||
std::vector<value_type> positions;
|
||||
mapnik::util::spatial_index<value_type,
|
||||
mapnik::filter_in_box,
|
||||
std::ifstream>::query_first_n(filter, index, positions, num_features_to_query_);
|
||||
mapnik::filter_in_box<float>,
|
||||
std::ifstream,
|
||||
mapnik::box2d<float>>::query_first_n(filter, index, positions, num_features_to_query_);
|
||||
|
||||
mapnik::util::file file(filename_);
|
||||
|
||||
|
@ -582,7 +585,7 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons
|
|||
}
|
||||
else if (has_disk_index_)
|
||||
{
|
||||
mapnik::filter_in_box filter(q.get_bbox());
|
||||
mapnik::filter_in_box<float> filter(mapnik::box2d<float>(q.get_bbox()));
|
||||
return std::make_shared<geojson_index_featureset>(filename_, filter);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
geojson_index_featureset::geojson_index_featureset(std::string const& filename, mapnik::filter_in_box const& filter)
|
||||
geojson_index_featureset::geojson_index_featureset(std::string const& filename, mapnik::filter_in_box<float> const& filter)
|
||||
:
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
//
|
||||
|
@ -63,8 +63,9 @@ geojson_index_featureset::geojson_index_featureset(std::string const& filename,
|
|||
std::ifstream index(indexname.c_str(), std::ios::binary);
|
||||
if (!index) throw mapnik::datasource_exception("GeoJSON Plugin: can't open index file " + indexname);
|
||||
mapnik::util::spatial_index<value_type,
|
||||
mapnik::filter_in_box,
|
||||
std::ifstream>::query(filter, index, positions_);
|
||||
mapnik::filter_in_box<float>,
|
||||
std::ifstream,
|
||||
mapnik::box2d<float>>::query(filter, index, positions_);
|
||||
|
||||
std::sort(positions_.begin(), positions_.end(),
|
||||
[](value_type const& lhs, value_type const& rhs) { return lhs.first < rhs.first;});
|
||||
|
|
|
@ -43,7 +43,7 @@ class geojson_index_featureset : public mapnik::Featureset
|
|||
{
|
||||
using value_type = std::pair<std::size_t, std::size_t>;
|
||||
public:
|
||||
geojson_index_featureset(std::string const& filename, mapnik::filter_in_box const& filter);
|
||||
geojson_index_featureset(std::string const& filename, mapnik::filter_in_box<float> const& filter);
|
||||
virtual ~geojson_index_featureset();
|
||||
mapnik::feature_ptr next();
|
||||
|
||||
|
|
|
@ -537,20 +537,20 @@ featureset_ptr ogr_datasource::features(query const& q) const
|
|||
|
||||
if (indexed_)
|
||||
{
|
||||
filter_in_box filter(q.get_bbox());
|
||||
filter_in_box<double> filter(q.get_bbox());
|
||||
|
||||
return featureset_ptr(new ogr_index_featureset<filter_in_box>(ctx,
|
||||
*layer,
|
||||
filter,
|
||||
index_name_,
|
||||
desc_.get_encoding()));
|
||||
return featureset_ptr(new ogr_index_featureset<filter_in_box<double> >(ctx,
|
||||
*layer,
|
||||
filter,
|
||||
index_name_,
|
||||
desc_.get_encoding()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return featureset_ptr(new ogr_featureset(ctx,
|
||||
*layer,
|
||||
q.get_bbox(),
|
||||
desc_.get_encoding()));
|
||||
*layer,
|
||||
q.get_bbox(),
|
||||
desc_.get_encoding()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -578,13 +578,13 @@ featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol)
|
|||
|
||||
if (indexed_)
|
||||
{
|
||||
filter_at_point filter(pt, tol);
|
||||
filter_at_point<double> filter(pt, tol);
|
||||
|
||||
return featureset_ptr(new ogr_index_featureset<filter_at_point> (ctx,
|
||||
*layer,
|
||||
filter,
|
||||
index_name_,
|
||||
desc_.get_encoding()));
|
||||
return featureset_ptr(new ogr_index_featureset<filter_at_point<double>> (ctx,
|
||||
*layer,
|
||||
filter,
|
||||
index_name_,
|
||||
desc_.get_encoding()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -207,5 +207,5 @@ feature_ptr ogr_index_featureset<filterT>::next()
|
|||
return feature_ptr();
|
||||
}
|
||||
|
||||
template class ogr_index_featureset<mapnik::filter_in_box>;
|
||||
template class ogr_index_featureset<mapnik::filter_at_point>;
|
||||
template class ogr_index_featureset<mapnik::filter_in_box<double>>;
|
||||
template class ogr_index_featureset<mapnik::filter_at_point<double>>;
|
||||
|
|
|
@ -236,25 +236,25 @@ featureset_ptr shape_datasource::features(query const& q) const
|
|||
mapnik::progress_timer __stats__(std::clog, "shape_datasource::features");
|
||||
#endif
|
||||
|
||||
filter_in_box filter(q.get_bbox());
|
||||
filter_in_box<float> filter(mapnik::box2d<float>(q.get_bbox()));
|
||||
if (indexed_)
|
||||
{
|
||||
std::unique_ptr<shape_io> shape_ptr = std::make_unique<shape_io>(shape_name_);
|
||||
return featureset_ptr
|
||||
(new shape_index_featureset<filter_in_box>(filter,
|
||||
std::move(shape_ptr),
|
||||
q.property_names(),
|
||||
desc_.get_encoding(),
|
||||
shape_name_,
|
||||
row_limit_));
|
||||
(new shape_index_featureset<filter_in_box<float> >(filter,
|
||||
std::move(shape_ptr),
|
||||
q.property_names(),
|
||||
desc_.get_encoding(),
|
||||
shape_name_,
|
||||
row_limit_));
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::make_shared<shape_featureset<filter_in_box> >(filter,
|
||||
shape_name_,
|
||||
q.property_names(),
|
||||
desc_.get_encoding(),
|
||||
row_limit_);
|
||||
return std::make_shared<shape_featureset<filter_in_box<float> > >(filter,
|
||||
shape_name_,
|
||||
q.property_names(),
|
||||
desc_.get_encoding(),
|
||||
row_limit_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol
|
|||
mapnik::progress_timer __stats__(std::clog, "shape_datasource::features_at_point");
|
||||
#endif
|
||||
|
||||
filter_at_point filter(pt,tol);
|
||||
filter_at_point<float> filter(pt, tol);
|
||||
// collect all attribute names
|
||||
auto const& desc = desc_.get_descriptors();
|
||||
std::set<std::string> names;
|
||||
|
@ -278,20 +278,20 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol
|
|||
{
|
||||
std::unique_ptr<shape_io> shape_ptr = std::make_unique<shape_io>(shape_name_);
|
||||
return featureset_ptr
|
||||
(new shape_index_featureset<filter_at_point>(filter,
|
||||
std::move(shape_ptr),
|
||||
names,
|
||||
desc_.get_encoding(),
|
||||
shape_name_,
|
||||
row_limit_));
|
||||
(new shape_index_featureset<filter_at_point<float> >(filter,
|
||||
std::move(shape_ptr),
|
||||
names,
|
||||
desc_.get_encoding(),
|
||||
shape_name_,
|
||||
row_limit_));
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::make_shared<shape_featureset<filter_at_point> >(filter,
|
||||
shape_name_,
|
||||
names,
|
||||
desc_.get_encoding(),
|
||||
row_limit_);
|
||||
return std::make_shared<shape_featureset<filter_at_point<float> > >(filter,
|
||||
shape_name_,
|
||||
names,
|
||||
desc_.get_encoding(),
|
||||
row_limit_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ feature_ptr shape_featureset<filterT>::next()
|
|||
{
|
||||
double x = record.read_double();
|
||||
double y = record.read_double();
|
||||
if (!filter_.pass(mapnik::box2d<double>(x,y,x,y)))
|
||||
if (!filter_.pass(mapnik::box2d<float>(x,y,x,y)))
|
||||
continue;
|
||||
feature->set_geometry(mapnik::geometry::point<double>(x,y));
|
||||
break;
|
||||
|
@ -105,7 +105,7 @@ feature_ptr shape_featureset<filterT>::next()
|
|||
case shape_io::shape_multipointz:
|
||||
{
|
||||
shape_io::read_bbox(record, feature_bbox_);
|
||||
if (!filter_.pass(feature_bbox_)) continue;
|
||||
if (!filter_.pass(mapnik::box2d<float>(feature_bbox_))) continue;
|
||||
int num_points = record.read_ndr_integer();
|
||||
mapnik::geometry::multi_point<double> multi_point;
|
||||
for (int i = 0; i < num_points; ++i)
|
||||
|
@ -123,7 +123,7 @@ feature_ptr shape_featureset<filterT>::next()
|
|||
case shape_io::shape_polylinez:
|
||||
{
|
||||
shape_io::read_bbox(record, feature_bbox_);
|
||||
if (!filter_.pass(feature_bbox_)) continue;
|
||||
if (!filter_.pass(mapnik::box2d<float>(feature_bbox_))) continue;
|
||||
feature->set_geometry(shape_io::read_polyline(record));
|
||||
break;
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ feature_ptr shape_featureset<filterT>::next()
|
|||
case shape_io::shape_polygonz:
|
||||
{
|
||||
shape_io::read_bbox(record, feature_bbox_);
|
||||
if (!filter_.pass(feature_bbox_)) continue;
|
||||
if (!filter_.pass(mapnik::box2d<float>(feature_bbox_))) continue;
|
||||
feature->set_geometry(shape_io::read_polygon(record));
|
||||
break;
|
||||
}
|
||||
|
@ -167,5 +167,5 @@ feature_ptr shape_featureset<filterT>::next()
|
|||
template <typename filterT>
|
||||
shape_featureset<filterT>::~shape_featureset() {}
|
||||
|
||||
template class shape_featureset<mapnik::filter_in_box>;
|
||||
template class shape_featureset<mapnik::filter_at_point>;
|
||||
template class shape_featureset<mapnik::filter_in_box<float>>;
|
||||
template class shape_featureset<mapnik::filter_at_point<float>>;
|
||||
|
|
|
@ -117,7 +117,7 @@ feature_ptr shape_index_featureset<filterT>::next()
|
|||
case shape_io::shape_multipointz:
|
||||
{
|
||||
shape_io::read_bbox(record, feature_bbox_);
|
||||
if (!filter_.pass(feature_bbox_)) continue;
|
||||
if (!filter_.pass(mapnik::box2d<float>(feature_bbox_))) continue;
|
||||
int num_points = record.read_ndr_integer();
|
||||
mapnik::geometry::multi_point<double> multi_point;
|
||||
for (int i = 0; i < num_points; ++i)
|
||||
|
@ -134,7 +134,7 @@ feature_ptr shape_index_featureset<filterT>::next()
|
|||
case shape_io::shape_polylinez:
|
||||
{
|
||||
shape_io::read_bbox(record, feature_bbox_);
|
||||
if (!filter_.pass(feature_bbox_)) continue;
|
||||
if (!filter_.pass(mapnik::box2d<float>(feature_bbox_))) continue;
|
||||
if (parts.size() < 2) feature->set_geometry(shape_io::read_polyline(record));
|
||||
else feature->set_geometry(shape_io::read_polyline_parts(record, parts));
|
||||
break;
|
||||
|
@ -144,7 +144,7 @@ feature_ptr shape_index_featureset<filterT>::next()
|
|||
case shape_io::shape_polygonz:
|
||||
{
|
||||
shape_io::read_bbox(record, feature_bbox_);
|
||||
if (!filter_.pass(feature_bbox_)) continue;
|
||||
if (!filter_.pass(mapnik::box2d<float>(feature_bbox_))) continue;
|
||||
if (parts.size() < 2) feature->set_geometry(shape_io::read_polygon(record));
|
||||
else feature->set_geometry(shape_io::read_polygon_parts(record, parts));
|
||||
break;
|
||||
|
@ -181,5 +181,5 @@ feature_ptr shape_index_featureset<filterT>::next()
|
|||
template <typename filterT>
|
||||
shape_index_featureset<filterT>::~shape_index_featureset() {}
|
||||
|
||||
template class shape_index_featureset<mapnik::filter_in_box>;
|
||||
template class shape_index_featureset<mapnik::filter_at_point>;
|
||||
template class shape_index_featureset<mapnik::filter_in_box<float>>;
|
||||
template class shape_index_featureset<mapnik::filter_at_point<float>>;
|
||||
|
|
|
@ -33,7 +33,7 @@ TEST_CASE("spatial_index")
|
|||
using value_type = std::int32_t;
|
||||
using mapnik::filter_in_box;
|
||||
mapnik::box2d<double> extent(0,0,100,100);
|
||||
mapnik::quad_tree<value_type> tree(extent);
|
||||
mapnik::quad_tree<value_type,mapnik::box2d<double>> tree(extent);
|
||||
REQUIRE(tree.extent() == extent);
|
||||
// insert some items
|
||||
tree.insert(1, mapnik::box2d<double>(10,10,20,20));
|
||||
|
@ -55,12 +55,12 @@ TEST_CASE("spatial_index")
|
|||
|
||||
// read bounding box
|
||||
std::istringstream in(out.str(), std::ios::binary);
|
||||
auto box = mapnik::util::spatial_index<value_type, filter_in_box, std::istringstream>::bounding_box(in);
|
||||
auto box = mapnik::util::spatial_index<value_type, filter_in_box<double>, std::istringstream, mapnik::box2d<double>>::bounding_box(in);
|
||||
REQUIRE(box == tree.extent());
|
||||
// bounding box query
|
||||
std::vector<value_type> results;
|
||||
filter_in_box filter(box);
|
||||
mapnik::util::spatial_index<value_type, filter_in_box, std::istringstream>::query(filter, in, results);
|
||||
filter_in_box<double> filter(box);
|
||||
mapnik::util::spatial_index<value_type, filter_in_box<double>, std::istringstream, mapnik::box2d<double>>::query(filter, in, results);
|
||||
|
||||
REQUIRE(results[0] == 1);
|
||||
REQUIRE(results[1] == 4);
|
||||
|
@ -71,13 +71,13 @@ TEST_CASE("spatial_index")
|
|||
// query first N elements interface
|
||||
results.clear();
|
||||
in.seekg(0, std::ios::beg);
|
||||
mapnik::util::spatial_index<value_type, filter_in_box, std::istringstream>::query_first_n(filter, in, results, 2);
|
||||
mapnik::util::spatial_index<value_type, filter_in_box<double>, std::istringstream, mapnik::box2d<double>>::query_first_n(filter, in, results, 2);
|
||||
REQUIRE(results.size() == 2);
|
||||
REQUIRE(results[0] == 1);
|
||||
REQUIRE(results[1] == 4);
|
||||
results.clear();
|
||||
in.seekg(0, std::ios::beg);
|
||||
mapnik::util::spatial_index<value_type, filter_in_box, std::istringstream>::query_first_n(filter, in, results, 5);
|
||||
mapnik::util::spatial_index<value_type, filter_in_box<double>, std::istringstream, mapnik::box2d<double>>::query_first_n(filter, in, results, 5);
|
||||
REQUIRE(results[0] == 1);
|
||||
REQUIRE(results[1] == 4);
|
||||
REQUIRE(results[2] == 3);
|
||||
|
|
|
@ -198,12 +198,10 @@ int main (int argc, char** argv)
|
|||
if (extent.valid())
|
||||
{
|
||||
std::clog << extent << std::endl;
|
||||
mapnik::box2d<double> extent_d(extent.minx(), extent.miny(), extent.maxx(), extent.maxy());
|
||||
mapnik::quad_tree<std::pair<std::size_t, std::size_t>> tree(extent_d, depth, ratio);
|
||||
mapnik::quad_tree<std::pair<std::size_t, std::size_t>> tree(extent, depth, ratio);
|
||||
for (auto const& item : boxes)
|
||||
{
|
||||
auto ext_f = std::get<0>(item);
|
||||
tree.insert(std::get<1>(item), mapnik::box2d<double>(ext_f.minx(), ext_f.miny(), ext_f.maxx(), ext_f.maxy()));
|
||||
tree.insert(std::get<1>(item), std::get<0>(item));
|
||||
}
|
||||
|
||||
std::fstream file((filename + ".index").c_str(),
|
||||
|
|
|
@ -171,7 +171,7 @@ int main (int argc,char** argv)
|
|||
}
|
||||
int pos = 50;
|
||||
shx.seek(pos * 2);
|
||||
mapnik::quad_tree<mapnik::detail::node> tree(extent, depth, ratio);
|
||||
mapnik::quad_tree<mapnik::detail::node> tree(mapnik::box2d<float>(extent), depth, ratio);
|
||||
int count = 0;
|
||||
|
||||
if (shape_type != shape_io::shape_null)
|
||||
|
@ -234,7 +234,7 @@ int main (int argc,char** argv)
|
|||
{
|
||||
std::clog << "record number " << record_number << " box=" << item_ext << std::endl;
|
||||
}
|
||||
tree.insert(mapnik::detail::node(offset * 2, start, end),item_ext);
|
||||
tree.insert(mapnik::detail::node(offset * 2, start, end), mapnik::box2d<float>(item_ext));
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ int main (int argc,char** argv)
|
|||
{
|
||||
std::clog << "record number " << record_number << " box=" << item_ext << std::endl;
|
||||
}
|
||||
tree.insert(mapnik::detail::node(offset * 2,-1,0),item_ext);
|
||||
tree.insert(mapnik::detail::node(offset * 2,-1,0), mapnik::box2d<float>(item_ext));
|
||||
++count;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue