Add duration to edges and use it in table plugin
This commit is contained in:
parent
c059d15cb9
commit
25baf51a2c
@ -219,3 +219,74 @@ Feature: Basic Distance Matrix
|
||||
| 2 | 70 +-1 | 0 | 30 +-1 | 40 +-1 |
|
||||
| 3 | 40 +-1 | 50 +-1 | 0 | 10 +-1 |
|
||||
| 4 | 30 +-1 | 40 +-1 | 70 +-1 | 0 |
|
||||
|
||||
Scenario: Testbot - Travel time matrix based on segment durations
|
||||
Given the profile file "testbot" extended with
|
||||
"""
|
||||
api_version = 1
|
||||
properties.traffic_signal_penalty = 0
|
||||
properties.u_turn_penalty = 0
|
||||
function segment_function (segment)
|
||||
segment.weight = 2
|
||||
segment.duration = 11
|
||||
end
|
||||
"""
|
||||
|
||||
And the node map
|
||||
"""
|
||||
a-b-c-d
|
||||
.
|
||||
e
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| abcd |
|
||||
| ce |
|
||||
|
||||
When I request a travel time matrix I should get
|
||||
| | a | b | c | d | e |
|
||||
| a | 0 | 11 | 22 | 33 | 33 |
|
||||
| b | 11 | 0 | 11 | 22 | 22 |
|
||||
| c | 22 | 11 | 0 | 11 | 11 |
|
||||
| d | 33 | 22 | 11 | 0 | 22 |
|
||||
| e | 33 | 22 | 11 | 22 | 0 |
|
||||
|
||||
|
||||
Scenario: Testbot - Travel time matrix for alternative loop paths
|
||||
Given the profile file "testbot" extended with
|
||||
"""
|
||||
api_version = 1
|
||||
properties.traffic_signal_penalty = 0
|
||||
properties.u_turn_penalty = 0
|
||||
properties.weight_precision = 3
|
||||
function segment_function (segment)
|
||||
segment.weight = 777
|
||||
segment.duration = 3
|
||||
end
|
||||
"""
|
||||
And the node map
|
||||
"""
|
||||
a 2 1 b
|
||||
7 4
|
||||
8 3
|
||||
c 5 6 d
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes | oneway |
|
||||
| ab | yes |
|
||||
| bd | yes |
|
||||
| dc | yes |
|
||||
| ca | yes |
|
||||
|
||||
When I request a travel time matrix I should get
|
||||
| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|
||||
| 1 | 0 | 11 | 3 | 2 | 6 | 5 | 8.9 | 7.9 |
|
||||
| 2 | 1 | 0 | 4 | 3 | 7 | 6 | 9.9 | 8.9 |
|
||||
| 3 | 9 | 8 | 0 | 11 | 3 | 2 | 5.9 | 4.9 |
|
||||
| 4 | 10 | 9 | 1 | 0 | 4 | 3 | 6.9 | 5.9 |
|
||||
| 5 | 6 | 5 | 9 | 8 | 0 | 11 | 2.9 | 1.9 |
|
||||
| 6 | 7 | 6 | 10 | 9 | 1 | 0 | 3.9 | 2.9 |
|
||||
| 7 | 3.1 | 2.1 | 6.1 | 5.1 | 9.1 | 8.1 | 0 | 11 |
|
||||
| 8 | 4.1 | 3.1 | 7.1 | 6.1 | 10.1 | 9.1 | 1 | 0 |
|
||||
|
@ -12,21 +12,24 @@ namespace contractor
|
||||
struct ContractorEdgeData
|
||||
{
|
||||
ContractorEdgeData()
|
||||
: weight(0), id(0), originalEdges(0), shortcut(0), forward(0), backward(0),
|
||||
: weight(0), duration(0), id(0), originalEdges(0), shortcut(0), forward(0), backward(0),
|
||||
is_original_via_node_ID(false)
|
||||
{
|
||||
}
|
||||
ContractorEdgeData(EdgeWeight weight,
|
||||
EdgeWeight duration,
|
||||
unsigned original_edges,
|
||||
unsigned id,
|
||||
bool shortcut,
|
||||
bool forward,
|
||||
bool backward)
|
||||
: weight(weight), id(id), originalEdges(std::min((unsigned)1 << 28, original_edges)),
|
||||
shortcut(shortcut), forward(forward), backward(backward), is_original_via_node_ID(false)
|
||||
: weight(weight), duration(duration), id(id),
|
||||
originalEdges(std::min((unsigned)1 << 28, original_edges)), shortcut(shortcut),
|
||||
forward(forward), backward(backward), is_original_via_node_ID(false)
|
||||
{
|
||||
}
|
||||
EdgeWeight weight;
|
||||
EdgeWeight duration;
|
||||
unsigned id;
|
||||
unsigned originalEdges : 28;
|
||||
bool shortcut : 1;
|
||||
|
@ -134,6 +134,7 @@ class GraphContractor
|
||||
BOOST_ASSERT_MSG(SPECIAL_NODEID != new_edge.source, "Source id invalid");
|
||||
BOOST_ASSERT_MSG(SPECIAL_NODEID != new_edge.target, "Target id invalid");
|
||||
new_edge.data.weight = data.weight;
|
||||
new_edge.data.duration = data.duration;
|
||||
new_edge.data.shortcut = data.shortcut;
|
||||
if (!data.is_original_via_node_ID && !orig_node_id_from_new_node_id_map.empty())
|
||||
{
|
||||
@ -241,6 +242,7 @@ class GraphContractor
|
||||
inserted_edges.emplace_back(source,
|
||||
target,
|
||||
path_weight,
|
||||
in_data.duration + out_data.duration,
|
||||
out_data.originalEdges +
|
||||
in_data.originalEdges,
|
||||
node,
|
||||
@ -251,6 +253,7 @@ class GraphContractor
|
||||
inserted_edges.emplace_back(target,
|
||||
source,
|
||||
path_weight,
|
||||
in_data.duration + out_data.duration,
|
||||
out_data.originalEdges +
|
||||
in_data.originalEdges,
|
||||
node,
|
||||
@ -294,6 +297,7 @@ class GraphContractor
|
||||
const NodeID target = contractor_graph->GetTarget(out_edge);
|
||||
if (target == node)
|
||||
continue;
|
||||
|
||||
const EdgeWeight path_weight = in_data.weight + out_data.weight;
|
||||
const EdgeWeight weight = dijkstra.GetKey(target);
|
||||
if (path_weight < weight)
|
||||
@ -310,6 +314,7 @@ class GraphContractor
|
||||
inserted_edges.emplace_back(source,
|
||||
target,
|
||||
path_weight,
|
||||
in_data.duration + out_data.duration,
|
||||
out_data.originalEdges + in_data.originalEdges,
|
||||
node,
|
||||
SHORTCUT_ARC,
|
||||
@ -319,6 +324,7 @@ class GraphContractor
|
||||
inserted_edges.emplace_back(target,
|
||||
source,
|
||||
path_weight,
|
||||
in_data.duration + out_data.duration,
|
||||
out_data.originalEdges + in_data.originalEdges,
|
||||
node,
|
||||
SHORTCUT_ARC,
|
||||
|
@ -33,6 +33,7 @@ std::vector<ContractorEdge> adaptToContractorInput(InputEdgeContainer input_edge
|
||||
edges.emplace_back(input_edge.source,
|
||||
input_edge.target,
|
||||
std::max(input_edge.weight, 1),
|
||||
input_edge.duration,
|
||||
1,
|
||||
input_edge.edge_id,
|
||||
false,
|
||||
@ -42,6 +43,7 @@ std::vector<ContractorEdge> adaptToContractorInput(InputEdgeContainer input_edge
|
||||
edges.emplace_back(input_edge.target,
|
||||
input_edge.source,
|
||||
std::max(input_edge.weight, 1),
|
||||
input_edge.duration,
|
||||
1,
|
||||
input_edge.edge_id,
|
||||
false,
|
||||
|
@ -16,11 +16,15 @@ struct QueryEdge
|
||||
NodeID target;
|
||||
struct EdgeData
|
||||
{
|
||||
EdgeData() : id(0), shortcut(false), weight(0), forward(false), backward(false) {}
|
||||
explicit EdgeData()
|
||||
: id(0), shortcut(false), weight(0), duration(0), forward(false), backward(false)
|
||||
{
|
||||
}
|
||||
|
||||
template <class OtherT> EdgeData(const OtherT &other)
|
||||
{
|
||||
weight = other.weight;
|
||||
duration = other.duration;
|
||||
shortcut = other.shortcut;
|
||||
id = other.id;
|
||||
forward = other.forward;
|
||||
@ -31,9 +35,10 @@ struct QueryEdge
|
||||
// node. Otherwise we see the edge based node to access node data.
|
||||
NodeID id : 31;
|
||||
bool shortcut : 1;
|
||||
EdgeWeight weight : 30;
|
||||
bool forward : 1;
|
||||
bool backward : 1;
|
||||
EdgeWeight weight;
|
||||
EdgeWeight duration : 30;
|
||||
std::uint32_t forward : 1;
|
||||
std::uint32_t backward : 1;
|
||||
} data;
|
||||
|
||||
QueryEdge() : source(SPECIAL_NODEID), target(SPECIAL_NODEID) {}
|
||||
@ -51,9 +56,9 @@ struct QueryEdge
|
||||
bool operator==(const QueryEdge &right) const
|
||||
{
|
||||
return (source == right.source && target == right.target &&
|
||||
data.weight == right.data.weight && data.shortcut == right.data.shortcut &&
|
||||
data.forward == right.data.forward && data.backward == right.data.backward &&
|
||||
data.id == right.data.id);
|
||||
data.weight == right.data.weight && data.duration == right.data.duration &&
|
||||
data.shortcut == right.data.shortcut && data.forward == right.data.forward &&
|
||||
data.backward == right.data.backward && data.id == right.data.id);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ class TableAPI final : public BaseAPI
|
||||
row_end_iterator,
|
||||
json_row.values.begin(),
|
||||
[](const EdgeWeight duration) {
|
||||
if (duration == INVALID_EDGE_WEIGHT)
|
||||
if (duration == MAXIMAL_EDGE_DURATION)
|
||||
{
|
||||
return util::json::Value(util::json::Null());
|
||||
}
|
||||
|
@ -369,8 +369,10 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
// Find the node-based-edge that this belongs to, and directly
|
||||
// calculate the forward_weight, forward_offset, reverse_weight, reverse_offset
|
||||
|
||||
EdgeWeight forward_offset = 0, forward_weight = 0, forward_duration = 0;
|
||||
EdgeWeight reverse_offset = 0, reverse_weight = 0, reverse_duration = 0;
|
||||
EdgeWeight forward_weight_offset = 0, forward_weight = 0;
|
||||
EdgeWeight reverse_weight_offset = 0, reverse_weight = 0;
|
||||
EdgeWeight forward_duration_offset = 0, forward_duration = 0;
|
||||
EdgeWeight reverse_duration_offset = 0, reverse_duration = 0;
|
||||
|
||||
const std::vector<EdgeWeight> forward_weight_vector =
|
||||
datafacade.GetUncompressedForwardWeights(data.packed_geometry_id);
|
||||
@ -383,7 +385,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
|
||||
for (std::size_t i = 0; i < data.fwd_segment_position; i++)
|
||||
{
|
||||
forward_offset += forward_weight_vector[i];
|
||||
forward_weight_offset += forward_weight_vector[i];
|
||||
forward_duration_offset += forward_duration_vector[i];
|
||||
}
|
||||
forward_weight = forward_weight_vector[data.fwd_segment_position];
|
||||
forward_duration = forward_duration_vector[data.fwd_segment_position];
|
||||
@ -393,7 +396,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
for (std::size_t i = 0; i < reverse_weight_vector.size() - data.fwd_segment_position - 1;
|
||||
i++)
|
||||
{
|
||||
reverse_offset += reverse_weight_vector[i];
|
||||
reverse_weight_offset += reverse_weight_vector[i];
|
||||
reverse_duration_offset += reverse_duration_vector[i];
|
||||
}
|
||||
reverse_weight =
|
||||
reverse_weight_vector[reverse_weight_vector.size() - data.fwd_segment_position - 1];
|
||||
@ -415,10 +419,12 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
auto transformed = PhantomNodeWithDistance{PhantomNode{data,
|
||||
forward_weight,
|
||||
reverse_weight,
|
||||
forward_weight_offset,
|
||||
reverse_weight_offset,
|
||||
forward_duration,
|
||||
reverse_duration,
|
||||
forward_offset,
|
||||
reverse_offset,
|
||||
forward_duration_offset,
|
||||
reverse_duration_offset,
|
||||
point_on_segment,
|
||||
input_coordinate},
|
||||
current_perpendicular_distance};
|
||||
|
@ -63,8 +63,8 @@ struct Hint
|
||||
friend std::ostream &operator<<(std::ostream &, const Hint &);
|
||||
};
|
||||
|
||||
static_assert(sizeof(Hint) == 64 + 4, "Hint is bigger than expected");
|
||||
constexpr std::size_t ENCODED_HINT_SIZE = 92;
|
||||
static_assert(sizeof(Hint) == 72 + 4, "Hint is bigger than expected");
|
||||
constexpr std::size_t ENCODED_HINT_SIZE = 104;
|
||||
static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint),
|
||||
"ENCODED_HINT_SIZE does not match size of Hint");
|
||||
}
|
||||
|
@ -51,10 +51,12 @@ struct PhantomNode
|
||||
unsigned name_id,
|
||||
EdgeWeight forward_weight,
|
||||
EdgeWeight reverse_weight,
|
||||
EdgeWeight forward_weight_offset,
|
||||
EdgeWeight reverse_weight_offset,
|
||||
EdgeWeight forward_duration,
|
||||
EdgeWeight reverse_duration,
|
||||
EdgeWeight forward_offset,
|
||||
EdgeWeight reverse_offset,
|
||||
EdgeWeight forward_duration_offset,
|
||||
EdgeWeight reverse_duration_offset,
|
||||
unsigned packed_geometry_id_,
|
||||
bool is_tiny_component,
|
||||
unsigned component_id,
|
||||
@ -65,12 +67,13 @@ struct PhantomNode
|
||||
extractor::TravelMode backward_travel_mode)
|
||||
: forward_segment_id(forward_segment_id), reverse_segment_id(reverse_segment_id),
|
||||
name_id(name_id), forward_weight(forward_weight), reverse_weight(reverse_weight),
|
||||
forward_duration(forward_duration), reverse_duration(reverse_duration),
|
||||
forward_offset(forward_offset), reverse_offset(reverse_offset),
|
||||
packed_geometry_id(packed_geometry_id_), component{component_id, is_tiny_component},
|
||||
location(std::move(location)), input_location(std::move(input_location)),
|
||||
fwd_segment_position(fwd_segment_position), forward_travel_mode(forward_travel_mode),
|
||||
backward_travel_mode(backward_travel_mode)
|
||||
forward_weight_offset(forward_weight_offset),
|
||||
reverse_weight_offset(reverse_weight_offset), forward_duration(forward_duration),
|
||||
reverse_duration(reverse_duration), forward_duration_offset(forward_duration_offset),
|
||||
reverse_duration_offset(reverse_duration_offset), packed_geometry_id(packed_geometry_id_),
|
||||
component{component_id, is_tiny_component}, location(std::move(location)),
|
||||
input_location(std::move(input_location)), fwd_segment_position(fwd_segment_position),
|
||||
forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode)
|
||||
{
|
||||
}
|
||||
|
||||
@ -78,8 +81,9 @@ struct PhantomNode
|
||||
: forward_segment_id{SPECIAL_SEGMENTID, false},
|
||||
reverse_segment_id{SPECIAL_SEGMENTID, false},
|
||||
name_id(std::numeric_limits<unsigned>::max()), forward_weight(INVALID_EDGE_WEIGHT),
|
||||
reverse_weight(INVALID_EDGE_WEIGHT), forward_duration(INVALID_EDGE_WEIGHT),
|
||||
reverse_duration(INVALID_EDGE_WEIGHT), forward_offset(0), reverse_offset(0),
|
||||
reverse_weight(INVALID_EDGE_WEIGHT), forward_weight_offset(0), reverse_weight_offset(0),
|
||||
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION),
|
||||
forward_duration_offset(0), reverse_duration_offset(0),
|
||||
packed_geometry_id(SPECIAL_GEOMETRYID), component{INVALID_COMPONENTID, false},
|
||||
fwd_segment_position(0), forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
|
||||
backward_travel_mode(TRAVEL_MODE_INACCESSIBLE)
|
||||
@ -89,13 +93,25 @@ struct PhantomNode
|
||||
EdgeWeight GetForwardWeightPlusOffset() const
|
||||
{
|
||||
BOOST_ASSERT(forward_segment_id.enabled);
|
||||
return forward_offset + forward_weight;
|
||||
return forward_weight_offset + forward_weight;
|
||||
}
|
||||
|
||||
EdgeWeight GetReverseWeightPlusOffset() const
|
||||
{
|
||||
BOOST_ASSERT(reverse_segment_id.enabled);
|
||||
return reverse_offset + reverse_weight;
|
||||
return reverse_weight_offset + reverse_weight;
|
||||
}
|
||||
|
||||
EdgeWeight GetForwardDuration() const
|
||||
{
|
||||
BOOST_ASSERT(forward_segment_id.enabled);
|
||||
return forward_duration + forward_duration_offset;
|
||||
}
|
||||
|
||||
EdgeWeight GetReverseDuration() const
|
||||
{
|
||||
BOOST_ASSERT(reverse_segment_id.enabled);
|
||||
return reverse_duration + reverse_duration_offset;
|
||||
}
|
||||
|
||||
bool IsBidirected() const { return forward_segment_id.enabled && reverse_segment_id.enabled; }
|
||||
@ -106,8 +122,8 @@ struct PhantomNode
|
||||
(reverse_segment_id.id < number_of_nodes)) &&
|
||||
((forward_weight != INVALID_EDGE_WEIGHT) ||
|
||||
(reverse_weight != INVALID_EDGE_WEIGHT)) &&
|
||||
((forward_duration != INVALID_EDGE_WEIGHT) ||
|
||||
(reverse_duration != INVALID_EDGE_WEIGHT)) &&
|
||||
((forward_duration != MAXIMAL_EDGE_DURATION) ||
|
||||
(reverse_duration != MAXIMAL_EDGE_DURATION)) &&
|
||||
(component.id != INVALID_COMPONENTID) && (name_id != INVALID_NAMEID);
|
||||
}
|
||||
|
||||
@ -124,17 +140,21 @@ struct PhantomNode
|
||||
explicit PhantomNode(const OtherT &other,
|
||||
EdgeWeight forward_weight,
|
||||
EdgeWeight reverse_weight,
|
||||
EdgeWeight forward_weight_offset,
|
||||
EdgeWeight reverse_weight_offset,
|
||||
EdgeWeight forward_duration,
|
||||
EdgeWeight reverse_duration,
|
||||
EdgeWeight forward_offset,
|
||||
EdgeWeight reverse_offset,
|
||||
EdgeWeight forward_duration_offset,
|
||||
EdgeWeight reverse_duration_offset,
|
||||
const util::Coordinate location,
|
||||
const util::Coordinate input_location)
|
||||
: forward_segment_id{other.forward_segment_id},
|
||||
reverse_segment_id{other.reverse_segment_id}, name_id{other.name_id},
|
||||
forward_weight{forward_weight}, reverse_weight{reverse_weight},
|
||||
forward_duration{forward_duration}, reverse_duration{reverse_duration},
|
||||
forward_offset{forward_offset}, reverse_offset{reverse_offset},
|
||||
forward_weight_offset{forward_weight_offset},
|
||||
reverse_weight_offset{reverse_weight_offset}, forward_duration{forward_duration},
|
||||
reverse_duration{reverse_duration}, forward_duration_offset{forward_duration_offset},
|
||||
reverse_duration_offset{reverse_duration_offset},
|
||||
packed_geometry_id{other.packed_geometry_id},
|
||||
component{other.component.id, other.component.is_tiny}, location{location},
|
||||
input_location{input_location}, fwd_segment_position{other.fwd_segment_position},
|
||||
@ -148,10 +168,12 @@ struct PhantomNode
|
||||
unsigned name_id;
|
||||
EdgeWeight forward_weight;
|
||||
EdgeWeight reverse_weight;
|
||||
EdgeWeight forward_weight_offset; // TODO: try to remove -> requires path unpacking changes
|
||||
EdgeWeight reverse_weight_offset; // TODO: try to remove -> requires path unpacking changes
|
||||
EdgeWeight forward_duration;
|
||||
EdgeWeight reverse_duration;
|
||||
EdgeWeight forward_offset;
|
||||
EdgeWeight reverse_offset;
|
||||
EdgeWeight forward_duration_offset; // TODO: try to remove -> requires path unpacking changes
|
||||
EdgeWeight reverse_duration_offset; // TODO: try to remove -> requires path unpacking changes
|
||||
unsigned packed_geometry_id;
|
||||
struct ComponentType
|
||||
{
|
||||
@ -169,7 +191,7 @@ struct PhantomNode
|
||||
extractor::TravelMode backward_travel_mode;
|
||||
};
|
||||
|
||||
static_assert(sizeof(PhantomNode) == 64, "PhantomNode has more padding then expected");
|
||||
static_assert(sizeof(PhantomNode) == 72, "PhantomNode has more padding then expected");
|
||||
|
||||
using PhantomNodePair = std::pair<PhantomNode, PhantomNode>;
|
||||
|
||||
@ -199,10 +221,12 @@ inline std::ostream &operator<<(std::ostream &out, const PhantomNode &pn)
|
||||
<< "name: " << pn.name_id << ", "
|
||||
<< "fwd-w: " << pn.forward_weight << ", "
|
||||
<< "rev-w: " << pn.reverse_weight << ", "
|
||||
<< "fwd-o: " << pn.forward_weight_offset << ", "
|
||||
<< "rev-o: " << pn.reverse_weight_offset << ", "
|
||||
<< "fwd-d: " << pn.forward_duration << ", "
|
||||
<< "rev-d: " << pn.reverse_duration << ", "
|
||||
<< "fwd-o: " << pn.forward_offset << ", "
|
||||
<< "rev-o: " << pn.reverse_offset << ", "
|
||||
<< "fwd-do: " << pn.forward_duration_offset << ", "
|
||||
<< "rev-do: " << pn.reverse_duration_offset << ", "
|
||||
<< "geom: " << pn.packed_geometry_id << ", "
|
||||
<< "comp: " << pn.component.is_tiny << " / " << pn.component.id << ", "
|
||||
<< "pos: " << pn.fwd_segment_position << ", "
|
||||
|
@ -138,7 +138,7 @@ class AlternativeRouting final : private BasicRoutingInterface
|
||||
else
|
||||
{
|
||||
// check whether there is a loop present at the node
|
||||
const auto loop_weight = super::GetLoopWeight(facade, node);
|
||||
const auto loop_weight = super::GetLoopWeight<false>(facade, node);
|
||||
const EdgeWeight new_weight_with_loop = new_weight + loop_weight;
|
||||
if (loop_weight != INVALID_EDGE_WEIGHT &&
|
||||
new_weight_with_loop <= *upper_bound_to_shortest_path_weight)
|
||||
|
@ -23,15 +23,16 @@ namespace routing_algorithms
|
||||
class ManyToManyRouting final : public BasicRoutingInterface
|
||||
{
|
||||
using super = BasicRoutingInterface;
|
||||
using QueryHeap = SearchEngineData::QueryHeap;
|
||||
using QueryHeap = SearchEngineData::ManyToManyQueryHeap;
|
||||
SearchEngineData &engine_working_data;
|
||||
|
||||
struct NodeBucket
|
||||
{
|
||||
unsigned target_id; // essentially a row in the weight matrix
|
||||
EdgeWeight weight;
|
||||
NodeBucket(const unsigned target_id, const EdgeWeight weight)
|
||||
: target_id(target_id), weight(weight)
|
||||
EdgeWeight duration;
|
||||
NodeBucket(const unsigned target_id, const EdgeWeight weight, const EdgeWeight duration)
|
||||
: target_id(target_id), weight(weight), duration(duration)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -56,7 +57,8 @@ class ManyToManyRouting final : public BasicRoutingInterface
|
||||
const unsigned number_of_targets,
|
||||
QueryHeap &query_heap,
|
||||
const SearchSpaceWithBuckets &search_space_with_buckets,
|
||||
std::vector<EdgeWeight> &result_table) const;
|
||||
std::vector<EdgeWeight> &weights_table,
|
||||
std::vector<EdgeWeight> &durations_table) const;
|
||||
|
||||
void BackwardRoutingStep(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
const unsigned column_idx,
|
||||
@ -67,6 +69,7 @@ class ManyToManyRouting final : public BasicRoutingInterface
|
||||
inline void RelaxOutgoingEdges(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
const NodeID node,
|
||||
const EdgeWeight weight,
|
||||
const EdgeWeight duration,
|
||||
QueryHeap &query_heap) const
|
||||
{
|
||||
for (auto edge : facade->GetAdjacentEdgeRange(node))
|
||||
@ -77,20 +80,22 @@ class ManyToManyRouting final : public BasicRoutingInterface
|
||||
{
|
||||
const NodeID to = facade->GetTarget(edge);
|
||||
const EdgeWeight edge_weight = data.weight;
|
||||
const EdgeWeight edge_duration = data.duration;
|
||||
|
||||
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
|
||||
const EdgeWeight to_weight = weight + edge_weight;
|
||||
const EdgeWeight to_duration = duration + edge_duration;
|
||||
|
||||
// New Node discovered -> Add to Heap + Node Info Storage
|
||||
if (!query_heap.WasInserted(to))
|
||||
{
|
||||
query_heap.Insert(to, to_weight, node);
|
||||
query_heap.Insert(to, to_weight, {node, to_duration});
|
||||
}
|
||||
// Found a shorter Path -> Update weight
|
||||
else if (to_weight < query_heap.GetKey(to))
|
||||
{
|
||||
// new parent
|
||||
query_heap.GetData(to).parent = node;
|
||||
query_heap.GetData(to) = {node, to_duration};
|
||||
query_heap.DecreaseKey(to, to_weight);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
@ -77,8 +78,26 @@ class BasicRoutingInterface
|
||||
const bool force_loop_forward,
|
||||
const bool force_loop_reverse) const;
|
||||
|
||||
template <bool UseDuration>
|
||||
EdgeWeight GetLoopWeight(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
NodeID node) const;
|
||||
NodeID node) const
|
||||
{
|
||||
EdgeWeight loop_weight = UseDuration ? MAXIMAL_EDGE_DURATION : INVALID_EDGE_WEIGHT;
|
||||
for (auto edge : facade->GetAdjacentEdgeRange(node))
|
||||
{
|
||||
const auto &data = facade->GetEdgeData(edge);
|
||||
if (data.forward)
|
||||
{
|
||||
const NodeID to = facade->GetTarget(edge);
|
||||
if (to == node)
|
||||
{
|
||||
const auto value = UseDuration ? data.duration : data.weight;
|
||||
loop_weight = std::min(loop_weight, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return loop_weight;
|
||||
}
|
||||
|
||||
template <typename RandomIter>
|
||||
void UnpackPath(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
|
@ -17,24 +17,41 @@ struct HeapData
|
||||
/* explicit */ HeapData(NodeID p) : parent(p) {}
|
||||
};
|
||||
|
||||
struct ManyToManyHeapData : HeapData
|
||||
{
|
||||
EdgeWeight duration;
|
||||
ManyToManyHeapData(NodeID p, EdgeWeight duration) : HeapData(p), duration(duration) {}
|
||||
};
|
||||
|
||||
struct SearchEngineData
|
||||
{
|
||||
using QueryHeap = util::
|
||||
BinaryHeap<NodeID, NodeID, EdgeWeight, HeapData, util::UnorderedMapStorage<NodeID, int>>;
|
||||
using SearchEngineHeapPtr = boost::thread_specific_ptr<QueryHeap>;
|
||||
|
||||
using ManyToManyQueryHeap = util::BinaryHeap<NodeID,
|
||||
NodeID,
|
||||
EdgeWeight,
|
||||
ManyToManyHeapData,
|
||||
util::UnorderedMapStorage<NodeID, int>>;
|
||||
|
||||
using ManyToManyHeapPtr = boost::thread_specific_ptr<ManyToManyQueryHeap>;
|
||||
|
||||
static SearchEngineHeapPtr forward_heap_1;
|
||||
static SearchEngineHeapPtr reverse_heap_1;
|
||||
static SearchEngineHeapPtr forward_heap_2;
|
||||
static SearchEngineHeapPtr reverse_heap_2;
|
||||
static SearchEngineHeapPtr forward_heap_3;
|
||||
static SearchEngineHeapPtr reverse_heap_3;
|
||||
static ManyToManyHeapPtr many_to_many_heap;
|
||||
|
||||
void InitializeOrClearFirstThreadLocalStorage(const unsigned number_of_nodes);
|
||||
|
||||
void InitializeOrClearSecondThreadLocalStorage(const unsigned number_of_nodes);
|
||||
|
||||
void InitializeOrClearThirdThreadLocalStorage(const unsigned number_of_nodes);
|
||||
|
||||
void InitializeOrClearManyToManyThreadLocalStorage(const unsigned number_of_nodes);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ struct EdgeBasedEdge
|
||||
const NodeID target,
|
||||
const NodeID edge_id,
|
||||
const EdgeWeight weight,
|
||||
const EdgeWeight duration,
|
||||
const bool forward,
|
||||
const bool backward);
|
||||
|
||||
@ -29,11 +30,12 @@ struct EdgeBasedEdge
|
||||
NodeID source;
|
||||
NodeID target;
|
||||
NodeID edge_id;
|
||||
EdgeWeight weight : 30;
|
||||
EdgeWeight weight;
|
||||
EdgeWeight duration : 30;
|
||||
std::uint32_t forward : 1;
|
||||
std::uint32_t backward : 1;
|
||||
};
|
||||
static_assert(sizeof(extractor::EdgeBasedEdge) == 16,
|
||||
static_assert(sizeof(extractor::EdgeBasedEdge) == 20,
|
||||
"Size of extractor::EdgeBasedEdge type is "
|
||||
"bigger than expected. This will influence "
|
||||
"memory consumption.");
|
||||
@ -41,14 +43,7 @@ static_assert(sizeof(extractor::EdgeBasedEdge) == 16,
|
||||
// Impl.
|
||||
|
||||
inline EdgeBasedEdge::EdgeBasedEdge()
|
||||
: source(0), target(0), edge_id(0), weight(0), forward(false), backward(false)
|
||||
{
|
||||
}
|
||||
|
||||
template <class EdgeT>
|
||||
inline EdgeBasedEdge::EdgeBasedEdge(const EdgeT &other)
|
||||
: source(other.source), target(other.target), edge_id(other.data.via),
|
||||
weight(other.data.distance), forward(other.data.forward), backward(other.data.backward)
|
||||
: source(0), target(0), edge_id(0), weight(0), duration(0), forward(false), backward(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -56,10 +51,11 @@ inline EdgeBasedEdge::EdgeBasedEdge(const NodeID source,
|
||||
const NodeID target,
|
||||
const NodeID edge_id,
|
||||
const EdgeWeight weight,
|
||||
const EdgeWeight duration,
|
||||
const bool forward,
|
||||
const bool backward)
|
||||
: source(source), target(target), edge_id(edge_id), weight(weight), forward(forward),
|
||||
backward(backward)
|
||||
: source(source), target(target), edge_id(edge_id), weight(weight), duration(duration),
|
||||
forward(forward), backward(backward)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ struct SegmentBlock
|
||||
OSMNodeID this_osm_node_id;
|
||||
double segment_length;
|
||||
EdgeWeight segment_weight;
|
||||
// TODO MKR add duration if needed
|
||||
};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(SegmentBlock) == 20, "SegmentBlock is not packed correctly");
|
||||
|
@ -84,6 +84,7 @@ static const NameID INVALID_NAMEID = std::numeric_limits<NameID>::max();
|
||||
static const NameID EMPTY_NAMEID = 0;
|
||||
static const unsigned INVALID_COMPONENTID = 0;
|
||||
static const EdgeWeight INVALID_EDGE_WEIGHT = std::numeric_limits<EdgeWeight>::max();
|
||||
static const EdgeWeight MAXIMAL_EDGE_DURATION = std::numeric_limits<EdgeWeight>::max();
|
||||
static const TurnPenalty INVALID_TURN_PENALTY = std::numeric_limits<TurnPenalty>::max();
|
||||
|
||||
using DatasourceID = std::uint8_t;
|
||||
|
@ -778,6 +778,7 @@ Contractor::LoadEdgeExpandedGraph(const ContractorConfig &config,
|
||||
|
||||
// Find a segment with zero speed and simultaneously compute the new edge weight
|
||||
EdgeWeight new_weight = 0;
|
||||
// TODO MKR add new_duration if needed
|
||||
auto osm_node_id = header->previous_osm_node_id;
|
||||
bool skip_edge =
|
||||
std::find_if(first, last, [&](const auto &segment) {
|
||||
@ -789,6 +790,9 @@ Contractor::LoadEdgeExpandedGraph(const ContractorConfig &config,
|
||||
if (value->speed == 0)
|
||||
return true;
|
||||
|
||||
// TODO MKR add new_duration = ConvertToDuration(segment.segment_length,
|
||||
// value->speed) if needed
|
||||
|
||||
segment_weight =
|
||||
std::isfinite(value->weight)
|
||||
? std::round(value->weight * config.weight_multiplier)
|
||||
@ -798,6 +802,7 @@ Contractor::LoadEdgeExpandedGraph(const ContractorConfig &config,
|
||||
// Update the edge weight and the next OSM node ID
|
||||
osm_node_id = segment.this_osm_node_id;
|
||||
new_weight += segment_weight;
|
||||
// TODO MKR new_duration += segment_duration;
|
||||
return false;
|
||||
}) != last;
|
||||
|
||||
@ -844,6 +849,7 @@ Contractor::LoadEdgeExpandedGraph(const ContractorConfig &config,
|
||||
|
||||
// Update edge weight
|
||||
inbuffer.weight = new_weight + turn_weight_penalty;
|
||||
// TODO MKR inbuffer.duration = new_duration + turn_duration_penalty;
|
||||
}
|
||||
|
||||
edge_based_edge_list.emplace_back(std::move(inbuffer));
|
||||
|
@ -39,16 +39,21 @@ GraphContractor::GraphContractor(int nodes,
|
||||
forward_edge.data.id = reverse_edge.data.id = id;
|
||||
forward_edge.data.originalEdges = reverse_edge.data.originalEdges = 1;
|
||||
forward_edge.data.weight = reverse_edge.data.weight = INVALID_EDGE_WEIGHT;
|
||||
forward_edge.data.duration = reverse_edge.data.duration = MAXIMAL_EDGE_DURATION;
|
||||
// remove parallel edges
|
||||
while (i < edges.size() && edges[i].source == source && edges[i].target == target)
|
||||
{
|
||||
if (edges[i].data.forward)
|
||||
{
|
||||
forward_edge.data.weight = std::min(edges[i].data.weight, forward_edge.data.weight);
|
||||
forward_edge.data.duration =
|
||||
std::min(edges[i].data.duration, forward_edge.data.duration);
|
||||
}
|
||||
if (edges[i].data.backward)
|
||||
{
|
||||
reverse_edge.data.weight = std::min(edges[i].data.weight, reverse_edge.data.weight);
|
||||
reverse_edge.data.duration =
|
||||
std::min(edges[i].data.duration, reverse_edge.data.duration);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
|
@ -18,11 +18,13 @@ operator()(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
const auto number_of_targets =
|
||||
target_indices.empty() ? phantom_nodes.size() : target_indices.size();
|
||||
const auto number_of_entries = number_of_sources * number_of_targets;
|
||||
std::vector<EdgeWeight> result_table(number_of_entries, std::numeric_limits<EdgeWeight>::max());
|
||||
|
||||
engine_working_data.InitializeOrClearFirstThreadLocalStorage(facade->GetNumberOfNodes());
|
||||
std::vector<EdgeWeight> weights_table(number_of_entries, INVALID_EDGE_WEIGHT);
|
||||
std::vector<EdgeWeight> durations_table(number_of_entries, MAXIMAL_EDGE_DURATION);
|
||||
|
||||
QueryHeap &query_heap = *(engine_working_data.forward_heap_1);
|
||||
engine_working_data.InitializeOrClearManyToManyThreadLocalStorage(facade->GetNumberOfNodes());
|
||||
|
||||
QueryHeap &query_heap = *(engine_working_data.many_to_many_heap);
|
||||
|
||||
SearchSpaceWithBuckets search_space_with_buckets;
|
||||
|
||||
@ -35,13 +37,13 @@ operator()(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
{
|
||||
query_heap.Insert(phantom.forward_segment_id.id,
|
||||
phantom.GetForwardWeightPlusOffset(),
|
||||
phantom.forward_segment_id.id);
|
||||
{phantom.forward_segment_id.id, phantom.GetForwardDuration()});
|
||||
}
|
||||
if (phantom.reverse_segment_id.enabled)
|
||||
{
|
||||
query_heap.Insert(phantom.reverse_segment_id.id,
|
||||
phantom.GetReverseWeightPlusOffset(),
|
||||
phantom.reverse_segment_id.id);
|
||||
{phantom.reverse_segment_id.id, phantom.GetReverseDuration()});
|
||||
}
|
||||
|
||||
// explore search space
|
||||
@ -62,13 +64,13 @@ operator()(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
{
|
||||
query_heap.Insert(phantom.forward_segment_id.id,
|
||||
-phantom.GetForwardWeightPlusOffset(),
|
||||
phantom.forward_segment_id.id);
|
||||
{phantom.forward_segment_id.id, -phantom.GetForwardDuration()});
|
||||
}
|
||||
if (phantom.reverse_segment_id.enabled)
|
||||
{
|
||||
query_heap.Insert(phantom.reverse_segment_id.id,
|
||||
-phantom.GetReverseWeightPlusOffset(),
|
||||
phantom.reverse_segment_id.id);
|
||||
{phantom.reverse_segment_id.id, -phantom.GetReverseDuration()});
|
||||
}
|
||||
|
||||
// explore search space
|
||||
@ -79,7 +81,8 @@ operator()(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
number_of_targets,
|
||||
query_heap,
|
||||
search_space_with_buckets,
|
||||
result_table);
|
||||
weights_table,
|
||||
durations_table);
|
||||
}
|
||||
++row_idx;
|
||||
};
|
||||
@ -116,7 +119,7 @@ operator()(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
}
|
||||
}
|
||||
|
||||
return result_table;
|
||||
return durations_table;
|
||||
}
|
||||
|
||||
void ManyToManyRouting::ForwardRoutingStep(
|
||||
@ -125,10 +128,12 @@ void ManyToManyRouting::ForwardRoutingStep(
|
||||
const unsigned number_of_targets,
|
||||
QueryHeap &query_heap,
|
||||
const SearchSpaceWithBuckets &search_space_with_buckets,
|
||||
std::vector<EdgeWeight> &result_table) const
|
||||
std::vector<EdgeWeight> &weights_table,
|
||||
std::vector<EdgeWeight> &durations_table) const
|
||||
{
|
||||
const NodeID node = query_heap.DeleteMin();
|
||||
const EdgeWeight source_weight = query_heap.GetKey(node);
|
||||
const EdgeWeight source_duration = query_heap.GetData(node).duration;
|
||||
|
||||
// check if each encountered node has an entry
|
||||
const auto bucket_iterator = search_space_with_buckets.find(node);
|
||||
@ -141,21 +146,29 @@ void ManyToManyRouting::ForwardRoutingStep(
|
||||
// get target id from bucket entry
|
||||
const unsigned column_idx = current_bucket.target_id;
|
||||
const EdgeWeight target_weight = current_bucket.weight;
|
||||
auto ¤t_weight = result_table[row_idx * number_of_targets + column_idx];
|
||||
const EdgeWeight target_duration = current_bucket.duration;
|
||||
|
||||
auto ¤t_weight = weights_table[row_idx * number_of_targets + column_idx];
|
||||
auto ¤t_duration = durations_table[row_idx * number_of_targets + column_idx];
|
||||
|
||||
// check if new weight is better
|
||||
const EdgeWeight new_weight = source_weight + target_weight;
|
||||
if (new_weight < 0)
|
||||
{
|
||||
const EdgeWeight loop_weight = super::GetLoopWeight(facade, node);
|
||||
const EdgeWeight loop_weight = super::GetLoopWeight<false>(facade, node);
|
||||
const EdgeWeight new_weight_with_loop = new_weight + loop_weight;
|
||||
if (loop_weight != INVALID_EDGE_WEIGHT && new_weight_with_loop >= 0)
|
||||
{
|
||||
current_weight = std::min(current_weight, new_weight_with_loop);
|
||||
current_duration = std::min(current_duration,
|
||||
source_duration + target_duration +
|
||||
super::GetLoopWeight<true>(facade, node));
|
||||
}
|
||||
}
|
||||
else if (new_weight < current_weight)
|
||||
{
|
||||
result_table[row_idx * number_of_targets + column_idx] = new_weight;
|
||||
current_weight = new_weight;
|
||||
current_duration = source_duration + target_duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,7 +176,7 @@ void ManyToManyRouting::ForwardRoutingStep(
|
||||
{
|
||||
return;
|
||||
}
|
||||
RelaxOutgoingEdges<true>(facade, node, source_weight, query_heap);
|
||||
RelaxOutgoingEdges<true>(facade, node, source_weight, source_duration, query_heap);
|
||||
}
|
||||
|
||||
void ManyToManyRouting::BackwardRoutingStep(
|
||||
@ -174,16 +187,17 @@ void ManyToManyRouting::BackwardRoutingStep(
|
||||
{
|
||||
const NodeID node = query_heap.DeleteMin();
|
||||
const EdgeWeight target_weight = query_heap.GetKey(node);
|
||||
const EdgeWeight target_duration = query_heap.GetData(node).duration;
|
||||
|
||||
// store settled nodes in search space bucket
|
||||
search_space_with_buckets[node].emplace_back(column_idx, target_weight);
|
||||
search_space_with_buckets[node].emplace_back(column_idx, target_weight, target_duration);
|
||||
|
||||
if (StallAtNode<false>(facade, node, target_weight, query_heap))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RelaxOutgoingEdges<false>(facade, node, target_weight, query_heap);
|
||||
RelaxOutgoingEdges<false>(facade, node, target_weight, target_duration, query_heap);
|
||||
}
|
||||
|
||||
} // namespace routing_algorithms
|
||||
|
@ -127,26 +127,6 @@ void BasicRoutingInterface::RoutingStep(
|
||||
}
|
||||
}
|
||||
|
||||
EdgeWeight
|
||||
BasicRoutingInterface::GetLoopWeight(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
NodeID node) const
|
||||
{
|
||||
EdgeWeight loop_weight = INVALID_EDGE_WEIGHT;
|
||||
for (auto edge : facade->GetAdjacentEdgeRange(node))
|
||||
{
|
||||
const auto &data = facade->GetEdgeData(edge);
|
||||
if (data.forward)
|
||||
{
|
||||
const NodeID to = facade->GetTarget(edge);
|
||||
if (to == node)
|
||||
{
|
||||
loop_weight = std::min(loop_weight, data.weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
return loop_weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpacks a single edge (NodeID->NodeID) from the CH graph down to it's original non-shortcut
|
||||
* route.
|
||||
|
@ -13,6 +13,7 @@ SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_2;
|
||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_2;
|
||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_3;
|
||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_3;
|
||||
SearchEngineData::ManyToManyHeapPtr SearchEngineData::many_to_many_heap;
|
||||
|
||||
void SearchEngineData::InitializeOrClearFirstThreadLocalStorage(const unsigned number_of_nodes)
|
||||
{
|
||||
@ -76,5 +77,17 @@ void SearchEngineData::InitializeOrClearThirdThreadLocalStorage(const unsigned n
|
||||
reverse_heap_3.reset(new QueryHeap(number_of_nodes));
|
||||
}
|
||||
}
|
||||
|
||||
void SearchEngineData::InitializeOrClearManyToManyThreadLocalStorage(const unsigned number_of_nodes)
|
||||
{
|
||||
if (many_to_many_heap.get())
|
||||
{
|
||||
many_to_many_heap->Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
many_to_many_heap.reset(new ManyToManyQueryHeap(number_of_nodes));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -544,8 +544,15 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
auto turn_id = m_edge_based_edge_list.size();
|
||||
auto weight =
|
||||
boost::numeric_cast<EdgeWeight>(edge_data1.weight + weight_penalty);
|
||||
m_edge_based_edge_list.emplace_back(
|
||||
edge_data1.edge_id, edge_data2.edge_id, turn_id, weight, true, false);
|
||||
auto duration =
|
||||
boost::numeric_cast<EdgeWeight>(edge_data1.duration + duration_penalty);
|
||||
m_edge_based_edge_list.emplace_back(edge_data1.edge_id,
|
||||
edge_data2.edge_id,
|
||||
turn_id,
|
||||
weight,
|
||||
duration,
|
||||
true,
|
||||
false);
|
||||
BOOST_ASSERT(original_edges_counter == m_edge_based_edge_list.size());
|
||||
|
||||
BOOST_ASSERT(turn_weight_penalties.size() == turn_id);
|
||||
|
@ -324,6 +324,7 @@ void Extractor::FindComponents(unsigned max_edge_id,
|
||||
{
|
||||
struct UncontractedEdgeData
|
||||
{
|
||||
EdgeWeight duration;
|
||||
};
|
||||
struct InputEdge
|
||||
{
|
||||
@ -353,12 +354,12 @@ void Extractor::FindComponents(unsigned max_edge_id,
|
||||
BOOST_ASSERT(edge.target <= max_edge_id);
|
||||
if (edge.forward)
|
||||
{
|
||||
edges.push_back({edge.source, edge.target, {}});
|
||||
edges.push_back({edge.source, edge.target, {edge.duration}});
|
||||
}
|
||||
|
||||
if (edge.backward)
|
||||
{
|
||||
edges.push_back({edge.target, edge.source, {}});
|
||||
edges.push_back({edge.target, edge.source, {edge.duration}});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,9 +81,9 @@ BOOST_AUTO_TEST_CASE(invalid_table_urls)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(valid_route_hint)
|
||||
{
|
||||
auto hint = engine::Hint::FromBase64("XAYAgP___3-QAAAABAAAACEAAAA_"
|
||||
"AAAAHgAAAHsFAAAUAAAAaWhxALeCmwI7aHEAy4KbAjtocQDLgpsCAAAAA"
|
||||
"KCQXlw=");
|
||||
auto hint = engine::Hint::FromBase64("XAYAgP___3-"
|
||||
"QAAAABQAAACgAAABMAAAAJQAAAAUAAAAoAAAATAAAACUAAAB7BQAAFAAA"
|
||||
"AGpocQC3gpsCO2hxAMuCmwIFAAEBDJujEQ==");
|
||||
BOOST_CHECK_EQUAL(
|
||||
hint.phantom.input_location,
|
||||
util::Coordinate(util::FloatLongitude{7.432251}, util::FloatLatitude{43.745995}));
|
||||
@ -152,12 +152,14 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
|
||||
CHECK_EQUAL_RANGE(reference_3.hints, result_3->hints);
|
||||
|
||||
std::vector<boost::optional<engine::Hint>> hints_4 = {
|
||||
engine::Hint::FromBase64("0QkAgFcLAIBFAAAADAAAACcAAAA0AAAANAAAAB4AAAAmAAAAGA0AAL8QAAARAAAAJ"
|
||||
"ipxAP1ImwIfKnEABUmbAgIAAQFy"),
|
||||
engine::Hint::FromBase64("YwsAgP___3-fAAAAEQAAACcAAAAnAAAAJwAAABYAAAAxAAAA3wEAAOQBAAARAAAA-"
|
||||
"DlxAGBcmwLLOXEAfVybAgEAAQFy"),
|
||||
engine::Hint::FromBase64("awQAgDIJAID7AQAAAAAAAB0AAAAdAAAAHQAAAP4DAAABAQAADwsAAMULAAARAAAAd"
|
||||
"T5yADqVmwIAtMQEAAAAABUAAQFy")};
|
||||
engine::Hint::FromBase64("XAYAgP___3-"
|
||||
"QAAAABQAAACgAAABMAAAAJQAAAAUAAAAoAAAATAAAACUAAAB7BQAAFAAAAGpocQC3"
|
||||
"gpsCO2hxAMuCmwIFAAEBDJujEQ=="),
|
||||
engine::Hint::FromBase64("lgQAgP___3-"
|
||||
"QAAAAEwAAABgAAAAyAAAAOAAAABMAAAAYAAAAMgAAADgAAAA0AAAAFAAAAJphcQC-"
|
||||
"c5sC3GFxALtzmwIEAAEBDJujEQ=="),
|
||||
engine::Hint::FromBase64("OAUAgMUFAIAAAAAAHgAAAAUAAAAAAAAALQEAAB4AAAAFAAAAAAAAAC0BAAC8BAAAF"
|
||||
"AAAAIM-cQBQVpsCiD5xAFBWmwIAAAEBDJujEQ==")};
|
||||
RouteParameters reference_4{false,
|
||||
false,
|
||||
false,
|
||||
@ -170,12 +172,13 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
|
||||
std::vector<boost::optional<engine::Bearing>>{}};
|
||||
auto result_4 = parseParameters<RouteParameters>(
|
||||
"1,2;3,4?steps=false&hints="
|
||||
"0QkAgFcLAIBFAAAADAAAACcAAAA0AAAANAAAAB4AAAAmAAAAGA0AAL8QAAARAAAAJipxAP1ImwIfKnEABUmbAgIAAQ"
|
||||
"Fy;"
|
||||
"YwsAgP___3-fAAAAEQAAACcAAAAnAAAAJwAAABYAAAAxAAAA3wEAAOQBAAARAAAA-"
|
||||
"DlxAGBcmwLLOXEAfVybAgEAAQFy;"
|
||||
"awQAgDIJAID7AQAAAAAAAB0AAAAdAAAAHQAAAP4DAAABAQAADwsAAMULAAARAAAAdT5yADqVmwIAtMQEAAAAABUAAQ"
|
||||
"Fy");
|
||||
"XAYAgP___3-"
|
||||
"QAAAABQAAACgAAABMAAAAJQAAAAUAAAAoAAAATAAAACUAAAB7BQAAFAAAAGpocQC3gpsCO2hxAMuCmwIFAAEBDJujE"
|
||||
"Q==;"
|
||||
"lgQAgP___3-QAAAAEwAAABgAAAAyAAAAOAAAABMAAAAYAAAAMgAAADgAAAA0AAAAFAAAAJphcQC-"
|
||||
"c5sC3GFxALtzmwIEAAEBDJujEQ==;"
|
||||
"OAUAgMUFAIAAAAAAHgAAAAUAAAAAAAAALQEAAB4AAAAFAAAAAAAAAC0BAAC8BAAAFAAAAIM-"
|
||||
"cQBQVpsCiD5xAFBWmwIAAAEBDJujEQ==");
|
||||
BOOST_CHECK(result_4);
|
||||
BOOST_CHECK_EQUAL(reference_4.steps, result_4->steps);
|
||||
BOOST_CHECK_EQUAL(reference_4.alternatives, result_4->alternatives);
|
||||
@ -270,11 +273,12 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
|
||||
{util::FloatLongitude{5}, util::FloatLatitude{6}},
|
||||
{util::FloatLongitude{7}, util::FloatLatitude{8}}};
|
||||
std::vector<boost::optional<engine::Hint>> hints_10 = {
|
||||
engine::Hint::FromBase64("0QkAgFcLAIBFAAAADAAAACcAAAA0AAAANAAAAB4AAAAmAAAAGA0AAL8QAAARAAAAJ"
|
||||
"ipxAP1ImwIfKnEABUmbAgIAAQFy"),
|
||||
engine::Hint::FromBase64("XAYAgP___3-"
|
||||
"QAAAABQAAACgAAABMAAAAJQAAAAUAAAAoAAAATAAAACUAAAB7BQAAFAAAAGpocQC3"
|
||||
"gpsCO2hxAMuCmwIFAAEBDJujEQ=="),
|
||||
boost::none,
|
||||
engine::Hint::FromBase64("awQAgDIJAID7AQAAAAAAAB0AAAAdAAAAHQAAAP4DAAABAQAADwsAAMULAAARAAAAd"
|
||||
"T5yADqVmwIAtMQEAAAAABUAAQFy"),
|
||||
engine::Hint::FromBase64("OAUAgMUFAIAAAAAAHgAAAAUAAAAAAAAALQEAAB4AAAAFAAAAAAAAAC0BAAC8BAAAF"
|
||||
"AAAAIM-cQBQVpsCiD5xAFBWmwIAAAEBDJujEQ=="),
|
||||
boost::none};
|
||||
RouteParameters reference_10{false,
|
||||
false,
|
||||
@ -288,11 +292,11 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
|
||||
std::vector<boost::optional<engine::Bearing>>{}};
|
||||
auto result_10 =
|
||||
parseParameters<RouteParameters>("1,2;3,4;5,6;7,8?steps=false&hints="
|
||||
"0QkAgFcLAIBFAAAADAAAACcAAAA0AAAANAAAAB4AAAAmAAAAGA0AAL8QA"
|
||||
"AARAAAAJipxAP1ImwIfKnEABUmbAgIAAQFy;;"
|
||||
"awQAgDIJAID7AQAAAAAAAB0AAAAdAAAAHQAAAP4DAAABAQAADwsAAMULA"
|
||||
"AARAAAAdT5yADqVmwIAtMQEAAAAABUAAQFy"
|
||||
";");
|
||||
"XAYAgP___3-"
|
||||
"QAAAABQAAACgAAABMAAAAJQAAAAUAAAAoAAAATAAAACUAAAB7BQAAFAAA"
|
||||
"AGpocQC3gpsCO2hxAMuCmwIFAAEBDJujEQ==;;"
|
||||
"OAUAgMUFAIAAAAAAHgAAAAUAAAAAAAAALQEAAB4AAAAFAAAAAAAAAC0BA"
|
||||
"AC8BAAAFAAAAIM-cQBQVpsCiD5xAFBWmwIAAAEBDJujEQ==;");
|
||||
BOOST_CHECK(result_10);
|
||||
BOOST_CHECK_EQUAL(reference_10.steps, result_10->steps);
|
||||
BOOST_CHECK_EQUAL(reference_10.alternatives, result_10->alternatives);
|
||||
|
Loading…
Reference in New Issue
Block a user