Permalink
Browse files

Compute turn angles in mercartor projection. Implements issues #596,

  • Loading branch information...
1 parent bec4e44 commit 2cc2c967d19e5f85defc85b2a12b6eab47fc8c0c DennisOSRM committed Feb 28, 2013
Showing with 17 additions and 9 deletions.
  1. +5 −5 Contractor/EdgeBasedGraphFactory.cpp
  2. +1 −0 Contractor/EdgeBasedGraphFactory.h
  3. +11 −4 features/testbot/turns.feature
@@ -397,12 +397,12 @@ unsigned EdgeBasedGraphFactory::GetNumberOfNodes() const {
/* Get angle of line segment (A,C)->(C,B), atan2 magic, formerly cosine theorem*/
template<class CoordinateT>
double EdgeBasedGraphFactory::GetAngleBetweenTwoEdges(const CoordinateT& A, const CoordinateT& C, const CoordinateT& B) const {
- const int v1x = A.lon - C.lon;
- const int v1y = A.lat - C.lat;
- const int v2x = B.lon - C.lon;
- const int v2y = B.lat - C.lat;
+ const double v1x = (A.lon - C.lon)/100000.;
+ const double v1y = lat2y(A.lat/100000.) - lat2y(C.lat/100000.);
+ const double v2x = (B.lon - C.lon)/100000.;
+ const double v2y = lat2y(B.lat/100000.) - lat2y(C.lat/100000.);
- double angle = (atan2((double)v2y,v2x) - atan2((double)v1y,v1x) )*180/M_PI;
+ double angle = (atan2(v2y,v2x) - atan2(v1y,v1x) )*180/M_PI;
while(angle < 0)
angle += 360;
return angle;
@@ -45,6 +45,7 @@
#include "../Extractor/ExtractorStructs.h"
#include "../DataStructures/HashTable.h"
#include "../DataStructures/ImportEdge.h"
+#include "../DataStructures/MercatorUtil.h"
#include "../DataStructures/QueryEdge.h"
#include "../DataStructures/Percent.h"
#include "../DataStructures/TurnInstructions.h"
@@ -97,20 +97,27 @@ Feature: Turn directions/codes
| g | c | xg,xc | head,right,destination |
| g | e | xg,xe | head,sharp_right,destination |
- @todo
- Scenario: Skadestuevej, København
+ Scenario: Turn instructions at high latitude
https://github.com/DennisOSRM/Project-OSRM/issues/532
Given the node locations
| node | lat | lon |
| a | 55.68740 | 12.52430 |
| b | 55.68745 | 12.52409 |
| c | 55.68711 | 12.52383 |
+ | x | -55.68740 | 12.52430 |
+ | y | -55.68745 | 12.52409 |
+ | z | -55.68711 | 12.52383 |
And the ways
| nodes |
| ab |
| bc |
+ | xy |
+ | yz |
When I route I should get
- | from | to | route | turns |
- | a | c | ab,bc | head,left,destination |
+ | from | to | route | turns |
+ | a | c | ab,bc | head,left,destination |
+ | c | a | bc,ab | head,right,destination |
+ | x | z | xy,yz | head,right,destination |
+ | z | x | yz,xy | head,left,destination |

0 comments on commit 2cc2c96

Please sign in to comment.