2017-08-15 07:57:44 -04:00
|
|
|
#ifndef OSRM_LOCATION_DEPENDENT_DATA_HPP
|
|
|
|
#define OSRM_LOCATION_DEPENDENT_DATA_HPP
|
|
|
|
|
|
|
|
#include <boost/geometry.hpp>
|
2017-08-30 10:33:23 -04:00
|
|
|
#include <boost/geometry/geometries/point_xy.hpp>
|
2017-08-15 07:57:44 -04:00
|
|
|
#include <boost/geometry/index/rtree.hpp>
|
|
|
|
|
|
|
|
#include <osmium/osm/way.hpp>
|
|
|
|
|
2024-06-20 15:44:28 -04:00
|
|
|
#include <filesystem>
|
2017-08-15 07:57:44 -04:00
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
2022-12-11 04:10:26 -05:00
|
|
|
namespace osrm::extractor
|
2017-08-15 07:57:44 -04:00
|
|
|
{
|
2017-08-30 10:33:23 -04:00
|
|
|
|
2017-08-15 07:57:44 -04:00
|
|
|
struct LocationDependentData
|
|
|
|
{
|
2017-08-30 10:33:23 -04:00
|
|
|
using point_t = boost::geometry::model::d2::
|
|
|
|
point_xy<double, boost::geometry::cs::spherical_equatorial<boost::geometry::degree>>;
|
2017-08-31 06:31:04 -04:00
|
|
|
using segment_t = boost::geometry::model::segment<point_t>;
|
2017-08-15 07:57:44 -04:00
|
|
|
using polygon_t = boost::geometry::model::polygon<point_t>;
|
2017-08-30 10:33:23 -04:00
|
|
|
using polygon_bands_t = std::vector<std::vector<segment_t>>;
|
2017-08-15 07:57:44 -04:00
|
|
|
using box_t = boost::geometry::model::box<point_t>;
|
|
|
|
|
|
|
|
using polygon_position_t = std::size_t;
|
|
|
|
using rtree_t = boost::geometry::index::rtree<std::pair<box_t, polygon_position_t>,
|
|
|
|
boost::geometry::index::rstar<8>>;
|
|
|
|
|
|
|
|
using property_t = boost::variant<boost::blank, double, std::string, bool>;
|
|
|
|
using properties_t = std::unordered_map<std::string, property_t>;
|
|
|
|
|
2024-06-20 15:44:28 -04:00
|
|
|
LocationDependentData(const std::vector<std::filesystem::path> &file_paths);
|
2017-08-15 07:57:44 -04:00
|
|
|
|
2017-08-30 16:11:26 -04:00
|
|
|
bool empty() const { return rtree.empty(); }
|
|
|
|
|
2017-10-03 08:17:45 -04:00
|
|
|
std::vector<std::size_t> GetPropertyIndexes(const point_t &point) const;
|
|
|
|
|
|
|
|
property_t FindByKey(const std::vector<std::size_t> &property_indexes, const char *key) const;
|
2017-08-30 16:11:26 -04:00
|
|
|
|
2017-08-15 07:57:44 -04:00
|
|
|
private:
|
2024-06-20 15:44:28 -04:00
|
|
|
void loadLocationDependentData(const std::filesystem::path &file_path,
|
2017-09-22 10:42:00 -04:00
|
|
|
std::vector<rtree_t::value_type> &bounding_boxes);
|
2017-08-18 09:27:49 -04:00
|
|
|
|
2017-08-15 07:57:44 -04:00
|
|
|
rtree_t rtree;
|
2017-08-30 10:33:23 -04:00
|
|
|
std::vector<std::pair<polygon_bands_t, std::size_t>> polygons;
|
2017-08-18 10:21:50 -04:00
|
|
|
std::vector<properties_t> properties;
|
2017-08-15 07:57:44 -04:00
|
|
|
};
|
2022-12-20 12:00:11 -05:00
|
|
|
} // namespace osrm::extractor
|
2017-08-15 07:57:44 -04:00
|
|
|
|
|
|
|
#endif
|