Add namespace around all files
This commit is contained in:
@@ -13,6 +13,13 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace routing_algorithms
|
||||
{
|
||||
|
||||
const double VIAPATH_ALPHA = 0.10;
|
||||
const double VIAPATH_EPSILON = 0.15; // alternative at most 15% longer
|
||||
const double VIAPATH_GAMMA = 0.75; // alternative shares at most 75% with the shortest.
|
||||
@@ -81,7 +88,7 @@ class AlternativeRouting final
|
||||
|
||||
if (phantom_node_pair.source_phantom.forward_node_id != SPECIAL_NODEID)
|
||||
{
|
||||
// SimpleLogger().Write(logDEBUG) << "fwd-a insert: " <<
|
||||
// util::SimpleLogger().Write(logDEBUG) << "fwd-a insert: " <<
|
||||
// phantom_node_pair.source_phantom.forward_node_id << ", w: " <<
|
||||
// -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
|
||||
forward_heap1.Insert(phantom_node_pair.source_phantom.forward_node_id,
|
||||
@@ -90,7 +97,7 @@ class AlternativeRouting final
|
||||
}
|
||||
if (phantom_node_pair.source_phantom.reverse_node_id != SPECIAL_NODEID)
|
||||
{
|
||||
// SimpleLogger().Write(logDEBUG) << "fwd-b insert: " <<
|
||||
// util::SimpleLogger().Write(logDEBUG) << "fwd-b insert: " <<
|
||||
// phantom_node_pair.source_phantom.reverse_node_id << ", w: " <<
|
||||
// -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
|
||||
forward_heap1.Insert(phantom_node_pair.source_phantom.reverse_node_id,
|
||||
@@ -100,7 +107,7 @@ class AlternativeRouting final
|
||||
|
||||
if (phantom_node_pair.target_phantom.forward_node_id != SPECIAL_NODEID)
|
||||
{
|
||||
// SimpleLogger().Write(logDEBUG) << "rev-a insert: " <<
|
||||
// util::SimpleLogger().Write(logDEBUG) << "rev-a insert: " <<
|
||||
// phantom_node_pair.target_phantom.forward_node_id << ", w: " <<
|
||||
// phantom_node_pair.target_phantom.GetForwardWeightPlusOffset();
|
||||
reverse_heap1.Insert(phantom_node_pair.target_phantom.forward_node_id,
|
||||
@@ -109,7 +116,7 @@ class AlternativeRouting final
|
||||
}
|
||||
if (phantom_node_pair.target_phantom.reverse_node_id != SPECIAL_NODEID)
|
||||
{
|
||||
// SimpleLogger().Write(logDEBUG) << "rev-b insert: " <<
|
||||
// util::SimpleLogger().Write(logDEBUG) << "rev-b insert: " <<
|
||||
// phantom_node_pair.target_phantom.reverse_node_id << ", w: " <<
|
||||
// phantom_node_pair.target_phantom.GetReverseWeightPlusOffset();
|
||||
reverse_heap1.Insert(phantom_node_pair.target_phantom.reverse_node_id,
|
||||
@@ -141,7 +148,7 @@ class AlternativeRouting final
|
||||
return;
|
||||
}
|
||||
|
||||
osrm::sort_unique_resize(via_node_candidate_list);
|
||||
util::sort_unique_resize(via_node_candidate_list);
|
||||
|
||||
std::vector<NodeID> packed_forward_path;
|
||||
std::vector<NodeID> packed_reverse_path;
|
||||
@@ -204,10 +211,10 @@ class AlternativeRouting final
|
||||
}
|
||||
}
|
||||
|
||||
// SimpleLogger().Write(logDEBUG) << "fwd_search_space size: " <<
|
||||
// util::SimpleLogger().Write(logDEBUG) << "fwd_search_space size: " <<
|
||||
// forward_search_space.size() << ", marked " << approximated_forward_sharing.size() << "
|
||||
// nodes";
|
||||
// SimpleLogger().Write(logDEBUG) << "rev_search_space size: " <<
|
||||
// util::SimpleLogger().Write(logDEBUG) << "rev_search_space size: " <<
|
||||
// reverse_search_space.size() << ", marked " << approximated_reverse_sharing.size() << "
|
||||
// nodes";
|
||||
|
||||
@@ -403,7 +410,7 @@ class AlternativeRouting final
|
||||
// First partially unpack s-->v until paths deviate, note length of common path.
|
||||
const int64_t s_v_min_path_size =
|
||||
static_cast<int64_t>(std::min(packed_s_v_path.size(), packed_shortest_path.size())) - 1;
|
||||
for (const int64_t current_node : osrm::irange<int64_t>(0, s_v_min_path_size))
|
||||
for (const int64_t current_node : util::irange<int64_t>(0, s_v_min_path_size))
|
||||
{
|
||||
if (packed_s_v_path[current_node] == packed_shortest_path[current_node] &&
|
||||
packed_s_v_path[current_node + 1] == packed_shortest_path[current_node + 1])
|
||||
@@ -519,7 +526,7 @@ class AlternativeRouting final
|
||||
// //compute forward sharing
|
||||
// while( (packed_alternate_path[aindex] == packed_shortest_path[aindex]) &&
|
||||
// (packed_alternate_path[aindex+1] == packed_shortest_path[aindex+1]) ) {
|
||||
// // SimpleLogger().Write() << "retrieving edge (" <<
|
||||
// // util::SimpleLogger().Write() << "retrieving edge (" <<
|
||||
// packed_alternate_path[aindex] << "," << packed_alternate_path[aindex+1] << ")";
|
||||
// EdgeID edgeID = facade->FindEdgeInEitherDirection(packed_alternate_path[aindex],
|
||||
// packed_alternate_path[aindex+1]);
|
||||
@@ -557,7 +564,7 @@ class AlternativeRouting final
|
||||
const NodeID node = forward_heap.DeleteMin();
|
||||
const int distance = forward_heap.GetKey(node);
|
||||
// const NodeID parentnode = forward_heap.GetData(node).parent;
|
||||
// SimpleLogger().Write() << (is_forward_directed ? "[fwd] " : "[rev] ") << "settled edge ("
|
||||
// util::SimpleLogger().Write() << (is_forward_directed ? "[fwd] " : "[rev] ") << "settled edge ("
|
||||
// << parentnode << "," << node << "), dist: " << distance;
|
||||
|
||||
const int scaled_distance =
|
||||
@@ -581,10 +588,10 @@ class AlternativeRouting final
|
||||
{
|
||||
*middle_node = node;
|
||||
*upper_bound_to_shortest_path_distance = new_distance;
|
||||
// SimpleLogger().Write() << "accepted middle_node " << *middle_node << " at
|
||||
// util::SimpleLogger().Write() << "accepted middle_node " << *middle_node << " at
|
||||
// distance " << new_distance;
|
||||
// } else {
|
||||
// SimpleLogger().Write() << "discarded middle_node " << *middle_node << "
|
||||
// util::SimpleLogger().Write() << "discarded middle_node " << *middle_node << "
|
||||
// at distance " << new_distance;
|
||||
}
|
||||
}
|
||||
@@ -840,4 +847,8 @@ class AlternativeRouting final
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ALTERNATIVE_PATH_ROUTING_HPP */
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
#include "util/timing_util.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace routing_algorithms
|
||||
{
|
||||
|
||||
/// This is a striped down version of the general shortest path algorithm.
|
||||
/// The general algorithm always computes two queries for each leg. This is only
|
||||
/// necessary in case of vias, where the directions of the start node is constrainted
|
||||
@@ -125,4 +132,8 @@ class DirectShortestPathRouting final
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DIRECT_SHORTEST_PATH_HPP */
|
||||
|
||||
@@ -12,6 +12,13 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace routing_algorithms
|
||||
{
|
||||
|
||||
template <class DataFacadeT>
|
||||
class ManyToManyRouting final
|
||||
: public BasicRoutingInterface<DataFacadeT, ManyToManyRouting<DataFacadeT>>
|
||||
@@ -226,4 +233,8 @@ class ManyToManyRouting final
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace matching
|
||||
namespace engine
|
||||
{
|
||||
namespace routing_algorithms
|
||||
{
|
||||
|
||||
struct SubMatching
|
||||
@@ -32,15 +34,12 @@ struct SubMatching
|
||||
|
||||
using CandidateList = std::vector<PhantomNodeWithDistance>;
|
||||
using CandidateLists = std::vector<CandidateList>;
|
||||
using HMM = HiddenMarkovModel<CandidateLists>;
|
||||
using HMM = map_matching::HiddenMarkovModel<CandidateLists>;
|
||||
using SubMatchingList = std::vector<SubMatching>;
|
||||
|
||||
constexpr static const unsigned MAX_BROKEN_STATES = 10;
|
||||
|
||||
constexpr static const double MAX_SPEED = 180 / 3.6; // 180km -> m/s
|
||||
constexpr static const unsigned SUSPICIOUS_DISTANCE_DELTA = 100;
|
||||
}
|
||||
}
|
||||
|
||||
// implements a hidden markov model map matching algorithm
|
||||
template <class DataFacadeT>
|
||||
@@ -71,12 +70,12 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
{
|
||||
}
|
||||
|
||||
void operator()(const osrm::matching::CandidateLists &candidates_list,
|
||||
const std::vector<FixedPointCoordinate> &trace_coordinates,
|
||||
void operator()(const CandidateLists &candidates_list,
|
||||
const std::vector<util::FixedPointCoordinate> &trace_coordinates,
|
||||
const std::vector<unsigned> &trace_timestamps,
|
||||
const double matching_beta,
|
||||
const double gps_precision,
|
||||
osrm::matching::SubMatchingList &sub_matchings) const
|
||||
SubMatchingList &sub_matchings) const
|
||||
{
|
||||
BOOST_ASSERT(candidates_list.size() == trace_coordinates.size());
|
||||
BOOST_ASSERT(candidates_list.size() > 1);
|
||||
@@ -94,12 +93,12 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
return 1u;
|
||||
}
|
||||
}();
|
||||
const auto max_broken_time = median_sample_time * osrm::matching::MAX_BROKEN_STATES;
|
||||
const auto max_broken_time = median_sample_time * MAX_BROKEN_STATES;
|
||||
const auto max_distance_delta = [&]()
|
||||
{
|
||||
if (use_timestamps)
|
||||
{
|
||||
return median_sample_time * osrm::matching::MAX_SPEED;
|
||||
return median_sample_time * MAX_SPEED;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -108,18 +107,18 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
}();
|
||||
|
||||
// TODO replace default values with table lookup based on sampling frequency
|
||||
EmissionLogProbability emission_log_probability(gps_precision);
|
||||
TransitionLogProbability transition_log_probability(matching_beta);
|
||||
map_matching::EmissionLogProbability emission_log_probability(gps_precision);
|
||||
map_matching::TransitionLogProbability transition_log_probability(matching_beta);
|
||||
|
||||
osrm::matching::HMM model(candidates_list, emission_log_probability);
|
||||
HMM model(candidates_list, emission_log_probability);
|
||||
|
||||
std::size_t initial_timestamp = model.initialize(0);
|
||||
if (initial_timestamp == osrm::matching::INVALID_STATE)
|
||||
if (initial_timestamp == map_matching::INVALID_STATE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MatchingDebugInfo matching_debug(osrm::json::Logger::get());
|
||||
util::MatchingDebugInfo matching_debug(util::json::Logger::get());
|
||||
matching_debug.initialize(candidates_list);
|
||||
|
||||
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
||||
@@ -128,7 +127,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
QueryHeap &forward_heap = *(engine_working_data.forward_heap_1);
|
||||
QueryHeap &reverse_heap = *(engine_working_data.reverse_heap_1);
|
||||
|
||||
std::size_t breakage_begin = osrm::matching::INVALID_STATE;
|
||||
std::size_t breakage_begin = map_matching::INVALID_STATE;
|
||||
std::vector<std::size_t> split_points;
|
||||
std::vector<std::size_t> prev_unbroken_timestamps;
|
||||
prev_unbroken_timestamps.reserve(candidates_list.size());
|
||||
@@ -149,16 +148,16 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
else
|
||||
{
|
||||
trace_split = trace_split || (t - prev_unbroken_timestamps.back() >
|
||||
osrm::matching::MAX_BROKEN_STATES);
|
||||
MAX_BROKEN_STATES);
|
||||
}
|
||||
|
||||
if (trace_split)
|
||||
{
|
||||
std::size_t split_index = t;
|
||||
if (breakage_begin != osrm::matching::INVALID_STATE)
|
||||
if (breakage_begin != map_matching::INVALID_STATE)
|
||||
{
|
||||
split_index = breakage_begin;
|
||||
breakage_begin = osrm::matching::INVALID_STATE;
|
||||
breakage_begin = map_matching::INVALID_STATE;
|
||||
}
|
||||
split_points.push_back(split_index);
|
||||
|
||||
@@ -166,7 +165,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
model.clear(split_index);
|
||||
std::size_t new_start = model.initialize(split_index);
|
||||
// no new start was found -> stop viterbi calculation
|
||||
if (new_start == osrm::matching::INVALID_STATE)
|
||||
if (new_start == map_matching::INVALID_STATE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -196,17 +195,17 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
const auto ¤t_coordinate = trace_coordinates[t];
|
||||
|
||||
const auto haversine_distance =
|
||||
coordinate_calculation::haversineDistance(prev_coordinate, current_coordinate);
|
||||
util::coordinate_calculation::haversineDistance(prev_coordinate, current_coordinate);
|
||||
|
||||
// compute d_t for this timestamp and the next one
|
||||
for (const auto s : osrm::irange<std::size_t>(0u, prev_viterbi.size()))
|
||||
for (const auto s : util::irange<std::size_t>(0u, prev_viterbi.size()))
|
||||
{
|
||||
if (prev_pruned[s])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const auto s_prime : osrm::irange<std::size_t>(0u, current_viterbi.size()))
|
||||
for (const auto s_prime : util::irange<std::size_t>(0u, current_viterbi.size()))
|
||||
{
|
||||
// how likely is candidate s_prime at time t to be emitted?
|
||||
// FIXME this can be pre-computed
|
||||
@@ -248,7 +247,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
current_lengths[s_prime] = network_distance;
|
||||
current_pruned[s_prime] = false;
|
||||
current_suspicious[s_prime] =
|
||||
d_t > osrm::matching::SUSPICIOUS_DISTANCE_DELTA;
|
||||
d_t > SUSPICIOUS_DISTANCE_DELTA;
|
||||
model.breakage[t] = false;
|
||||
}
|
||||
}
|
||||
@@ -282,7 +281,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
std::size_t sub_matching_begin = initial_timestamp;
|
||||
for (const auto sub_matching_end : split_points)
|
||||
{
|
||||
osrm::matching::SubMatching matching;
|
||||
SubMatching matching;
|
||||
|
||||
std::size_t parent_timestamp_index = sub_matching_end - 1;
|
||||
while (parent_timestamp_index >= sub_matching_begin &&
|
||||
@@ -338,7 +337,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
matching.length = 0.0;
|
||||
matching.nodes.resize(reconstructed_indices.size());
|
||||
matching.indices.resize(reconstructed_indices.size());
|
||||
for (const auto i : osrm::irange<std::size_t>(0u, reconstructed_indices.size()))
|
||||
for (const auto i : util::irange<std::size_t>(0u, reconstructed_indices.size()))
|
||||
{
|
||||
const auto timestamp_index = reconstructed_indices[i].first;
|
||||
const auto location_index = reconstructed_indices[i].second;
|
||||
@@ -357,6 +356,10 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//[1] "Hidden Markov Map Matching Through Noise and Sparseness"; P. Newson and J. Krumm; 2009; ACM
|
||||
// GIS
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
#include <stack>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
|
||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_1;
|
||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_1;
|
||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_2;
|
||||
@@ -17,6 +22,10 @@ SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_2;
|
||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_3;
|
||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_3;
|
||||
|
||||
namespace routing_algorithms
|
||||
{
|
||||
|
||||
|
||||
template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
{
|
||||
private:
|
||||
@@ -222,8 +231,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
{
|
||||
BOOST_ASSERT_MSG(!ed.shortcut, "original edge flagged as shortcut");
|
||||
unsigned name_index = facade->GetNameIndexFromEdgeID(ed.id);
|
||||
const TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id);
|
||||
const TravelMode travel_mode = facade->GetTravelModeForEdgeID(ed.id);
|
||||
const extractor::TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id);
|
||||
const extractor::TravelMode travel_mode = facade->GetTravelModeForEdgeID(ed.id);
|
||||
|
||||
if (!facade->EdgeIsCompressed(ed.id))
|
||||
{
|
||||
@@ -251,7 +260,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
for (std::size_t i = start_index; i < end_index; ++i)
|
||||
{
|
||||
unpacked_path.emplace_back(id_vector[i], name_index,
|
||||
TurnInstruction::NoTurn, 0, travel_mode);
|
||||
extractor::TurnInstruction::NoTurn, 0, travel_mode);
|
||||
}
|
||||
unpacked_path.back().turn_instruction = turn_instruction;
|
||||
unpacked_path.back().segment_duration = ed.distance;
|
||||
@@ -296,7 +305,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
BOOST_ASSERT(i < id_vector.size());
|
||||
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0);
|
||||
unpacked_path.emplace_back(PathData{
|
||||
id_vector[i], phantom_node_pair.target_phantom.name_id, TurnInstruction::NoTurn,
|
||||
id_vector[i], phantom_node_pair.target_phantom.name_id, extractor::TurnInstruction::NoTurn,
|
||||
0, phantom_node_pair.target_phantom.forward_travel_mode});
|
||||
}
|
||||
}
|
||||
@@ -642,21 +651,25 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
nodes.target_phantom = target_phantom;
|
||||
UnpackPath(packed_leg.begin(), packed_leg.end(), nodes, unpacked_path);
|
||||
|
||||
FixedPointCoordinate previous_coordinate = source_phantom.location;
|
||||
FixedPointCoordinate current_coordinate;
|
||||
util::FixedPointCoordinate previous_coordinate = source_phantom.location;
|
||||
util::FixedPointCoordinate current_coordinate;
|
||||
distance = 0;
|
||||
for (const auto &p : unpacked_path)
|
||||
{
|
||||
current_coordinate = facade->GetCoordinateOfNode(p.node);
|
||||
distance += coordinate_calculation::haversineDistance(previous_coordinate,
|
||||
distance += util::coordinate_calculation::haversineDistance(previous_coordinate,
|
||||
current_coordinate);
|
||||
previous_coordinate = current_coordinate;
|
||||
}
|
||||
distance += coordinate_calculation::haversineDistance(previous_coordinate,
|
||||
distance += util::coordinate_calculation::haversineDistance(previous_coordinate,
|
||||
target_phantom.location);
|
||||
}
|
||||
return distance;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ROUTING_BASE_HPP
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
{
|
||||
namespace routing_algorithms
|
||||
{
|
||||
|
||||
template <class DataFacadeT>
|
||||
class ShortestPathRouting final
|
||||
: public BasicRoutingInterface<DataFacadeT, ShortestPathRouting<DataFacadeT>>
|
||||
@@ -262,7 +269,7 @@ class ShortestPathRouting final
|
||||
|
||||
raw_route_data.shortest_path_length = shortest_path_length;
|
||||
|
||||
for (const auto current_leg : osrm::irange<std::size_t>(0, packed_leg_begin.size() - 1))
|
||||
for (const auto current_leg : util::irange<std::size_t>(0, packed_leg_begin.size() - 1))
|
||||
{
|
||||
auto leg_begin = total_packed_path.begin() + packed_leg_begin[current_leg];
|
||||
auto leg_end = total_packed_path.begin() + packed_leg_begin[current_leg + 1];
|
||||
@@ -515,4 +522,8 @@ class ShortestPathRouting final
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SHORTEST_PATH_HPP */
|
||||
|
||||
Reference in New Issue
Block a user