Fixes issue 63
This commit is contained in:
parent
f5226b2228
commit
b133beed5e
@ -35,7 +35,6 @@ private:
|
|||||||
_DescriptorConfig config;
|
_DescriptorConfig config;
|
||||||
_RouteSummary summary;
|
_RouteSummary summary;
|
||||||
DescriptionFactory descriptionFactory;
|
DescriptionFactory descriptionFactory;
|
||||||
std::string tmp;
|
|
||||||
_Coordinate current;
|
_Coordinate current;
|
||||||
struct {
|
struct {
|
||||||
int startIndex;
|
int startIndex;
|
||||||
@ -47,7 +46,7 @@ public:
|
|||||||
JSONDescriptor() {}
|
JSONDescriptor() {}
|
||||||
void SetConfig(const _DescriptorConfig & c) { config = c; }
|
void SetConfig(const _DescriptorConfig & c) { config = c; }
|
||||||
|
|
||||||
void Run(http::Reply & reply, RawRouteData &rawRoute, PhantomNodes &phantomNodes, SearchEngineT &sEngine, unsigned durationOfTrip) {
|
void Run(http::Reply & reply, RawRouteData &rawRoute, PhantomNodes &phantomNodes, SearchEngineT &sEngine, const unsigned durationOfTrip) {
|
||||||
WriteHeaderToOutput(reply.content);
|
WriteHeaderToOutput(reply.content);
|
||||||
if(durationOfTrip != INT_MAX && rawRoute.routeSegments.size() > 0) {
|
if(durationOfTrip != INT_MAX && rawRoute.routeSegments.size() > 0) {
|
||||||
summary.startName = sEngine.GetEscapedNameForNameID(phantomNodes.startPhantom.nodeBasedEdgeNameID);
|
summary.startName = sEngine.GetEscapedNameForNameID(phantomNodes.startPhantom.nodeBasedEdgeNameID);
|
||||||
@ -55,13 +54,11 @@ public:
|
|||||||
summary.destName = sEngine.GetEscapedNameForNameID(phantomNodes.targetPhantom.nodeBasedEdgeNameID);
|
summary.destName = sEngine.GetEscapedNameForNameID(phantomNodes.targetPhantom.nodeBasedEdgeNameID);
|
||||||
reply.content += "0,"
|
reply.content += "0,"
|
||||||
"\"status_message\": \"Found route between points\",";
|
"\"status_message\": \"Found route between points\",";
|
||||||
for(unsigned segmentIdx = 0; segmentIdx < rawRoute.routeSegments.size(); segmentIdx++) {
|
for(unsigned segmentIdx = 0; segmentIdx < rawRoute.routeSegments.size(); ++segmentIdx) {
|
||||||
const std::vector< _PathData > & path = rawRoute.routeSegments[segmentIdx];
|
BOOST_FOREACH(_PathData & pathData, rawRoute.routeSegments[segmentIdx]) {
|
||||||
BOOST_FOREACH(_PathData pathData, path) {
|
|
||||||
sEngine.GetCoordinatesForNodeID(pathData.node, current);
|
sEngine.GetCoordinatesForNodeID(pathData.node, current);
|
||||||
descriptionFactory.AppendSegment(current, pathData );
|
descriptionFactory.AppendSegment(current, pathData );
|
||||||
}
|
}
|
||||||
//TODO: Add via points
|
|
||||||
}
|
}
|
||||||
descriptionFactory.SetEndSegment(phantomNodes.targetPhantom);
|
descriptionFactory.SetEndSegment(phantomNodes.targetPhantom);
|
||||||
} else {
|
} else {
|
||||||
@ -104,9 +101,9 @@ public:
|
|||||||
unsigned prefixSumOfNecessarySegments = 0;
|
unsigned prefixSumOfNecessarySegments = 0;
|
||||||
roundAbout.leaveAtExit = 0;
|
roundAbout.leaveAtExit = 0;
|
||||||
roundAbout.nameID = 0;
|
roundAbout.nameID = 0;
|
||||||
std::string tmpDist, tmpLength, tmp;
|
std::string tmpDist, tmpLength, tmpDuration;
|
||||||
//Fetch data from Factory and generate a string from it.
|
//Fetch data from Factory and generate a string from it.
|
||||||
BOOST_FOREACH(SegmentInformation segment, descriptionFactory.pathDescription) {
|
BOOST_FOREACH(SegmentInformation & segment, descriptionFactory.pathDescription) {
|
||||||
if(TurnInstructions.TurnIsNecessary( segment.turnInstruction) ) {
|
if(TurnInstructions.TurnIsNecessary( segment.turnInstruction) ) {
|
||||||
if(TurnInstructions.EnterRoundAbout == segment.turnInstruction) {
|
if(TurnInstructions.EnterRoundAbout == segment.turnInstruction) {
|
||||||
roundAbout.nameID = segment.nameID;
|
roundAbout.nameID = segment.nameID;
|
||||||
@ -134,7 +131,8 @@ public:
|
|||||||
intToString(prefixSumOfNecessarySegments, tmpLength);
|
intToString(prefixSumOfNecessarySegments, tmpLength);
|
||||||
reply.content += tmpLength;
|
reply.content += tmpLength;
|
||||||
reply.content += ",";
|
reply.content += ",";
|
||||||
intToString(segment.duration, tmp);
|
intToString(segment.duration, tmpDuration);
|
||||||
|
reply.content += tmpDuration;
|
||||||
reply.content += ",\"";
|
reply.content += ",\"";
|
||||||
reply.content += tmpLength;
|
reply.content += tmpLength;
|
||||||
//TODO: fix heading
|
//TODO: fix heading
|
||||||
@ -151,7 +149,9 @@ public:
|
|||||||
reply.content += "],";
|
reply.content += "],";
|
||||||
//list all viapoints so that the client may display it
|
//list all viapoints so that the client may display it
|
||||||
reply.content += "\"via_points\":[";
|
reply.content += "\"via_points\":[";
|
||||||
for(unsigned segmentIdx = 1; (true == config.geometry) && (segmentIdx < rawRoute.segmentEndCoordinates.size()); segmentIdx++) {
|
if(true == config.geometry) {
|
||||||
|
std::string tmp;
|
||||||
|
for(unsigned segmentIdx = 1; segmentIdx < rawRoute.segmentEndCoordinates.size(); ++segmentIdx) {
|
||||||
if(segmentIdx > 1)
|
if(segmentIdx > 1)
|
||||||
reply.content += ",";
|
reply.content += ",";
|
||||||
reply.content += "[";
|
reply.content += "[";
|
||||||
@ -162,12 +162,13 @@ public:
|
|||||||
reply.content += tmp;
|
reply.content += tmp;
|
||||||
reply.content += "]";
|
reply.content += "]";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
reply.content += "],"
|
reply.content += "],"
|
||||||
"\"transactionId\": \"OSRM Routing Engine JSON Descriptor (v0.2)\"";
|
"\"transactionId\": \"OSRM Routing Engine JSON Descriptor (v0.3)\"";
|
||||||
reply.content += "}";
|
reply.content += "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteHeaderToOutput(std::string & output) {
|
inline void WriteHeaderToOutput(std::string & output) {
|
||||||
output += "{"
|
output += "{"
|
||||||
"\"version\": 0.3,"
|
"\"version\": 0.3,"
|
||||||
"\"status\":";
|
"\"status\":";
|
||||||
|
Loading…
Reference in New Issue
Block a user