osrm-backend/include/extractor/extractor_callbacks.hpp

92 lines
2.7 KiB
C++
Raw Normal View History

#ifndef EXTRACTOR_CALLBACKS_HPP
#define EXTRACTOR_CALLBACKS_HPP
#include "extractor/guidance/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;
}
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 InputRestrictionContainer;
struct ExtractionNode;
struct ExtractionWay;
struct ProfileProperties;
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;
2016-09-05 09:01:51 -04:00
std::unordered_map<MapKey, MapVal> string_map;
guidance::LaneDescriptionMap lane_description_map;
2014-05-09 10:17:31 -04:00
ExtractionContainers &external_memory;
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:
explicit ExtractorCallbacks(ExtractionContainers &extraction_containers,
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 boost::optional<InputRestrictionContainer> &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);
// destroys the internal laneDescriptionMap
guidance::LaneDescriptionMap &&moveOutLaneDescriptionMap();
};
2016-01-05 10:51:13 -05:00
}
}
#endif /* EXTRACTOR_CALLBACKS_HPP */