osrm-backend/include/extractor/extractor_callbacks.hpp

102 lines
3.1 KiB
C++
Raw Normal View History

#ifndef EXTRACTOR_CALLBACKS_HPP
#define EXTRACTOR_CALLBACKS_HPP
#include "extractor/class_data.hpp"
#include "extractor/turn_lane_types.hpp"
2016-07-26 09:00:58 -04:00
#include "util/typedefs.hpp"
2016-05-26 18:47:46 -04:00
#include <boost/functional/hash.hpp>
2016-06-02 07:14:33 -04:00
#include <boost/optional/optional_fwd.hpp>
#include <string>
2014-08-26 11:50:34 -04:00
#include <unordered_map>
namespace osmium
{
class Node;
class Way;
class Relation;
}
2016-09-05 09:01:51 -04:00
namespace std
{
template <> struct hash<std::tuple<std::string, std::string, std::string, std::string, std::string>>
2016-09-05 09:01:51 -04:00
{
std::size_t operator()(
const std::tuple<std::string, std::string, std::string, std::string, std::string> &mk) const
noexcept
2016-09-05 09:01:51 -04:00
{
std::size_t seed = 0;
boost::hash_combine(seed, std::get<0>(mk));
boost::hash_combine(seed, std::get<1>(mk));
boost::hash_combine(seed, std::get<2>(mk));
boost::hash_combine(seed, std::get<3>(mk));
boost::hash_combine(seed, std::get<4>(mk));
2016-09-05 09:01:51 -04:00
return seed;
}
};
}
2016-01-05 10:51:13 -05:00
namespace osrm
{
namespace extractor
{
class ExtractionContainers;
struct ExtractionNode;
struct ExtractionWay;
struct ExtractionRelation;
struct ProfileProperties;
struct InputConditionalTurnRestriction;
2018-02-09 13:32:09 -05:00
struct InputManeuverOverride;
2016-01-05 10:51:13 -05:00
/**
2016-09-05 09:01:51 -04:00
* This class is used by the extractor with the results of the
* osmium based parsing and the customization through the lua profile.
*
* It mediates between the multi-threaded extraction process and the external memory containers.
* Thus the synchronization is handled inside of the extractor.
*/
2014-05-09 10:17:31 -04:00
class ExtractorCallbacks
{
private:
// used to deduplicate street names, refs, destinations, pronunciation, exits:
// actually maps to name ids
using MapKey = std::tuple<std::string, std::string, std::string, std::string, std::string>;
2016-05-26 18:47:46 -04:00
using MapVal = unsigned;
2017-10-13 12:05:04 -04:00
using StringMap = std::unordered_map<MapKey, MapVal>;
StringMap string_map;
2014-05-09 10:17:31 -04:00
ExtractionContainers &external_memory;
std::unordered_map<std::string, ClassData> &classes_map;
LaneDescriptionMap &lane_description_map;
bool fallback_to_duration;
2017-03-29 17:48:57 -04:00
bool force_split_edges;
2014-05-09 10:17:31 -04:00
public:
using ClassesMap = std::unordered_map<std::string, ClassData>;
explicit ExtractorCallbacks(ExtractionContainers &extraction_containers,
std::unordered_map<std::string, ClassData> &classes_map,
LaneDescriptionMap &lane_description_map,
const ProfileProperties &properties);
ExtractorCallbacks(const ExtractorCallbacks &) = delete;
ExtractorCallbacks &operator=(const ExtractorCallbacks &) = delete;
2014-05-09 10:17:31 -04:00
// warning: caller needs to take care of synchronization!
void ProcessNode(const osmium::Node &current_node, const ExtractionNode &result_node);
2014-05-09 10:17:31 -04:00
// warning: caller needs to take care of synchronization!
void ProcessRestriction(const InputConditionalTurnRestriction &restriction);
2014-05-09 10:17:31 -04:00
// warning: caller needs to take care of synchronization!
void ProcessWay(const osmium::Way &current_way, const ExtractionWay &result_way);
2018-02-09 13:32:09 -05:00
// warning: caller needs to take care of synchronization!
void ProcessManeuverOverride(const InputManeuverOverride & override);
};
2016-01-05 10:51:13 -05:00
}
}
#endif /* EXTRACTOR_CALLBACKS_HPP */