Fixes issue where two ways with same name but different pronunciation where deduplicated, resolves #2860
This commit is contained in:
parent
05c1fe7f46
commit
e6fe9d0d67
@ -35,6 +35,23 @@ Feature: Car - Street names in instructions
|
||||
| a | d | My Way,My Way | ,meyeway | ,A1 |
|
||||
| 1 | c | Your Way,Your Way | yourewaye,yourewaye | , |
|
||||
|
||||
# See #2860
|
||||
Scenario: Car - same street name but different pronunciation
|
||||
Given the node map
|
||||
| a | b | c |
|
||||
| | d | |
|
||||
| | e | |
|
||||
|
||||
And the ways
|
||||
| nodes | name | name:pronunciation |
|
||||
| abc | Houston St | hew-stun |
|
||||
| bde | Houston St | how-stun |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | pronunciations |
|
||||
| a | c | Houston St,Houston St | hew-stun,hew-stun |
|
||||
| a | e | Houston St,Houston St,Houston St | hew-stun,how-stun,how-stun |
|
||||
|
||||
@todo
|
||||
Scenario: Car - Use way type to describe unnamed ways
|
||||
Given the node map
|
||||
|
@ -18,14 +18,17 @@ class Way;
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <> struct hash<std::tuple<std::string, std::string, std::string>>
|
||||
template <> struct hash<std::tuple<std::string, 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
|
||||
operator()(const std::tuple<std::string, 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));
|
||||
boost::hash_combine(seed, std::get<3>(mk));
|
||||
return seed;
|
||||
}
|
||||
};
|
||||
@ -51,8 +54,9 @@ struct ExtractionWay;
|
||||
class ExtractorCallbacks
|
||||
{
|
||||
private:
|
||||
// used to deduplicate street names and street destinations: actually maps to name ids
|
||||
using MapKey = std::tuple<std::string, std::string, std::string>;
|
||||
// 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>;
|
||||
using MapVal = unsigned;
|
||||
std::unordered_map<MapKey, MapVal> string_map;
|
||||
guidance::LaneDescriptionMap lane_description_map;
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "extractor/extractor_callbacks.hpp"
|
||||
#include "extractor/external_memory_node.hpp"
|
||||
#include "extractor/extraction_containers.hpp"
|
||||
#include "extractor/extraction_node.hpp"
|
||||
#include "extractor/extraction_way.hpp"
|
||||
#include "extractor/extractor_callbacks.hpp"
|
||||
#include "extractor/guidance/road_classification.hpp"
|
||||
#include "extractor/restriction.hpp"
|
||||
|
||||
@ -34,8 +34,8 @@ namespace TurnLaneType = guidance::TurnLaneType;
|
||||
ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers &extraction_containers)
|
||||
: external_memory(extraction_containers)
|
||||
{
|
||||
// we reserved 0, 1, 2 for the empty case
|
||||
string_map[MapKey("", "", "")] = 0;
|
||||
// we reserved 0, 1, 2, 3 for the empty case
|
||||
string_map[MapKey("", "", "", "")] = 0;
|
||||
lane_description_map[TurnLaneDescription()] = 0;
|
||||
}
|
||||
|
||||
@ -233,16 +233,16 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
||||
}
|
||||
};
|
||||
|
||||
// Deduplicates street names, destination names and refs based on the string_map map.
|
||||
// In case we do not already store the name, inserts (name, id) tuple and return id.
|
||||
// Deduplicates street names, refs, destinations, pronunciation based on the string_map.
|
||||
// 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);
|
||||
const auto turn_lane_id_backward = requestId(parsed_way.turn_lanes_backward);
|
||||
|
||||
const constexpr auto MAX_STRING_LENGTH = 255u;
|
||||
// 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));
|
||||
const auto name_iterator = string_map.find(
|
||||
MapKey(parsed_way.name, parsed_way.destinations, parsed_way.ref, parsed_way.pronunciation));
|
||||
unsigned name_id = EMPTY_NAMEID;
|
||||
if (string_map.end() == name_iterator)
|
||||
{
|
||||
@ -280,7 +280,8 @@ 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};
|
||||
auto k = MapKey{
|
||||
parsed_way.name, parsed_way.destinations, parsed_way.ref, parsed_way.pronunciation};
|
||||
auto v = MapVal{name_id};
|
||||
string_map.emplace(std::move(k), std::move(v));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user