osrm-backend/include/extractor/location_dependent_data.hpp
2017-10-04 10:03:42 +02:00

52 lines
1.5 KiB
C++

#ifndef OSRM_LOCATION_DEPENDENT_DATA_HPP
#define OSRM_LOCATION_DEPENDENT_DATA_HPP
#include <boost/filesystem/path.hpp>
#include <boost/geometry.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <osmium/osm/way.hpp>
#include <string>
#include <unordered_map>
namespace osrm
{
namespace extractor
{
struct LocationDependentData
{
using point_t = boost::geometry::model::
point<double, 2, boost::geometry::cs::spherical_equatorial<boost::geometry::degree>>;
using polygon_t = boost::geometry::model::polygon<point_t>;
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>;
LocationDependentData(const boost::filesystem::path &path);
LocationDependentData(const std::vector<boost::filesystem::path> &file_paths);
bool empty() const { return rtree.empty(); }
properties_t operator()(const point_t &point) const;
properties_t operator()(const osmium::Way &way) const;
private:
void loadLocationDependentData(const boost::filesystem::path &file_path);
rtree_t rtree;
std::vector<std::pair<polygon_t, std::size_t>> polygons;
std::vector<properties_t> properties;
};
}
}
#endif