switch edge-expanded street name indexes to be first segment names (18 failed tests left)

This commit is contained in:
Dennis Luxen 2014-03-28 17:13:00 +01:00
parent 549bcb502b
commit 752fb880be
10 changed files with 202 additions and 77 deletions

View File

@ -318,14 +318,6 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(
BOOST_ASSERT( m_geometry_compressor.HasEntryForID(e1) == m_geometry_compressor.HasEntryForID(e2) ); BOOST_ASSERT( m_geometry_compressor.HasEntryForID(e1) == m_geometry_compressor.HasEntryForID(e2) );
if( m_geometry_compressor.HasEntryForID(e1) ) { if( m_geometry_compressor.HasEntryForID(e1) ) {
if(forward_data.edgeBasedNodeID == 16176) {
SimpleLogger().Write(logDEBUG) << "reverse_data.edgeBasedNodeID=" << reverse_data.edgeBasedNodeID;
SimpleLogger().Write(logDEBUG) << "u: " << u << ", v: " << v << " at " << m_node_info_list.at(u).lat/COORDINATE_PRECISION << ","
<< m_node_info_list.at(u).lon/COORDINATE_PRECISION << "<->" << m_node_info_list.at(v).lat/COORDINATE_PRECISION << ","
<< m_node_info_list.at(v).lon/COORDINATE_PRECISION;
SimpleLogger().Write(logDEBUG) << "pos(" << e1 << ")=" << m_geometry_compressor.GetPositionForID(e1);
SimpleLogger().Write(logDEBUG) << "pos(" << e2 << ")=" << m_geometry_compressor.GetPositionForID(e2);
}
BOOST_ASSERT( m_geometry_compressor.HasEntryForID(e2) ); BOOST_ASSERT( m_geometry_compressor.HasEntryForID(e2) );
@ -605,6 +597,7 @@ void EdgeBasedGraphFactory::Run(
forward_weight1 + (add_traffic_signal_penalty ? speed_profile.trafficSignalPenalty :0), forward_weight1 + (add_traffic_signal_penalty ? speed_profile.trafficSignalPenalty :0),
forward_weight2 forward_weight2
); );
SimpleLogger().Write(logDEBUG) << "compressing fwd segment with name " << m_node_based_graph->GetEdgeData(forward_e1).nameID;
m_geometry_compressor.CompressEdge( m_geometry_compressor.CompressEdge(
reverse_e1, reverse_e1,
reverse_e2, reverse_e2,
@ -613,8 +606,14 @@ void EdgeBasedGraphFactory::Run(
reverse_weight1 , reverse_weight1 ,
reverse_weight2 + (add_traffic_signal_penalty ? speed_profile.trafficSignalPenalty :0) reverse_weight2 + (add_traffic_signal_penalty ? speed_profile.trafficSignalPenalty :0)
); );
SimpleLogger().Write(logDEBUG) << "compressing rev segment with name " << m_node_based_graph->GetEdgeData(reverse_e1).nameID;
++removed_node_count; ++removed_node_count;
BOOST_ASSERT
(
m_node_based_graph->GetEdgeData(forward_e1).nameID ==
m_node_based_graph->GetEdgeData(reverse_e1).nameID
);
} }
} }
SimpleLogger().Write() << "removed " << removed_node_count << " nodes"; SimpleLogger().Write() << "removed " << removed_node_count << " nodes";
@ -840,7 +839,7 @@ void EdgeBasedGraphFactory::Run(
original_edge_data_vector.push_back( original_edge_data_vector.push_back(
OriginalEdgeData( OriginalEdgeData(
(edge_is_compressed ? m_geometry_compressor.GetPositionForID(e1) : v), (edge_is_compressed ? m_geometry_compressor.GetPositionForID(e1) : v),
edge_data2.nameID, (edge_is_compressed ? edge_data1.nameID : edge_data1.nameID),
turn_instruction, turn_instruction,
edge_is_compressed edge_is_compressed
) )

View File

@ -42,7 +42,6 @@ struct PhantomNode {
forward_offset(0), forward_offset(0),
reverse_offset(0), reverse_offset(0),
packed_geometry_id(SPECIAL_EDGEID), packed_geometry_id(SPECIAL_EDGEID),
ratio(0.),
fwd_segment_position(0) fwd_segment_position(0)
{ } { }
@ -54,11 +53,10 @@ struct PhantomNode {
int forward_offset; int forward_offset;
int reverse_offset; int reverse_offset;
unsigned packed_geometry_id; unsigned packed_geometry_id;
double ratio; // double ratio;
FixedPointCoordinate location; FixedPointCoordinate location;
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;
@ -79,7 +77,7 @@ struct PhantomNode {
reverse_weight = INVALID_EDGE_WEIGHT; reverse_weight = INVALID_EDGE_WEIGHT;
forward_offset = 0; forward_offset = 0;
reverse_offset = 0; reverse_offset = 0;
ratio = 0.; // ratio = 0.;
location.Reset(); location.Reset();
} }
@ -106,8 +104,8 @@ struct PhantomNode {
(forward_weight != INVALID_EDGE_WEIGHT) || (forward_weight != INVALID_EDGE_WEIGHT) ||
(reverse_weight != INVALID_EDGE_WEIGHT) (reverse_weight != INVALID_EDGE_WEIGHT)
) && ) &&
(ratio >= 0.) && // (ratio >= 0.) &&
(ratio <= 1.) && // (ratio <= 1.) &&
(name_id != std::numeric_limits<unsigned>::max() (name_id != std::numeric_limits<unsigned>::max()
); );
} }
@ -162,7 +160,7 @@ inline std::ostream& operator<<(std::ostream &out, const PhantomNode & pn) {
"rev-w: " << pn.reverse_weight << ", " << "rev-w: " << pn.reverse_weight << ", " <<
"fwd-o: " << pn.forward_offset << ", " << "fwd-o: " << pn.forward_offset << ", " <<
"rev-o: " << pn.reverse_offset << ", " << "rev-o: " << pn.reverse_offset << ", " <<
"ratio: " << pn.ratio << ", " << // "ratio: " << pn.ratio << ", " <<
"geom: " << pn.packed_geometry_id << ", " << "geom: " << pn.packed_geometry_id << ", " <<
"pos: " << pn.fwd_segment_position << ", " << "pos: " << pn.fwd_segment_position << ", " <<
"loc: " << pn.location; "loc: " << pn.location;

View File

@ -70,10 +70,19 @@ struct RawRouteData {
unsigned checkSum; unsigned checkSum;
int lengthOfShortestPath; int lengthOfShortestPath;
int lengthOfAlternativePath; int lengthOfAlternativePath;
bool source_traversed_in_reverse;
bool target_traversed_in_reverse;
bool alt_source_traversed_in_reverse;
bool alt_target_traversed_in_reverse;
RawRouteData() : RawRouteData() :
checkSum(UINT_MAX), checkSum(UINT_MAX),
lengthOfShortestPath(INT_MAX), lengthOfShortestPath(INT_MAX),
lengthOfAlternativePath(INT_MAX) lengthOfAlternativePath(INT_MAX),
source_traversed_in_reverse(false),
target_traversed_in_reverse(false),
alt_source_traversed_in_reverse(false),
alt_target_traversed_in_reverse(false)
{ } { }
}; };

View File

@ -771,12 +771,12 @@ public:
{ {
result_phantom_node.reverse_weight *= 1.-ratio; result_phantom_node.reverse_weight *= 1.-ratio;
} }
result_phantom_node.ratio = ratio; // result_phantom_node.ratio = ratio;
SimpleLogger().Write(logDEBUG) << "result location: " << result_phantom_node.location << ", start: " << current_start_coordinate << ", end: " << current_end_coordinate; SimpleLogger().Write(logDEBUG) << "result location: " << result_phantom_node.location << ", start: " << current_start_coordinate << ", end: " << current_end_coordinate;
SimpleLogger().Write(logDEBUG) << "fwd node: " << result_phantom_node.forward_node_id << ", rev node: " << result_phantom_node.reverse_node_id; SimpleLogger().Write(logDEBUG) << "fwd node: " << result_phantom_node.forward_node_id << ", rev node: " << result_phantom_node.reverse_node_id;
SimpleLogger().Write(logDEBUG) << "fwd weight: " << result_phantom_node.forward_weight << ", rev weight: " << result_phantom_node.reverse_weight << ", ratio: " << result_phantom_node.ratio; SimpleLogger().Write(logDEBUG) << "fwd weight: " << result_phantom_node.forward_weight << ", rev weight: " << result_phantom_node.reverse_weight;// << ", ratio: " << result_phantom_node.ratio;
SimpleLogger().Write(logDEBUG) << "fwd offset: " << result_phantom_node.forward_offset << ", rev offset: " << result_phantom_node.reverse_offset << ", ratio: " << result_phantom_node.ratio; SimpleLogger().Write(logDEBUG) << "fwd offset: " << result_phantom_node.forward_offset << ", rev offset: " << result_phantom_node.reverse_offset;// << ", ratio: " << result_phantom_node.ratio;
SimpleLogger().Write(logDEBUG) << "bidirected: " << (result_phantom_node.isBidirected() ? "y" : "n"); SimpleLogger().Write(logDEBUG) << "bidirected: " << (result_phantom_node.isBidirected() ? "y" : "n");
SimpleLogger().Write(logDEBUG) << "name id: " << result_phantom_node.name_id; SimpleLogger().Write(logDEBUG) << "name id: " << result_phantom_node.name_id;
SimpleLogger().Write(logDEBUG) << "geom id: " << result_phantom_node.packed_geometry_id; SimpleLogger().Write(logDEBUG) << "geom id: " << result_phantom_node.packed_geometry_id;

View File

@ -31,18 +31,18 @@ DescriptionFactory::DescriptionFactory() : entireLength(0) { }
DescriptionFactory::~DescriptionFactory() { } DescriptionFactory::~DescriptionFactory() { }
inline double DescriptionFactory::DegreeToRadian(const double degree) const { inline double DescriptionFactory::DegreeToRadian(const double degree) const
return degree * (M_PI/180); {
return degree * (M_PI/180.);
} }
inline double DescriptionFactory::RadianToDegree(const double radian) const { inline double DescriptionFactory::RadianToDegree(const double radian) const
return radian * (180/M_PI); {
return radian * (180./M_PI);
} }
double DescriptionFactory::GetBearing( double DescriptionFactory::GetBearing(const FixedPointCoordinate & A, const FixedPointCoordinate & B) const
const FixedPointCoordinate & A, {
const FixedPointCoordinate & B
) const {
double delta_long = DegreeToRadian(B.lon/COORDINATE_PRECISION - A.lon/COORDINATE_PRECISION); double delta_long = DegreeToRadian(B.lon/COORDINATE_PRECISION - A.lon/COORDINATE_PRECISION);
const double lat1 = DegreeToRadian(A.lat/COORDINATE_PRECISION); const double lat1 = DegreeToRadian(A.lat/COORDINATE_PRECISION);
@ -51,24 +51,42 @@ double DescriptionFactory::GetBearing(
const double y = sin(delta_long) * cos(lat2); const double y = sin(delta_long) * cos(lat2);
const double x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(delta_long); const double x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(delta_long);
double result = RadianToDegree(atan2(y, x)); double result = RadianToDegree(atan2(y, x));
while(result < 0.) { while (result < 0.)
{
result += 360.; result += 360.;
} }
while(result >= 360.) {
while (result >= 360.)
{
result -= 360.; result -= 360.;
} }
return result; return result;
} }
void DescriptionFactory::SetStartSegment(const PhantomNode & start) { void DescriptionFactory::SetStartSegment(const PhantomNode & source, const bool source_traversed_in_reverse)
start_phantom = start; {
int fwd_weight = source.forward_weight;
int rev_weight = source.reverse_weight;
int fwd_offset = source.forward_offset;
int rev_offset = source.reverse_offset;
SimpleLogger().Write(logDEBUG) << "df source, traversed in reverse: " << (source_traversed_in_reverse ? "y" : "n") << ", location: " << source.location << ", fwd_weight: " << fwd_weight << ", fwd_offset: " << fwd_offset << ", rev_weight: " << rev_weight << ", rev_offset: " << rev_offset;
SimpleLogger().Write(logDEBUG) << "duration of first segment: " << (source_traversed_in_reverse ? source.GetReverseWeightPlusOffset() : source.GetForwardWeightPlusOffset());
start_phantom = source;
AppendSegment( AppendSegment(
start.location, source.location,
PathData(0, start.name_id, 10, start.forward_weight) PathData(0, source.name_id, 10, source.forward_weight)
); );
} }
void DescriptionFactory::SetEndSegment(const PhantomNode & target) { void DescriptionFactory::SetEndSegment(const PhantomNode & target, const bool target_traversed_in_reverse)
{
int fwd_weight = target.forward_weight;
int rev_weight = target.reverse_weight;
int fwd_offset = target.forward_offset;
int rev_offset = target.reverse_offset;
SimpleLogger().Write(logDEBUG) << "df target, traversed in reverse: " << (target_traversed_in_reverse ? "y" : "n") << ", location: " << target.location << ", fwd_weight: " << fwd_weight << ", fwd_offset: " << fwd_offset << ", rev_weight: " << rev_weight << ", rev_offset: " << rev_offset;
SimpleLogger().Write(logDEBUG) << "duration of last segment: " << (target_traversed_in_reverse ? target.GetReverseWeightPlusOffset() : target.GetForwardWeightPlusOffset());
target_phantom = target; target_phantom = target;
pathDescription.push_back( pathDescription.push_back(
SegmentInformation( SegmentInformation(
@ -86,22 +104,22 @@ void DescriptionFactory::AppendSegment(
const FixedPointCoordinate & coordinate, const FixedPointCoordinate & coordinate,
const PathData & data const PathData & data
) { ) {
if( // if(
( 1 == pathDescription.size()) && // ( 1 == pathDescription.size()) &&
( pathDescription.back().location == coordinate) // ( pathDescription.back().location == coordinate)
) { // ) {
pathDescription.back().name_id = data.name_id; // pathDescription.back().name_id = data.name_id;
} else { // } else {
pathDescription.push_back( pathDescription.push_back(
SegmentInformation( SegmentInformation(
coordinate, coordinate,
data.name_id, data.name_id,
data.durationOfSegment, data.durationOfSegment,
0, 0,
data.turnInstruction data.turnInstruction
) )
); );
} // }
} }
void DescriptionFactory::AppendEncodedPolylineString( void DescriptionFactory::AppendEncodedPolylineString(

View File

@ -87,8 +87,8 @@ public:
void AppendUnencodedPolylineString(std::vector<std::string> &output) const; void AppendUnencodedPolylineString(std::vector<std::string> &output) const;
void AppendSegment(const FixedPointCoordinate & coordinate, const PathData & data); void AppendSegment(const FixedPointCoordinate & coordinate, const PathData & data);
void BuildRouteSummary(const double distance, const unsigned time); void BuildRouteSummary(const double distance, const unsigned time);
void SetStartSegment(const PhantomNode & start_phantom); void SetStartSegment(const PhantomNode & start_phantom, const bool source_traversed_in_reverse);
void SetEndSegment(const PhantomNode & start_phantom); void SetEndSegment(const PhantomNode & start_phantom, const bool target_traversed_in_reverse);
void AppendEncodedPolylineString( void AppendEncodedPolylineString(
const bool return_encoded, const bool return_encoded,
std::vector<std::string> & output std::vector<std::string> & output
@ -105,15 +105,17 @@ public:
/** starts at index 1 */ /** starts at index 1 */
pathDescription[0].length = 0; pathDescription[0].length = 0;
for(unsigned i = 1; i < pathDescription.size(); ++i) for (unsigned i = 1; i < pathDescription.size(); ++i)
{ {
//move down names by one, q&d hack
pathDescription[i-1].name_id = pathDescription[i].name_id;
pathDescription[i].length = FixedPointCoordinate::ApproximateEuclideanDistance(pathDescription[i-1].location, pathDescription[i].location); pathDescription[i].length = FixedPointCoordinate::ApproximateEuclideanDistance(pathDescription[i-1].location, pathDescription[i].location);
} }
for (unsigned i = 0; i < pathDescription.size(); ++i) for (unsigned i = 0; i < pathDescription.size(); ++i)
{ {
const std::string name = facade->GetEscapedNameForNameID(pathDescription[0].name_id); const std::string name = facade->GetEscapedNameForNameID(pathDescription[0].name_id);
SimpleLogger().Write(logDEBUG) << "[" << i << "] name: " << name << ", duration: " << pathDescription[i].duration << ", length: " << pathDescription[i].length << ", coordinate: " << pathDescription[i].location; SimpleLogger().Write(logDEBUG) << "df [" << i << "] name: " << name << ", duration: " << pathDescription[i].duration << ", length: " << pathDescription[i].length << ", coordinate: " << pathDescription[i].location;
} }
/*Simplify turn instructions /*Simplify turn instructions
@ -186,7 +188,7 @@ public:
target_phantom.name_id = (pathDescription.end()-2)->name_id; target_phantom.name_id = (pathDescription.end()-2)->name_id;
} }
} else { } else {
pathDescription[segment_start_index].duration *= (1.-target_phantom.ratio); // pathDescription[segment_start_index].duration *= (1.-target_phantom.ratio);
} }
if(std::numeric_limits<double>::epsilon() > pathDescription[0].length) { if(std::numeric_limits<double>::epsilon() > pathDescription[0].length) {
if(pathDescription.size() > 2) { if(pathDescription.size() > 2) {
@ -196,7 +198,7 @@ public:
start_phantom.name_id = pathDescription[0].name_id; start_phantom.name_id = pathDescription[0].name_id;
} }
} else { } else {
pathDescription[0].duration *= start_phantom.ratio; // pathDescription[0].duration *= start_phantom.ratio;
} }
//Generalize poly line //Generalize poly line

View File

@ -99,7 +99,7 @@ public:
FixedPointCoordinate current_coordinate; FixedPointCoordinate current_coordinate;
BOOST_FOREACH(const PathData & path_data, route_leg) { BOOST_FOREACH(const PathData & path_data, route_leg) {
current_coordinate = facade->GetCoordinateOfNode(path_data.node); current_coordinate = facade->GetCoordinateOfNode(path_data.node);
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.target_phantom ); // description_factory.SetEndSegment( leg_phantoms.target_phantom );
@ -120,7 +120,8 @@ public:
"{\"status\":" "{\"status\":"
); );
if(INT_MAX == raw_route.lengthOfShortestPath) { if (INVALID_EDGE_WEIGHT == raw_route.lengthOfShortestPath)
{
//We do not need to do much, if there is no route ;-) //We do not need to do much, if there is no route ;-)
reply.content.push_back( reply.content.push_back(
"207,\"status_message\": \"Cannot find route between points\"}" "207,\"status_message\": \"Cannot find route between points\"}"
@ -128,12 +129,87 @@ public:
return; return;
} }
description_factory.SetStartSegment(phantom_nodes.source_phantom); std::string name = facade->GetEscapedNameForNameID(phantom_nodes.source_phantom.name_id);
int fwd_weight = phantom_nodes.source_phantom.forward_weight;
int rev_weight = phantom_nodes.source_phantom.reverse_weight;
int fwd_offset = phantom_nodes.source_phantom.forward_offset;
int rev_offset = phantom_nodes.source_phantom.reverse_offset;
SimpleLogger().Write(logDEBUG) << "json source: " << name << ", location: " << phantom_nodes.source_phantom.location << ", fwd_weight: " << fwd_weight << ", fwd_offset: " << fwd_offset << ", rev_weight: " << rev_weight << ", rev_offset: " << rev_offset;
name = facade->GetEscapedNameForNameID(phantom_nodes.target_phantom.name_id);
fwd_weight = phantom_nodes.target_phantom.forward_weight;
rev_weight = phantom_nodes.target_phantom.reverse_weight;
fwd_offset = phantom_nodes.target_phantom.forward_offset;
rev_offset = phantom_nodes.target_phantom.reverse_offset;
SimpleLogger().Write(logDEBUG) << "json target: " << name << ", location: " << phantom_nodes.target_phantom.location << ", fwd_weight: " << fwd_weight << ", fwd_offset: " << fwd_offset << ", rev_weight: " << rev_weight << ", rev_offset: " << rev_offset;
//TODO: replace the previous logic with this one.
//check if first segment is non-zero
std::string road_name;
int source_duration = phantom_nodes.source_phantom.GetForwardWeightPlusOffset();
SimpleLogger().Write(logDEBUG) << "-> source_traversed_in_reverse: " << (raw_route.source_traversed_in_reverse ? "y" : "n");
if (!raw_route.source_traversed_in_reverse)
{
source_duration = phantom_nodes.source_phantom.GetReverseWeightPlusOffset();
}
BOOST_ASSERT(source_duration >= 0);
road_name = facade->GetEscapedNameForNameID(phantom_nodes.source_phantom.name_id);
if (source_duration > 0)
{
SimpleLogger().Write(logDEBUG) << "adding source \"" << road_name << "\" at " << phantom_nodes.source_phantom.location << ", duration: " << source_duration;
}
else
{
SimpleLogger().Write(logDEBUG) << "ignoring source \"" << road_name << "\"";
}
// TODO, for each unpacked segment add the leg to the description
BOOST_ASSERT( raw_route.unpacked_path_segments.size() == raw_route.segmentEndCoordinates.size() );
for (unsigned i = 0; i < raw_route.unpacked_path_segments.size(); ++i)
{
const std::vector<PathData> & leg_path = raw_route.unpacked_path_segments[i];
const PhantomNodes & leg_phantoms = raw_route.segmentEndCoordinates[i];
SimpleLogger().Write(logDEBUG) << " Describing leg from " << leg_phantoms.source_phantom.location << " and " << leg_phantoms.target_phantom.location;
FixedPointCoordinate current_coordinate;
BOOST_FOREACH(const PathData & path_data, leg_path)
{
current_coordinate = facade->GetCoordinateOfNode(path_data.node);
road_name = facade->GetEscapedNameForNameID(path_data.name_id);
SimpleLogger().Write(logDEBUG) << " adding way point for \"" << road_name << "\" at " << current_coordinate << ", duration: " << path_data.durationOfSegment;
}
}
//check if last segment is non-zero
road_name = facade->GetEscapedNameForNameID(phantom_nodes.target_phantom.name_id);
int target_duration = phantom_nodes.target_phantom.GetForwardWeightPlusOffset();
if (raw_route.target_traversed_in_reverse)
{
target_duration = phantom_nodes.target_phantom.GetReverseWeightPlusOffset();
}
BOOST_ASSERT(target_duration >= 0);
if (target_duration > 0)
{
SimpleLogger().Write(logDEBUG) << "adding target \"" << road_name << "\" at " << phantom_nodes.target_phantom.location << ", duration: " << target_duration;
}
else
{
SimpleLogger().Write(logDEBUG) << "ignoring target \"" << road_name << "\"";
}
SimpleLogger().Write(logDEBUG) << "-> target_traversed_in_reverse: " << (raw_route.target_traversed_in_reverse ? "y" : "n");
//END OF TODO
description_factory.SetStartSegment(phantom_nodes.source_phantom, raw_route.source_traversed_in_reverse);
reply.content.push_back("0," reply.content.push_back("0,"
"\"status_message\": \"Found route between points\","); "\"status_message\": \"Found route between points\",");
BOOST_ASSERT( raw_route.unpacked_path_segments.size() == raw_route.segmentEndCoordinates.size() ); BOOST_ASSERT( raw_route.unpacked_path_segments.size() == raw_route.segmentEndCoordinates.size() );
for( unsigned i = 0; i < raw_route.unpacked_path_segments.size(); ++i ) { for (unsigned i = 0; i < raw_route.unpacked_path_segments.size(); ++i)
{
const int added_segments = DescribeLeg( const int added_segments = DescribeLeg(
raw_route.unpacked_path_segments[i], raw_route.unpacked_path_segments[i],
raw_route.segmentEndCoordinates[i] raw_route.segmentEndCoordinates[i]
@ -143,7 +219,7 @@ public:
added_segments + shortest_leg_end_indices.back() added_segments + shortest_leg_end_indices.back()
); );
} }
description_factory.SetEndSegment(phantom_nodes.target_phantom); description_factory.SetEndSegment(phantom_nodes.target_phantom, raw_route.target_traversed_in_reverse);
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,14 +271,16 @@ 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) {
alternate_descriptionFactory.SetStartSegment(phantom_nodes.source_phantom); if(raw_route.lengthOfAlternativePath != INVALID_EDGE_WEIGHT)
{
alternate_descriptionFactory.SetStartSegment(phantom_nodes.source_phantom, raw_route.alt_source_traversed_in_reverse);
//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.target_phantom); alternate_descriptionFactory.SetEndSegment(phantom_nodes.target_phantom, raw_route.alt_target_traversed_in_reverse);
} }
alternate_descriptionFactory.Run(facade, config.zoom_level); alternate_descriptionFactory.Run(facade, config.zoom_level);

View File

@ -316,8 +316,9 @@ public:
} }
//Unpack shortest path and alternative, if they exist //Unpack shortest path and alternative, if they exist
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.source_phantom.fwd_segment_position; // SimpleLogger().Write() << "fwd offset1: " << phantom_node_pair.source_phantom.fwd_segment_position;
// SimpleLogger().Write() << "fwd offset2: " << phantom_node_pair.source_phantom.rev_segment_position; // SimpleLogger().Write() << "fwd offset2: " << phantom_node_pair.source_phantom.rev_segment_position;
@ -332,6 +333,9 @@ public:
// SimpleLogger().Write(logDEBUG) << "phantom_node_pair.target_phantom.packed_geometry_id: " << phantom_node_pair.target_phantom.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();
raw_route_data.source_traversed_in_reverse = (packed_shortest_path.front() != phantom_node_pair.source_phantom.forward_node_id);
raw_route_data.target_traversed_in_reverse = (packed_shortest_path.back() != phantom_node_pair.target_phantom.forward_node_id);
super::UnpackPath( super::UnpackPath(
// -- packed input // -- packed input
packed_shortest_path, packed_shortest_path,
@ -357,6 +361,9 @@ public:
packed_alternate_path packed_alternate_path
); );
raw_route_data.source_traversed_in_reverse = (packed_alternate_path.front() != phantom_node_pair.source_phantom.forward_node_id);
raw_route_data.target_traversed_in_reverse = (packed_alternate_path.back() != phantom_node_pair.target_phantom.forward_node_id);
// unpack the alternate path // unpack the alternate path
super::UnpackPath( super::UnpackPath(
packed_alternate_path, packed_alternate_path,

View File

@ -186,6 +186,7 @@ public:
} }
} }
if( SPECIAL_EDGEID == smaller_edge_id ){ if( SPECIAL_EDGEID == smaller_edge_id ){
SimpleLogger().Write() << "checking reverse";
for( for(
EdgeID edge_id = facade->BeginEdges(edge.second); EdgeID edge_id = facade->BeginEdges(edge.second);
edge_id < facade->EndEdges(edge.second); edge_id < facade->EndEdges(edge.second);
@ -234,6 +235,9 @@ public:
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 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();
std::string name = facade->GetEscapedNameForNameID(name_index);
SimpleLogger().Write(logDEBUG) << "compressed via segment " << name << " from [" << start_index << "," << end_index << "]";
BOOST_ASSERT( start_index >= 0 ); BOOST_ASSERT( start_index >= 0 );
BOOST_ASSERT( start_index <= end_index ); BOOST_ASSERT( start_index <= end_index );
@ -293,7 +297,7 @@ public:
} }
} }
// SimpleLogger().Write(logDEBUG) << "fetching from [" << start_index << "," << end_index << "]"; SimpleLogger().Write(logDEBUG) << "fetching target segment from [" << start_index << "," << end_index << "]";
BOOST_ASSERT( start_index >= 0 ); BOOST_ASSERT( start_index >= 0 );
for( for(
@ -302,10 +306,10 @@ public:
( start_index < end_index ? ++i :--i) ( start_index < end_index ? ++i :--i)
) { ) {
BOOST_ASSERT( i >= -1 ); BOOST_ASSERT( i >= -1 );
// if ( i >= 0 ) if ( i >= 0 )
// { {
// SimpleLogger().Write(logDEBUG) << "[" << i << "]" << facade->GetCoordinateOfNode(id_vector[i]); SimpleLogger().Write(logDEBUG) << "target [" << i << "]" << facade->GetCoordinateOfNode(id_vector[i]);
// } }
unpacked_path.push_back( unpacked_path.push_back(
PathData( PathData(
id_vector[i], id_vector[i],
@ -316,6 +320,11 @@ public:
); );
} }
} }
BOOST_FOREACH(const PathData & path_data, unpacked_path)
{
std::string name = facade->GetEscapedNameForNameID(path_data.name_id);
SimpleLogger().Write(logDEBUG) << "{up} " << facade->GetCoordinateOfNode(path_data.node) << ", name: " << name;
}
} }
inline void UnpackEdge( inline void UnpackEdge(

View File

@ -362,17 +362,22 @@ public:
++current_leg; ++current_leg;
} }
if( distance1 > distance2 ) { if (distance1 > distance2)
{
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().source_phantom.forward_node_id ? 1 : -1 )*phantom_nodes_vector.front().source_phantom.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){ raw_route_data.source_traversed_in_reverse = (packed_legs1.front().front() != phantom_nodes_vector.front().source_phantom.forward_node_id);
BOOST_ASSERT( !phantom_nodes_vector.empty() ); raw_route_data.target_traversed_in_reverse = (packed_legs1.back().back() != phantom_nodes_vector.back().target_phantom.forward_node_id);
for (unsigned i = 0; i < packed_legs1.size(); ++i)
{
BOOST_ASSERT(!phantom_nodes_vector.empty());
// const bool at_beginning = (packed_legs1[i] == packed_legs1.front()); // const bool at_beginning = (packed_legs1[i] == packed_legs1.front());
// const bool at_end = (packed_legs1[i] == packed_legs1.back()); // const bool at_end = (packed_legs1[i] == packed_legs1.back());
BOOST_ASSERT(packed_legs1.size() == raw_route_data.unpacked_path_segments.size() ); BOOST_ASSERT(packed_legs1.size() == raw_route_data.unpacked_path_segments.size());
PhantomNodes unpack_phantom_node_pair = phantom_nodes_vector[i]; PhantomNodes unpack_phantom_node_pair = phantom_nodes_vector[i];
// if (!at_beginning) // if (!at_beginning)