Add destinations API feature

This commit is contained in:
Daniel J. Hofmann
2016-05-26 18:47:46 -04:00
parent bb0c2754d3
commit 6edc565c01
17 changed files with 92 additions and 25 deletions
@@ -147,6 +147,8 @@ class BaseDataFacade
virtual std::string GetPronunciationForID(const unsigned name_id) const = 0;
virtual std::string GetDestinationsForID(const unsigned name_id) const = 0;
virtual std::size_t GetCoreSize() const = 0;
virtual std::string GetTimestamp() const = 0;
@@ -593,9 +593,19 @@ class InternalDataFacade final : public BaseDataFacade
std::string GetPronunciationForID(const unsigned name_id) const override final
{
// We store the pronounciation directly after the name of a street.
// We store the pronounciation 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.
// if we concatenate these. Order (see extractor_callbacks):
// name (0), destination (1), pronunciation (2)
return GetNameForID(name_id + 2);
}
std::string GetDestinationsForID(const unsigned name_id) const override final
{
// 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)
return GetNameForID(name_id + 1);
}
@@ -662,6 +662,19 @@ class SharedDataFacade final : public BaseDataFacade
std::string GetPronunciationForID(const unsigned name_id) const override final
{
// We store the pronounciation 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)
return GetNameForID(name_id + 2);
}
std::string GetDestinationsForID(const unsigned name_id) const override final
{
// 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)
return GetNameForID(name_id + 1);
}
@@ -99,11 +99,13 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
BOOST_ASSERT(segment_duration >= 0);
const auto name = facade.GetNameForID(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(pronunciation),
std::move(destinations),
NO_ROTARY_NAME,
segment_duration / 10.0,
distance,
@@ -155,6 +157,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
steps.push_back(RouteStep{step_name_id,
facade.GetNameForID(step_name_id),
facade.GetPronunciationForID(step_name_id),
facade.GetDestinationsForID(step_name_id),
NO_ROTARY_NAME,
duration / 10.,
distance,
@@ -179,6 +182,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
steps.push_back(RouteStep{source_node.name_id,
facade.GetNameForID(source_node.name_id),
facade.GetPronunciationForID(source_node.name_id),
facade.GetDestinationsForID(source_node.name_id),
NO_ROTARY_NAME,
duration / 10.,
leg_geometry.segment_distances[segment_index],
@@ -209,6 +213,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
steps.push_back(RouteStep{target_node.name_id,
facade.GetNameForID(target_node.name_id),
facade.GetPronunciationForID(target_node.name_id),
facade.GetDestinationsForID(target_node.name_id),
NO_ROTARY_NAME,
ZERO_DURATION,
ZERO_DISTANCE,
+2
View File
@@ -50,6 +50,7 @@ struct RouteStep
unsigned name_id;
std::string name;
std::string pronunciation;
std::string destinations;
std::string rotary_name;
double duration;
double distance;
@@ -67,6 +68,7 @@ inline RouteStep getInvalidRouteStep()
"",
"",
"",
"",
0,
0,
TRAVEL_MODE_INACCESSIBLE,
+2
View File
@@ -32,6 +32,7 @@ struct ExtractionWay
is_access_restricted = false;
name.clear();
pronunciation.clear();
destinations.clear();
forward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
backward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
}
@@ -48,6 +49,7 @@ struct ExtractionWay
double duration;
std::string name;
std::string pronunciation;
std::string destinations;
bool roundabout;
bool is_access_restricted;
bool is_startpoint;
+4 -1
View File
@@ -3,6 +3,7 @@
#include "util/typedefs.hpp"
#include <boost/optional/optional_fwd.hpp>
#include <boost/functional/hash.hpp>
#include <string>
#include <unordered_map>
@@ -34,7 +35,9 @@ class ExtractorCallbacks
{
private:
// used to deduplicate street names and street destinations: actually maps to name ids
std::unordered_map<std::string, unsigned> string_map;
using MapKey = std::pair<std::string, std::string>;
using MapVal = unsigned;
std::unordered_map<MapKey, MapVal, boost::hash<MapKey>> string_map;
ExtractionContainers &external_memory;
public: