parent
4c0203c108
commit
75561b8278
@ -58,7 +58,7 @@ public:
|
||||
//decision points have been previously marked
|
||||
do {
|
||||
assert(inputVector[leftBorderOfRange].necessary);
|
||||
assert(inputVector[inputVector.back()].necessary);
|
||||
assert(inputVector.back().necessary);
|
||||
|
||||
if(inputVector[rightBorderOfRange].necessary) {
|
||||
recursionStack.push(std::make_pair(leftBorderOfRange, rightBorderOfRange));
|
||||
@ -75,7 +75,7 @@ public:
|
||||
assert(inputVector[pair.second].necessary);
|
||||
assert(pair.second < sizeOfInputVector);
|
||||
assert(pair.first < pair.second);
|
||||
int maxDistance = -INT_MIN;
|
||||
int maxDistance = INT_MIN;
|
||||
std::size_t indexOfFarthestElement = pair.second;
|
||||
//find index idx of element with maxDistance
|
||||
for(std::size_t i = pair.first+1; i < pair.second; ++i){
|
||||
@ -102,24 +102,24 @@ public:
|
||||
* the other distance function. It is an approximation only, but works more or less ok.
|
||||
*/
|
||||
template<class CoordT>
|
||||
double fastDistance(const CoordT& point, const CoordT& segA, const CoordT& segB) {
|
||||
int p2x = (segB.lon - segA.lat);
|
||||
int p2y = (segB.lon - segA.lat);
|
||||
int something = p2x*p2x + p2y*p2y;
|
||||
int u = ((point.lon - segA.lon) * p2x + (point.lat - segA.lat) * p2y) / something;
|
||||
inline int fastDistance(const CoordT& point, const CoordT& segA, const CoordT& segB) const {
|
||||
const int p2x = (segB.lon - segA.lat);
|
||||
const int p2y = (segB.lon - segA.lat);
|
||||
const int something = p2x*p2x + p2y*p2y;
|
||||
int u = (something < FLT_EPSILON ? 0 : ((point.lon - segA.lon) * p2x + (point.lat - segA.lat) * p2y) / something);
|
||||
|
||||
if (u > 1)
|
||||
u = 1;
|
||||
else if (u < 0)
|
||||
u = 0;
|
||||
|
||||
int x = segA.lon + u * p2x;
|
||||
int y = segA.lat + u * p2y;
|
||||
const int x = segA.lon + u * p2x;
|
||||
const int y = segA.lat + u * p2y;
|
||||
|
||||
int dx = x - point.lon;
|
||||
int dy = y - point.lat;
|
||||
const int dx = x - point.lon;
|
||||
const int dy = y - point.lat;
|
||||
|
||||
int dist = (dx*dx + dy*dy);
|
||||
const int dist = (dx*dx + dy*dy);
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
@ -74,26 +74,42 @@ Feature: Basic Routing
|
||||
|
||||
Scenario: 2 unconnected parallel ways
|
||||
Given the node map
|
||||
| a | b |
|
||||
| c | d |
|
||||
| a | b | c |
|
||||
| d | e | f |
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| cd |
|
||||
| abc |
|
||||
| def |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route |
|
||||
| a | b | ab |
|
||||
| b | a | ab |
|
||||
| c | d | cd |
|
||||
| d | c | cd |
|
||||
| a | c | |
|
||||
| c | a | |
|
||||
| b | d | |
|
||||
| d | b | |
|
||||
| a | b | abc |
|
||||
| b | a | abc |
|
||||
| b | c | abc |
|
||||
| c | b | abc |
|
||||
| d | e | def |
|
||||
| e | d | def |
|
||||
| e | f | def |
|
||||
| f | e | def |
|
||||
| a | d | |
|
||||
| d | a | |
|
||||
| b | d | |
|
||||
| d | b | |
|
||||
| c | d | |
|
||||
| d | c | |
|
||||
| a | e | |
|
||||
| e | a | |
|
||||
| b | e | |
|
||||
| e | b | |
|
||||
| c | e | |
|
||||
| e | c | |
|
||||
| a | f | |
|
||||
| f | a | |
|
||||
| b | f | |
|
||||
| f | b | |
|
||||
| c | f | |
|
||||
| f | c | |
|
||||
|
||||
Scenario: 3 ways connected in a triangle
|
||||
Given the node map
|
||||
@ -253,4 +269,4 @@ Feature: Basic Routing
|
||||
| f | e | fg,gh,ha,ab,bc,cd,de |
|
||||
| g | f | gh,ha,ab,bc,cd,de,ef |
|
||||
| h | g | ha,ab,bc,cd,de,ef,fg |
|
||||
| a | h | ab,bc,cd,de,ef,fg,gh |
|
||||
| a | h | ab,bc,cd,de,ef,fg,gh |
|
||||
|
Loading…
Reference in New Issue
Block a user