return name and reference separately

This commit is contained in:
karenzshea
2016-09-05 09:01:51 -04:00
committed by Moritz Kobitzsch
parent 938dff011f
commit dcc1b5ab2b
29 changed files with 131 additions and 74 deletions
@@ -152,6 +152,8 @@ class BaseDataFacade
virtual std::string GetNameForID(const unsigned name_id) const = 0;
virtual std::string GetRefForID(const unsigned name_id) const = 0;
virtual std::string GetPronunciationForID(const unsigned name_id) const = 0;
virtual std::string GetDestinationsForID(const unsigned name_id) const = 0;
@@ -636,6 +636,15 @@ class InternalDataFacade final : public BaseDataFacade
return result;
}
std::string GetRefForID(const unsigned name_id) const override final
{
// We store the ref after the name, destination and pronunciation of a street.
// We do this to get around the street length limit of 255 which would hit
// if we concatenate these. Order (see extractor_callbacks):
// name (0), destination (1), pronunciation (2), ref (3)
return GetNameForID(name_id + 3);
}
std::string GetPronunciationForID(const unsigned name_id) const override final
{
// We store the pronunciation after the name and destination of a street.
@@ -707,12 +707,21 @@ class SharedDataFacade final : public BaseDataFacade
return result;
}
std::string GetRefForID(const unsigned name_id) const override final
{
// We store the ref after the name, destination and pronunciation of a street.
// We do this to get around the street length limit of 255 which would hit
// if we concatenate these. Order (see extractor_callbacks):
// name (0), destination (1), pronunciation (2), ref (3)
return GetNameForID(name_id + 3);
}
std::string GetPronunciationForID(const unsigned name_id) const override final
{
// We store the pronunciation after the name and destination of a street.
// We do this to get around the street length limit of 255 which would hit
// if we concatenate these. Order (see extractor_callbacks):
// name (0), destination (1), pronunciation (2)
// name (0), destination (1), pronunciation (2), ref (3)
return GetNameForID(name_id + 2);
}
@@ -721,7 +730,7 @@ class SharedDataFacade final : public BaseDataFacade
// We store the destination after the name of a street.
// We do this to get around the street length limit of 255 which would hit
// if we concatenate these. Order (see extractor_callbacks):
// name (0), destination (1), pronunciation (2)
// name (0), destination (1), pronunciation (2), ref (3)
return GetNameForID(name_id + 1);
}
@@ -103,12 +103,14 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
{
BOOST_ASSERT(segment_duration >= 0);
const auto name = facade.GetNameForID(step_name_id);
const auto ref = facade.GetRefForID(step_name_id);
const auto pronunciation = facade.GetPronunciationForID(step_name_id);
const auto destinations = facade.GetDestinationsForID(step_name_id);
const auto distance = leg_geometry.segment_distances[segment_index];
steps.push_back(RouteStep{step_name_id,
std::move(name),
std::move(ref),
std::move(pronunciation),
std::move(destinations),
NO_ROTARY_NAME,
@@ -168,6 +170,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
BOOST_ASSERT(duration >= 0);
steps.push_back(RouteStep{step_name_id,
facade.GetNameForID(step_name_id),
facade.GetRefForID(step_name_id),
facade.GetPronunciationForID(step_name_id),
facade.GetDestinationsForID(step_name_id),
NO_ROTARY_NAME,
@@ -194,6 +197,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
steps.push_back(RouteStep{source_node.name_id,
facade.GetNameForID(source_node.name_id),
facade.GetRefForID(source_node.name_id),
facade.GetPronunciationForID(source_node.name_id),
facade.GetDestinationsForID(source_node.name_id),
NO_ROTARY_NAME,
@@ -229,6 +233,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
BOOST_ASSERT(!leg_geometry.locations.empty());
steps.push_back(RouteStep{target_node.name_id,
facade.GetNameForID(target_node.name_id),
facade.GetRefForID(target_node.name_id),
facade.GetPronunciationForID(target_node.name_id),
facade.GetDestinationsForID(target_node.name_id),
NO_ROTARY_NAME,
+4 -2
View File
@@ -25,10 +25,10 @@ namespace guidance
// a --> b --> c
// this struct saves the information of the segment b,c.
// Notable exceptions are Departure and Arrival steps.
// Departue: s --> a --> b. Represents the segment s,a with location being s.
// Departure: s --> a --> b. Represents the segment s,a with location being s.
// Arrive: a --> b --> t. The segment (b,t) is already covered by the previous segment.
// A represenetation of intermediate intersections
// A representation of intermediate intersections
struct Intersection
{
static const constexpr std::size_t NO_INDEX = std::numeric_limits<std::size_t>::max();
@@ -58,6 +58,7 @@ struct RouteStep
{
unsigned name_id;
std::string name;
std::string ref;
std::string pronunciation;
std::string destinations;
std::string rotary_name;
@@ -80,6 +81,7 @@ inline RouteStep getInvalidRouteStep()
"",
"",
"",
"",
0,
0,
TRAVEL_MODE_INACCESSIBLE,
+2
View File
@@ -33,6 +33,7 @@ struct ExtractionWay
is_startpoint = true;
is_access_restricted = false;
name.clear();
ref.clear();
pronunciation.clear();
destinations.clear();
forward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
@@ -53,6 +54,7 @@ struct ExtractionWay
double backward_speed;
double duration;
std::string name;
std::string ref;
std::string pronunciation;
std::string destinations;
std::string turn_lanes_forward;
+18 -3
View File
@@ -16,6 +16,21 @@ class Node;
class Way;
}
namespace std
{
template <> struct hash<std::tuple<std::string, std::string, std::string>>
{
std::size_t operator()(const std::tuple<std::string, std::string, std::string> &mk) const noexcept
{
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));
return seed;
}
};
}
namespace osrm
{
namespace extractor
@@ -27,7 +42,7 @@ struct ExtractionNode;
struct ExtractionWay;
/**
* This class is uses by the extractor with the results of the
* 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.
@@ -37,9 +52,9 @@ class ExtractorCallbacks
{
private:
// used to deduplicate street names and street destinations: actually maps to name ids
using MapKey = std::pair<std::string, std::string>;
using MapKey = std::tuple<std::string, std::string, std::string>;
using MapVal = unsigned;
std::unordered_map<MapKey, MapVal, boost::hash<MapKey>> string_map;
std::unordered_map<MapKey, MapVal> string_map;
guidance::LaneDescriptionMap lane_description_map;
ExtractionContainers &external_memory;