test nearest/locate at high lat/lon, fix fuzzy match of negative numbers
This commit is contained in:
parent
a6c52fd154
commit
1d6e602473
@ -80,7 +80,7 @@ Feature: Locate - return nearest node
|
|||||||
| nodes |
|
| nodes |
|
||||||
| ab |
|
| ab |
|
||||||
|
|
||||||
When I request nearest I should get
|
When I request locate I should get
|
||||||
| in | out |
|
| in | out |
|
||||||
| 0 | a |
|
| 0 | a |
|
||||||
| 1 | a |
|
| 1 | a |
|
||||||
@ -105,7 +105,7 @@ Feature: Locate - return nearest node
|
|||||||
| nodes |
|
| nodes |
|
||||||
| ab |
|
| ab |
|
||||||
|
|
||||||
When I request nearest I should get
|
When I request locate I should get
|
||||||
| in | out |
|
| in | out |
|
||||||
| 0 | a |
|
| 0 | a |
|
||||||
| 1 | a |
|
| 1 | a |
|
||||||
@ -131,7 +131,7 @@ Feature: Locate - return nearest node
|
|||||||
| nodes |
|
| nodes |
|
||||||
| axyb |
|
| axyb |
|
||||||
|
|
||||||
When I request nearest I should get
|
When I request locate I should get
|
||||||
| in | out |
|
| in | out |
|
||||||
| 0 | x |
|
| 0 | x |
|
||||||
| 1 | a |
|
| 1 | a |
|
||||||
@ -177,3 +177,21 @@ Feature: Locate - return nearest node
|
|||||||
| b | b |
|
| b | b |
|
||||||
| x | x |
|
| x | x |
|
||||||
| y | y |
|
| y | y |
|
||||||
|
|
||||||
|
Scenario: Locate - High lat/lon
|
||||||
|
Given the node locations
|
||||||
|
| node | lat | lon |
|
||||||
|
| a | -85 | -180 |
|
||||||
|
| b | 0 | 0 |
|
||||||
|
| c | 85 | 180 |
|
||||||
|
| x | -84 | -180 |
|
||||||
|
| y | 84 | 180 |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes |
|
||||||
|
| abc |
|
||||||
|
|
||||||
|
When I request locate I should get
|
||||||
|
| in | out |
|
||||||
|
| x | a |
|
||||||
|
| y | c |
|
||||||
|
@ -54,3 +54,25 @@ Feature: Locating Nearest node on a Way - pick closest way
|
|||||||
| 2 | x |
|
| 2 | x |
|
||||||
| 3 | u |
|
| 3 | u |
|
||||||
| 4 | w |
|
| 4 | w |
|
||||||
|
|
||||||
|
Scenario: Nearest - High lat/lon
|
||||||
|
Given the node locations
|
||||||
|
| node | lat | lon |
|
||||||
|
| a | -85 | -180 |
|
||||||
|
| b | 0 | 0 |
|
||||||
|
| c | 85 | 180 |
|
||||||
|
| x | -70 | -100 |
|
||||||
|
| y | 70 | 100 |
|
||||||
|
| v | 1 | 1 |
|
||||||
|
| w | -1 | -1 |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes |
|
||||||
|
| abc |
|
||||||
|
|
||||||
|
When I request nearest I should get
|
||||||
|
| in | out |
|
||||||
|
| x | a |
|
||||||
|
| y | c |
|
||||||
|
| v | b |
|
||||||
|
| w | b |
|
||||||
|
@ -5,10 +5,14 @@ class FuzzyMatch
|
|||||||
if got == want
|
if got == want
|
||||||
return true
|
return true
|
||||||
elsif want.match /(.*)\s+~(.+)%$/ #percentage range: 100 ~5%
|
elsif want.match /(.*)\s+~(.+)%$/ #percentage range: 100 ~5%
|
||||||
margin = 1 - $2.to_f*0.01
|
target = $1.to_f
|
||||||
from = $1.to_f*margin
|
percentage = $2.to_f
|
||||||
to = $1.to_f/margin
|
if target==0
|
||||||
return got.to_f >= from && got.to_f <= to
|
return true
|
||||||
|
else
|
||||||
|
ratio = (1-(got.to_f / target)).abs;
|
||||||
|
return 100*ratio < percentage;
|
||||||
|
end
|
||||||
elsif want.match /(.*)\s+\+\-(.+)$/ #absolute range: 100 +-5
|
elsif want.match /(.*)\s+\+\-(.+)$/ #absolute range: 100 +-5
|
||||||
margin = $2.to_f
|
margin = $2.to_f
|
||||||
from = $1.to_f-margin
|
from = $1.to_f-margin
|
||||||
|
Loading…
Reference in New Issue
Block a user