rename phantom nodes members

This commit is contained in:
Dennis Luxen 2014-03-25 18:06:05 +01:00
parent 2861bacd2a
commit 7b5902a580
7 changed files with 146 additions and 134 deletions

View File

@ -59,18 +59,20 @@ struct PhantomNode {
unsigned short fwd_segment_position; unsigned short fwd_segment_position;
int GetForwardWeightPlusOffset() const { int GetForwardWeightPlusOffset() const
{
SimpleLogger().Write(logDEBUG) << "->fwd_offset: " << forward_offset << ", weight: " << forward_weight; SimpleLogger().Write(logDEBUG) << "->fwd_offset: " << forward_offset << ", weight: " << forward_weight;
return reverse_offset + forward_weight; return reverse_offset + forward_weight;
} }
int GetReverseWeightPlusOffset() const { int GetReverseWeightPlusOffset() const
{
SimpleLogger().Write(logDEBUG) << "->rev_offset: " << reverse_offset << ", weight: " << reverse_weight; SimpleLogger().Write(logDEBUG) << "->rev_offset: " << reverse_offset << ", weight: " << reverse_weight;
return forward_offset + reverse_weight; return forward_offset + reverse_weight;
} }
void Reset() { void Reset()
{
forward_node_id = SPECIAL_NODEID; forward_node_id = SPECIAL_NODEID;
name_id = SPECIAL_NODEID; name_id = SPECIAL_NODEID;
forward_weight = INVALID_EDGE_WEIGHT; forward_weight = INVALID_EDGE_WEIGHT;
@ -81,16 +83,19 @@ struct PhantomNode {
location.Reset(); location.Reset();
} }
bool isBidirected() const { bool isBidirected() const
{
return (forward_node_id != SPECIAL_NODEID) && return (forward_node_id != SPECIAL_NODEID) &&
(reverse_node_id != SPECIAL_NODEID); (reverse_node_id != SPECIAL_NODEID);
} }
bool IsCompressed() const { bool IsCompressed() const
{
return (forward_offset != 0) || (reverse_offset != 0); return (forward_offset != 0) || (reverse_offset != 0);
} }
bool isValid(const unsigned numberOfNodes) const { bool isValid(const unsigned numberOfNodes) const
{
return return
location.isValid() && location.isValid() &&
( (
@ -107,39 +112,45 @@ struct PhantomNode {
); );
} }
bool operator==(const PhantomNode & other) const { bool operator==(const PhantomNode & other) const
{
return location == other.location; return location == other.location;
} }
}; };
struct PhantomNodes { struct PhantomNodes
{
//TODO: rename to lower-case non-camel source_*,target_* //TODO: rename to lower-case non-camel source_*,target_*
PhantomNode startPhantom; PhantomNode source_phantom;
PhantomNode targetPhantom; PhantomNode target_phantom;
void Reset() { void Reset()
startPhantom.Reset(); {
targetPhantom.Reset(); source_phantom.Reset();
target_phantom.Reset();
} }
bool PhantomsAreOnSameNodeBasedEdge() const { bool PhantomsAreOnSameNodeBasedEdge() const
return (startPhantom.forward_node_id == targetPhantom.forward_node_id); {
return (source_phantom.forward_node_id == target_phantom.forward_node_id);
} }
bool AtLeastOnePhantomNodeIsInvalid() const { bool AtLeastOnePhantomNodeIsInvalid() const
return ((startPhantom.forward_node_id == SPECIAL_NODEID) && (startPhantom.reverse_node_id == SPECIAL_NODEID)) || {
((targetPhantom.forward_node_id == SPECIAL_NODEID) && (targetPhantom.reverse_node_id == SPECIAL_NODEID)); return ((source_phantom.forward_node_id == SPECIAL_NODEID) && (source_phantom.reverse_node_id == SPECIAL_NODEID)) ||
((target_phantom.forward_node_id == SPECIAL_NODEID) && (target_phantom.reverse_node_id == SPECIAL_NODEID));
} }
bool PhantomNodesHaveEqualLocation() const { bool PhantomNodesHaveEqualLocation() const
return startPhantom == targetPhantom; {
return source_phantom == target_phantom;
} }
}; };
inline std::ostream& operator<<(std::ostream &out, const PhantomNodes & pn) { inline std::ostream& operator<<(std::ostream &out, const PhantomNodes & pn) {
// out << "Node1: " << pn.startPhantom.forward_node_id << "\n"; // out << "Node1: " << pn.source_phantom.forward_node_id << "\n";
// out << "Node2: " << pn.targetPhantom.reverse_node_id << "\n"; // out << "Node2: " << pn.target_phantom.reverse_node_id << "\n";
out << "start_coord: " << pn.startPhantom.location << "\n"; out << "source_coord: " << pn.source_phantom.location << "\n";
out << "target_coord: " << pn.targetPhantom.location << std::endl; out << "target_coord: " << pn.target_phantom.location << std::endl;
return out; return out;
} }

View File

@ -65,12 +65,12 @@ public:
(raw_route.unpacked_path_segments[0].size()); (raw_route.unpacked_path_segments[0].size());
if( found_route ) { if( found_route ) {
FixedPointCoordinate::convertInternalLatLonToString( FixedPointCoordinate::convertInternalLatLonToString(
phantom_node_list.startPhantom.location.lat, phantom_node_list.source_phantom.location.lat,
tmp tmp
); );
reply.content.push_back("<rtept lat=\"" + tmp + "\" "); reply.content.push_back("<rtept lat=\"" + tmp + "\" ");
FixedPointCoordinate::convertInternalLatLonToString( FixedPointCoordinate::convertInternalLatLonToString(
phantom_node_list.startPhantom.location.lon, phantom_node_list.source_phantom.location.lon,
tmp tmp
); );
reply.content.push_back("lon=\"" + tmp + "\"></rtept>"); reply.content.push_back("lon=\"" + tmp + "\"></rtept>");
@ -90,12 +90,12 @@ public:
} }
// Add the via point or the end coordinate // Add the via point or the end coordinate
FixedPointCoordinate::convertInternalLatLonToString( FixedPointCoordinate::convertInternalLatLonToString(
phantom_node_list.targetPhantom.location.lat, phantom_node_list.target_phantom.location.lat,
tmp tmp
); );
reply.content.push_back("<rtept lat=\"" + tmp + "\" "); reply.content.push_back("<rtept lat=\"" + tmp + "\" ");
FixedPointCoordinate::convertInternalLatLonToString( FixedPointCoordinate::convertInternalLatLonToString(
phantom_node_list.targetPhantom.location.lon, phantom_node_list.target_phantom.location.lon,
tmp tmp
); );
reply.content.push_back("lon=\"" + tmp + "\"></rtept>"); reply.content.push_back("lon=\"" + tmp + "\"></rtept>");

View File

@ -101,7 +101,7 @@ public:
description_factory.AppendSegment(current_coordinate, path_data ); description_factory.AppendSegment(current_coordinate, path_data );
++added_element_count; ++added_element_count;
} }
// description_factory.SetEndSegment( leg_phantoms.targetPhantom ); // description_factory.SetEndSegment( leg_phantoms.target_phantom );
++added_element_count; ++added_element_count;
BOOST_ASSERT( (int)(route_leg.size() + 1) == added_element_count ); BOOST_ASSERT( (int)(route_leg.size() + 1) == added_element_count );
return added_element_count; return added_element_count;
@ -127,7 +127,7 @@ public:
return; return;
} }
description_factory.SetStartSegment(phantom_nodes.startPhantom); description_factory.SetStartSegment(phantom_nodes.source_phantom);
reply.content.push_back("0," reply.content.push_back("0,"
"\"status_message\": \"Found route between points\","); "\"status_message\": \"Found route between points\",");
@ -142,7 +142,7 @@ public:
added_segments + shortest_leg_end_indices.back() added_segments + shortest_leg_end_indices.back()
); );
} }
description_factory.SetEndSegment(phantom_nodes.targetPhantom); description_factory.SetEndSegment(phantom_nodes.target_phantom);
description_factory.Run(facade, config.zoom_level); description_factory.Run(facade, config.zoom_level);
reply.content.push_back("\"route_geometry\": "); reply.content.push_back("\"route_geometry\": ");
@ -195,13 +195,13 @@ public:
//only one alternative route is computed at this time, so this is hardcoded //only one alternative route is computed at this time, so this is hardcoded
if(raw_route.lengthOfAlternativePath != INT_MAX) { if(raw_route.lengthOfAlternativePath != INT_MAX) {
alternate_descriptionFactory.SetStartSegment(phantom_nodes.startPhantom); alternate_descriptionFactory.SetStartSegment(phantom_nodes.source_phantom);
//Get all the coordinates for the computed route //Get all the coordinates for the computed route
BOOST_FOREACH(const PathData & path_data, raw_route.unpacked_alternative) { BOOST_FOREACH(const PathData & path_data, raw_route.unpacked_alternative) {
current = facade->GetCoordinateOfNode(path_data.node); current = facade->GetCoordinateOfNode(path_data.node);
alternate_descriptionFactory.AppendSegment(current, path_data ); alternate_descriptionFactory.AppendSegment(current, path_data );
} }
alternate_descriptionFactory.SetEndSegment(phantom_nodes.targetPhantom); alternate_descriptionFactory.SetEndSegment(phantom_nodes.target_phantom);
} }
alternate_descriptionFactory.Run(facade, config.zoom_level); alternate_descriptionFactory.Run(facade, config.zoom_level);
@ -286,7 +286,7 @@ public:
std::string tmp; std::string tmp;
FixedPointCoordinate::convertInternalReversedCoordinateToString( FixedPointCoordinate::convertInternalReversedCoordinateToString(
raw_route.segmentEndCoordinates.front().startPhantom.location, raw_route.segmentEndCoordinates.front().source_phantom.location,
tmp tmp
); );
reply.content.push_back("["); reply.content.push_back("[");
@ -296,7 +296,7 @@ public:
BOOST_FOREACH(const PhantomNodes & nodes, raw_route.segmentEndCoordinates) { BOOST_FOREACH(const PhantomNodes & nodes, raw_route.segmentEndCoordinates) {
tmp.clear(); tmp.clear();
FixedPointCoordinate::convertInternalReversedCoordinateToString( FixedPointCoordinate::convertInternalReversedCoordinateToString(
nodes.targetPhantom.location, nodes.target_phantom.location,
tmp tmp
); );
reply.content.push_back(",["); reply.content.push_back(",[");
@ -332,11 +332,11 @@ public:
std::string hint; std::string hint;
for(unsigned i = 0; i < raw_route.segmentEndCoordinates.size(); ++i) { for(unsigned i = 0; i < raw_route.segmentEndCoordinates.size(); ++i) {
reply.content.push_back("\""); reply.content.push_back("\"");
EncodeObjectToBase64(raw_route.segmentEndCoordinates[i].startPhantom, hint); EncodeObjectToBase64(raw_route.segmentEndCoordinates[i].source_phantom, hint);
reply.content.push_back(hint); reply.content.push_back(hint);
reply.content.push_back("\", "); reply.content.push_back("\", ");
} }
EncodeObjectToBase64(raw_route.segmentEndCoordinates.back().targetPhantom, hint); EncodeObjectToBase64(raw_route.segmentEndCoordinates.back().target_phantom, hint);
reply.content.push_back("\""); reply.content.push_back("\"");
reply.content.push_back(hint); reply.content.push_back(hint);
reply.content.push_back("\"]"); reply.content.push_back("\"]");

View File

@ -112,8 +112,8 @@ public:
PhantomNodes segmentPhantomNodes; PhantomNodes segmentPhantomNodes;
for(unsigned i = 0; i < phantomNodeVector.size()-1; ++i) { for(unsigned i = 0; i < phantomNodeVector.size()-1; ++i) {
segmentPhantomNodes.startPhantom = phantomNodeVector[i]; segmentPhantomNodes.source_phantom = phantomNodeVector[i];
segmentPhantomNodes.targetPhantom = phantomNodeVector[i+1]; segmentPhantomNodes.target_phantom = phantomNodeVector[i+1];
rawRoute.segmentEndCoordinates.push_back(segmentPhantomNodes); rawRoute.segmentEndCoordinates.push_back(segmentPhantomNodes);
} }
@ -172,8 +172,8 @@ public:
} }
PhantomNodes phantomNodes; PhantomNodes phantomNodes;
phantomNodes.startPhantom = rawRoute.segmentEndCoordinates[0].startPhantom; phantomNodes.source_phantom = rawRoute.segmentEndCoordinates[0].source_phantom;
phantomNodes.targetPhantom = rawRoute.segmentEndCoordinates[rawRoute.segmentEndCoordinates.size()-1].targetPhantom; phantomNodes.target_phantom = rawRoute.segmentEndCoordinates[rawRoute.segmentEndCoordinates.size()-1].target_phantom;
desc->SetConfig(descriptorConfig); desc->SetConfig(descriptorConfig);
desc->Run(rawRoute, phantomNodes, facade, reply); desc->Run(rawRoute, phantomNodes, facade, reply);

View File

@ -119,45 +119,45 @@ public:
int upper_bound_to_shortest_path_distance = INVALID_EDGE_WEIGHT; int upper_bound_to_shortest_path_distance = INVALID_EDGE_WEIGHT;
NodeID middle_node = SPECIAL_NODEID; NodeID middle_node = SPECIAL_NODEID;
if(phantom_node_pair.startPhantom.forward_node_id != SPECIAL_NODEID ) { if(phantom_node_pair.source_phantom.forward_node_id != SPECIAL_NODEID ) {
SimpleLogger().Write(logDEBUG) << "fwd insert: " << phantom_node_pair.startPhantom.forward_node_id << ", w: " << -phantom_node_pair.startPhantom.GetForwardWeightPlusOffset(); SimpleLogger().Write(logDEBUG) << "fwd insert: " << phantom_node_pair.source_phantom.forward_node_id << ", w: " << -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
forward_heap1.Insert( forward_heap1.Insert(
phantom_node_pair.startPhantom.forward_node_id, phantom_node_pair.source_phantom.forward_node_id,
-phantom_node_pair.startPhantom.GetForwardWeightPlusOffset(), -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(),
phantom_node_pair.startPhantom.forward_node_id phantom_node_pair.source_phantom.forward_node_id
); );
} }
if(phantom_node_pair.startPhantom.reverse_node_id != SPECIAL_NODEID ) { if(phantom_node_pair.source_phantom.reverse_node_id != SPECIAL_NODEID ) {
SimpleLogger().Write(logDEBUG) << "fwd insert: " << phantom_node_pair.startPhantom.reverse_node_id << ", w: " << -phantom_node_pair.startPhantom.GetReverseWeightPlusOffset(); SimpleLogger().Write(logDEBUG) << "fwd insert: " << phantom_node_pair.source_phantom.reverse_node_id << ", w: " << -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
forward_heap1.Insert( forward_heap1.Insert(
phantom_node_pair.startPhantom.reverse_node_id, phantom_node_pair.source_phantom.reverse_node_id,
-phantom_node_pair.startPhantom.GetReverseWeightPlusOffset(), -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(),
phantom_node_pair.startPhantom.reverse_node_id phantom_node_pair.source_phantom.reverse_node_id
); );
} }
if(phantom_node_pair.targetPhantom.forward_node_id != SPECIAL_NODEID ) { if(phantom_node_pair.target_phantom.forward_node_id != SPECIAL_NODEID ) {
SimpleLogger().Write(logDEBUG) << "rev insert: " << phantom_node_pair.targetPhantom.forward_node_id << ", w: " << phantom_node_pair.targetPhantom.GetForwardWeightPlusOffset(); SimpleLogger().Write(logDEBUG) << "rev insert: " << phantom_node_pair.target_phantom.forward_node_id << ", w: " << phantom_node_pair.target_phantom.GetForwardWeightPlusOffset();
reverse_heap1.Insert( reverse_heap1.Insert(
phantom_node_pair.targetPhantom.forward_node_id, phantom_node_pair.target_phantom.forward_node_id,
phantom_node_pair.targetPhantom.GetForwardWeightPlusOffset(), phantom_node_pair.target_phantom.GetForwardWeightPlusOffset(),
phantom_node_pair.targetPhantom.forward_node_id phantom_node_pair.target_phantom.forward_node_id
); );
} }
if(phantom_node_pair.targetPhantom.reverse_node_id != SPECIAL_NODEID ) { if(phantom_node_pair.target_phantom.reverse_node_id != SPECIAL_NODEID ) {
SimpleLogger().Write(logDEBUG) << "rev insert: " << phantom_node_pair.targetPhantom.reverse_node_id << ", w: " << phantom_node_pair.targetPhantom.GetReverseWeightPlusOffset(); SimpleLogger().Write(logDEBUG) << "rev insert: " << phantom_node_pair.target_phantom.reverse_node_id << ", w: " << phantom_node_pair.target_phantom.GetReverseWeightPlusOffset();
reverse_heap1.Insert( reverse_heap1.Insert(
phantom_node_pair.targetPhantom.reverse_node_id, phantom_node_pair.target_phantom.reverse_node_id,
phantom_node_pair.targetPhantom.GetReverseWeightPlusOffset(), phantom_node_pair.target_phantom.GetReverseWeightPlusOffset(),
phantom_node_pair.targetPhantom.reverse_node_id phantom_node_pair.target_phantom.reverse_node_id
); );
} }
const int forward_offset = super::ComputeEdgeOffset( const int forward_offset = super::ComputeEdgeOffset(
phantom_node_pair.startPhantom phantom_node_pair.source_phantom
); );
const int reverse_offset = super::ComputeEdgeOffset( const int reverse_offset = super::ComputeEdgeOffset(
phantom_node_pair.targetPhantom phantom_node_pair.target_phantom
); );
SimpleLogger().Write(logDEBUG) << "fwd_offset: " << forward_offset << ", reverse_offset: " << reverse_offset; SimpleLogger().Write(logDEBUG) << "fwd_offset: " << forward_offset << ", reverse_offset: " << reverse_offset;
@ -319,17 +319,17 @@ public:
if( INVALID_EDGE_WEIGHT != upper_bound_to_shortest_path_distance ) { if( INVALID_EDGE_WEIGHT != upper_bound_to_shortest_path_distance ) {
BOOST_ASSERT( !packed_shortest_path.empty() ); BOOST_ASSERT( !packed_shortest_path.empty() );
raw_route_data.unpacked_path_segments.resize(1); raw_route_data.unpacked_path_segments.resize(1);
// SimpleLogger().Write() << "fwd offset1: " << phantom_node_pair.startPhantom.fwd_segment_position; // SimpleLogger().Write() << "fwd offset1: " << phantom_node_pair.source_phantom.fwd_segment_position;
// SimpleLogger().Write() << "fwd offset2: " << phantom_node_pair.startPhantom.rev_segment_position; // SimpleLogger().Write() << "fwd offset2: " << phantom_node_pair.source_phantom.rev_segment_position;
// SimpleLogger().Write() << "rev offset1: " << phantom_node_pair.targetPhantom.fwd_segment_position; // SimpleLogger().Write() << "rev offset1: " << phantom_node_pair.target_phantom.fwd_segment_position;
// SimpleLogger().Write() << "rev offset2: " << phantom_node_pair.targetPhantom.rev_segment_position; // SimpleLogger().Write() << "rev offset2: " << phantom_node_pair.target_phantom.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; // int start_offset = ( packed_shortest_path.front() == phantom_node_pair.source_phantom.forward_node_id ? 1 : -1 )*phantom_node_pair.source_phantom.fwd_segment_position;
// SimpleLogger().Write(logDEBUG) << "unpacking from index " << phantom_node_pair.startPhantom.fwd_segment_position; // SimpleLogger().Write(logDEBUG) << "unpacking from index " << phantom_node_pair.source_phantom.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.source_phantom.forward_node_id: " << phantom_node_pair.source_phantom.forward_node_id;
// SimpleLogger().Write(logDEBUG) << "phantom_node_pair.startPhantom.reverse_node_id: " << phantom_node_pair.startPhantom.reverse_node_id; // SimpleLogger().Write(logDEBUG) << "phantom_node_pair.source_phantom.reverse_node_id: " << phantom_node_pair.source_phantom.reverse_node_id;
// SimpleLogger().Write(logDEBUG) << "phantom_node_pair.targetPhantom.packed_geometry_id: " << phantom_node_pair.targetPhantom.packed_geometry_id; // SimpleLogger().Write(logDEBUG) << "phantom_node_pair.target_phantom.packed_geometry_id: " << phantom_node_pair.target_phantom.packed_geometry_id;
// SimpleLogger().Write(logDEBUG) << "packed_shortest_path.back(): " << packed_shortest_path.back(); // SimpleLogger().Write(logDEBUG) << "packed_shortest_path.back(): " << packed_shortest_path.back();
super::UnpackPath( super::UnpackPath(

View File

@ -147,8 +147,8 @@ public:
std::vector<PathData> & unpacked_path std::vector<PathData> & unpacked_path
) const { ) const {
// SimpleLogger().Write(logDEBUG) << "packed_path.size: " << packed_path.size(); // SimpleLogger().Write(logDEBUG) << "packed_path.size: " << packed_path.size();
const bool start_traversed_in_reverse = (packed_path.front() != phantom_node_pair.startPhantom.forward_node_id); const bool start_traversed_in_reverse = (packed_path.front() != phantom_node_pair.source_phantom.forward_node_id);
const bool target_traversed_in_reverse = (packed_path.back() != phantom_node_pair.targetPhantom.forward_node_id); const bool target_traversed_in_reverse = (packed_path.back() != phantom_node_pair.target_phantom.forward_node_id);
const unsigned packed_path_size = packed_path.size(); const unsigned packed_path_size = packed_path.size();
std::stack<std::pair<NodeID, NodeID> > recursion_stack; std::stack<std::pair<NodeID, NodeID> > recursion_stack;
@ -232,7 +232,7 @@ public:
std::vector<unsigned> id_vector; std::vector<unsigned> id_vector;
facade->GetUncompressedGeometry(facade->GetGeometryIndexForEdgeID(ed.id), id_vector); facade->GetUncompressedGeometry(facade->GetGeometryIndexForEdgeID(ed.id), id_vector);
const int start_index = ( unpacked_path.empty() ? ( ( start_traversed_in_reverse ) ? id_vector.size() - phantom_node_pair.startPhantom.fwd_segment_position - 1 : phantom_node_pair.startPhantom.fwd_segment_position ) : 0 ); const int start_index = ( unpacked_path.empty() ? ( ( start_traversed_in_reverse ) ? id_vector.size() - phantom_node_pair.source_phantom.fwd_segment_position - 1 : phantom_node_pair.source_phantom.fwd_segment_position ) : 0 );
const int end_index = id_vector.size(); const int end_index = id_vector.size();
BOOST_ASSERT( start_index >= 0 ); BOOST_ASSERT( start_index >= 0 );
@ -256,40 +256,40 @@ public:
} }
} }
} }
if(SPECIAL_EDGEID != phantom_node_pair.targetPhantom.packed_geometry_id ) { if(SPECIAL_EDGEID != phantom_node_pair.target_phantom.packed_geometry_id ) {
// SimpleLogger().Write(logDEBUG) << "unpacking last segment " << phantom_node_pair.targetPhantom.packed_geometry_id; // SimpleLogger().Write(logDEBUG) << "unpacking last segment " << phantom_node_pair.target_phantom.packed_geometry_id;
// SimpleLogger().Write(logDEBUG) << "start_traversed_in_reverse: " << (start_traversed_in_reverse ? "y" : "n"); // SimpleLogger().Write(logDEBUG) << "start_traversed_in_reverse: " << (start_traversed_in_reverse ? "y" : "n");
// SimpleLogger().Write(logDEBUG) << "target_traversed_in_reverse: " << (target_traversed_in_reverse ? "y" : "n"); // SimpleLogger().Write(logDEBUG) << "target_traversed_in_reverse: " << (target_traversed_in_reverse ? "y" : "n");
// SimpleLogger().Write(logDEBUG) << "phantom_node_pair.startPhantom.fwd_segment_position: " << phantom_node_pair.startPhantom.fwd_segment_position << ", " << // SimpleLogger().Write(logDEBUG) << "phantom_node_pair.source_phantom.fwd_segment_position: " << phantom_node_pair.source_phantom.fwd_segment_position << ", " <<
// "phantom_node_pair.targetPhantom.fwd_segment_position: " << phantom_node_pair.targetPhantom.fwd_segment_position; // "phantom_node_pair.target_phantom.fwd_segment_position: " << phantom_node_pair.target_phantom.fwd_segment_position;
std::vector<unsigned> id_vector; std::vector<unsigned> id_vector;
facade->GetUncompressedGeometry(phantom_node_pair.targetPhantom.packed_geometry_id, id_vector); facade->GetUncompressedGeometry(phantom_node_pair.target_phantom.packed_geometry_id, id_vector);
if( target_traversed_in_reverse ) { if( target_traversed_in_reverse ) {
std::reverse(id_vector.begin(), id_vector.end() ); std::reverse(id_vector.begin(), id_vector.end() );
} }
// SimpleLogger().Write(logDEBUG) << "id_vector.size() " << id_vector.size(); // SimpleLogger().Write(logDEBUG) << "id_vector.size() " << id_vector.size();
// SimpleLogger().Write(logDEBUG) << "unpacked_path.empty()=" << (unpacked_path.empty() ? "y" : "n"); // SimpleLogger().Write(logDEBUG) << "unpacked_path.empty()=" << (unpacked_path.empty() ? "y" : "n");
const bool is_local_path = (phantom_node_pair.startPhantom.packed_geometry_id == phantom_node_pair.targetPhantom.packed_geometry_id) && unpacked_path.empty(); const bool is_local_path = (phantom_node_pair.source_phantom.packed_geometry_id == phantom_node_pair.target_phantom.packed_geometry_id) && unpacked_path.empty();
// SimpleLogger().Write(logDEBUG) << "is_local_path: " << (is_local_path ? "y" : "n"); // SimpleLogger().Write(logDEBUG) << "is_loc_pl_path: " << (is_local_path ? "y" : "n");
int start_index = 0; int start_index = 0;
int end_index = phantom_node_pair.targetPhantom.fwd_segment_position; int end_index = phantom_node_pair.target_phantom.fwd_segment_position;
// SimpleLogger().Write(logDEBUG) << "case1"; // SimpleLogger().Write(logDEBUG) << "case1";
if (target_traversed_in_reverse) if (target_traversed_in_reverse)
{ {
end_index = id_vector.size() - phantom_node_pair.targetPhantom.fwd_segment_position; end_index = id_vector.size() - phantom_node_pair.target_phantom.fwd_segment_position;
} }
if (is_local_path) if (is_local_path)
{ {
// SimpleLogger().Write(logDEBUG) << "case3"; // SimpleLogger().Write(logDEBUG) << "case3";
start_index = phantom_node_pair.startPhantom.fwd_segment_position; start_index = phantom_node_pair.source_phantom.fwd_segment_position;
end_index = phantom_node_pair.targetPhantom.fwd_segment_position; end_index = phantom_node_pair.target_phantom.fwd_segment_position;
if (target_traversed_in_reverse) if (target_traversed_in_reverse)
{ {
// SimpleLogger().Write(logDEBUG) << "case4"; // SimpleLogger().Write(logDEBUG) << "case4";
start_index = id_vector.size() - phantom_node_pair.startPhantom.fwd_segment_position; start_index = id_vector.size() - phantom_node_pair.source_phantom.fwd_segment_position;
end_index = id_vector.size() - phantom_node_pair.targetPhantom.fwd_segment_position; end_index = id_vector.size() - phantom_node_pair.target_phantom.fwd_segment_position;
} }
} }
@ -309,7 +309,7 @@ public:
unpacked_path.push_back( unpacked_path.push_back(
PathData( PathData(
id_vector[i], id_vector[i],
phantom_node_pair.targetPhantom.name_id, phantom_node_pair.target_phantom.name_id,
TurnInstructionsClass::NoTurn, TurnInstructionsClass::NoTurn,
0 0
) )

View File

@ -55,7 +55,8 @@ public:
void operator()( void operator()(
const std::vector<PhantomNodes> & phantom_nodes_vector, const std::vector<PhantomNodes> & phantom_nodes_vector,
RawRouteData & raw_route_data RawRouteData & raw_route_data
) const { ) const
{
BOOST_FOREACH( BOOST_FOREACH(
const PhantomNodes & phantom_node_pair, const PhantomNodes & phantom_node_pair,
phantom_nodes_vector phantom_nodes_vector
@ -108,61 +109,61 @@ public:
//insert new starting nodes into forward heap, adjusted by previous distances. //insert new starting nodes into forward heap, adjusted by previous distances.
if( if(
search_from_1st_node && search_from_1st_node &&
phantom_node_pair.startPhantom.forward_node_id != SPECIAL_NODEID phantom_node_pair.source_phantom.forward_node_id != SPECIAL_NODEID
) { ) {
SimpleLogger().Write(logDEBUG) << "fwd1 insert: " << phantom_node_pair.startPhantom.forward_node_id << ", w: " << -phantom_node_pair.startPhantom.GetForwardWeightPlusOffset(); SimpleLogger().Write(logDEBUG) << "fwd1 insert: " << phantom_node_pair.source_phantom.forward_node_id << ", w: " << -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
forward_heap1.Insert( forward_heap1.Insert(
phantom_node_pair.startPhantom.forward_node_id, phantom_node_pair.source_phantom.forward_node_id,
distance1-phantom_node_pair.startPhantom.GetForwardWeightPlusOffset(), distance1-phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(),
phantom_node_pair.startPhantom.forward_node_id phantom_node_pair.source_phantom.forward_node_id
); );
forward_heap2.Insert( forward_heap2.Insert(
phantom_node_pair.startPhantom.forward_node_id, phantom_node_pair.source_phantom.forward_node_id,
distance1-phantom_node_pair.startPhantom.GetForwardWeightPlusOffset(), distance1-phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(),
phantom_node_pair.startPhantom.forward_node_id phantom_node_pair.source_phantom.forward_node_id
); );
} }
if( if(
search_from_2nd_node && search_from_2nd_node &&
phantom_node_pair.startPhantom.reverse_node_id != SPECIAL_NODEID phantom_node_pair.source_phantom.reverse_node_id != SPECIAL_NODEID
) { ) {
SimpleLogger().Write(logDEBUG) << "fwd1 insert: " << phantom_node_pair.startPhantom.reverse_node_id << ", w: " << -phantom_node_pair.startPhantom.GetReverseWeightPlusOffset(); SimpleLogger().Write(logDEBUG) << "fwd1 insert: " << phantom_node_pair.source_phantom.reverse_node_id << ", w: " << -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
forward_heap1.Insert( forward_heap1.Insert(
phantom_node_pair.startPhantom.reverse_node_id, phantom_node_pair.source_phantom.reverse_node_id,
distance2-phantom_node_pair.startPhantom.GetReverseWeightPlusOffset(), distance2-phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(),
phantom_node_pair.startPhantom.reverse_node_id phantom_node_pair.source_phantom.reverse_node_id
); );
forward_heap2.Insert( forward_heap2.Insert(
phantom_node_pair.startPhantom.reverse_node_id, phantom_node_pair.source_phantom.reverse_node_id,
distance2-phantom_node_pair.startPhantom.GetReverseWeightPlusOffset(), distance2-phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(),
phantom_node_pair.startPhantom.reverse_node_id phantom_node_pair.source_phantom.reverse_node_id
); );
} }
//insert new backward nodes into backward heap, unadjusted. //insert new backward nodes into backward heap, unadjusted.
if( phantom_node_pair.targetPhantom.forward_node_id != SPECIAL_NODEID ) { if( phantom_node_pair.target_phantom.forward_node_id != SPECIAL_NODEID ) {
SimpleLogger().Write(logDEBUG) << "rev insert: " << phantom_node_pair.targetPhantom.forward_node_id << ", w: " << phantom_node_pair.targetPhantom.GetForwardWeightPlusOffset(); SimpleLogger().Write(logDEBUG) << "rev insert: " << phantom_node_pair.target_phantom.forward_node_id << ", w: " << phantom_node_pair.target_phantom.GetForwardWeightPlusOffset();
reverse_heap1.Insert( reverse_heap1.Insert(
phantom_node_pair.targetPhantom.forward_node_id, phantom_node_pair.target_phantom.forward_node_id,
phantom_node_pair.targetPhantom.GetForwardWeightPlusOffset(), phantom_node_pair.target_phantom.GetForwardWeightPlusOffset(),
phantom_node_pair.targetPhantom.forward_node_id phantom_node_pair.target_phantom.forward_node_id
); );
} }
if( phantom_node_pair.targetPhantom.reverse_node_id != SPECIAL_NODEID ) { if( phantom_node_pair.target_phantom.reverse_node_id != SPECIAL_NODEID ) {
SimpleLogger().Write(logDEBUG) << "rev insert: " << phantom_node_pair.targetPhantom.reverse_node_id << ", w: " << phantom_node_pair.targetPhantom.GetReverseWeightPlusOffset(); SimpleLogger().Write(logDEBUG) << "rev insert: " << phantom_node_pair.target_phantom.reverse_node_id << ", w: " << phantom_node_pair.target_phantom.GetReverseWeightPlusOffset();
reverse_heap2.Insert( reverse_heap2.Insert(
phantom_node_pair.targetPhantom.reverse_node_id, phantom_node_pair.target_phantom.reverse_node_id,
phantom_node_pair.targetPhantom.GetReverseWeightPlusOffset(), phantom_node_pair.target_phantom.GetReverseWeightPlusOffset(),
phantom_node_pair.targetPhantom.reverse_node_id phantom_node_pair.target_phantom.reverse_node_id
); );
} }
const int forward_offset = super::ComputeEdgeOffset( const int forward_offset = super::ComputeEdgeOffset(
phantom_node_pair.startPhantom phantom_node_pair.source_phantom
); );
const int reverse_offset = super::ComputeEdgeOffset( const int reverse_offset = super::ComputeEdgeOffset(
phantom_node_pair.targetPhantom phantom_node_pair.target_phantom
); );
//run two-Target Dijkstra routing step. //run two-Target Dijkstra routing step.
@ -348,11 +349,11 @@ public:
if( if(
(packed_legs1[current_leg].back() == packed_legs2[current_leg].back()) && (packed_legs1[current_leg].back() == packed_legs2[current_leg].back()) &&
phantom_node_pair.targetPhantom.isBidirected() phantom_node_pair.target_phantom.isBidirected()
) { ) {
const NodeID last_node_id = packed_legs2[current_leg].back(); const NodeID last_node_id = packed_legs2[current_leg].back();
search_from_1st_node &= !(last_node_id == phantom_node_pair.targetPhantom.reverse_node_id); search_from_1st_node &= !(last_node_id == phantom_node_pair.target_phantom.reverse_node_id);
search_from_2nd_node &= !(last_node_id == phantom_node_pair.targetPhantom.forward_node_id); search_from_2nd_node &= !(last_node_id == phantom_node_pair.target_phantom.forward_node_id);
BOOST_ASSERT( search_from_1st_node != search_from_2nd_node ); BOOST_ASSERT( search_from_1st_node != search_from_2nd_node );
} }
@ -365,7 +366,7 @@ public:
std::swap( packed_legs1, packed_legs2 ); std::swap( packed_legs1, packed_legs2 );
} }
raw_route_data.unpacked_path_segments.resize( packed_legs1.size() ); 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; // const int start_offset = ( packed_legs1[0].front() == phantom_nodes_vector.front().source_phantom.forward_node_id ? 1 : -1 )*phantom_nodes_vector.front().source_phantom.fwd_segment_position;
for(unsigned i = 0; i < packed_legs1.size(); ++i){ for(unsigned i = 0; i < packed_legs1.size(); ++i){
BOOST_ASSERT( !phantom_nodes_vector.empty() ); BOOST_ASSERT( !phantom_nodes_vector.empty() );
@ -376,14 +377,14 @@ public:
PhantomNodes unpack_phantom_node_pair = phantom_nodes_vector[i]; PhantomNodes unpack_phantom_node_pair = phantom_nodes_vector[i];
// if (!at_beginning) // if (!at_beginning)
// { // {
// unpack_phantom_node_pair.startPhantom.packed_geometry_id = SPECIAL_EDGEID; // unpack_phantom_node_pair.source_phantom.packed_geometry_id = SPECIAL_EDGEID;
// unpack_phantom_node_pair.startPhantom.fwd_segment_position = 0; // unpack_phantom_node_pair.source_phantom.fwd_segment_position = 0;
// } // }
// if (!at_end) // if (!at_end)
// { // {
// unpack_phantom_node_pair.targetPhantom.packed_geometry_id = SPECIAL_EDGEID; // unpack_phantom_node_pair.target_phantom.packed_geometry_id = SPECIAL_EDGEID;
// unpack_phantom_node_pair.targetPhantom.fwd_segment_position = 0; // unpack_phantom_node_pair.target_phantom.fwd_segment_position = 0;
// } // }
super::UnpackPath( super::UnpackPath(