store box2d<float> directly in index_record to avoid conversions.

This commit is contained in:
artemp 2017-08-18 16:59:58 +01:00
parent d81a7610d3
commit 6c19efa990
5 changed files with 7 additions and 7 deletions

View file

@ -41,7 +41,7 @@ struct index_record
{
std::uint64_t off;
std::uint64_t size;
float box[4];
box2d<float> box;
};
template <typename InputStream>

View file

@ -81,7 +81,7 @@ csv_index_featureset::csv_index_featureset(std::string const& filename,
positions_.erase(std::remove_if(positions_.begin(),
positions_.end(),
[&](value_type const& pos)
{ return !mapnik::box2d<float>{pos.box[0], pos.box[1], pos.box[2], pos.box[3]}.intersects(filter.box_);}),
{ return !pos.box.intersects(filter.box_);}),
positions_.end());
std::sort(positions_.begin(), positions_.end(),
[](value_type const& lhs, value_type const& rhs) { return lhs.off < rhs.off;});

View file

@ -210,9 +210,9 @@ void geojson_datasource::initialise_disk_index(std::string const& filename)
std::ifstream index(filename_ + ".index", std::ios::binary);
if (!index) throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + ".index'");
auto ext_f = mapnik::util::spatial_index<value_type,
mapnik::bounding_box_filter<float>,
std::ifstream,
mapnik::box2d<float>>::bounding_box(index);
mapnik::bounding_box_filter<float>,
std::ifstream,
mapnik::box2d<float>>::bounding_box(index);
extent_ = { ext_f.minx(), ext_f.miny(),ext_f.maxx(), ext_f.maxy() };
mapnik::bounding_box_filter<float> filter(ext_f);
std::vector<value_type> positions;

View file

@ -72,7 +72,7 @@ geojson_index_featureset::geojson_index_featureset(std::string const& filename,
positions_.erase(std::remove_if(positions_.begin(),
positions_.end(),
[&](value_type const& pos)
{ return !mapnik::box2d<float>{pos.box[0], pos.box[1], pos.box[2], pos.box[3]}.intersects(filter.box_);}),
{ return !pos.box.intersects(filter.box_);}),
positions_.end());
std::sort(positions_.begin(), positions_.end(),

View file

@ -222,7 +222,7 @@ int main (int argc, char** argv)
auto ext_f = std::get<0>(item);
if (use_bbox && !bbox.intersects(ext_f)) continue;
mapnik::util::index_record rec =
{std::get<1>(item).first, std::get<1>(item).second, {ext_f.minx(), ext_f.miny(), ext_f.maxx(), ext_f.maxy()}};
{std::get<1>(item).first, std::get<1>(item).second, ext_f};
tree.insert(rec, ext_f);
}