Allow multiple GeoJSON files with locations data

This commit is contained in:
Michael Krasnyk
2017-09-22 16:42:00 +02:00
parent 095b345713
commit 476bc347b4
4 changed files with 24 additions and 21 deletions
+9 -13
View File
@@ -19,20 +19,22 @@ namespace osrm
namespace extractor
{
LocationDependentData::LocationDependentData(const boost::filesystem::path &path)
{
loadLocationDependentData(path);
}
LocationDependentData::LocationDependentData(const std::vector<boost::filesystem::path> &file_paths)
{
std::vector<rtree_t::value_type> bounding_boxes;
for (const auto &path : file_paths)
{
loadLocationDependentData(path);
loadLocationDependentData(path, bounding_boxes);
}
// Create R-tree for bounding boxes of collected polygons
rtree = rtree_t(bounding_boxes);
util::Log() << "Parsed " << properties.size() << " location-dependent features with "
<< polygons.size() << " GeoJSON polygons";
}
void LocationDependentData::loadLocationDependentData(const boost::filesystem::path &file_path)
void LocationDependentData::loadLocationDependentData(
const boost::filesystem::path &file_path, std::vector<rtree_t::value_type> &bounding_boxes)
{
if (file_path.empty())
return;
@@ -64,7 +66,6 @@ void LocationDependentData::loadLocationDependentData(const boost::filesystem::p
BOOST_ASSERT(geojson["features"].IsArray());
const auto &features_array = geojson["features"].GetArray();
std::vector<rtree_t::value_type> bounding_boxes;
auto convert_value = [](const auto &property) -> property_t {
if (property.IsString())
@@ -188,11 +189,6 @@ void LocationDependentData::loadLocationDependentData(const boost::filesystem::p
}
}
}
// Create R-tree for bounding boxes of collected polygons
rtree = rtree_t(bounding_boxes);
util::Log() << "Parsed " << properties.size() << " location-dependent features with "
<< polygons.size() << " GeoJSON polygons";
}
LocationDependentData::property_t LocationDependentData::operator()(const point_t &point,