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
+2
View File
@@ -250,6 +250,8 @@ util::json::Object makeRouteStep(guidance::RouteStep step, util::json::Value geo
route_step.values["pronunciation"] = std::move(step.pronunciation);
if (!step.destinations.empty())
route_step.values["destinations"] = std::move(step.destinations);
if (!step.exits.empty())
route_step.values["exits"] = std::move(step.exits);
if (!step.rotary_name.empty())
{
route_step.values["rotary_name"] = std::move(step.rotary_name);
+2 -1
View File
@@ -120,7 +120,8 @@ ExtractionContainers::ExtractionContainers()
// Check if stxxl can be instantiated
stxxl::vector<unsigned> dummy_vector;
// Insert four empty strings offsets for name, ref, destination and pronunciation
// Insert four empty strings offsets for name, ref, destination, pronunciation, and exits
name_offsets.push_back(0);
name_offsets.push_back(0);
name_offsets.push_back(0);
name_offsets.push_back(0);
+19 -8
View File
@@ -39,8 +39,8 @@ ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers &extraction_containe
fallback_to_duration(properties.fallback_to_duration),
force_split_edges(properties.force_split_edges)
{
// we reserved 0, 1, 2, 3 for the empty case
string_map[MapKey("", "", "", "")] = 0;
// we reserved 0, 1, 2, 3, 4 for the empty case
string_map[MapKey("", "", "", "", "")] = 0;
lane_description_map.data[TurnLaneDescription()] = 0;
}
@@ -254,7 +254,7 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
return lane_description_map.ConcurrentFindOrAdd(lane_description);
};
// Deduplicates street names, refs, destinations, pronunciation based on the string_map.
// Deduplicates street names, refs, destinations, pronunciation, exits.
// In case we do not already store the key, inserts (key, id) tuple and return id.
// Otherwise fetches the id based on the name and returns it without insertion.
const auto turn_lane_id_forward = requestId(parsed_way.turn_lanes_forward);
@@ -263,14 +263,17 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
const auto road_classification = parsed_way.road_classification;
// Get the unique identifier for the street name, destination, and ref
const auto name_iterator = string_map.find(
MapKey(parsed_way.name, parsed_way.destinations, parsed_way.ref, parsed_way.pronunciation));
const auto name_iterator = string_map.find(MapKey(parsed_way.name,
parsed_way.destinations,
parsed_way.ref,
parsed_way.pronunciation,
parsed_way.exits));
NameID name_id = EMPTY_NAMEID;
if (string_map.end() == name_iterator)
{
// name_offsets has a sentinel element with the total name data size
// take the sentinels index as the name id of the new name data pack
// (name [name_id], destination [+1], pronunciation [+2], ref [+3])
// (name [name_id], destination [+1], pronunciation [+2], ref [+3], exits [+4])
name_id = external_memory.name_offsets.size() - 1;
std::copy(parsed_way.name.begin(),
@@ -293,8 +296,16 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
std::back_inserter(external_memory.name_char_data));
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
auto k = MapKey{
parsed_way.name, parsed_way.destinations, parsed_way.ref, parsed_way.pronunciation};
std::copy(parsed_way.exits.begin(),
parsed_way.exits.end(),
std::back_inserter(external_memory.name_char_data));
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
auto k = MapKey{parsed_way.name,
parsed_way.destinations,
parsed_way.ref,
parsed_way.pronunciation,
parsed_way.exits};
auto v = MapVal{name_id};
string_map.emplace(std::move(k), std::move(v));
}
@@ -330,6 +330,8 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
sol::property(&ExtractionWay::GetPronunciation, &ExtractionWay::SetPronunciation),
"destinations",
sol::property(&ExtractionWay::GetDestinations, &ExtractionWay::SetDestinations),
"exits",
sol::property(&ExtractionWay::GetExits, &ExtractionWay::SetExits),
"turn_lanes_forward",
sol::property(&ExtractionWay::GetTurnLanesForward, &ExtractionWay::SetTurnLanesForward),
"turn_lanes_backward",
+13 -5
View File
@@ -37,7 +37,7 @@ StringView NameTable::GetNameForID(const NameID id) const
if (id == INVALID_NAMEID)
return {};
return m_name_table.at(id);
return m_name_table.at(id + 0);
}
StringView NameTable::GetDestinationsForID(const NameID id) const
@@ -48,6 +48,14 @@ StringView NameTable::GetDestinationsForID(const NameID id) const
return m_name_table.at(id + 1);
}
StringView NameTable::GetExitsForID(const NameID id) const
{
if (id == INVALID_NAMEID)
return {};
return m_name_table.at(id + 4);
}
StringView NameTable::GetRefForID(const NameID id) const
{
if (id == INVALID_NAMEID)
@@ -55,14 +63,14 @@ StringView NameTable::GetRefForID(const NameID id) const
// Way string data is stored in blocks based on `id` as follows:
//
// | name | destination | pronunciation | ref |
// | name | destination | pronunciation | ref | exits
// ^ ^
// [range)
// ^ id + 3
//
// `id + offset` gives us the range of chars.
//
// Offset 0 is name, 1 is destination, 2 is pronunciation, 3 is ref.
// Offset 0 is name, 1 is destination, 2 is pronunciation, 3 is ref, 4 is exits
// See datafacades and extractor callbacks for details.
const constexpr auto OFFSET_REF = 3u;
return m_name_table.at(id + OFFSET_REF);
@@ -75,14 +83,14 @@ StringView NameTable::GetPronunciationForID(const NameID id) const
// Way string data is stored in blocks based on `id` as follows:
//
// | name | destination | pronunciation | ref |
// | name | destination | pronunciation | ref | exits
// ^ ^
// [range)
// ^ id + 2
//
// `id + offset` gives us the range of chars.
//
// Offset 0 is name, 1 is destination, 2 is pronunciation, 3 is ref.
// Offset 0 is name, 1 is destination, 2 is pronunciation, 3 is ref, 4 is exits
// See datafacades and extractor callbacks for details.
const constexpr auto OFFSET_PRONUNCIATION = 2u;
return m_name_table.at(id + OFFSET_PRONUNCIATION);