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
+1
View File
@@ -235,6 +235,7 @@ util::json::Object makeRouteStep(guidance::RouteStep step, util::json::Value geo
route_step.values["distance"] = std::round(step.distance * 10) / 10.;
route_step.values["duration"] = std::round(step.duration * 10) / 10.;
route_step.values["name"] = std::move(step.name);
if (!step.ref.empty()) route_step.values["ref"] = std::move(step.ref);
if (!step.pronunciation.empty())
route_step.values["pronunciation"] = std::move(step.pronunciation);
if (!step.destinations.empty())
+2
View File
@@ -52,6 +52,8 @@ inline void forwardStepSignage(RouteStep &destination, const RouteStep &origin)
destination.name = origin.name;
destination.pronunciation = origin.pronunciation;
destination.destinations = origin.destinations;
destination.destinations = origin.destinations;
destination.ref = origin.ref;
}
inline bool choiceless(const RouteStep &step, const RouteStep &previous)
+11 -8
View File
@@ -35,9 +35,7 @@ ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers &extraction_containe
: external_memory(extraction_containers)
{
// we reserved 0, 1, 2 for the empty case
string_map[MapKey("", "")] = 0;
// The map should be empty before we start initializing it
string_map[MapKey("", "", "")] = 0;
lane_description_map[TurnLaneDescription()] = 0;
}
@@ -235,16 +233,15 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
}
};
// Deduplicates street names and street destination names based on the street_map map.
// 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.
// 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
// Get the unique identifier for the street name and destination
const auto name_iterator = string_map.find(MapKey(parsed_way.name, parsed_way.destinations));
// 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));
unsigned name_id = EMPTY_NAMEID;
if (string_map.end() == name_iterator)
{
@@ -253,6 +250,7 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
std::min<unsigned>(MAX_STRING_LENGTH, parsed_way.destinations.size());
const auto pronunciation_length =
std::min<unsigned>(MAX_STRING_LENGTH, parsed_way.pronunciation.size());
const auto ref_length = std::min<unsigned>(MAX_STRING_LENGTH, parsed_way.ref.size());
// name_offsets already has an offset of a new name, take the offset index as the name id
name_id = external_memory.name_offsets.size() - 1;
@@ -275,7 +273,12 @@ 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};
std::copy(parsed_way.ref.c_str(),
parsed_way.ref.c_str() + ref_length,
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 v = MapVal{name_id};
string_map.emplace(std::move(k), std::move(v));
}
@@ -175,6 +175,7 @@ void LuaScriptingEnvironment::InitContext(LuaScriptingContext &context)
.def_readwrite("forward_speed", &ExtractionWay::forward_speed)
.def_readwrite("backward_speed", &ExtractionWay::backward_speed)
.def_readwrite("name", &ExtractionWay::name)
.def_readwrite("ref", &ExtractionWay::ref)
.def_readwrite("pronunciation", &ExtractionWay::pronunciation)
.def_readwrite("destinations", &ExtractionWay::destinations)
.def_readwrite("roundabout", &ExtractionWay::roundabout)