first segment needs to be properly cut
This commit is contained in:
@@ -76,15 +76,16 @@ public:
|
||||
|
||||
~AlternativeRouting() {}
|
||||
|
||||
void operator()(
|
||||
void operator() (
|
||||
const PhantomNodes & phantom_node_pair,
|
||||
RawRouteData & raw_route_data
|
||||
) {
|
||||
if( (!phantom_node_pair.AtLeastOnePhantomNodeIsUINTMAX()) ||
|
||||
phantom_node_pair.PhantomNodesHaveEqualLocation()
|
||||
if( //phantom_node_pair.AtLeastOnePhantomNodeIsUINTMAX() ||
|
||||
phantom_node_pair.PhantomNodesHaveEqualLocation()
|
||||
) {
|
||||
raw_route_data.lengthOfShortestPath = INT_MAX;
|
||||
raw_route_data.lengthOfAlternativePath = INT_MAX;
|
||||
SimpleLogger().Write(logDEBUG) << "not executing path search";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,14 +110,18 @@ public:
|
||||
QueryHeap & forward_heap2 = *(engine_working_data.forwardHeap2);
|
||||
QueryHeap & reverse_heap2 = *(engine_working_data.backwardHeap2);
|
||||
|
||||
int upper_bound_to_shortest_path_distance = INT_MAX;
|
||||
int upper_bound_to_shortest_path_distance = INVALID_EDGE_WEIGHT;
|
||||
NodeID middle_node = UINT_MAX;
|
||||
forward_heap1.Insert(
|
||||
phantom_node_pair.startPhantom.forward_node_id,
|
||||
-phantom_node_pair.startPhantom.GetForwardWeightPlusOffset(),
|
||||
phantom_node_pair.startPhantom.forward_node_id
|
||||
);
|
||||
if(phantom_node_pair.startPhantom.isBidirected() ) {
|
||||
if(phantom_node_pair.startPhantom.forward_node_id != SPECIAL_NODEID ) {
|
||||
SimpleLogger().Write(logDEBUG) << "fwd insert: " << phantom_node_pair.startPhantom.forward_node_id;
|
||||
forward_heap1.Insert(
|
||||
phantom_node_pair.startPhantom.forward_node_id,
|
||||
-phantom_node_pair.startPhantom.GetForwardWeightPlusOffset(),
|
||||
phantom_node_pair.startPhantom.forward_node_id
|
||||
);
|
||||
}
|
||||
if(phantom_node_pair.startPhantom.reverse_node_id != SPECIAL_NODEID ) {
|
||||
SimpleLogger().Write(logDEBUG) << "fwd insert: " << phantom_node_pair.startPhantom.reverse_node_id;
|
||||
forward_heap1.Insert(
|
||||
phantom_node_pair.startPhantom.reverse_node_id,
|
||||
-phantom_node_pair.startPhantom.GetReverseWeightPlusOffset(),
|
||||
@@ -124,12 +129,16 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
reverse_heap1.Insert(
|
||||
phantom_node_pair.targetPhantom.forward_node_id,
|
||||
phantom_node_pair.targetPhantom.GetForwardWeightPlusOffset(),
|
||||
phantom_node_pair.targetPhantom.forward_node_id
|
||||
);
|
||||
if(phantom_node_pair.targetPhantom.isBidirected() ) {
|
||||
if(phantom_node_pair.targetPhantom.forward_node_id != SPECIAL_NODEID ) {
|
||||
SimpleLogger().Write(logDEBUG) << "rev insert: " << phantom_node_pair.targetPhantom.forward_node_id;
|
||||
reverse_heap1.Insert(
|
||||
phantom_node_pair.targetPhantom.forward_node_id,
|
||||
phantom_node_pair.targetPhantom.GetForwardWeightPlusOffset(),
|
||||
phantom_node_pair.targetPhantom.forward_node_id
|
||||
);
|
||||
}
|
||||
if(phantom_node_pair.targetPhantom.reverse_node_id != SPECIAL_NODEID ) {
|
||||
SimpleLogger().Write(logDEBUG) << "rev insert: " << phantom_node_pair.targetPhantom.reverse_node_id;
|
||||
reverse_heap1.Insert(
|
||||
phantom_node_pair.targetPhantom.reverse_node_id,
|
||||
phantom_node_pair.targetPhantom.GetReverseWeightPlusOffset(),
|
||||
@@ -237,16 +246,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<NodeID> & packedShortestPath = packed_forward_path;
|
||||
std::reverse(packedShortestPath.begin(), packedShortestPath.end());
|
||||
packedShortestPath.push_back(middle_node);
|
||||
packedShortestPath.insert(packedShortestPath.end(),packed_reverse_path.begin(), packed_reverse_path.end());
|
||||
std::vector<NodeID> & packed_shortest_path = packed_forward_path;
|
||||
std::reverse(packed_shortest_path.begin(), packed_shortest_path.end());
|
||||
packed_shortest_path.push_back(middle_node);
|
||||
packed_shortest_path.insert(packed_shortest_path.end(),packed_reverse_path.begin(), packed_reverse_path.end());
|
||||
std::vector<RankedCandidateNode > rankedCandidates;
|
||||
|
||||
//prioritizing via nodes for deep inspection
|
||||
BOOST_FOREACH(const NodeID node, nodes_that_passed_preselection) {
|
||||
int lengthOfViaPath = 0, sharingOfViaPath = 0;
|
||||
computeLengthAndSharingOfViaPath(node, &lengthOfViaPath, &sharingOfViaPath, forward_offset+reverse_offset, packedShortestPath);
|
||||
computeLengthAndSharingOfViaPath(node, &lengthOfViaPath, &sharingOfViaPath, forward_offset+reverse_offset, packed_shortest_path);
|
||||
if(sharingOfViaPath <= upper_bound_to_shortest_path_distance*VIAPATH_GAMMA) {
|
||||
rankedCandidates.push_back(RankedCandidateNode(node, lengthOfViaPath, sharingOfViaPath));
|
||||
}
|
||||
@@ -267,33 +276,92 @@ public:
|
||||
|
||||
//Unpack shortest path and alternative, if they exist
|
||||
if(INT_MAX != upper_bound_to_shortest_path_distance) {
|
||||
BOOST_ASSERT( !packed_shortest_path.empty() );
|
||||
raw_route_data.unpacked_path_segments.resize(1);
|
||||
super::UnpackPath(packedShortestPath, raw_route_data.unpacked_path_segments[0]);
|
||||
// SimpleLogger().Write() << "fwd offset1: " << phantom_node_pair.startPhantom.fwd_segment_position;
|
||||
// SimpleLogger().Write() << "fwd offset2: " << phantom_node_pair.startPhantom.rev_segment_position;
|
||||
// SimpleLogger().Write() << "rev offset1: " << phantom_node_pair.targetPhantom.fwd_segment_position;
|
||||
// SimpleLogger().Write() << "rev offset2: " << phantom_node_pair.targetPhantom.rev_segment_position;
|
||||
|
||||
// int start_offset = ( packed_shortest_path.front() == phantom_node_pair.startPhantom.forward_node_id ? 1 : -1 )*phantom_node_pair.startPhantom.fwd_segment_position;
|
||||
// SimpleLogger().Write(logDEBUG) << "unpacking from index " << phantom_node_pair.startPhantom.fwd_segment_position;
|
||||
|
||||
SimpleLogger().Write(logDEBUG) << "phantom_node_pair.startPhantom.forward_node_id: " << phantom_node_pair.startPhantom.forward_node_id;
|
||||
SimpleLogger().Write(logDEBUG) << "phantom_node_pair.startPhantom.reverse_node_id: " << phantom_node_pair.startPhantom.reverse_node_id;
|
||||
SimpleLogger().Write(logDEBUG) << "packed_shortest_path.front(): " << packed_shortest_path.front();
|
||||
// SimpleLogger().Write(logDEBUG) << "packed_shortest_path.back(): " << packed_shortest_path.back();
|
||||
|
||||
super::UnpackPath(
|
||||
packed_shortest_path,
|
||||
phantom_node_pair.startPhantom.fwd_segment_position,
|
||||
(packed_shortest_path.front() == phantom_node_pair.startPhantom.reverse_node_id),
|
||||
phantom_node_pair.targetPhantom.fwd_segment_position,//( packed_forward_path.back() == phantom_node_pair.targetPhantom.forward_node_id ? 1 : -1 )*phantom_node_pair.targetPhantom.fwd_segment_position,
|
||||
raw_route_data.unpacked_path_segments.front()
|
||||
);
|
||||
raw_route_data.lengthOfShortestPath = upper_bound_to_shortest_path_distance;
|
||||
} else {
|
||||
//TODO: kill this branch by initialization
|
||||
raw_route_data.lengthOfShortestPath = INT_MAX;
|
||||
}
|
||||
|
||||
if(selectedViaNode != UINT_MAX) {
|
||||
retrievePackedViaPath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, s_v_middle, v_t_middle, raw_route_data.unpacked_alternative);
|
||||
RetrieveAndUnpackAlternatePath(
|
||||
forward_heap1,
|
||||
reverse_heap1,
|
||||
forward_heap2,
|
||||
reverse_heap2,
|
||||
s_v_middle,
|
||||
v_t_middle,
|
||||
raw_route_data.unpacked_alternative
|
||||
);
|
||||
raw_route_data.lengthOfAlternativePath = lengthOfViaPath;
|
||||
} else {
|
||||
//TODO: kill this branch by initialization
|
||||
raw_route_data.lengthOfAlternativePath = INT_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
//unpack <s,..,v,..,t> by exploring search spaces from v
|
||||
inline void retrievePackedViaPath(QueryHeap & _forwardHeap1, QueryHeap & _backwardHeap1, QueryHeap & _forwardHeap2, QueryHeap & _backwardHeap2,
|
||||
const NodeID s_v_middle, const NodeID v_t_middle, std::vector<PathData> & unpackedPath) {
|
||||
//unpack [s,v)
|
||||
inline void RetrieveAndUnpackAlternatePath(
|
||||
const QueryHeap & forward_heap1,
|
||||
const QueryHeap & reverse_heap1,
|
||||
const QueryHeap & forward_heap2,
|
||||
const QueryHeap & reverse_heap2,
|
||||
const NodeID s_v_middle,
|
||||
const NodeID v_t_middle,
|
||||
std::vector<PathData> & unpacked_path
|
||||
) const {
|
||||
//fetch packed path [s,v)
|
||||
std::vector<NodeID> packed_s_v_path, packed_v_t_path;
|
||||
super::RetrievePackedPathFromHeap(_forwardHeap1, _backwardHeap2, s_v_middle, packed_s_v_path);
|
||||
packed_s_v_path.resize(packed_s_v_path.size()-1);
|
||||
//unpack [v,t]
|
||||
super::RetrievePackedPathFromHeap(_forwardHeap2, _backwardHeap1, v_t_middle, packed_v_t_path);
|
||||
packed_s_v_path.insert(packed_s_v_path.end(),packed_v_t_path.begin(), packed_v_t_path.end() );
|
||||
super::UnpackPath(packed_s_v_path, unpackedPath);
|
||||
super::RetrievePackedPathFromHeap(
|
||||
forward_heap1,
|
||||
reverse_heap2,
|
||||
s_v_middle,
|
||||
packed_s_v_path
|
||||
);
|
||||
packed_s_v_path.pop_back(); //remove v, other we get it twice
|
||||
|
||||
//fetch patched path [v,t]
|
||||
super::RetrievePackedPathFromHeap(
|
||||
forward_heap2,
|
||||
reverse_heap1,
|
||||
v_t_middle,
|
||||
packed_v_t_path
|
||||
);
|
||||
|
||||
packed_s_v_path.insert(
|
||||
packed_s_v_path.end(),
|
||||
packed_v_t_path.begin(),
|
||||
packed_v_t_path.end()
|
||||
);
|
||||
|
||||
// unpack, supply correct offsets to packed start and end nodes.
|
||||
super::UnpackPath(
|
||||
packed_s_v_path,
|
||||
0, false, 0, //TODO: replace by real offsets
|
||||
unpacked_path
|
||||
);
|
||||
}
|
||||
|
||||
inline void computeLengthAndSharingOfViaPath(const NodeID via_node, int *real_length_of_via_path, int *sharing_of_via_path,
|
||||
@@ -312,7 +380,7 @@ private:
|
||||
std::vector < NodeID > packed_s_v_path;
|
||||
std::vector < NodeID > packed_v_t_path;
|
||||
|
||||
std::vector<NodeID> partiallyUnpackedShortestPath;
|
||||
std::vector<NodeID> partiallyUnpacked_shortest_path;
|
||||
std::vector<NodeID> partiallyUnpackedViaPath;
|
||||
|
||||
NodeID s_v_middle = UINT_MAX;
|
||||
@@ -346,13 +414,13 @@ private:
|
||||
} else {
|
||||
if (packed_s_v_path[i] == packed_shortest_path[i]) {
|
||||
super::UnpackEdge(packed_s_v_path[i], packed_s_v_path[i+1], partiallyUnpackedViaPath);
|
||||
super::UnpackEdge(packed_shortest_path[i], packed_shortest_path[i+1], partiallyUnpackedShortestPath);
|
||||
super::UnpackEdge(packed_shortest_path[i], packed_shortest_path[i+1], partiallyUnpacked_shortest_path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//traverse partially unpacked edge and note common prefix
|
||||
for (int i = 0, lengthOfPackedPath = std::min( partiallyUnpackedViaPath.size(), partiallyUnpackedShortestPath.size()) - 1; (i < lengthOfPackedPath) && (partiallyUnpackedViaPath[i] == partiallyUnpackedShortestPath[i] && partiallyUnpackedViaPath[i+1] == partiallyUnpackedShortestPath[i+1]); ++i) {
|
||||
for (int i = 0, lengthOfPackedPath = std::min( partiallyUnpackedViaPath.size(), partiallyUnpacked_shortest_path.size()) - 1; (i < lengthOfPackedPath) && (partiallyUnpackedViaPath[i] == partiallyUnpacked_shortest_path[i] && partiallyUnpackedViaPath[i+1] == partiallyUnpacked_shortest_path[i+1]); ++i) {
|
||||
EdgeID edgeID = facade->FindEdgeInEitherDirection(partiallyUnpackedViaPath[i], partiallyUnpackedViaPath[i+1]);
|
||||
*sharing_of_via_path += facade->GetEdgeData(edgeID).distance;
|
||||
}
|
||||
@@ -367,16 +435,16 @@ private:
|
||||
} else {
|
||||
if (packed_v_t_path[viaPathIndex] == packed_shortest_path[shortestPathIndex]) {
|
||||
super::UnpackEdge(packed_v_t_path[viaPathIndex-1], packed_v_t_path[viaPathIndex], partiallyUnpackedViaPath);
|
||||
super::UnpackEdge(packed_shortest_path[shortestPathIndex-1] , packed_shortest_path[shortestPathIndex], partiallyUnpackedShortestPath);
|
||||
super::UnpackEdge(packed_shortest_path[shortestPathIndex-1] , packed_shortest_path[shortestPathIndex], partiallyUnpacked_shortest_path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viaPathIndex = partiallyUnpackedViaPath.size() - 1;
|
||||
shortestPathIndex = partiallyUnpackedShortestPath.size() - 1;
|
||||
shortestPathIndex = partiallyUnpacked_shortest_path.size() - 1;
|
||||
for (; viaPathIndex > 0 && shortestPathIndex > 0; --viaPathIndex,--shortestPathIndex) {
|
||||
if (partiallyUnpackedViaPath[viaPathIndex - 1] == partiallyUnpackedShortestPath[shortestPathIndex - 1] && partiallyUnpackedViaPath[viaPathIndex] == partiallyUnpackedShortestPath[shortestPathIndex]) {
|
||||
if (partiallyUnpackedViaPath[viaPathIndex - 1] == partiallyUnpacked_shortest_path[shortestPathIndex - 1] && partiallyUnpackedViaPath[viaPathIndex] == partiallyUnpacked_shortest_path[shortestPathIndex]) {
|
||||
EdgeID edgeID = facade->FindEdgeInEitherDirection( partiallyUnpackedViaPath[viaPathIndex - 1], partiallyUnpackedViaPath[viaPathIndex]);
|
||||
*sharing_of_via_path += facade->GetEdgeData(edgeID).distance;
|
||||
} else {
|
||||
@@ -386,17 +454,17 @@ private:
|
||||
//finished partial unpacking spree! Amount of sharing is stored to appropriate pointer variable
|
||||
}
|
||||
|
||||
inline int approximateAmountOfSharing(const NodeID middleNodeIDOfAlternativePath, QueryHeap & _forwardHeap, QueryHeap & _backwardHeap, const std::vector<NodeID> & packedShortestPath) {
|
||||
inline int approximateAmountOfSharing(const NodeID middleNodeIDOfAlternativePath, QueryHeap & _forwardHeap, QueryHeap & _backwardHeap, const std::vector<NodeID> & packed_shortest_path) {
|
||||
std::vector<NodeID> packedAlternativePath;
|
||||
super::RetrievePackedPathFromHeap(_forwardHeap, _backwardHeap, middleNodeIDOfAlternativePath, packedAlternativePath);
|
||||
|
||||
if(packedShortestPath.size() < 2 || packedAlternativePath.size() < 2)
|
||||
if(packed_shortest_path.size() < 2 || packedAlternativePath.size() < 2)
|
||||
return 0;
|
||||
|
||||
int sharing = 0;
|
||||
int aindex = 0;
|
||||
//compute forward sharing
|
||||
while( (packedAlternativePath[aindex] == packedShortestPath[aindex]) && (packedAlternativePath[aindex+1] == packedShortestPath[aindex+1]) ) {
|
||||
while( (packedAlternativePath[aindex] == packed_shortest_path[aindex]) && (packedAlternativePath[aindex+1] == packed_shortest_path[aindex+1]) ) {
|
||||
// SimpleLogger().Write() << "retrieving edge (" << packedAlternativePath[aindex] << "," << packedAlternativePath[aindex+1] << ")";
|
||||
EdgeID edgeID = facade->FindEdgeInEitherDirection(packedAlternativePath[aindex], packedAlternativePath[aindex+1]);
|
||||
sharing += facade->GetEdgeData(edgeID).distance;
|
||||
@@ -404,9 +472,9 @@ private:
|
||||
}
|
||||
|
||||
aindex = packedAlternativePath.size()-1;
|
||||
int bindex = packedShortestPath.size()-1;
|
||||
int bindex = packed_shortest_path.size()-1;
|
||||
//compute backward sharing
|
||||
while( aindex > 0 && bindex > 0 && (packedAlternativePath[aindex] == packedShortestPath[bindex]) && (packedAlternativePath[aindex-1] == packedShortestPath[bindex-1]) ) {
|
||||
while( aindex > 0 && bindex > 0 && (packedAlternativePath[aindex] == packed_shortest_path[bindex]) && (packedAlternativePath[aindex-1] == packed_shortest_path[bindex-1]) ) {
|
||||
EdgeID edgeID = facade->FindEdgeInEitherDirection(packedAlternativePath[aindex], packedAlternativePath[aindex-1]);
|
||||
sharing += facade->GetEdgeData(edgeID).distance;
|
||||
--aindex; --bindex;
|
||||
|
||||
@@ -138,8 +138,24 @@ public:
|
||||
|
||||
inline void UnpackPath(
|
||||
const std::vector<NodeID> & packed_path,
|
||||
int fwd_index_offset,
|
||||
bool start_traversed_in_reverse,
|
||||
int rev_index_offset,
|
||||
std::vector<PathData> & unpacked_path
|
||||
) const {
|
||||
|
||||
// SimpleLogger().Write(logDEBUG) << "unpacking path";
|
||||
// for(unsigned i = 0; i < packed_path.size(); ++i) {
|
||||
// std::cout << packed_path[i] << " ";
|
||||
// }
|
||||
|
||||
bool segment_reversed = false;
|
||||
|
||||
SimpleLogger().Write(logDEBUG) << "fwd offset: " << fwd_index_offset;
|
||||
SimpleLogger().Write(logDEBUG) << "rev offset: " << rev_index_offset;
|
||||
SimpleLogger().Write(logDEBUG) << "start_traversed_in_reverse: " << ( start_traversed_in_reverse ? "y" : "n" );
|
||||
|
||||
// SimpleLogger().Write() << "starting unpack";
|
||||
const unsigned packed_path_size = packed_path.size();
|
||||
std::stack<std::pair<NodeID, NodeID> > recursion_stack;
|
||||
|
||||
@@ -155,42 +171,13 @@ public:
|
||||
edge = recursion_stack.top();
|
||||
recursion_stack.pop();
|
||||
|
||||
EdgeID smaller_edge_id = SPECIAL_EDGEID;
|
||||
int edge_weight = INT_MAX;
|
||||
for(
|
||||
EdgeID edge_id = facade->BeginEdges(edge.first);
|
||||
edge_id < facade->EndEdges(edge.first);
|
||||
++edge_id
|
||||
){
|
||||
const int weight = facade->GetEdgeData(edge_id).distance;
|
||||
if(
|
||||
(facade->GetTarget(edge_id) == edge.second) &&
|
||||
(weight < edge_weight) &&
|
||||
facade->GetEdgeData(edge_id).forward
|
||||
){
|
||||
smaller_edge_id = edge_id;
|
||||
edge_weight = weight;
|
||||
}
|
||||
}
|
||||
EdgeID smaller_edge_id = facade->FindEdgeIndicateIfReverse(
|
||||
edge.first,
|
||||
edge.second,
|
||||
segment_reversed
|
||||
);
|
||||
|
||||
if( SPECIAL_EDGEID == smaller_edge_id ){
|
||||
for(
|
||||
EdgeID edge_id = facade->BeginEdges(edge.second);
|
||||
edge_id < facade->EndEdges(edge.second);
|
||||
++edge_id
|
||||
){
|
||||
const int weight = facade->GetEdgeData(edge_id).distance;
|
||||
if(
|
||||
(facade->GetTarget(edge_id) == edge.first) &&
|
||||
(weight < edge_weight) &&
|
||||
facade->GetEdgeData(edge_id).backward
|
||||
){
|
||||
smaller_edge_id = edge_id;
|
||||
edge_weight = weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOST_ASSERT_MSG(edge_weight != INT_MAX, "edge weight invalid");
|
||||
BOOST_ASSERT( SPECIAL_EDGEID != smaller_edge_id );
|
||||
|
||||
const EdgeData& ed = facade->GetEdgeData(smaller_edge_id);
|
||||
if( ed.shortcut ) {//unpack
|
||||
@@ -201,11 +188,10 @@ public:
|
||||
} else {
|
||||
BOOST_ASSERT_MSG(!ed.shortcut, "original edge flagged as shortcut");
|
||||
unsigned name_index = facade->GetNameIndexFromEdgeID(ed.id);
|
||||
TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id);
|
||||
const TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id);
|
||||
|
||||
//TODO: refactor to iterate over a result vector in both cases
|
||||
if ( !facade->EdgeIsCompressed(ed.id) ){
|
||||
SimpleLogger().Write() << "Edge " << ed.id << " is not compressed, smaller_edge_id: " << smaller_edge_id;
|
||||
BOOST_ASSERT( !facade->EdgeIsCompressed(ed.id) );
|
||||
unpacked_path.push_back(
|
||||
PathData(
|
||||
@@ -216,38 +202,74 @@ public:
|
||||
)
|
||||
);
|
||||
} else {
|
||||
SimpleLogger().Write() << "Edge " << ed.id << " is compressed";
|
||||
std::vector<unsigned> id_vector;
|
||||
facade->GetUncompressedGeometry(ed.id, id_vector);
|
||||
|
||||
|
||||
//TODO use only a single for loop
|
||||
if( unpacked_path.empty() ) {
|
||||
SimpleLogger().Write(logDEBUG) << "first segment(" << facade->GetEscapedNameForNameID(ed.id) << ") is packed";
|
||||
// // SimpleLogger().Write(logDEBUG) << "1st node in packed path: " << packed_path.front() << ", edge (" << edge.first << "," << edge.second << ")";
|
||||
// // SimpleLogger().Write(logDEBUG) << "REVERSED1: " << ( facade->GetTarget(smaller_edge_id) != edge.second ? "y" : "n" );
|
||||
// // SimpleLogger().Write(logDEBUG) << "REVERSED2: " << ( facade->GetTarget(smaller_edge_id) != edge.first ? "y" : "n" );
|
||||
// SimpleLogger().Write(logDEBUG) << "segment_reversed: " << ( segment_reversed ? "y" : "n" );
|
||||
// // SimpleLogger().Write(logDEBUG) << "target of edge: " << facade->GetTarget(smaller_edge_id);
|
||||
// // SimpleLogger().Write(logDEBUG) << "first geometry: " << id_vector.front() << ", last geometry: " << id_vector.back();
|
||||
|
||||
const bool edge_is_reversed = (!ed.forward && ed.backward);
|
||||
|
||||
// if( edge_is_reversed ) {
|
||||
// SimpleLogger().Write(logDEBUG) << "reversing geometry";
|
||||
// std::reverse( id_vector.begin(), id_vector.end() );
|
||||
// fwd_index_offset = id_vector.size() - (1+fwd_index_offset);
|
||||
// SimpleLogger().Write() << "new fwd offset: " << fwd_index_offset;
|
||||
// }
|
||||
|
||||
SimpleLogger().Write(logDEBUG) << "edge data fwd: " << (ed.forward ? "y": "n") << ", reverse: " << (ed.backward ? "y" : "n" );
|
||||
SimpleLogger().Write() << "Edge " << ed.id << "=(" << edge.first << "," << edge.second << ") is compressed";
|
||||
SimpleLogger().Write(logDEBUG) << "packed ids: ";
|
||||
BOOST_FOREACH(unsigned number, id_vector) {
|
||||
SimpleLogger().Write() << "[" << number << "] " << facade->GetCoordinateOfNode(number);
|
||||
}
|
||||
const int start_index = ( ( start_traversed_in_reverse ) ? fwd_index_offset : 0 );
|
||||
const int end_index = ( ( start_traversed_in_reverse ) ? id_vector.size() : fwd_index_offset );
|
||||
|
||||
// BOOST_ASSERT( start_index >= 0 );
|
||||
// // BOOST_ASSERT( start_index <= end_index );
|
||||
SimpleLogger().Write(logDEBUG) << "geometry count: " << id_vector.size() << ", fetching[" << start_index << "..." << end_index << "]";
|
||||
for(
|
||||
unsigned i = start_index;
|
||||
i != end_index;
|
||||
(start_index > end_index) ? --i : ++i
|
||||
) {
|
||||
SimpleLogger().Write(logDEBUG) << "[" << i << "]pushing id: " << id_vector[i];
|
||||
unpacked_path.push_back(
|
||||
PathData(
|
||||
id_vector[i],
|
||||
name_index,
|
||||
TurnInstructionsClass::NoTurn,
|
||||
0
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
BOOST_FOREACH(const unsigned coordinate_id, id_vector){
|
||||
// SimpleLogger().Write(logDEBUG) << "pushing id: " << coordinate_id;
|
||||
unpacked_path.push_back(
|
||||
PathData(
|
||||
coordinate_id,
|
||||
name_index,
|
||||
TurnInstructionsClass::NoTurn,
|
||||
0
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
unpacked_path.back().turnInstruction = turn_instruction;
|
||||
unpacked_path.back().durationOfSegment = ed.distance;
|
||||
}
|
||||
|
||||
// if( recursion_stack.empty() ) {
|
||||
// SimpleLogger().Write(logDEBUG) << "last segment is packed";
|
||||
// }
|
||||
|
||||
BOOST_FOREACH(const unsigned coordinate_id, id_vector){
|
||||
//TODO: skip if first edge is compressed until start point is reached
|
||||
unpacked_path.push_back(
|
||||
PathData(
|
||||
coordinate_id,
|
||||
name_index,
|
||||
TurnInstructionsClass::NoTurn,
|
||||
0
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
unpacked_path.back().turnInstruction = turn_instruction;
|
||||
unpacked_path.back().durationOfSegment = ed.distance;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
inline void UnpackEdge(
|
||||
@@ -319,8 +341,8 @@ public:
|
||||
}
|
||||
|
||||
inline void RetrievePackedPathFromHeap(
|
||||
SearchEngineData::QueryHeap & forward_heap,
|
||||
SearchEngineData::QueryHeap & reverse_heap,
|
||||
const SearchEngineData::QueryHeap & forward_heap,
|
||||
const SearchEngineData::QueryHeap & reverse_heap,
|
||||
const NodeID middle_node_id,
|
||||
std::vector<NodeID> & packed_path
|
||||
) const {
|
||||
@@ -329,6 +351,7 @@ public:
|
||||
current_node_id = forward_heap.GetData(current_node_id).parent;
|
||||
packed_path.push_back(current_node_id);
|
||||
}
|
||||
//throw away first segment, unpack individually
|
||||
|
||||
std::reverse(packed_path.begin(), packed_path.end());
|
||||
packed_path.push_back(middle_node_id);
|
||||
|
||||
@@ -356,10 +356,17 @@ public:
|
||||
std::swap( packed_legs1, packed_legs2 );
|
||||
}
|
||||
raw_route_data.unpacked_path_segments.resize( packed_legs1.size() );
|
||||
const int start_offset = ( packed_legs1[0].front() == phantom_nodes_vector.front().startPhantom.forward_node_id ? 1 : -1 )*phantom_nodes_vector.front().startPhantom.fwd_segment_position;
|
||||
|
||||
for(unsigned i = 0; i < packed_legs1.size(); ++i){
|
||||
BOOST_ASSERT( !phantom_nodes_vector.empty() );
|
||||
bool at_beginning = (0 == i);
|
||||
BOOST_ASSERT(packed_legs1.size() == raw_route_data.unpacked_path_segments.size() );
|
||||
super::UnpackPath(
|
||||
packed_legs1[i],
|
||||
( at_beginning ? start_offset : 0),
|
||||
0,
|
||||
false,
|
||||
raw_route_data.unpacked_path_segments[i]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user