BREAKING CHANGE, REPROCESS YOUR OSM FILES
All preparations necessary to compute and output turn directions.
This commit is contained in:
@@ -26,6 +26,8 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
#include <string>
|
||||
#include <libxml/xmlreader.h>
|
||||
|
||||
#include "Util.h"
|
||||
|
||||
/* Default Speed Profile:
|
||||
motorway 110
|
||||
motorway_link 90
|
||||
@@ -113,13 +115,13 @@ struct Settings {
|
||||
vector< double > speed;
|
||||
vector< string > names;
|
||||
} speedProfile;
|
||||
vector<string> accessList;
|
||||
// vector<string> accessList;
|
||||
int trafficLightPenalty;
|
||||
int indexInAccessListOf( const string & key)
|
||||
{
|
||||
for(int i = 0; i< accessList.size(); i++)
|
||||
for(int i = 0; i< speedProfile.names.size(); i++)
|
||||
{
|
||||
if(accessList[i] == key)
|
||||
if(speedProfile.names[i] == key)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
@@ -468,6 +470,30 @@ double ApproximateDistance( const int lat1, const int lon1, const int lat2, cons
|
||||
return EARTH_RADIUS_IN_METERS * distanceArc;
|
||||
}
|
||||
|
||||
/* Get angle of line segment (A,C)->(C,B), atan2 magic, formerly cosine theorem*/
|
||||
double GetAngleBetweenTwoEdges(const _Coordinate& A, const _Coordinate& C, const _Coordinate& B)
|
||||
{
|
||||
// double a = ApproximateDistance(A.lat, A.lon, C.lat, C.lon); //first edge segment
|
||||
// double b = ApproximateDistance(B.lat, B.lon, C.lat, C.lon); //second edge segment
|
||||
// double c = ApproximateDistance(A.lat, A.lon, B.lat, B.lon); //third edgefrom triangle
|
||||
//
|
||||
// double cosAlpha = (a*a + b*b - c*c)/ (2*a*b);
|
||||
//
|
||||
// double alpha = ( (acos(cosAlpha) * 180.0 / M_PI) * (cosAlpha > 0 ? -1 : 1) ) + 180;
|
||||
// return alpha;
|
||||
// V = <x2 - x1, y2 - y1>
|
||||
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(v2y,v2x) - atan2(v1y,v1x) )*180/M_PI;
|
||||
while(angle < 0)
|
||||
angle += 360;
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
string GetRandomString() {
|
||||
char s[128];
|
||||
static const char alphanum[] =
|
||||
|
||||
@@ -44,27 +44,26 @@ public:
|
||||
/** Default constructor. target and weight are set to 0.*/
|
||||
Edge() { assert(false); } //shall not be used.
|
||||
|
||||
explicit Edge(NodeID s, NodeID t, NodeID n, EdgeWeight w, bool f, bool b, bool l) : _source(s), _target(t), _name(n), _weight(w), forward(f), backward(b), locatable(l) { }
|
||||
explicit Edge(NodeID s, NodeID t, NodeID n, EdgeWeight w, bool f, bool b, short ty) : _source(s), _target(t), _name(n), _weight(w), forward(f), backward(b), _type(ty) { assert(ty >= 0); }
|
||||
|
||||
NodeID target() const {return _target; }
|
||||
NodeID source() const {return _source; }
|
||||
NodeID name() const { return _name; }
|
||||
EdgeWeight weight() const {return _weight; }
|
||||
|
||||
short type() const { assert(_type >= 0); return _type; }
|
||||
bool isBackward() const { return backward; }
|
||||
|
||||
bool isForward() const { return forward; }
|
||||
|
||||
bool isLocatable() const { return locatable; }
|
||||
bool isLocatable() const { return _type != 14; }
|
||||
|
||||
private:
|
||||
NodeID _source;
|
||||
NodeID _target;
|
||||
NodeID _name;
|
||||
EdgeWeight _weight:29;
|
||||
NodeID _name:31;
|
||||
EdgeWeight _weight:31;
|
||||
bool forward:1;
|
||||
bool backward:1;
|
||||
bool locatable:1;
|
||||
short _type;
|
||||
};
|
||||
|
||||
typedef Edge ImportEdge;
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
|
||||
NodeID getNumberOfNodes() const { return numberOfNodes; }
|
||||
|
||||
inline void findNearestNodeIDForLatLon(const _Coordinate coord, _Coordinate& result) { result = g->FindNearestPointOnEdge(coord); }
|
||||
inline void findNearestNodeCoordForLatLon(const _Coordinate coord, _Coordinate& result) { result = g->FindNearestPointOnEdge(coord); }
|
||||
|
||||
inline bool FindRoutingStarts(const _Coordinate start, const _Coordinate target, PhantomNodes * phantomNodes) {
|
||||
g->FindRoutingStarts(start, target, phantomNodes);
|
||||
|
||||
@@ -22,6 +22,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
||||
#define TIMEUTIL_H_
|
||||
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <sys/time.h>
|
||||
|
||||
@@ -33,4 +34,7 @@ inline double get_timestamp()
|
||||
return double(tp.tv_sec) + tp.tv_usec / 1000000.;
|
||||
}
|
||||
|
||||
double y2lat(double a) { return 180/M_PI * (2 * atan(exp(a*M_PI/180)) - M_PI/2); }
|
||||
double lat2y(double a) { return 180/M_PI * log(tan(M_PI/4+a*(M_PI/180)/2)); }
|
||||
|
||||
#endif /* TIMEUTIL_H_ */
|
||||
|
||||
Reference in New Issue
Block a user