Roundabouts generate only one instruction

This commit is contained in:
DennisOSRM 2011-11-24 11:14:59 +01:00
parent fb1857f7cc
commit b5d2e56faf

View File

@ -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,21 +102,29 @@ 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(TurnInstructions.EnterRoundAbout == segment.turnInstruction) {
roundAbout.nameID = segment.nameID;
roundAbout.startIndex = prefixSumOfNecessarySegments;
} else {
if(0 != prefixSumOfNecessarySegments) if(0 != prefixSumOfNecessarySegments)
reply.content += ","; reply.content += ",";
reply.content += "[\""; reply.content += "[\"";
INFO("Instruction: " << segment.turnInstruction); INFO("Instruction: " << segment.turnInstruction);
reply.content += TurnInstructions.TurnStrings[segment.turnInstruction];
if(TurnInstructions.LeaveRoundAbout == segment.turnInstruction) { if(TurnInstructions.LeaveRoundAbout == segment.turnInstruction) {
reply.content += " at "; reply.content += TurnInstructions.TurnStrings[TurnInstructions.EnterRoundAbout];
reply.content += TurnInstructions.Ordinals[leaveAtExit+1]; reply.content += " and leave at ";
reply.content += TurnInstructions.Ordinals[roundAbout.leaveAtExit+1];
reply.content += " exit"; reply.content += " exit";
leaveAtExit = 0; roundAbout.leaveAtExit = 0;
} else {
reply.content += TurnInstructions.TurnStrings[segment.turnInstruction];
} }
reply.content += "\",\""; reply.content += "\",\"";
reply.content += sEngine.GetEscapedNameForNameID(segment.nameID); reply.content += sEngine.GetEscapedNameForNameID(segment.nameID);
@ -128,8 +141,9 @@ public:
//TODO: fix heading //TODO: fix heading
reply.content += "\",\"NE\",22.5"; reply.content += "\",\"NE\",22.5";
reply.content += "]"; 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;