Entering and leaving roundabouts is getting handled.

This commit is contained in:
DennisOSRM
2011-11-22 16:47:15 +01:00
parent 8c0db16b13
commit 070050a48e
13 changed files with 160 additions and 129 deletions
-16
View File
@@ -34,22 +34,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "../Plugins/RawRouteData.h"
static double areaThresholds[19] = { 5000, 5000, 5000, 5000, 5000, 2500, 2000, 1500, 800, 400, 250, 150, 100, 75, 25, 20, 10, 5, 0 };
/* Get angle of line segment (A,C)->(C,B), atan2 magic, formerly cosine theorem*/
static double GetAngleBetweenTwoEdges(const _Coordinate& A, const _Coordinate& C, const _Coordinate& B) {
int v1x = A.lon - C.lon;
int v1y = A.lat - C.lat;
int v2x = B.lon - C.lon;
int v2y = B.lat - C.lat;
double angle = (atan2((double)v2y,v2x) - atan2((double)v1y,v1x) )*180/M_PI;
while(angle < 0)
angle += 360;
return angle;
}
struct _RouteSummary {
std::string lengthString;
std::string durationString;
+1 -1
View File
@@ -38,7 +38,7 @@ void DescriptionFactory::SetEndSegment(const PhantomNode & _targetPhantom) {
pathDescription.push_back(SegmentInformation(_targetPhantom.location, _targetPhantom.nodeBasedEdgeNameID, 0, _targetPhantom.weight1, 0, true) );
}
inline void DescriptionFactory::AppendSegment(const _Coordinate & coordinate, const _PathData & data ) {
void DescriptionFactory::AppendSegment(const _Coordinate & coordinate, const _PathData & data ) {
pathDescription.push_back(SegmentInformation(coordinate, data.nameID, 0, data.durationOfSegment, data.turnInstruction) );
}
+4 -84
View File
@@ -50,87 +50,10 @@ public:
void AppendEncodedPolylineString(std::string & output, bool isEncoded);
unsigned Run(const unsigned zoomLevel);
// static inline void getDirectionOfInstruction(double angle, DirectionOfInstruction & dirInst) {
// if(angle >= 23 && angle < 67) {
// dirInst.direction = "southeast";
// dirInst.shortDirection = "SE";
// return;
// }
// if(angle >= 67 && angle < 113) {
// dirInst.direction = "south";
// dirInst.shortDirection = "S";
// return;
// }
// if(angle >= 113 && angle < 158) {
// dirInst.direction = "southwest";
// dirInst.shortDirection = "SW";
// return;
// }
// if(angle >= 158 && angle < 202) {
// dirInst.direction = "west";
// dirInst.shortDirection = "W";
// return;
// }
// if(angle >= 202 && angle < 248) {
// dirInst.direction = "northwest";
// dirInst.shortDirection = "NW";
// return;
// }
// if(angle >= 248 && angle < 292) {
// dirInst.direction = "north";
// dirInst.shortDirection = "N";
// return;
// }
// if(angle >= 292 && angle < 336) {
// dirInst.direction = "northeast";
// dirInst.shortDirection = "NE";
// return;
// }
// dirInst.direction = "East";
// dirInst.shortDirection = "E";
// return;
// }
//
// static inline void getTurnDirectionOfInstruction(double angle, std::string & output) {
// if(angle >= 23 && angle < 67) {
// output = "Turn sharp right";
// // cout << "angle " << angle << "-> " << output << endl;
// return;
// }
// if (angle >= 67 && angle < 113) {
// output = "Turn right";
// // cout << "angle " << angle << "-> " << output << endl;
// return;
// }
// if (angle >= 113 && angle < 158) {
// output = "Bear right";
// // cout << "angle " << angle << "-> " << output << endl;
// return;
// }
//
// if (angle >= 158 && angle < 202) {
// output = "Continue";
// // cout << "angle " << angle << "-> " << output << endl;
// return;
// }
// if (angle >= 202 && angle < 248) {
// output = "Bear left";
// // cout << "angle " << angle << "-> " << output << endl;
// return;
// }
// if (angle >= 248 && angle < 292) {
// output = "Turn left";
// // cout << "angle " << angle << "-> " << output << endl;
// return;
// }
// if (angle >= 292 && angle < 336) {
// output = "Turn sharp left";
// // cout << "angle " << angle << "-> " << output << endl;
// return;
// }
// output = "U-Turn";
// // cout << "angle " << angle << "-> " << output << endl;
// }
};
#endif /* DESCRIPTIONFACTORY_H_ */
//private:
// void appendInstructionNameToString(const std::string & nameOfStreet, const std::string & instructionOrDirection, std::string &output, bool firstAdvice = false) {
// output += "[";
@@ -173,6 +96,3 @@ public:
// }
// output += "]";
// }
};
#endif /* DESCRIPTIONFACTORY_H_ */
+2 -1
View File
@@ -100,10 +100,11 @@ public:
std::string tmpDist, tmpLength, tmp;
//Fetch data from Factory and generate a string from it.
BOOST_FOREACH(SegmentInformation segment, descriptionFactory.pathDescription) {
if(0 != segment.turnInstruction) {
if(TurnInstructions.TurnIsNecessary( segment.turnInstruction) ) {
if(0 != prefixSumOfNecessarySegments)
reply.content += ",";
reply.content += "[\"";
INFO("INstruction: " << segment.turnInstruction);
reply.content += TurnInstructions.TurnStrings[segment.turnInstruction];
reply.content += "\",\"";
reply.content += sEngine.GetEscapedNameForNameID(segment.nameID);