From 88890a19140f76fda7e8a25f2baef9a8fb8589a5 Mon Sep 17 00:00:00 2001 From: DennisOSRM Date: Thu, 8 Mar 2012 11:37:41 +0100 Subject: [PATCH] Upper bound for ordinals. Unlikely that any roundabout has more than 10 exits, but again, OSM has unlimited opportunities. --- DataStructures/TurnInstructions.h | 5 +++-- Descriptors/JSONDescriptor.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DataStructures/TurnInstructions.h b/DataStructures/TurnInstructions.h index 76f5244f2..9b1c252e5 100644 --- a/DataStructures/TurnInstructions.h +++ b/DataStructures/TurnInstructions.h @@ -43,7 +43,7 @@ struct TurnInstructionsClass { const static short StartAtEndOfStreet = 14; std::string TurnStrings[15]; - std::string Ordinals[11]; + std::string Ordinals[12]; //This is a hack until c++0x is available enough to use initializer lists. TurnInstructionsClass(){ @@ -73,7 +73,8 @@ struct TurnInstructionsClass { Ordinals[7] = "seventh"; Ordinals[8] = "eighth"; Ordinals[9] = "nineth"; - Ordinals[10] = "tenth"; + Ordinals[10] = "tenth"; + Ordinals[11] = "one of the too many"; }; static inline double GetTurnDirectionOfInstruction( const double angle ) { diff --git a/Descriptors/JSONDescriptor.h b/Descriptors/JSONDescriptor.h index c1dc46b9f..54f6a0c96 100644 --- a/Descriptors/JSONDescriptor.h +++ b/Descriptors/JSONDescriptor.h @@ -114,7 +114,7 @@ public: 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 += TurnInstructions.Ordinals[std::min(11,roundAbout.leaveAtExit+1)]; reply.content += " exit"; roundAbout.leaveAtExit = 0; } else {