Unpacking of intermediate paths
This commit is contained in:
@@ -112,28 +112,28 @@ public:
|
||||
int upper_bound_to_shortest_path_distance = INT_MAX;
|
||||
NodeID middle_node = UINT_MAX;
|
||||
forward_heap1.Insert(
|
||||
phantom_node_pair.startPhantom.edgeBasedNode,
|
||||
-phantom_node_pair.startPhantom.weight1,
|
||||
phantom_node_pair.startPhantom.edgeBasedNode
|
||||
phantom_node_pair.startPhantom.forward_node_id,
|
||||
-phantom_node_pair.startPhantom.forward_weight,
|
||||
phantom_node_pair.startPhantom.forward_node_id
|
||||
);
|
||||
if(phantom_node_pair.startPhantom.isBidirected() ) {
|
||||
forward_heap1.Insert(
|
||||
phantom_node_pair.startPhantom.edgeBasedNode+1,
|
||||
-phantom_node_pair.startPhantom.weight2,
|
||||
phantom_node_pair.startPhantom.edgeBasedNode+1
|
||||
phantom_node_pair.startPhantom.reverse_node_id,
|
||||
-phantom_node_pair.startPhantom.reverse_weight,
|
||||
phantom_node_pair.startPhantom.reverse_node_id
|
||||
);
|
||||
}
|
||||
|
||||
reverse_heap1.Insert(
|
||||
phantom_node_pair.targetPhantom.edgeBasedNode,
|
||||
phantom_node_pair.targetPhantom.weight1,
|
||||
phantom_node_pair.targetPhantom.edgeBasedNode
|
||||
phantom_node_pair.targetPhantom.forward_node_id,
|
||||
phantom_node_pair.targetPhantom.forward_weight,
|
||||
phantom_node_pair.targetPhantom.forward_node_id
|
||||
);
|
||||
if(phantom_node_pair.targetPhantom.isBidirected() ) {
|
||||
reverse_heap1.Insert(
|
||||
phantom_node_pair.targetPhantom.edgeBasedNode+1,
|
||||
phantom_node_pair.targetPhantom.weight2,
|
||||
phantom_node_pair.targetPhantom.edgeBasedNode+1
|
||||
phantom_node_pair.targetPhantom.reverse_node_id,
|
||||
phantom_node_pair.targetPhantom.reverse_weight,
|
||||
phantom_node_pair.targetPhantom.reverse_node_id
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "../DataStructures/RawRouteData.h"
|
||||
#include "../DataStructures/SearchEngineData.h"
|
||||
#include "../DataStructures/TurnInstructions.h"
|
||||
#include "../Util/ContainerUtils.h"
|
||||
#include "../Util/SimpleLogger.h"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
#include <climits>
|
||||
@@ -188,7 +190,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOST_ASSERT_MSG(edge_weight != INT_MAX, "edge id invalid");
|
||||
BOOST_ASSERT_MSG(edge_weight != INT_MAX, "edge weight invalid");
|
||||
|
||||
const EdgeData& ed = facade->GetEdgeData(smaller_edge_id);
|
||||
if( ed.shortcut ) {//unpack
|
||||
@@ -197,15 +199,43 @@ public:
|
||||
recursion_stack.push(std::make_pair(middle_node_id, edge.second));
|
||||
recursion_stack.push(std::make_pair(edge.first, middle_node_id));
|
||||
} else {
|
||||
BOOST_ASSERT_MSG(!ed.shortcut, "edge must be a shortcut");
|
||||
unpacked_path.push_back(
|
||||
PathData(
|
||||
ed.id,
|
||||
facade->GetNameIndexFromEdgeID(ed.id),
|
||||
facade->GetTurnInstructionForEdgeID(ed.id),
|
||||
ed.distance
|
||||
)
|
||||
);
|
||||
BOOST_ASSERT_MSG(!ed.shortcut, "original edge flagged as shortcut");
|
||||
unsigned name_index = facade->GetNameIndexFromEdgeID(ed.id);
|
||||
TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id);
|
||||
//TODO: reorder to always iterate over a result vector
|
||||
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(
|
||||
facade->GetGeometryIndexForEdgeID(ed.id),
|
||||
name_index,
|
||||
turn_instruction,
|
||||
ed.distance
|
||||
)
|
||||
);
|
||||
} else {
|
||||
SimpleLogger().Write() << "Edge " << ed.id << " is compressed";
|
||||
std::vector<unsigned> id_vector;
|
||||
facade->GetUncompressedGeometry(ed.id, id_vector);
|
||||
BOOST_FOREACH(const unsigned coordinate_id, id_vector){
|
||||
//TODO: unpack entire geometry
|
||||
//TODO: set distance to 0, see if works
|
||||
|
||||
unpacked_path.push_back(
|
||||
PathData(
|
||||
coordinate_id,
|
||||
name_index,
|
||||
TurnInstructionsClass::NoTurn,
|
||||
0
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
unpacked_path.back().turnInstruction = turn_instruction;
|
||||
unpacked_path.back().durationOfSegment = ed.distance;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -313,7 +343,7 @@ public:
|
||||
}
|
||||
|
||||
int ComputeEdgeOffset(const PhantomNode & phantom) const {
|
||||
return phantom.weight1 + (phantom.isBidirected() ? phantom.weight2 : 0);
|
||||
return phantom.forward_weight + (phantom.isBidirected() ? phantom.reverse_weight : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -105,41 +105,47 @@ public:
|
||||
|
||||
//insert new starting nodes into forward heap, adjusted by previous distances.
|
||||
if(search_from_1st_node) {
|
||||
BOOST_ASSERT(phantom_node_pair.startPhantom.forward_node_id != UINT_MAX);
|
||||
|
||||
forward_heap1.Insert(
|
||||
phantom_node_pair.startPhantom.edgeBasedNode,
|
||||
distance1-phantom_node_pair.startPhantom.weight1,
|
||||
phantom_node_pair.startPhantom.edgeBasedNode
|
||||
phantom_node_pair.startPhantom.forward_node_id,
|
||||
distance1-phantom_node_pair.startPhantom.forward_weight,
|
||||
phantom_node_pair.startPhantom.forward_node_id
|
||||
);
|
||||
forward_heap2.Insert(
|
||||
phantom_node_pair.startPhantom.edgeBasedNode,
|
||||
distance1-phantom_node_pair.startPhantom.weight1,
|
||||
phantom_node_pair.startPhantom.edgeBasedNode
|
||||
phantom_node_pair.startPhantom.forward_node_id,
|
||||
distance1-phantom_node_pair.startPhantom.forward_weight,
|
||||
phantom_node_pair.startPhantom.forward_node_id
|
||||
);
|
||||
}
|
||||
if(phantom_node_pair.startPhantom.isBidirected() && search_from_2nd_node) {
|
||||
BOOST_ASSERT(phantom_node_pair.startPhantom.reverse_node_id != UINT_MAX);
|
||||
forward_heap1.Insert(
|
||||
phantom_node_pair.startPhantom.edgeBasedNode+1,
|
||||
distance2-phantom_node_pair.startPhantom.weight2,
|
||||
phantom_node_pair.startPhantom.edgeBasedNode+1
|
||||
phantom_node_pair.startPhantom.reverse_node_id,
|
||||
distance2-phantom_node_pair.startPhantom.reverse_weight,
|
||||
phantom_node_pair.startPhantom.reverse_node_id
|
||||
);
|
||||
forward_heap2.Insert(
|
||||
phantom_node_pair.startPhantom.edgeBasedNode+1,
|
||||
distance2-phantom_node_pair.startPhantom.weight2,
|
||||
phantom_node_pair.startPhantom.edgeBasedNode+1
|
||||
phantom_node_pair.startPhantom.reverse_node_id,
|
||||
distance2-phantom_node_pair.startPhantom.reverse_weight,
|
||||
phantom_node_pair.startPhantom.reverse_node_id
|
||||
);
|
||||
}
|
||||
|
||||
//insert new backward nodes into backward heap, unadjusted.
|
||||
reverse_heap1.Insert(
|
||||
phantom_node_pair.targetPhantom.edgeBasedNode,
|
||||
phantom_node_pair.targetPhantom.weight1,
|
||||
phantom_node_pair.targetPhantom.edgeBasedNode
|
||||
phantom_node_pair.targetPhantom.forward_node_id,
|
||||
phantom_node_pair.targetPhantom.forward_weight,
|
||||
phantom_node_pair.targetPhantom.forward_node_id
|
||||
);
|
||||
BOOST_ASSERT(phantom_node_pair.targetPhantom.forward_node_id != UINT_MAX);
|
||||
|
||||
if(phantom_node_pair.targetPhantom.isBidirected() ) {
|
||||
BOOST_ASSERT(phantom_node_pair.startPhantom.forward_node_id != UINT_MAX);
|
||||
reverse_heap2.Insert(
|
||||
phantom_node_pair.targetPhantom.edgeBasedNode+1,
|
||||
phantom_node_pair.targetPhantom.weight2,
|
||||
phantom_node_pair.targetPhantom.edgeBasedNode+1
|
||||
phantom_node_pair.targetPhantom.reverse_node_id,
|
||||
phantom_node_pair.targetPhantom.reverse_weight,
|
||||
phantom_node_pair.targetPhantom.reverse_node_id
|
||||
);
|
||||
}
|
||||
|
||||
@@ -264,8 +270,6 @@ public:
|
||||
local_upper_bound2 = local_upper_bound1;
|
||||
}
|
||||
|
||||
// SimpleLogger().Write() << "fetched packed paths";
|
||||
|
||||
BOOST_ASSERT_MSG(
|
||||
!temporary_packed_leg1.empty() ||
|
||||
!temporary_packed_leg2.empty(),
|
||||
@@ -338,8 +342,8 @@ public:
|
||||
phantom_node_pair.targetPhantom.isBidirected()
|
||||
) {
|
||||
const NodeID last_node_id = packed_legs2[current_leg].back();
|
||||
search_from_1st_node &= !(last_node_id == phantom_node_pair.targetPhantom.edgeBasedNode+1);
|
||||
search_from_2nd_node &= !(last_node_id == phantom_node_pair.targetPhantom.edgeBasedNode);
|
||||
search_from_1st_node &= !(last_node_id == phantom_node_pair.targetPhantom.reverse_node_id);
|
||||
search_from_2nd_node &= !(last_node_id == phantom_node_pair.targetPhantom.forward_node_id);
|
||||
BOOST_ASSERT( search_from_1st_node != search_from_2nd_node );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user