explicitly give the locations of all via locations in response
This commit is contained in:
parent
58dc98460b
commit
d0b5929a9e
@ -37,6 +37,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct PathData {
|
struct PathData {
|
||||||
|
PathData() :
|
||||||
|
node(UINT_MAX),
|
||||||
|
name_id(UINT_MAX),
|
||||||
|
durationOfSegment(UINT_MAX),
|
||||||
|
turnInstruction(UCHAR_MAX)
|
||||||
|
{ }
|
||||||
|
|
||||||
PathData(
|
PathData(
|
||||||
NodeID no,
|
NodeID no,
|
||||||
unsigned na,
|
unsigned na,
|
||||||
@ -55,8 +62,8 @@ struct PathData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct RawRouteData {
|
struct RawRouteData {
|
||||||
std::vector< PathData > computedShortestPath;
|
std::vector< std::vector<PathData> > unpacked_path_segments;
|
||||||
std::vector< PathData > computedAlternativePath;
|
std::vector< PathData > unpacked_alternative;
|
||||||
std::vector< PhantomNodes > segmentEndCoordinates;
|
std::vector< PhantomNodes > segmentEndCoordinates;
|
||||||
std::vector< FixedPointCoordinate > rawViaNodeCoordinates;
|
std::vector< FixedPointCoordinate > rawViaNodeCoordinates;
|
||||||
unsigned checkSum;
|
unsigned checkSum;
|
||||||
|
@ -61,10 +61,10 @@ public:
|
|||||||
//Maybe someone can explain the pure virtual destructor thing to me (dennis)
|
//Maybe someone can explain the pure virtual destructor thing to me (dennis)
|
||||||
virtual ~BaseDescriptor() { }
|
virtual ~BaseDescriptor() { }
|
||||||
virtual void Run(
|
virtual void Run(
|
||||||
http::Reply & reply,
|
const RawRouteData & rawRoute,
|
||||||
const RawRouteData &rawRoute,
|
const PhantomNodes & phantomNodes,
|
||||||
PhantomNodes &phantomNodes,
|
DataFacadeT * facade,
|
||||||
const DataFacadeT * facade
|
http::Reply & reply
|
||||||
) = 0;
|
) = 0;
|
||||||
virtual void SetConfig(const DescriptorConfig & config) = 0;
|
virtual void SetConfig(const DescriptorConfig & config) = 0;
|
||||||
};
|
};
|
||||||
|
@ -43,13 +43,13 @@ double DescriptionFactory::GetBearing(
|
|||||||
const FixedPointCoordinate & A,
|
const FixedPointCoordinate & A,
|
||||||
const FixedPointCoordinate & B
|
const FixedPointCoordinate & B
|
||||||
) const {
|
) const {
|
||||||
double deltaLong = 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);
|
||||||
const double lat2 = DegreeToRadian(B.lat/COORDINATE_PRECISION);
|
const double lat2 = DegreeToRadian(B.lat/COORDINATE_PRECISION);
|
||||||
|
|
||||||
const double y = sin(deltaLong) * cos(lat2);
|
const double y = sin(delta_long) * cos(lat2);
|
||||||
const double x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(deltaLong);
|
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.;
|
||||||
@ -60,22 +60,22 @@ double DescriptionFactory::GetBearing(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptionFactory::SetStartSegment(const PhantomNode & sph) {
|
void DescriptionFactory::SetStartSegment(const PhantomNode & start) {
|
||||||
start_phantom = sph;
|
start_phantom = start;
|
||||||
AppendSegment(
|
AppendSegment(
|
||||||
sph.location,
|
start.location,
|
||||||
PathData(0, sph.nodeBasedEdgeNameID, 10, sph.weight1)
|
PathData(0, start.nodeBasedEdgeNameID, 10, start.weight1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DescriptionFactory::SetEndSegment(const PhantomNode & tph) {
|
void DescriptionFactory::SetEndSegment(const PhantomNode & target) {
|
||||||
target_phantom = tph;
|
target_phantom = target;
|
||||||
pathDescription.push_back(
|
pathDescription.push_back(
|
||||||
SegmentInformation(
|
SegmentInformation(
|
||||||
tph.location,
|
target.location,
|
||||||
tph.nodeBasedEdgeNameID,
|
target.nodeBasedEdgeNameID,
|
||||||
0,
|
0,
|
||||||
tph.weight1,
|
target.weight1,
|
||||||
0,
|
0,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
@ -86,10 +86,21 @@ void DescriptionFactory::AppendSegment(
|
|||||||
const FixedPointCoordinate & coordinate,
|
const FixedPointCoordinate & coordinate,
|
||||||
const PathData & data
|
const PathData & data
|
||||||
) {
|
) {
|
||||||
if(1 == pathDescription.size() && pathDescription.back().location == coordinate) {
|
if(
|
||||||
|
( 1 == pathDescription.size()) &&
|
||||||
|
( pathDescription.back().location == coordinate)
|
||||||
|
) {
|
||||||
pathDescription.back().name_id = data.name_id;
|
pathDescription.back().name_id = data.name_id;
|
||||||
} else {
|
} else {
|
||||||
pathDescription.push_back(SegmentInformation(coordinate, data.name_id, 0, data.durationOfSegment, data.turnInstruction) );
|
pathDescription.push_back(
|
||||||
|
SegmentInformation(
|
||||||
|
coordinate,
|
||||||
|
data.name_id,
|
||||||
|
0,
|
||||||
|
data.durationOfSegment,
|
||||||
|
data.turnInstruction
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,127 +133,6 @@ void DescriptionFactory::AppendUnencodedPolylineString(
|
|||||||
output.push_back(temp);
|
output.push_back(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void DescriptionFactory::Run(const SearchEngine &sEngine, const unsigned zoomLevel) {
|
|
||||||
|
|
||||||
// if(0 == pathDescription.size())
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// // unsigned entireLength = 0;
|
|
||||||
// /** starts at index 1 */
|
|
||||||
// pathDescription[0].length = 0;
|
|
||||||
// for(unsigned i = 1; i < pathDescription.size(); ++i) {
|
|
||||||
// pathDescription[i].length = ApproximateEuclideanDistance(pathDescription[i-1].location, pathDescription[i].location);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// double lengthOfSegment = 0;
|
|
||||||
// unsigned durationOfSegment = 0;
|
|
||||||
// unsigned indexOfSegmentBegin = 0;
|
|
||||||
|
|
||||||
// std::string string0 = sEngine.GetEscapedNameForNameID(pathDescription[0].name_id);
|
|
||||||
// std::string string1;
|
|
||||||
|
|
||||||
|
|
||||||
// /*Simplify turn instructions
|
|
||||||
// Input :
|
|
||||||
// 10. Turn left on B 36 for 20 km
|
|
||||||
// 11. Continue on B 35; B 36 for 2 km
|
|
||||||
// 12. Continue on B 36 for 13 km
|
|
||||||
|
|
||||||
// becomes:
|
|
||||||
// 10. Turn left on B 36 for 35 km
|
|
||||||
// */
|
|
||||||
// //TODO: rework to check only end and start of string.
|
|
||||||
// // stl string is way to expensive
|
|
||||||
|
|
||||||
// // unsigned lastTurn = 0;
|
|
||||||
// // for(unsigned i = 1; i < pathDescription.size(); ++i) {
|
|
||||||
// // string1 = sEngine.GetEscapedNameForNameID(pathDescription[i].name_id);
|
|
||||||
// // if(TurnInstructionsClass::GoStraight == pathDescription[i].turnInstruction) {
|
|
||||||
// // if(std::string::npos != string0.find(string1+";")
|
|
||||||
// // || std::string::npos != string0.find(";"+string1)
|
|
||||||
// // || std::string::npos != string0.find(string1+" ;")
|
|
||||||
// // || std::string::npos != string0.find("; "+string1)
|
|
||||||
// // ){
|
|
||||||
// // SimpleLogger().Write() << "->next correct: " << string0 << " contains " << string1;
|
|
||||||
// // for(; lastTurn != i; ++lastTurn)
|
|
||||||
// // pathDescription[lastTurn].name_id = pathDescription[i].name_id;
|
|
||||||
// // pathDescription[i].turnInstruction = TurnInstructionsClass::NoTurn;
|
|
||||||
// // } else if(std::string::npos != string1.find(string0+";")
|
|
||||||
// // || std::string::npos != string1.find(";"+string0)
|
|
||||||
// // || std::string::npos != string1.find(string0+" ;")
|
|
||||||
// // || std::string::npos != string1.find("; "+string0)
|
|
||||||
// // ){
|
|
||||||
// // SimpleLogger().Write() << "->prev correct: " << string1 << " contains " << string0;
|
|
||||||
// // pathDescription[i].name_id = pathDescription[i-1].name_id;
|
|
||||||
// // pathDescription[i].turnInstruction = TurnInstructionsClass::NoTurn;
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
// // if (TurnInstructionsClass::NoTurn != pathDescription[i].turnInstruction) {
|
|
||||||
// // lastTurn = i;
|
|
||||||
// // }
|
|
||||||
// // string0 = string1;
|
|
||||||
// // }
|
|
||||||
|
|
||||||
|
|
||||||
// for(unsigned i = 1; i < pathDescription.size(); ++i) {
|
|
||||||
// entireLength += pathDescription[i].length;
|
|
||||||
// lengthOfSegment += pathDescription[i].length;
|
|
||||||
// durationOfSegment += pathDescription[i].duration;
|
|
||||||
// pathDescription[indexOfSegmentBegin].length = lengthOfSegment;
|
|
||||||
// pathDescription[indexOfSegmentBegin].duration = durationOfSegment;
|
|
||||||
|
|
||||||
|
|
||||||
// if(TurnInstructionsClass::NoTurn != pathDescription[i].turnInstruction) {
|
|
||||||
// //SimpleLogger().Write() << "Turn after " << lengthOfSegment << "m into way with name id " << segment.name_id;
|
|
||||||
// assert(pathDescription[i].necessary);
|
|
||||||
// lengthOfSegment = 0;
|
|
||||||
// durationOfSegment = 0;
|
|
||||||
// indexOfSegmentBegin = i;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // SimpleLogger().Write() << "#segs: " << pathDescription.size();
|
|
||||||
|
|
||||||
// //Post-processing to remove empty or nearly empty path segments
|
|
||||||
// if(FLT_EPSILON > pathDescription.back().length) {
|
|
||||||
// // SimpleLogger().Write() << "#segs: " << pathDescription.size() << ", last ratio: " << target_phantom.ratio << ", length: " << pathDescription.back().length;
|
|
||||||
// if(pathDescription.size() > 2){
|
|
||||||
// pathDescription.pop_back();
|
|
||||||
// pathDescription.back().necessary = true;
|
|
||||||
// pathDescription.back().turnInstruction = TurnInstructions.NoTurn;
|
|
||||||
// target_phantom.nodeBasedEdgeNameID = (pathDescription.end()-2)->name_id;
|
|
||||||
// // SimpleLogger().Write() << "Deleting last turn instruction";
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// pathDescription[indexOfSegmentBegin].duration *= (1.-target_phantom.ratio);
|
|
||||||
// }
|
|
||||||
// if(FLT_EPSILON > pathDescription[0].length) {
|
|
||||||
// //TODO: this is never called actually?
|
|
||||||
// if(pathDescription.size() > 2) {
|
|
||||||
// pathDescription.erase(pathDescription.begin());
|
|
||||||
// pathDescription[0].turnInstruction = TurnInstructions.HeadOn;
|
|
||||||
// pathDescription[0].necessary = true;
|
|
||||||
// start_phantom.nodeBasedEdgeNameID = pathDescription[0].name_id;
|
|
||||||
// // SimpleLogger().Write() << "Deleting first turn instruction, ratio: " << start_phantom.ratio << ", length: " << pathDescription[0].length;
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// pathDescription[0].duration *= start_phantom.ratio;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //Generalize poly line
|
|
||||||
// dp.Run(pathDescription, zoomLevel);
|
|
||||||
|
|
||||||
// //fix what needs to be fixed else
|
|
||||||
// for(unsigned i = 0; i < pathDescription.size()-1 && pathDescription.size() >= 2; ++i){
|
|
||||||
// if(pathDescription[i].necessary) {
|
|
||||||
// double angle = GetBearing(pathDescription[i].location, pathDescription[i+1].location);
|
|
||||||
// pathDescription[i].bearing = angle;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // BuildRouteSummary(entireLength, duration);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
void DescriptionFactory::BuildRouteSummary(
|
void DescriptionFactory::BuildRouteSummary(
|
||||||
const double distance,
|
const double distance,
|
||||||
const unsigned time
|
const unsigned time
|
||||||
|
@ -94,8 +94,10 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
template<class DataFacadeT>
|
template<class DataFacadeT>
|
||||||
void Run(const DataFacadeT * facade, const unsigned zoomLevel) {
|
void Run(
|
||||||
|
const DataFacadeT * facade,
|
||||||
|
const unsigned zoomLevel
|
||||||
|
) {
|
||||||
if( pathDescription.empty() ) {
|
if( pathDescription.empty() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -107,10 +109,6 @@ public:
|
|||||||
pathDescription[i].length = ApproximateEuclideanDistance(pathDescription[i-1].location, pathDescription[i].location);
|
pathDescription[i].length = ApproximateEuclideanDistance(pathDescription[i-1].location, pathDescription[i].location);
|
||||||
}
|
}
|
||||||
|
|
||||||
double lengthOfSegment = 0;
|
|
||||||
unsigned durationOfSegment = 0;
|
|
||||||
unsigned indexOfSegmentBegin = 0;
|
|
||||||
|
|
||||||
// std::string string0 = facade->GetEscapedNameForNameID(pathDescription[0].name_id);
|
// std::string string0 = facade->GetEscapedNameForNameID(pathDescription[0].name_id);
|
||||||
// std::string string1;
|
// std::string string1;
|
||||||
|
|
||||||
@ -156,6 +154,9 @@ public:
|
|||||||
// string0 = string1;
|
// string0 = string1;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
double lengthOfSegment = 0;
|
||||||
|
unsigned durationOfSegment = 0;
|
||||||
|
unsigned indexOfSegmentBegin = 0;
|
||||||
|
|
||||||
for(unsigned i = 1; i < pathDescription.size(); ++i) {
|
for(unsigned i = 1; i < pathDescription.size(); ++i) {
|
||||||
entireLength += pathDescription[i].length;
|
entireLength += pathDescription[i].length;
|
||||||
@ -183,7 +184,7 @@ public:
|
|||||||
pathDescription.back().necessary = true;
|
pathDescription.back().necessary = true;
|
||||||
pathDescription.back().turn_instruction = TurnInstructions.NoTurn;
|
pathDescription.back().turn_instruction = TurnInstructions.NoTurn;
|
||||||
target_phantom.nodeBasedEdgeNameID = (pathDescription.end()-2)->name_id;
|
target_phantom.nodeBasedEdgeNameID = (pathDescription.end()-2)->name_id;
|
||||||
// SimpleLogger().Write() << "Deleting last turn instruction";
|
SimpleLogger().Write() << "Deleting last turn instruction";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pathDescription[indexOfSegmentBegin].duration *= (1.-target_phantom.ratio);
|
pathDescription[indexOfSegmentBegin].duration *= (1.-target_phantom.ratio);
|
||||||
|
@ -44,10 +44,10 @@ public:
|
|||||||
|
|
||||||
//TODO: reorder parameters
|
//TODO: reorder parameters
|
||||||
void Run(
|
void Run(
|
||||||
http::Reply & reply,
|
const RawRouteData &raw_route,
|
||||||
const RawRouteData &rawRoute,
|
const PhantomNodes &phantom_node_list,
|
||||||
PhantomNodes &phantomNodes,
|
DataFacadeT * facade,
|
||||||
const DataFacadeT * facade
|
http::Reply & reply
|
||||||
) {
|
) {
|
||||||
reply.content.push_back("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
reply.content.push_back("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||||
reply.content.push_back(
|
reply.content.push_back(
|
||||||
@ -61,23 +61,24 @@ public:
|
|||||||
" OpenStreetMap contributors (ODbL)</license></copyright>"
|
" OpenStreetMap contributors (ODbL)</license></copyright>"
|
||||||
"</metadata>");
|
"</metadata>");
|
||||||
reply.content.push_back("<rte>");
|
reply.content.push_back("<rte>");
|
||||||
bool found_route = (rawRoute.lengthOfShortestPath != INT_MAX) &&
|
bool found_route = (raw_route.lengthOfShortestPath != INT_MAX) &&
|
||||||
(rawRoute.computedShortestPath.size() );
|
(raw_route.unpacked_path_segments[0].size());
|
||||||
if( found_route ) {
|
if( found_route ) {
|
||||||
convertInternalLatLonToString(
|
convertInternalLatLonToString(
|
||||||
phantomNodes.startPhantom.location.lat,
|
phantom_node_list.startPhantom.location.lat,
|
||||||
tmp
|
tmp
|
||||||
);
|
);
|
||||||
reply.content.push_back("<rtept lat=\"" + tmp + "\" ");
|
reply.content.push_back("<rtept lat=\"" + tmp + "\" ");
|
||||||
convertInternalLatLonToString(
|
convertInternalLatLonToString(
|
||||||
phantomNodes.startPhantom.location.lon,
|
phantom_node_list.startPhantom.location.lon,
|
||||||
tmp
|
tmp
|
||||||
);
|
);
|
||||||
reply.content.push_back("lon=\"" + tmp + "\"></rtept>");
|
reply.content.push_back("lon=\"" + tmp + "\"></rtept>");
|
||||||
|
|
||||||
|
for(unsigned i=0; i < raw_route.unpacked_path_segments.size(); ++i){
|
||||||
BOOST_FOREACH(
|
BOOST_FOREACH(
|
||||||
const PathData & pathData,
|
const PathData & pathData,
|
||||||
rawRoute.computedShortestPath
|
raw_route.unpacked_path_segments[i]
|
||||||
) {
|
) {
|
||||||
current = facade->GetCoordinateOfNode(pathData.node);
|
current = facade->GetCoordinateOfNode(pathData.node);
|
||||||
|
|
||||||
@ -86,17 +87,19 @@ public:
|
|||||||
convertInternalLatLonToString(current.lon, tmp);
|
convertInternalLatLonToString(current.lon, tmp);
|
||||||
reply.content.push_back("lon=\"" + tmp + "\"></rtept>");
|
reply.content.push_back("lon=\"" + tmp + "\"></rtept>");
|
||||||
}
|
}
|
||||||
|
// TODO: Add the via point or the end coordinate
|
||||||
convertInternalLatLonToString(
|
convertInternalLatLonToString(
|
||||||
phantomNodes.targetPhantom.location.lat,
|
phantom_node_list.targetPhantom.location.lat,
|
||||||
tmp
|
tmp
|
||||||
);
|
);
|
||||||
reply.content.push_back("<rtept lat=\"" + tmp + "\" ");
|
reply.content.push_back("<rtept lat=\"" + tmp + "\" ");
|
||||||
convertInternalLatLonToString(
|
convertInternalLatLonToString(
|
||||||
phantomNodes.targetPhantom.location.lon,
|
phantom_node_list.targetPhantom.location.lon,
|
||||||
tmp
|
tmp
|
||||||
);
|
);
|
||||||
reply.content.push_back("lon=\"" + tmp + "\"></rtept>");
|
reply.content.push_back("lon=\"" + tmp + "\"></rtept>");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
reply.content.push_back("</rte></gpx>");
|
reply.content.push_back("</rte></gpx>");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -44,9 +44,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
template<class DataFacadeT>
|
template<class DataFacadeT>
|
||||||
class JSONDescriptor : public BaseDescriptor<DataFacadeT> {
|
class JSONDescriptor : public BaseDescriptor<DataFacadeT> {
|
||||||
private:
|
private:
|
||||||
|
DataFacadeT * facade;
|
||||||
DescriptorConfig config;
|
DescriptorConfig config;
|
||||||
DescriptionFactory description_factory;
|
DescriptionFactory description_factory;
|
||||||
DescriptionFactory alternateDescriptionFactory;
|
DescriptionFactory alternate_descriptionFactory;
|
||||||
FixedPointCoordinate current;
|
FixedPointCoordinate current;
|
||||||
unsigned entered_restricted_area_count;
|
unsigned entered_restricted_area_count;
|
||||||
struct RoundAbout{
|
struct RoundAbout{
|
||||||
@ -68,6 +69,7 @@ private:
|
|||||||
int position;
|
int position;
|
||||||
};
|
};
|
||||||
std::vector<Segment> shortest_path_segments, alternative_path_segments;
|
std::vector<Segment> shortest_path_segments, alternative_path_segments;
|
||||||
|
std::vector<unsigned> shortest_leg_end_indices, alternative_leg_end_indices;
|
||||||
|
|
||||||
struct RouteNames {
|
struct RouteNames {
|
||||||
std::string shortestPathName1;
|
std::string shortestPathName1;
|
||||||
@ -77,37 +79,68 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JSONDescriptor() : entered_restricted_area_count(0) {}
|
JSONDescriptor() : entered_restricted_area_count(0) {
|
||||||
|
shortest_leg_end_indices.push_back(0);
|
||||||
|
alternative_leg_end_indices.push_back(0);
|
||||||
|
}
|
||||||
|
|
||||||
void SetConfig(const DescriptorConfig & c) { config = c; }
|
void SetConfig(const DescriptorConfig & c) { config = c; }
|
||||||
|
|
||||||
//TODO: reorder parameters
|
int DescribeLeg(
|
||||||
void Run(
|
const std::vector<PathData> route_leg,
|
||||||
http::Reply & reply,
|
const PhantomNodes & leg_phantoms
|
||||||
const RawRouteData & raw_route_information,
|
|
||||||
PhantomNodes & phantom_nodes,
|
|
||||||
const DataFacadeT * facade
|
|
||||||
) {
|
) {
|
||||||
|
int added_element_count = 0;
|
||||||
|
//Get all the coordinates for the computed route
|
||||||
|
FixedPointCoordinate current_coordinate;
|
||||||
|
BOOST_FOREACH(const PathData & path_data, route_leg) {
|
||||||
|
current_coordinate = facade->GetCoordinateOfNode(path_data.node);
|
||||||
|
description_factory.AppendSegment(current_coordinate, path_data );
|
||||||
|
++added_element_count;
|
||||||
|
}
|
||||||
|
// description_factory.SetEndSegment( leg_phantoms.targetPhantom );
|
||||||
|
++added_element_count;
|
||||||
|
BOOST_ASSERT( route_leg.size() + 1 == added_element_count );
|
||||||
|
return added_element_count;
|
||||||
|
}
|
||||||
|
|
||||||
WriteHeaderToOutput(reply.content);
|
void Run(
|
||||||
|
const RawRouteData & raw_route,
|
||||||
|
const PhantomNodes & phantom_nodes,
|
||||||
|
// TODO: move facade initalization to c'tor
|
||||||
|
DataFacadeT * f,
|
||||||
|
http::Reply & reply
|
||||||
|
) {
|
||||||
|
facade = f;
|
||||||
|
reply.content.push_back(
|
||||||
|
"{\"status\":"
|
||||||
|
);
|
||||||
|
|
||||||
if(raw_route_information.lengthOfShortestPath != INT_MAX) {
|
if(raw_route.lengthOfShortestPath != INT_MAX) {
|
||||||
description_factory.SetStartSegment(phantom_nodes.startPhantom);
|
description_factory.SetStartSegment(phantom_nodes.startPhantom);
|
||||||
reply.content.push_back("0,"
|
reply.content.push_back("0,"
|
||||||
"\"status_message\": \"Found route between points\",");
|
"\"status_message\": \"Found route between points\",");
|
||||||
|
|
||||||
//Get all the coordinates for the computed route
|
BOOST_ASSERT( raw_route.unpacked_path_segments.size() == raw_route.segmentEndCoordinates.size() );
|
||||||
BOOST_FOREACH(const PathData & path_data, raw_route_information.computedShortestPath) {
|
for( unsigned i = 0; i < raw_route.unpacked_path_segments.size(); ++i ) {
|
||||||
current = facade->GetCoordinateOfNode(path_data.node);
|
const int added_segments = DescribeLeg(
|
||||||
description_factory.AppendSegment(current, path_data );
|
raw_route.unpacked_path_segments[i],
|
||||||
|
raw_route.segmentEndCoordinates[i]
|
||||||
|
);
|
||||||
|
BOOST_ASSERT( 0 < added_segments );
|
||||||
|
shortest_leg_end_indices.push_back(
|
||||||
|
added_segments + shortest_leg_end_indices.back()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
description_factory.SetEndSegment(phantom_nodes.targetPhantom);
|
description_factory.SetEndSegment(phantom_nodes.targetPhantom);
|
||||||
|
description_factory.Run(facade, config.zoom_level);
|
||||||
} else {
|
} else {
|
||||||
//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("207,"
|
reply.content.push_back("207,"
|
||||||
"\"status_message\": \"Cannot find route between points\",");
|
"\"status_message\": \"Cannot find route between points\"}");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
description_factory.Run(facade, config.zoom_level);
|
|
||||||
reply.content.push_back("\"route_geometry\": ");
|
reply.content.push_back("\"route_geometry\": ");
|
||||||
if(config.geometry) {
|
if(config.geometry) {
|
||||||
description_factory.AppendEncodedPolylineString(
|
description_factory.AppendEncodedPolylineString(
|
||||||
@ -118,30 +151,20 @@ public:
|
|||||||
reply.content.push_back("[]");
|
reply.content.push_back("[]");
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.content.push_back(","
|
reply.content.push_back(",\"route_instructions\": [");
|
||||||
"\"route_instructions\": [");
|
|
||||||
entered_restricted_area_count = 0;
|
|
||||||
if(config.instructions) {
|
if(config.instructions) {
|
||||||
BuildTextualDescription(
|
BuildTextualDescription(
|
||||||
description_factory,
|
description_factory,
|
||||||
reply,
|
reply,
|
||||||
raw_route_information.lengthOfShortestPath,
|
raw_route.lengthOfShortestPath,
|
||||||
facade,
|
facade,
|
||||||
shortest_path_segments
|
shortest_path_segments
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
BOOST_FOREACH(
|
|
||||||
const SegmentInformation & segment,
|
|
||||||
description_factory.pathDescription
|
|
||||||
) {
|
|
||||||
TurnInstruction current_instruction = segment.turn_instruction & TurnInstructions.InverseAccessRestrictionFlag;
|
|
||||||
entered_restricted_area_count += (current_instruction != segment.turn_instruction);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
reply.content.push_back("],");
|
reply.content.push_back("],");
|
||||||
description_factory.BuildRouteSummary(
|
description_factory.BuildRouteSummary(
|
||||||
description_factory.entireLength,
|
description_factory.entireLength,
|
||||||
raw_route_information.lengthOfShortestPath - ( entered_restricted_area_count*TurnInstructions.AccessRestrictionPenalty)
|
raw_route.lengthOfShortestPath
|
||||||
);
|
);
|
||||||
|
|
||||||
reply.content.push_back("\"route_summary\":");
|
reply.content.push_back("\"route_summary\":");
|
||||||
@ -167,62 +190,67 @@ 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_information.lengthOfAlternativePath != INT_MAX) {
|
if(raw_route.lengthOfAlternativePath != INT_MAX) {
|
||||||
alternateDescriptionFactory.SetStartSegment(phantom_nodes.startPhantom);
|
alternate_descriptionFactory.SetStartSegment(phantom_nodes.startPhantom);
|
||||||
//Get all the coordinates for the computed route
|
//Get all the coordinates for the computed route
|
||||||
BOOST_FOREACH(const PathData & path_data, raw_route_information.computedAlternativePath) {
|
BOOST_FOREACH(const PathData & path_data, raw_route.unpacked_alternative) {
|
||||||
current = facade->GetCoordinateOfNode(path_data.node);
|
current = facade->GetCoordinateOfNode(path_data.node);
|
||||||
alternateDescriptionFactory.AppendSegment(current, path_data );
|
alternate_descriptionFactory.AppendSegment(current, path_data );
|
||||||
}
|
}
|
||||||
alternateDescriptionFactory.SetEndSegment(phantom_nodes.targetPhantom);
|
alternate_descriptionFactory.SetEndSegment(phantom_nodes.targetPhantom);
|
||||||
}
|
}
|
||||||
alternateDescriptionFactory.Run(facade, config.zoom_level);
|
alternate_descriptionFactory.Run(facade, config.zoom_level);
|
||||||
|
|
||||||
//give an array of alternative routes
|
// //give an array of alternative routes
|
||||||
reply.content.push_back("\"alternative_geometries\": [");
|
reply.content.push_back("\"alternative_geometries\": [");
|
||||||
if(config.geometry && INT_MAX != raw_route_information.lengthOfAlternativePath) {
|
if(config.geometry && INT_MAX != raw_route.lengthOfAlternativePath) {
|
||||||
//Generate the linestrings for each alternative
|
//Generate the linestrings for each alternative
|
||||||
alternateDescriptionFactory.AppendEncodedPolylineString(
|
alternate_descriptionFactory.AppendEncodedPolylineString(
|
||||||
config.encode_geometry,
|
config.encode_geometry,
|
||||||
reply.content
|
reply.content
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
reply.content.push_back("],");
|
reply.content.push_back("],");
|
||||||
reply.content.push_back("\"alternative_instructions\":[");
|
reply.content.push_back("\"alternative_instructions\":[");
|
||||||
entered_restricted_area_count = 0;
|
if(INT_MAX != raw_route.lengthOfAlternativePath) {
|
||||||
if(INT_MAX != raw_route_information.lengthOfAlternativePath) {
|
|
||||||
reply.content.push_back("[");
|
reply.content.push_back("[");
|
||||||
//Generate instructions for each alternative
|
//Generate instructions for each alternative
|
||||||
if(config.instructions) {
|
if(config.instructions) {
|
||||||
BuildTextualDescription(
|
BuildTextualDescription(
|
||||||
alternateDescriptionFactory,
|
alternate_descriptionFactory,
|
||||||
reply,
|
reply,
|
||||||
raw_route_information.lengthOfAlternativePath,
|
raw_route.lengthOfAlternativePath,
|
||||||
facade,
|
facade,
|
||||||
alternative_path_segments
|
alternative_path_segments
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
BOOST_FOREACH(const SegmentInformation & segment, alternateDescriptionFactory.pathDescription) {
|
|
||||||
TurnInstruction current_instruction = segment.turn_instruction & TurnInstructions.InverseAccessRestrictionFlag;
|
|
||||||
entered_restricted_area_count += (current_instruction != segment.turn_instruction);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
reply.content.push_back("]");
|
reply.content.push_back("]");
|
||||||
}
|
}
|
||||||
reply.content.push_back("],");
|
reply.content.push_back("],");
|
||||||
reply.content.push_back("\"alternative_summaries\":[");
|
reply.content.push_back("\"alternative_summaries\":[");
|
||||||
if(INT_MAX != raw_route_information.lengthOfAlternativePath) {
|
if(INT_MAX != raw_route.lengthOfAlternativePath) {
|
||||||
//Generate route summary (length, duration) for each alternative
|
//Generate route summary (length, duration) for each alternative
|
||||||
alternateDescriptionFactory.BuildRouteSummary(alternateDescriptionFactory.entireLength, raw_route_information.lengthOfAlternativePath - ( entered_restricted_area_count*TurnInstructions.AccessRestrictionPenalty));
|
alternate_descriptionFactory.BuildRouteSummary(
|
||||||
|
alternate_descriptionFactory.entireLength,
|
||||||
|
raw_route.lengthOfAlternativePath
|
||||||
|
);
|
||||||
reply.content.push_back("{");
|
reply.content.push_back("{");
|
||||||
reply.content.push_back("\"total_distance\":");
|
reply.content.push_back("\"total_distance\":");
|
||||||
reply.content.push_back(alternateDescriptionFactory.summary.lengthString);
|
reply.content.push_back(
|
||||||
|
alternate_descriptionFactory.summary.lengthString
|
||||||
|
);
|
||||||
reply.content.push_back(","
|
reply.content.push_back(","
|
||||||
"\"total_time\":");
|
"\"total_time\":");
|
||||||
reply.content.push_back(alternateDescriptionFactory.summary.durationString);
|
reply.content.push_back(
|
||||||
|
alternate_descriptionFactory.summary.durationString
|
||||||
|
);
|
||||||
reply.content.push_back(","
|
reply.content.push_back(","
|
||||||
"\"start_point\":\"");
|
"\"start_point\":\"");
|
||||||
reply.content.push_back(facade->GetEscapedNameForNameID(description_factory.summary.startName));
|
reply.content.push_back(
|
||||||
|
facade->GetEscapedNameForNameID(
|
||||||
|
description_factory.summary.startName
|
||||||
|
)
|
||||||
|
);
|
||||||
reply.content.push_back("\","
|
reply.content.push_back("\","
|
||||||
"\"end_point\":\"");
|
"\"end_point\":\"");
|
||||||
reply.content.push_back(facade->GetEscapedNameForNameID(description_factory.summary.destName));
|
reply.content.push_back(facade->GetEscapedNameForNameID(description_factory.summary.destName));
|
||||||
@ -231,7 +259,7 @@ public:
|
|||||||
}
|
}
|
||||||
reply.content.push_back("],");
|
reply.content.push_back("],");
|
||||||
|
|
||||||
//Get Names for both routes
|
// //Get Names for both routes
|
||||||
RouteNames routeNames;
|
RouteNames routeNames;
|
||||||
GetRouteNames(shortest_path_segments, alternative_path_segments, facade, routeNames);
|
GetRouteNames(shortest_path_segments, alternative_path_segments, facade, routeNames);
|
||||||
|
|
||||||
@ -249,47 +277,66 @@ public:
|
|||||||
reply.content.push_back("],");
|
reply.content.push_back("],");
|
||||||
//list all viapoints so that the client may display it
|
//list all viapoints so that the client may display it
|
||||||
reply.content.push_back("\"via_points\":[");
|
reply.content.push_back("\"via_points\":[");
|
||||||
std::string tmp;
|
|
||||||
if(config.geometry && INT_MAX != raw_route_information.lengthOfShortestPath) {
|
|
||||||
for(unsigned i = 0; i < raw_route_information.segmentEndCoordinates.size(); ++i) {
|
|
||||||
reply.content.push_back("[");
|
|
||||||
if(raw_route_information.segmentEndCoordinates[i].startPhantom.location.isSet())
|
|
||||||
convertInternalReversedCoordinateToString(raw_route_information.segmentEndCoordinates[i].startPhantom.location, tmp);
|
|
||||||
else
|
|
||||||
convertInternalReversedCoordinateToString(raw_route_information.rawViaNodeCoordinates[i], tmp);
|
|
||||||
|
|
||||||
reply.content.push_back(tmp);
|
BOOST_ASSERT( !raw_route.segmentEndCoordinates.empty() );
|
||||||
reply.content.push_back("],");
|
|
||||||
}
|
std::string tmp;
|
||||||
|
convertInternalReversedCoordinateToString(
|
||||||
|
raw_route.segmentEndCoordinates.front().startPhantom.location,
|
||||||
|
tmp
|
||||||
|
);
|
||||||
reply.content.push_back("[");
|
reply.content.push_back("[");
|
||||||
if(raw_route_information.segmentEndCoordinates.back().startPhantom.location.isSet())
|
reply.content.push_back(tmp);
|
||||||
convertInternalReversedCoordinateToString(raw_route_information.segmentEndCoordinates.back().targetPhantom.location, tmp);
|
reply.content.push_back("]");
|
||||||
else
|
|
||||||
convertInternalReversedCoordinateToString(raw_route_information.rawViaNodeCoordinates.back(), tmp);
|
BOOST_FOREACH(const PhantomNodes & nodes, raw_route.segmentEndCoordinates) {
|
||||||
|
tmp.clear();
|
||||||
|
convertInternalReversedCoordinateToString(
|
||||||
|
nodes.targetPhantom.location,
|
||||||
|
tmp
|
||||||
|
);
|
||||||
|
reply.content.push_back(",[");
|
||||||
reply.content.push_back(tmp);
|
reply.content.push_back(tmp);
|
||||||
reply.content.push_back("]");
|
reply.content.push_back("]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reply.content.push_back("],");
|
||||||
|
reply.content.push_back("\"via_indices\":[");
|
||||||
|
BOOST_FOREACH(const unsigned index, shortest_leg_end_indices) {
|
||||||
|
tmp.clear();
|
||||||
|
intToString(index, tmp);
|
||||||
|
reply.content.push_back(tmp);
|
||||||
|
if( index != shortest_leg_end_indices.back() ) {
|
||||||
|
reply.content.push_back(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reply.content.push_back("],\"alternative_indices\":[");
|
||||||
|
if(INT_MAX != raw_route.lengthOfAlternativePath) {
|
||||||
|
reply.content.push_back("0,");
|
||||||
|
tmp.clear();
|
||||||
|
intToString(alternate_descriptionFactory.pathDescription.size(), tmp);
|
||||||
|
reply.content.push_back(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
reply.content.push_back("],");
|
reply.content.push_back("],");
|
||||||
reply.content.push_back("\"hint_data\": {");
|
reply.content.push_back("\"hint_data\": {");
|
||||||
reply.content.push_back("\"checksum\":");
|
reply.content.push_back("\"checksum\":");
|
||||||
intToString(raw_route_information.checkSum, tmp);
|
intToString(raw_route.checkSum, tmp);
|
||||||
reply.content.push_back(tmp);
|
reply.content.push_back(tmp);
|
||||||
reply.content.push_back(", \"locations\": [");
|
reply.content.push_back(", \"locations\": [");
|
||||||
|
|
||||||
std::string hint;
|
std::string hint;
|
||||||
for(unsigned i = 0; i < raw_route_information.segmentEndCoordinates.size(); ++i) {
|
for(unsigned i = 0; i < raw_route.segmentEndCoordinates.size(); ++i) {
|
||||||
reply.content.push_back("\"");
|
reply.content.push_back("\"");
|
||||||
EncodeObjectToBase64(raw_route_information.segmentEndCoordinates[i].startPhantom, hint);
|
EncodeObjectToBase64(raw_route.segmentEndCoordinates[i].startPhantom, hint);
|
||||||
reply.content.push_back(hint);
|
reply.content.push_back(hint);
|
||||||
reply.content.push_back("\", ");
|
reply.content.push_back("\", ");
|
||||||
}
|
}
|
||||||
EncodeObjectToBase64(raw_route_information.segmentEndCoordinates.back().targetPhantom, hint);
|
EncodeObjectToBase64(raw_route.segmentEndCoordinates.back().targetPhantom, 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("\"]");
|
||||||
reply.content.push_back("},");
|
reply.content.push_back("}}");
|
||||||
reply.content.push_back("\"transactionId\": \"OSRM Routing Engine JSON Descriptor (v0.3)\"");
|
|
||||||
reply.content.push_back("}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct routes names
|
// construct routes names
|
||||||
@ -357,14 +404,6 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void WriteHeaderToOutput(std::vector<std::string> & output) {
|
|
||||||
output.push_back(
|
|
||||||
"{"
|
|
||||||
"\"version\": 0.3,"
|
|
||||||
"\"status\":"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: reorder parameters
|
//TODO: reorder parameters
|
||||||
inline void BuildTextualDescription(
|
inline void BuildTextualDescription(
|
||||||
DescriptionFactory & description_factory,
|
DescriptionFactory & description_factory,
|
||||||
|
@ -68,7 +68,6 @@ public:
|
|||||||
}
|
}
|
||||||
reply.status = http::Reply::ok;
|
reply.status = http::Reply::ok;
|
||||||
reply.content.push_back ("{");
|
reply.content.push_back ("{");
|
||||||
reply.content.push_back ("\"version\":0.3,");
|
|
||||||
if(
|
if(
|
||||||
!facade->LocateClosestEndPointForCoordinate(
|
!facade->LocateClosestEndPointForCoordinate(
|
||||||
routeParameters.coordinates[0],
|
routeParameters.coordinates[0],
|
||||||
@ -90,7 +89,6 @@ public:
|
|||||||
reply.content.push_back(tmp);
|
reply.content.push_back(tmp);
|
||||||
reply.content.push_back("]");
|
reply.content.push_back("]");
|
||||||
}
|
}
|
||||||
reply.content.push_back(",\"transactionId\": \"OSRM Routing Engine JSON Locate (v0.3)\"");
|
|
||||||
reply.content.push_back("}");
|
reply.content.push_back("}");
|
||||||
reply.headers.resize(3);
|
reply.headers.resize(3);
|
||||||
if(!routeParameters.jsonpParameter.empty()) {
|
if(!routeParameters.jsonpParameter.empty()) {
|
||||||
|
@ -76,7 +76,6 @@ public:
|
|||||||
|
|
||||||
reply.status = http::Reply::ok;
|
reply.status = http::Reply::ok;
|
||||||
reply.content.push_back("{");
|
reply.content.push_back("{");
|
||||||
reply.content.push_back("\"version\":0.3,");
|
|
||||||
reply.content.push_back("\"status\":");
|
reply.content.push_back("\"status\":");
|
||||||
if(UINT_MAX != result.edgeBasedNode) {
|
if(UINT_MAX != result.edgeBasedNode) {
|
||||||
reply.content.push_back("0,");
|
reply.content.push_back("0,");
|
||||||
@ -99,7 +98,6 @@ public:
|
|||||||
reply.content.push_back(temp_string);
|
reply.content.push_back(temp_string);
|
||||||
}
|
}
|
||||||
reply.content.push_back("\"");
|
reply.content.push_back("\"");
|
||||||
reply.content.push_back(",\"transactionId\":\"OSRM Routing Engine JSON Nearest (v0.3)\"");
|
|
||||||
reply.content.push_back("}");
|
reply.content.push_back("}");
|
||||||
reply.headers.resize(3);
|
reply.headers.resize(3);
|
||||||
if( !routeParameters.jsonpParameter.empty() ) {
|
if( !routeParameters.jsonpParameter.empty() ) {
|
||||||
|
@ -48,13 +48,11 @@ public:
|
|||||||
|
|
||||||
reply.status = http::Reply::ok;
|
reply.status = http::Reply::ok;
|
||||||
reply.content.push_back("{");
|
reply.content.push_back("{");
|
||||||
reply.content.push_back("\"version\":0.3,");
|
|
||||||
reply.content.push_back("\"status\":");
|
reply.content.push_back("\"status\":");
|
||||||
reply.content.push_back("0,");
|
reply.content.push_back("0,");
|
||||||
reply.content.push_back("\"timestamp\":\"");
|
reply.content.push_back("\"timestamp\":\"");
|
||||||
reply.content.push_back(facade->GetTimestamp());
|
reply.content.push_back(facade->GetTimestamp());
|
||||||
reply.content.push_back("\"");
|
reply.content.push_back("\"");
|
||||||
reply.content.push_back(",\"transactionId\":\"OSRM Routing Engine JSON timestamp (v0.3)\"");
|
|
||||||
reply.content.push_back("}");
|
reply.content.push_back("}");
|
||||||
reply.headers.resize(3);
|
reply.headers.resize(3);
|
||||||
if("" != routeParameters.jsonpParameter) {
|
if("" != routeParameters.jsonpParameter) {
|
||||||
|
@ -83,7 +83,7 @@ public:
|
|||||||
|
|
||||||
RawRouteData rawRoute;
|
RawRouteData rawRoute;
|
||||||
rawRoute.checkSum = facade->GetCheckSum();
|
rawRoute.checkSum = facade->GetCheckSum();
|
||||||
bool checksumOK = (routeParameters.checkSum == rawRoute.checkSum);
|
const bool checksumOK = (routeParameters.checkSum == rawRoute.checkSum);
|
||||||
std::vector<std::string> textCoord;
|
std::vector<std::string> textCoord;
|
||||||
for(unsigned i = 0; i < routeParameters.coordinates.size(); ++i) {
|
for(unsigned i = 0; i < routeParameters.coordinates.size(); ++i) {
|
||||||
if( !checkCoord(routeParameters.coordinates[i]) ) {
|
if( !checkCoord(routeParameters.coordinates[i]) ) {
|
||||||
@ -110,12 +110,13 @@ public:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(unsigned i = 0; i < phantomNodeVector.size()-1; ++i) {
|
|
||||||
PhantomNodes segmentPhantomNodes;
|
PhantomNodes segmentPhantomNodes;
|
||||||
|
for(unsigned i = 0; i < phantomNodeVector.size()-1; ++i) {
|
||||||
segmentPhantomNodes.startPhantom = phantomNodeVector[i];
|
segmentPhantomNodes.startPhantom = phantomNodeVector[i];
|
||||||
segmentPhantomNodes.targetPhantom = phantomNodeVector[i+1];
|
segmentPhantomNodes.targetPhantom = phantomNodeVector[i+1];
|
||||||
rawRoute.segmentEndCoordinates.push_back(segmentPhantomNodes);
|
rawRoute.segmentEndCoordinates.push_back(segmentPhantomNodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
( routeParameters.alternateRoute ) &&
|
( routeParameters.alternateRoute ) &&
|
||||||
(1 == rawRoute.segmentEndCoordinates.size())
|
(1 == rawRoute.segmentEndCoordinates.size())
|
||||||
@ -175,7 +176,7 @@ public:
|
|||||||
phantomNodes.targetPhantom = rawRoute.segmentEndCoordinates[rawRoute.segmentEndCoordinates.size()-1].targetPhantom;
|
phantomNodes.targetPhantom = rawRoute.segmentEndCoordinates[rawRoute.segmentEndCoordinates.size()-1].targetPhantom;
|
||||||
desc->SetConfig(descriptorConfig);
|
desc->SetConfig(descriptorConfig);
|
||||||
|
|
||||||
desc->Run(reply, rawRoute, phantomNodes, facade);
|
desc->Run(rawRoute, phantomNodes, facade, reply);
|
||||||
if("" != routeParameters.jsonpParameter) {
|
if("" != routeParameters.jsonpParameter) {
|
||||||
reply.content.push_back(")\n");
|
reply.content.push_back(")\n");
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,8 @@ public:
|
|||||||
|
|
||||||
void operator()(
|
void operator()(
|
||||||
const PhantomNodes & phantom_node_pair,
|
const PhantomNodes & phantom_node_pair,
|
||||||
RawRouteData & raw_route_data) {
|
RawRouteData & raw_route_data
|
||||||
|
) {
|
||||||
if( (!phantom_node_pair.AtLeastOnePhantomNodeIsUINTMAX()) ||
|
if( (!phantom_node_pair.AtLeastOnePhantomNodeIsUINTMAX()) ||
|
||||||
phantom_node_pair.PhantomNodesHaveEqualLocation()
|
phantom_node_pair.PhantomNodesHaveEqualLocation()
|
||||||
) {
|
) {
|
||||||
@ -255,16 +256,18 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Unpack shortest path and alternative, if they exist
|
//Unpack shortest path and alternative, if they exist
|
||||||
if(INT_MAX != upper_bound_to_shortest_path_distance) {
|
if(INT_MAX != upper_bound_to_shortest_path_distance) {
|
||||||
super::UnpackPath(packedShortestPath, raw_route_data.computedShortestPath);
|
raw_route_data.unpacked_path_segments.resize(1);
|
||||||
|
super::UnpackPath(packedShortestPath, raw_route_data.unpacked_path_segments[0]);
|
||||||
raw_route_data.lengthOfShortestPath = upper_bound_to_shortest_path_distance;
|
raw_route_data.lengthOfShortestPath = upper_bound_to_shortest_path_distance;
|
||||||
} else {
|
} else {
|
||||||
raw_route_data.lengthOfShortestPath = INT_MAX;
|
raw_route_data.lengthOfShortestPath = INT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selectedViaNode != UINT_MAX) {
|
if(selectedViaNode != UINT_MAX) {
|
||||||
retrievePackedViaPath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, s_v_middle, v_t_middle, raw_route_data.computedAlternativePath);
|
retrievePackedViaPath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, s_v_middle, v_t_middle, raw_route_data.unpacked_alternative);
|
||||||
raw_route_data.lengthOfAlternativePath = lengthOfViaPath;
|
raw_route_data.lengthOfAlternativePath = lengthOfViaPath;
|
||||||
} else {
|
} else {
|
||||||
raw_route_data.lengthOfAlternativePath = INT_MAX;
|
raw_route_data.lengthOfAlternativePath = INT_MAX;
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
~ShortestPathRouting() {}
|
~ShortestPathRouting() {}
|
||||||
|
|
||||||
void operator()(
|
void operator()(
|
||||||
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(
|
||||||
@ -66,13 +66,13 @@ public:
|
|||||||
}
|
}
|
||||||
int distance1 = 0;
|
int distance1 = 0;
|
||||||
int distance2 = 0;
|
int distance2 = 0;
|
||||||
|
|
||||||
bool search_from_1st_node = true;
|
bool search_from_1st_node = true;
|
||||||
bool search_from_2nd_node = true;
|
bool search_from_2nd_node = true;
|
||||||
NodeID middle1 = UINT_MAX;
|
NodeID middle1 = UINT_MAX;
|
||||||
NodeID middle2 = UINT_MAX;
|
NodeID middle2 = UINT_MAX;
|
||||||
std::vector<NodeID> packed_path1;
|
std::vector<std::vector<NodeID> > packed_legs1(phantom_nodes_vector.size());
|
||||||
std::vector<NodeID> packed_path2;
|
std::vector<std::vector<NodeID> > packed_legs2(phantom_nodes_vector.size());
|
||||||
|
// SimpleLogger().Write() << "resizing to " << phantom_nodes_vector.size() << " legs";
|
||||||
|
|
||||||
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
||||||
super::facade->GetNumberOfNodes()
|
super::facade->GetNumberOfNodes()
|
||||||
@ -89,10 +89,11 @@ public:
|
|||||||
QueryHeap & forward_heap2 = *(engine_working_data.forwardHeap2);
|
QueryHeap & forward_heap2 = *(engine_working_data.forwardHeap2);
|
||||||
QueryHeap & reverse_heap2 = *(engine_working_data.backwardHeap2);
|
QueryHeap & reverse_heap2 = *(engine_working_data.backwardHeap2);
|
||||||
|
|
||||||
|
int current_leg = 0;
|
||||||
|
int previous_leg = 0;
|
||||||
//Get distance to next pair of target nodes.
|
//Get distance to next pair of target nodes.
|
||||||
BOOST_FOREACH(
|
BOOST_FOREACH(
|
||||||
const PhantomNodes & phantom_node_pair,
|
const PhantomNodes & phantom_node_pair, phantom_nodes_vector
|
||||||
phantom_nodes_vector
|
|
||||||
){
|
){
|
||||||
forward_heap1.Clear(); forward_heap2.Clear();
|
forward_heap1.Clear(); forward_heap2.Clear();
|
||||||
reverse_heap1.Clear(); reverse_heap2.Clear();
|
reverse_heap1.Clear(); reverse_heap2.Clear();
|
||||||
@ -102,6 +103,11 @@ public:
|
|||||||
middle1 = UINT_MAX;
|
middle1 = UINT_MAX;
|
||||||
middle2 = UINT_MAX;
|
middle2 = UINT_MAX;
|
||||||
|
|
||||||
|
// SimpleLogger().Write() << "search_from_1st_node: " << (search_from_1st_node ? "y" : "n");
|
||||||
|
// SimpleLogger().Write() << "search_from_2nd_node: " << (search_from_2nd_node ? "y" : "n");
|
||||||
|
// SimpleLogger().Write() << "FW node1: " << phantom_node_pair.startPhantom.edgeBasedNode << ", node2: " << phantom_node_pair.startPhantom.edgeBasedNode+1;
|
||||||
|
// SimpleLogger().Write() << "RV node1: " << phantom_node_pair.targetPhantom.edgeBasedNode << ", node2: " << phantom_node_pair.targetPhantom.edgeBasedNode+1;
|
||||||
|
|
||||||
//insert new starting nodes into forward heap, adjusted by previous distances.
|
//insert new starting nodes into forward heap, adjusted by previous distances.
|
||||||
if(search_from_1st_node) {
|
if(search_from_1st_node) {
|
||||||
forward_heap1.Insert(
|
forward_heap1.Insert(
|
||||||
@ -109,13 +115,13 @@ public:
|
|||||||
distance1-phantom_node_pair.startPhantom.weight1,
|
distance1-phantom_node_pair.startPhantom.weight1,
|
||||||
phantom_node_pair.startPhantom.edgeBasedNode
|
phantom_node_pair.startPhantom.edgeBasedNode
|
||||||
);
|
);
|
||||||
// INFO("fw1: " << phantom_node_pair.startPhantom.edgeBasedNode << "´, w: " << -phantomNodePair.startPhantom.weight1);
|
// SimpleLogger().Write() << "fq1: " << phantom_node_pair.startPhantom.edgeBasedNode << "´, w: " << distance1-phantom_node_pair.startPhantom.weight1;
|
||||||
forward_heap2.Insert(
|
forward_heap2.Insert(
|
||||||
phantom_node_pair.startPhantom.edgeBasedNode,
|
phantom_node_pair.startPhantom.edgeBasedNode,
|
||||||
distance1-phantom_node_pair.startPhantom.weight1,
|
distance1-phantom_node_pair.startPhantom.weight1,
|
||||||
phantom_node_pair.startPhantom.edgeBasedNode
|
phantom_node_pair.startPhantom.edgeBasedNode
|
||||||
);
|
);
|
||||||
// INFO("fw2: " << phantom_node_pair.startPhantom.edgeBasedNode << "´, w: " << -phantomNodePair.startPhantom.weight1);
|
// SimpleLogger().Write() << "fq2: " << phantom_node_pair.startPhantom.edgeBasedNode << "´, w: " << distance1-phantom_node_pair.startPhantom.weight1;
|
||||||
}
|
}
|
||||||
if(phantom_node_pair.startPhantom.isBidirected() && search_from_2nd_node) {
|
if(phantom_node_pair.startPhantom.isBidirected() && search_from_2nd_node) {
|
||||||
forward_heap1.Insert(
|
forward_heap1.Insert(
|
||||||
@ -123,13 +129,13 @@ public:
|
|||||||
distance2-phantom_node_pair.startPhantom.weight2,
|
distance2-phantom_node_pair.startPhantom.weight2,
|
||||||
phantom_node_pair.startPhantom.edgeBasedNode+1
|
phantom_node_pair.startPhantom.edgeBasedNode+1
|
||||||
);
|
);
|
||||||
// INFO("fw1: " << phantom_node_pair.startPhantom.edgeBasedNode+1 << "´, w: " << -phantomNodePair.startPhantom.weight2);
|
// SimpleLogger().Write() << "fq1: " << phantom_node_pair.startPhantom.edgeBasedNode+1 << "´, w: " << distance2-phantom_node_pair.startPhantom.weight2;
|
||||||
forward_heap2.Insert(
|
forward_heap2.Insert(
|
||||||
phantom_node_pair.startPhantom.edgeBasedNode+1,
|
phantom_node_pair.startPhantom.edgeBasedNode+1,
|
||||||
distance2-phantom_node_pair.startPhantom.weight2,
|
distance2-phantom_node_pair.startPhantom.weight2,
|
||||||
phantom_node_pair.startPhantom.edgeBasedNode+1
|
phantom_node_pair.startPhantom.edgeBasedNode+1
|
||||||
);
|
);
|
||||||
// INFO("fw2: " << phantom_node_pair.startPhantom.edgeBasedNode+1 << "´, w: " << -phantomNodePair.startPhantom.weight2);
|
// SimpleLogger().Write() << "fq2: " << phantom_node_pair.startPhantom.edgeBasedNode+1 << "´, w: " << distance2-phantom_node_pair.startPhantom.weight2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//insert new backward nodes into backward heap, unadjusted.
|
//insert new backward nodes into backward heap, unadjusted.
|
||||||
@ -138,15 +144,16 @@ public:
|
|||||||
phantom_node_pair.targetPhantom.weight1,
|
phantom_node_pair.targetPhantom.weight1,
|
||||||
phantom_node_pair.targetPhantom.edgeBasedNode
|
phantom_node_pair.targetPhantom.edgeBasedNode
|
||||||
);
|
);
|
||||||
// INFO("rv1: " << phantom_node_pair.targetPhantom.edgeBasedNode << ", w;" << phantom_node_pair.targetPhantom.weight1 );
|
// SimpleLogger().Write() << "rq1: " << phantom_node_pair.targetPhantom.edgeBasedNode << ", w: " << phantom_node_pair.targetPhantom.weight1;
|
||||||
if(phantom_node_pair.targetPhantom.isBidirected() ) {
|
if(phantom_node_pair.targetPhantom.isBidirected() ) {
|
||||||
reverse_heap2.Insert(
|
reverse_heap2.Insert(
|
||||||
phantom_node_pair.targetPhantom.edgeBasedNode+1,
|
phantom_node_pair.targetPhantom.edgeBasedNode+1,
|
||||||
phantom_node_pair.targetPhantom.weight2,
|
phantom_node_pair.targetPhantom.weight2,
|
||||||
phantom_node_pair.targetPhantom.edgeBasedNode+1
|
phantom_node_pair.targetPhantom.edgeBasedNode+1
|
||||||
);
|
);
|
||||||
// INFO("rv2: " << phantom_node_pair.targetPhantom.edgeBasedNode+1 << ", w;" << phantom_node_pair.targetPhantom.weight2 );
|
// SimpleLogger().Write() << "rq2: " << phantom_node_pair.targetPhantom.edgeBasedNode+1 << ", w: " << phantom_node_pair.targetPhantom.weight2;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int forward_offset = super::ComputeEdgeOffset(
|
const int forward_offset = super::ComputeEdgeOffset(
|
||||||
phantom_node_pair.startPhantom
|
phantom_node_pair.startPhantom
|
||||||
);
|
);
|
||||||
@ -177,6 +184,7 @@ public:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !reverse_heap2.Empty() ) {
|
if( !reverse_heap2.Empty() ) {
|
||||||
while(0 < (forward_heap2.Size() + reverse_heap2.Size() )){
|
while(0 < (forward_heap2.Size() + reverse_heap2.Size() )){
|
||||||
if( !forward_heap2.Empty() ){
|
if( !forward_heap2.Empty() ){
|
||||||
@ -202,6 +210,9 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SimpleLogger().Write() << "lb1: " << local_upper_bound1 << ", middle1: " << middle1;
|
||||||
|
// SimpleLogger().Write() << "lb2: " << local_upper_bound2 << ", middle2: " << middle2;
|
||||||
|
//
|
||||||
//No path found for both target nodes?
|
//No path found for both target nodes?
|
||||||
if(
|
if(
|
||||||
(INT_MAX == local_upper_bound1) &&
|
(INT_MAX == local_upper_bound1) &&
|
||||||
@ -224,15 +235,21 @@ public:
|
|||||||
"no path found"
|
"no path found"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// SimpleLogger().Write() << "computed leg " << current_leg;
|
||||||
|
|
||||||
//Unpack paths if they exist
|
//Unpack paths if they exist
|
||||||
std::vector<NodeID> temporary_packed_path1;
|
std::vector<NodeID> temporary_packed_leg1;
|
||||||
std::vector<NodeID> temporary_packed_path2;
|
std::vector<NodeID> temporary_packed_leg2;
|
||||||
|
|
||||||
|
BOOST_ASSERT( current_leg < packed_legs1.size() );
|
||||||
|
BOOST_ASSERT( current_leg < packed_legs2.size() );
|
||||||
|
|
||||||
if(INT_MAX != local_upper_bound1) {
|
if(INT_MAX != local_upper_bound1) {
|
||||||
super::RetrievePackedPathFromHeap(
|
super::RetrievePackedPathFromHeap(
|
||||||
forward_heap1,
|
forward_heap1,
|
||||||
reverse_heap1,
|
reverse_heap1,
|
||||||
middle1,
|
middle1,
|
||||||
temporary_packed_path1
|
temporary_packed_leg1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,102 +258,165 @@ public:
|
|||||||
forward_heap2,
|
forward_heap2,
|
||||||
reverse_heap2,
|
reverse_heap2,
|
||||||
middle2,
|
middle2,
|
||||||
temporary_packed_path2
|
temporary_packed_leg2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if one of the paths was not found, replace it with the other one.
|
//if one of the paths was not found, replace it with the other one.
|
||||||
if( temporary_packed_path1.empty() ) {
|
if( temporary_packed_leg1.empty() ) {
|
||||||
temporary_packed_path1.insert(
|
temporary_packed_leg1.insert(
|
||||||
temporary_packed_path1.end(),
|
temporary_packed_leg1.end(),
|
||||||
temporary_packed_path2.begin(),
|
temporary_packed_leg2.begin(),
|
||||||
temporary_packed_path2.end()
|
temporary_packed_leg2.end()
|
||||||
);
|
);
|
||||||
local_upper_bound1 = local_upper_bound2;
|
local_upper_bound1 = local_upper_bound2;
|
||||||
}
|
}
|
||||||
if( temporary_packed_path2.empty() ) {
|
if( temporary_packed_leg2.empty() ) {
|
||||||
temporary_packed_path2.insert(
|
temporary_packed_leg2.insert(
|
||||||
temporary_packed_path2.end(),
|
temporary_packed_leg2.end(),
|
||||||
temporary_packed_path1.begin(),
|
temporary_packed_leg1.begin(),
|
||||||
temporary_packed_path1.end()
|
temporary_packed_leg1.end()
|
||||||
);
|
);
|
||||||
local_upper_bound2 = local_upper_bound1;
|
local_upper_bound2 = local_upper_bound1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SimpleLogger().Write() << "fetched packed paths";
|
||||||
|
|
||||||
BOOST_ASSERT_MSG(
|
BOOST_ASSERT_MSG(
|
||||||
!temporary_packed_path1.empty() ||
|
!temporary_packed_leg1.empty() ||
|
||||||
!temporary_packed_path2.empty(),
|
!temporary_packed_leg2.empty(),
|
||||||
"tempory packed paths empty"
|
"tempory packed paths empty"
|
||||||
);
|
);
|
||||||
|
|
||||||
//Plug paths together, s.t. end of packed path is begin of temporary packed path
|
// SimpleLogger().Write() << "path1 size: " << temporary_packed_leg1.size();
|
||||||
if( !packed_path1.empty() && !packed_path2.empty() ) {
|
// SimpleLogger().Write() << "path2 size: " << temporary_packed_leg2.size();
|
||||||
if(
|
|
||||||
temporary_packed_path1.front() ==
|
BOOST_ASSERT(
|
||||||
temporary_packed_path2.front()
|
(0 == current_leg) || !packed_legs1[current_leg-1].empty()
|
||||||
|
);
|
||||||
|
BOOST_ASSERT(
|
||||||
|
(0 == current_leg) || !packed_legs2[current_leg-1].empty()
|
||||||
|
);
|
||||||
|
|
||||||
|
if( 0 < current_leg ) {
|
||||||
|
const NodeID end_id_of_segment1 = packed_legs1[current_leg-1].back();
|
||||||
|
const NodeID end_id_of_segment2 = packed_legs2[current_leg-1].back();
|
||||||
|
BOOST_ASSERT( !temporary_packed_leg1.empty() );
|
||||||
|
const NodeID start_id_of_leg1 = temporary_packed_leg1.front();
|
||||||
|
const NodeID start_id_of_leg2 = temporary_packed_leg2.front();
|
||||||
|
if( ( end_id_of_segment1 != start_id_of_leg1 ) &&
|
||||||
|
( end_id_of_segment2 != start_id_of_leg2 )
|
||||||
) {
|
) {
|
||||||
//both new route segments start with the same node
|
// SimpleLogger().Write() << "swapping legs";
|
||||||
//thus, one of the packedPath must go.
|
std::swap(temporary_packed_leg1, temporary_packed_leg2);
|
||||||
BOOST_ASSERT_MSG(
|
std::swap(local_upper_bound1, local_upper_bound2);
|
||||||
(packed_path1.size() == packed_path2.size() ) ||
|
}
|
||||||
(packed_path1.back() != packed_path2.back() ),
|
}
|
||||||
"packed paths must be different"
|
|
||||||
);
|
|
||||||
|
|
||||||
if( packed_path1.back() == temporary_packed_path1.front()) {
|
|
||||||
packed_path2.clear();
|
|
||||||
packed_path2.insert(
|
|
||||||
packed_path2.end(),
|
|
||||||
packed_path1.begin(),
|
|
||||||
packed_path1.end()
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
packed_path1.clear();
|
|
||||||
packed_path1.insert(
|
|
||||||
packed_path1.end(),
|
|
||||||
packed_path2.begin(),
|
|
||||||
packed_path2.end()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//packed paths 1 and 2 may need to switch.
|
|
||||||
if( packed_path1.back() != temporary_packed_path1.front()) {
|
|
||||||
packed_path1.swap(packed_path2);
|
|
||||||
std::swap(distance1, distance2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
packed_path1.insert(
|
|
||||||
packed_path1.end(),
|
|
||||||
temporary_packed_path1.begin(),
|
|
||||||
temporary_packed_path1.end()
|
|
||||||
);
|
|
||||||
packed_path2.insert(
|
|
||||||
packed_path2.end(),
|
|
||||||
temporary_packed_path2.begin(),
|
|
||||||
temporary_packed_path2.end()
|
|
||||||
);
|
|
||||||
|
|
||||||
|
// remove one path if both legs end at the same segment
|
||||||
|
if( 0 < current_leg ) {
|
||||||
|
const NodeID start_id_of_leg1 = temporary_packed_leg1.front();
|
||||||
|
const NodeID start_id_of_leg2 = temporary_packed_leg2.front();
|
||||||
if(
|
if(
|
||||||
(packed_path1.back() == packed_path2.back()) &&
|
start_id_of_leg1 == start_id_of_leg2
|
||||||
|
) {
|
||||||
|
const NodeID last_id_of_packed_legs1 = packed_legs1[current_leg-1].back();
|
||||||
|
const NodeID last_id_of_packed_legs2 = packed_legs2[current_leg-1].back();
|
||||||
|
if( start_id_of_leg1 != last_id_of_packed_legs1 ) {
|
||||||
|
// BOOST_ASSERT(
|
||||||
|
// last_id_of_packed_legs1 == temporary_packed_leg2.front()
|
||||||
|
// );
|
||||||
|
packed_legs1 = packed_legs2;
|
||||||
|
// SimpleLogger().Write() << "throw away packed_legs1";
|
||||||
|
BOOST_ASSERT(
|
||||||
|
start_id_of_leg1 == temporary_packed_leg1.front()
|
||||||
|
);
|
||||||
|
} else
|
||||||
|
if( start_id_of_leg2 != last_id_of_packed_legs2 ) {
|
||||||
|
// BOOST_ASSERT(
|
||||||
|
// start_id_of_leg2 == temporary_packed_leg1.front()
|
||||||
|
// );
|
||||||
|
packed_legs2 = packed_legs1;
|
||||||
|
// SimpleLogger().Write() << "throw away packed_legs2";
|
||||||
|
BOOST_ASSERT(
|
||||||
|
start_id_of_leg2 == temporary_packed_leg2.front()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BOOST_ASSERT(
|
||||||
|
packed_legs1.size() == packed_legs2.size()
|
||||||
|
);
|
||||||
|
|
||||||
|
// SimpleLogger().Write() << "packed_legs1[" << current_leg << "].size: " << packed_legs1[current_leg].size();
|
||||||
|
packed_legs1[current_leg].insert(
|
||||||
|
packed_legs1[current_leg].end(),
|
||||||
|
temporary_packed_leg1.begin(),
|
||||||
|
temporary_packed_leg1.end()
|
||||||
|
);
|
||||||
|
// SimpleLogger().Write() << "packed_legs1[" << current_leg << "].size: " << packed_legs1[current_leg].size();
|
||||||
|
//
|
||||||
|
BOOST_ASSERT(packed_legs1[current_leg].size() == temporary_packed_leg1.size() );
|
||||||
|
//
|
||||||
|
// SimpleLogger().Write() << "packed_legs2[" << current_leg << "].size: " << packed_legs2[current_leg].size();
|
||||||
|
packed_legs2[current_leg].insert(
|
||||||
|
packed_legs2[current_leg].end(),
|
||||||
|
temporary_packed_leg2.begin(),
|
||||||
|
temporary_packed_leg2.end()
|
||||||
|
);
|
||||||
|
BOOST_ASSERT(packed_legs2[current_leg].size() == temporary_packed_leg2.size() );
|
||||||
|
|
||||||
|
// SimpleLogger().Write() << "packed_legs2[" << current_leg << "].size: " << packed_legs2[current_leg].size();
|
||||||
|
//
|
||||||
|
if(
|
||||||
|
(packed_legs1[current_leg].back() == packed_legs2[current_leg].back()) &&
|
||||||
phantom_node_pair.targetPhantom.isBidirected()
|
phantom_node_pair.targetPhantom.isBidirected()
|
||||||
) {
|
) {
|
||||||
const NodeID last_node_id = packed_path2.back();
|
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_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_2nd_node &= !(last_node_id == phantom_node_pair.targetPhantom.edgeBasedNode);
|
||||||
|
BOOST_ASSERT( search_from_1st_node != search_from_2nd_node );
|
||||||
}
|
}
|
||||||
|
|
||||||
distance1 = local_upper_bound1;
|
distance1 = local_upper_bound1;
|
||||||
distance2 = local_upper_bound2;
|
distance2 = local_upper_bound2;
|
||||||
|
previous_leg = current_leg;
|
||||||
|
// SimpleLogger().Write() << "packed leg 1: ";
|
||||||
|
// for(unsigned j = 0; j < packed_legs1[current_leg].size(); ++j) {
|
||||||
|
// std::cout << packed_legs1[current_leg][j] << " ";
|
||||||
|
// }
|
||||||
|
// std::cout << std::endl;
|
||||||
|
//
|
||||||
|
// SimpleLogger().Write() << "packed leg 2: ";
|
||||||
|
// for(unsigned j = 0; j < packed_legs2[current_leg].size(); ++j) {
|
||||||
|
// std::cout << packed_legs2[current_leg][j] << " ";
|
||||||
|
// }
|
||||||
|
// std::cout << std::endl;
|
||||||
|
++current_leg;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( distance1 > distance2 ) {
|
if( distance1 > distance2 ) {
|
||||||
std::swap( packed_path1, packed_path2 );
|
std::swap( packed_legs1, packed_legs2 );
|
||||||
|
// SimpleLogger().Write() << "dist1: " << distance1 << ", dist2: " << distance2;
|
||||||
|
}
|
||||||
|
raw_route_data.unpacked_path_segments.resize( packed_legs1.size() );
|
||||||
|
for(unsigned i = 0; i < packed_legs1.size(); ++i){
|
||||||
|
// SimpleLogger().Write() << "unpacked leg " << i << ", size: " << packed_legs1[i].size();
|
||||||
|
// for(unsigned j = 0; j < packed_legs1[i].size(); ++j) {
|
||||||
|
// std::cout << packed_legs1[i][j] << " ";
|
||||||
|
// }
|
||||||
|
// std::cout << std::endl;
|
||||||
|
|
||||||
|
BOOST_ASSERT(packed_legs1.size() == raw_route_data.unpacked_path_segments.size() );
|
||||||
|
super::UnpackPath(
|
||||||
|
packed_legs1[i],
|
||||||
|
raw_route_data.unpacked_path_segments[i]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
remove_consecutive_duplicates_from_vector(packed_path1);
|
|
||||||
super::UnpackPath(packed_path1, raw_route_data.computedShortestPath);
|
|
||||||
raw_route_data.lengthOfShortestPath = std::min(distance1, distance2);
|
raw_route_data.lengthOfShortestPath = std::min(distance1, distance2);
|
||||||
|
// SimpleLogger().Write() << "done";
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SHORTESTPATHROUTING_H_ */
|
#endif /* SHORTESTPATHROUTING_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user