Implements Exit Numbers + Names (junction:ref way tag for now)

This commit is contained in:
Daniel J. Hofmann
2017-06-29 22:12:25 +02:00
committed by Patrick Niklaus
parent 6d78c11fd2
commit 7d900e3b5a
27 changed files with 160 additions and 30 deletions
@@ -808,6 +808,11 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
return m_name_table.GetDestinationsForID(id);
}
StringView GetExitsForID(const NameID id) const override final
{
return m_name_table.GetExitsForID(id);
}
StringView GetDatasourceName(const DatasourceID id) const override final
{
return m_datasources->GetSourceName(id);
@@ -158,6 +158,8 @@ class BaseDataFacade
virtual StringView GetDestinationsForID(const NameID id) const = 0;
virtual StringView GetExitsForID(const NameID id) const = 0;
virtual std::string GetTimestamp() const = 0;
virtual bool GetContinueStraightDefault() const = 0;
@@ -114,6 +114,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
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 exits = facade.GetExitsForID(step_name_id);
const auto distance = leg_geometry.segment_distances[segment_index];
steps.push_back(RouteStep{step_name_id,
@@ -121,6 +122,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
ref.to_string(),
pronunciation.to_string(),
destinations.to_string(),
exits.to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
segment_duration / 10.,
@@ -196,6 +198,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
facade.GetRefForID(step_name_id).to_string(),
facade.GetPronunciationForID(step_name_id).to_string(),
facade.GetDestinationsForID(step_name_id).to_string(),
facade.GetExitsForID(step_name_id).to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
duration / 10.,
@@ -237,6 +240,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
facade.GetRefForID(source_name_id).to_string(),
facade.GetPronunciationForID(source_name_id).to_string(),
facade.GetDestinationsForID(source_name_id).to_string(),
facade.GetExitsForID(source_name_id).to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
duration / 10.,
@@ -275,6 +279,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
facade.GetRefForID(target_name_id).to_string(),
facade.GetPronunciationForID(target_name_id).to_string(),
facade.GetDestinationsForID(target_name_id).to_string(),
facade.GetExitsForID(target_name_id).to_string(),
NO_ROTARY_NAME,
NO_ROTARY_NAME,
ZERO_DURATION,
@@ -130,8 +130,14 @@ inline bool haveSameName(const RouteStep &lhs, const RouteStep &rhs)
// ok, bite the sour grape and check the strings already
else
return !util::guidance::requiresNameAnnounced(
lhs.name, lhs.ref, lhs.pronunciation, rhs.name, rhs.ref, rhs.pronunciation);
return !util::guidance::requiresNameAnnounced(lhs.name,
lhs.ref,
lhs.pronunciation,
lhs.exits,
rhs.name,
rhs.ref,
rhs.pronunciation,
rhs.exits);
}
// alias for readability, both turn right | left
+3
View File
@@ -62,6 +62,7 @@ struct RouteStep
std::string ref;
std::string pronunciation;
std::string destinations;
std::string exits;
std::string rotary_name;
std::string rotary_pronunciation;
double duration; // duration in seconds
@@ -114,6 +115,7 @@ inline void RouteStep::Invalidate()
ref.clear();
pronunciation.clear();
destinations.clear();
exits.clear();
rotary_name.clear();
rotary_pronunciation.clear();
duration = 0;
@@ -178,6 +180,7 @@ inline RouteStep &RouteStep::AdaptStepSignage(const RouteStep &origin)
name = origin.name;
pronunciation = origin.pronunciation;
destinations = origin.destinations;
exits = origin.exits;
ref = origin.ref;
return *this;
+4
View File
@@ -53,6 +53,7 @@ struct ExtractionWay
ref.clear();
pronunciation.clear();
destinations.clear();
exits.clear();
forward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
backward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
turn_lanes_forward.clear();
@@ -69,6 +70,8 @@ struct ExtractionWay
const char *GetRef() const { return ref.c_str(); }
void SetDestinations(const char *value) { detail::maybeSetString(destinations, value); }
const char *GetDestinations() const { return destinations.c_str(); }
void SetExits(const char *value) { detail::maybeSetString(exits, value); }
const char *GetExits() const { return exits.c_str(); }
void SetPronunciation(const char *value) { detail::maybeSetString(pronunciation, value); }
const char *GetPronunciation() const { return pronunciation.c_str(); }
void SetTurnLanesForward(const char *value)
@@ -96,6 +99,7 @@ struct ExtractionWay
std::string ref;
std::string pronunciation;
std::string destinations;
std::string exits;
std::string turn_lanes_forward;
std::string turn_lanes_backward;
guidance::RoadClassification road_classification;
+7 -6
View File
@@ -18,10 +18,10 @@ class Way;
namespace std
{
template <> struct hash<std::tuple<std::string, std::string, std::string, std::string>>
template <> struct hash<std::tuple<std::string, std::string, std::string, std::string, std::string>>
{
std::size_t
operator()(const std::tuple<std::string, std::string, std::string, std::string> &mk) const
std::size_t operator()(
const std::tuple<std::string, std::string, std::string, std::string, std::string> &mk) const
noexcept
{
std::size_t seed = 0;
@@ -29,6 +29,7 @@ template <> struct hash<std::tuple<std::string, std::string, std::string, std::s
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));
return seed;
}
};
@@ -55,9 +56,9 @@ struct ProfileProperties;
class ExtractorCallbacks
{
private:
// used to deduplicate street names, refs, destinations, pronunciation: actually maps to name
// ids
using MapKey = std::tuple<std::string, std::string, std::string, std::string>;
// 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>;
using MapVal = unsigned;
std::unordered_map<MapKey, MapVal> string_map;
guidance::LaneDescriptionMap lane_description_map;
+2 -1
View File
@@ -46,7 +46,8 @@ inline void print(const engine::guidance::RouteStep &step)
std::cout << ")";
}
std::cout << "] name[" << step.name_id << "]: " << step.name << " Ref: " << step.ref
<< " Pronunciation: " << step.pronunciation << "Destination: " << step.destinations;
<< " Pronunciation: " << step.pronunciation << "Destination: " << step.destinations
<< "Exits: " << step.exits;
}
inline void print(const std::vector<engine::guidance::RouteStep> &steps)
+23 -4
View File
@@ -44,9 +44,11 @@ template <typename SuffixTable>
inline bool requiresNameAnnounced(const std::string &from_name,
const std::string &from_ref,
const std::string &from_pronunciation,
const std::string &from_exits,
const std::string &to_name,
const std::string &to_ref,
const std::string &to_pronunciation,
const std::string &to_exits,
const SuffixTable &suffix_table)
{
// first is empty and the second is not
@@ -128,17 +130,20 @@ inline bool requiresNameAnnounced(const std::string &from_name,
(!from_name.empty() && from_ref.empty() && to_name.empty() && !to_ref.empty());
const auto pronunciation_changes = from_pronunciation != to_pronunciation;
const auto exits_change = from_exits != to_exits;
return !obvious_change || needs_announce || pronunciation_changes;
return !obvious_change || needs_announce || pronunciation_changes || exits_change;
}
// Overload without suffix checking
inline bool requiresNameAnnounced(const std::string &from_name,
const std::string &from_ref,
const std::string &from_pronunciation,
const std::string &from_exits,
const std::string &to_name,
const std::string &to_ref,
const std::string &to_pronunciation)
const std::string &to_pronunciation,
const std::string &to_exits)
{
// Dummy since we need to provide a SuffixTable but do not have the data for it.
// (Guidance Post-Processing does not keep the suffix table around at the moment)
@@ -148,8 +153,15 @@ inline bool requiresNameAnnounced(const std::string &from_name,
bool isSuffix(const std::string &) const { return false; }
} static const table;
return requiresNameAnnounced(
from_name, from_ref, from_pronunciation, to_name, to_ref, to_pronunciation, table);
return requiresNameAnnounced(from_name,
from_ref,
from_pronunciation,
from_exits,
to_name,
to_ref,
to_pronunciation,
to_exits,
table);
}
inline bool requiresNameAnnounced(const NameID from_name_id,
@@ -163,9 +175,13 @@ inline bool requiresNameAnnounced(const NameID from_name_id,
return requiresNameAnnounced(name_table.GetNameForID(from_name_id).to_string(),
name_table.GetRefForID(from_name_id).to_string(),
name_table.GetPronunciationForID(from_name_id).to_string(),
name_table.GetExitsForID(from_name_id).to_string(),
//
name_table.GetNameForID(to_name_id).to_string(),
name_table.GetRefForID(to_name_id).to_string(),
name_table.GetPronunciationForID(to_name_id).to_string(),
name_table.GetExitsForID(to_name_id).to_string(),
//
suffix_table);
// FIXME: converts StringViews to strings since the name change heuristics mutates in place
}
@@ -180,8 +196,11 @@ inline bool requiresNameAnnounced(const NameID from_name_id,
return requiresNameAnnounced(name_table.GetNameForID(from_name_id).to_string(),
name_table.GetRefForID(from_name_id).to_string(),
name_table.GetPronunciationForID(from_name_id).to_string(),
name_table.GetExitsForID(from_name_id).to_string(),
//
name_table.GetNameForID(to_name_id).to_string(),
name_table.GetRefForID(to_name_id).to_string(),
name_table.GetExitsForID(to_name_id).to_string(),
name_table.GetPronunciationForID(to_name_id).to_string());
// FIXME: converts StringViews to strings since the name change heuristics mutates in place
}
+1 -1
View File
@@ -33,9 +33,9 @@ class NameTable
// This class provides a limited view over all the string data we serialize out.
// The following functions are a subset of what is available.
// See the data facades for they provide full access to this serialized string data.
// (at time of writing this: get{Name,Ref,Pronunciation,Destinations}ForID(name_id);)
util::StringView GetNameForID(const NameID id) const;
util::StringView GetDestinationsForID(const NameID id) const;
util::StringView GetExitsForID(const NameID id) const;
util::StringView GetRefForID(const NameID id) const;
util::StringView GetPronunciationForID(const NameID id) const;