Skip to content

Commit

Permalink
change haversine computation to cheap ruler in distance tables
Browse files Browse the repository at this point in the history
  • Loading branch information
chaupow committed Apr 25, 2018
1 parent 5bf05f9 commit 6b69ab6
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 115 deletions.
8 changes: 7 additions & 1 deletion features/support/data_classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ module.exports = {
matchRe = want.match(/^\/(.*)\/$/),
// we use this for matching before/after bearing
matchBearingListAbs = want.match(/^((\d+)->(\d+))(,(\d+)->(\d+))*\s+\+\-(.+)$/),
matchIntersectionListAbs = want.match(/^(((((true|false):\d+)\s{0,1})+,{0,1})+;{0,1})+\s+\+\-(.+)$/);
matchIntersectionListAbs = want.match(/^(((((true|false):\d+)\s{0,1})+,{0,1})+;{0,1})+\s+\+\-(.+)$/),
matchRangeNumbers = want.match(/\d+\+\-\d+/);

function inRange(margin, got, want) {
var fromR = parseFloat(want) - margin,
Expand Down Expand Up @@ -105,6 +106,11 @@ module.exports = {
return inRange(margin, got, matchAbs[1]);
} else if (matchRe) { // regex: /a,b,.*/
return got.match(matchRe[1]);
} else if (matchRangeNumbers) {
let real_want_and_margin = want.split('+-'),
margin = parseFloat(real_want_and_margin[1].trim()),
real_want = parseFloat(real_want_and_margin[0].trim());
return inRange(margin, got, real_want);
} else {
return false;
}
Expand Down
19 changes: 19 additions & 0 deletions features/testbot/distance.feature
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,22 @@ Feature: Distance calculation
| x | v | xv,xv | 424m +-1 |
| x | w | xw,xw | 360m +-1 |
| x | y | xy,xy | 316m +-1 |


# Check rounding errors
Scenario: Distances Long distances
Given a grid size of 1000 meters
Given the node map
"""
a b c d
"""

And the ways
| nodes |
| abcd |

When I route I should get
| from | to | distance |
| a | b | 1000m +-3 |
| a | c | 2000m +-3 |
| a | d | 3000m +-3 |
Loading

0 comments on commit 6b69ab6

Please sign in to comment.