Roundabouts generate only one instruction
This commit is contained in:
parent
fb1857f7cc
commit
b5d2e56faf
@ -37,6 +37,11 @@ private:
|
|||||||
DescriptionFactory descriptionFactory;
|
DescriptionFactory descriptionFactory;
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
_Coordinate current;
|
_Coordinate current;
|
||||||
|
struct {
|
||||||
|
int startIndex;
|
||||||
|
int nameID;
|
||||||
|
int leaveAtExit;
|
||||||
|
} roundAbout;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JSONDescriptor() {}
|
JSONDescriptor() {}
|
||||||
@ -97,39 +102,48 @@ public:
|
|||||||
//Example: ["Turn left","High Street",200,4,10,"200m","NE",22.5]
|
//Example: ["Turn left","High Street",200,4,10,"200m","NE",22.5]
|
||||||
//See also: http://developers.cloudmade.com/wiki/navengine/JSON_format
|
//See also: http://developers.cloudmade.com/wiki/navengine/JSON_format
|
||||||
unsigned prefixSumOfNecessarySegments = 0;
|
unsigned prefixSumOfNecessarySegments = 0;
|
||||||
unsigned leaveAtExit = 0;
|
roundAbout.leaveAtExit = 0;
|
||||||
|
roundAbout.nameID = 0;
|
||||||
std::string tmpDist, tmpLength, tmp;
|
std::string tmpDist, tmpLength, tmp;
|
||||||
//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(0 != prefixSumOfNecessarySegments)
|
if(TurnInstructions.EnterRoundAbout == segment.turnInstruction) {
|
||||||
|
roundAbout.nameID = segment.nameID;
|
||||||
|
roundAbout.startIndex = prefixSumOfNecessarySegments;
|
||||||
|
} else {
|
||||||
|
if(0 != prefixSumOfNecessarySegments)
|
||||||
|
reply.content += ",";
|
||||||
|
|
||||||
|
reply.content += "[\"";
|
||||||
|
INFO("Instruction: " << segment.turnInstruction);
|
||||||
|
if(TurnInstructions.LeaveRoundAbout == segment.turnInstruction) {
|
||||||
|
reply.content += TurnInstructions.TurnStrings[TurnInstructions.EnterRoundAbout];
|
||||||
|
reply.content += " and leave at ";
|
||||||
|
reply.content += TurnInstructions.Ordinals[roundAbout.leaveAtExit+1];
|
||||||
|
reply.content += " exit";
|
||||||
|
roundAbout.leaveAtExit = 0;
|
||||||
|
} else {
|
||||||
|
reply.content += TurnInstructions.TurnStrings[segment.turnInstruction];
|
||||||
|
}
|
||||||
|
reply.content += "\",\"";
|
||||||
|
reply.content += sEngine.GetEscapedNameForNameID(segment.nameID);
|
||||||
|
reply.content += "\",";
|
||||||
|
intToString(segment.length, tmpDist);
|
||||||
|
reply.content += tmpDist;
|
||||||
reply.content += ",";
|
reply.content += ",";
|
||||||
reply.content += "[\"";
|
intToString(prefixSumOfNecessarySegments, tmpLength);
|
||||||
INFO("Instruction: " << segment.turnInstruction);
|
reply.content += tmpLength;
|
||||||
reply.content += TurnInstructions.TurnStrings[segment.turnInstruction];
|
reply.content += ",";
|
||||||
if(TurnInstructions.LeaveRoundAbout == segment.turnInstruction) {
|
intToString(segment.duration, tmp);
|
||||||
reply.content += " at ";
|
reply.content += ",\"";
|
||||||
reply.content += TurnInstructions.Ordinals[leaveAtExit+1];
|
reply.content += tmpLength;
|
||||||
reply.content += " exit";
|
//TODO: fix heading
|
||||||
leaveAtExit = 0;
|
reply.content += "\",\"NE\",22.5";
|
||||||
|
reply.content += "]";
|
||||||
}
|
}
|
||||||
reply.content += "\",\"";
|
|
||||||
reply.content += sEngine.GetEscapedNameForNameID(segment.nameID);
|
|
||||||
reply.content += "\",";
|
|
||||||
intToString(segment.length, tmpDist);
|
|
||||||
reply.content += tmpDist;
|
|
||||||
reply.content += ",";
|
|
||||||
intToString(prefixSumOfNecessarySegments, tmpLength);
|
|
||||||
reply.content += tmpLength;
|
|
||||||
reply.content += ",";
|
|
||||||
intToString(segment.duration, tmp);
|
|
||||||
reply.content += ",\"";
|
|
||||||
reply.content += tmpLength;
|
|
||||||
//TODO: fix heading
|
|
||||||
reply.content += "\",\"NE\",22.5";
|
|
||||||
reply.content += "]";
|
|
||||||
} else if(TurnInstructions.StayOnRoundAbout == segment.turnInstruction) {
|
} else if(TurnInstructions.StayOnRoundAbout == segment.turnInstruction) {
|
||||||
++leaveAtExit;
|
++roundAbout.leaveAtExit;
|
||||||
}
|
}
|
||||||
if(segment.necessary)
|
if(segment.necessary)
|
||||||
++prefixSumOfNecessarySegments;
|
++prefixSumOfNecessarySegments;
|
||||||
|
Loading…
Reference in New Issue
Block a user