osrm-backend/include/extractor/location_dependent_data.hpp

52 lines
1.8 KiB
C++
Raw Permalink Normal View History

2017-08-15 07:57:44 -04:00
#ifndef OSRM_LOCATION_DEPENDENT_DATA_HPP
#define OSRM_LOCATION_DEPENDENT_DATA_HPP
#include <boost/filesystem/path.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>
#include <string>
#include <unordered_map>
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>;
2017-08-18 09:27:49 -04:00
LocationDependentData(const std::vector<boost::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(); }
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:
void loadLocationDependentData(const boost::filesystem::path &file_path,
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