cucumber test with specific lat/lon coordinates

This commit is contained in:
Emil Tin 2012-08-30 19:35:17 +02:00
parent d335e7d5e7
commit 1b581b1c17
3 changed files with 158 additions and 27 deletions

View File

@ -1,35 +1,65 @@
@bug @bug
Feature: Things that causes crashes or hangs Feature: Things that causes crashes or hangs
@nohang @nohang
Scenario: OK Scenario: OK
#this works as expected #this works as expected
Given the node map Given the node map
| a | | | a | |
| b | c | | b | c |
And the ways And the ways
| nodes | | nodes |
| ab | | ab |
| cb | | cb |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
| c | b | cb | | c | b | cb |
@hang @hang
Scenario: Routed hangs on simple ways Scenario: Routed hangs on simple ways
#this causes osrm-routed to hang (at least on mac 10.8) #this causes osrm-routed to hang (at least on mac 10.8)
#note that this is very similar to the example above, exept that the node map is mirrored #note that this is very similar to the example above, except that the node map is mirrored
Given the node map Given the node map
| | a | | | a |
| c | b | | c | b |
And the ways And the ways
| nodes | | nodes |
| ab | | ab |
| cb | | cb |
When I route I should get When I route I should get
| from | to | route | | from | to | route |
| c | b | cb | | c | b | cb |
@crash
Scenario: Quarter way around the equator
Given the node locations
| node | lat | lon |
| a | 0 | 0 |
| b | 0 | 90 |
And the ways
| nodes |
| ab |
When I route I should get
| from | to | route |
| a | b | ab |
@crash
Scenario: From the equator to the north pole
Given the node locations
| node | lat | lon |
| a | 0 | 0 |
| b | 90 | 0 |
And the ways
| nodes |
| ab |
When I route I should get
| from | to | route |
| a | b | ab |

View File

@ -0,0 +1,87 @@
@routing @planetary
Feature: Distance calculation
#reference distances have been calculated usign http://seismo.cqu.edu.au/CQSRG/VDistance/
Scenario: Longitudinal distances at equator
Given the node locations
| node | lat | lon |
| a | 0 | 80 |
| b | 0 | 0 |
And the ways
| nodes |
| ab |
When I route I should get
| from | to | route | distance |
| a | b | ab | 8905559 ~0.1% |
Scenario: Longitudinal distances at latitude 45
Given the node locations
| node | lat | lon |
| c | 45 | 80 |
| d | 45 | 0 |
And the ways
| nodes |
| cd |
When I route I should get
| from | to | route | distance |
| c | d | cd | 6028844 ~0.5% |
Scenario: Longitudinal distances at latitude 80
Given the node locations
| node | lat | lon |
| c | 80 | 80 |
| d | 80 | 0 |
And the ways
| nodes |
| cd |
When I route I should get
| from | to | route | distance |
| c | d | cd | 1431469 ~0.5% |
Scenario: Latitudinal distances at longitude 0
Given the node locations
| node | lat | lon |
| a | 80 | 0 |
| b | 0 | 0 |
And the ways
| nodes |
| ab |
When I route I should get
| from | to | route | distance |
| a | b | ab | 8905559 ~0.1% |
Scenario: Latitudinal distances at longitude 45
Given the node locations
| node | lat | lon |
| a | 80 | 45 |
| b | 0 | 45 |
And the ways
| nodes |
| ab |
When I route I should get
| from | to | route | distance |
| a | b | ab | 8905559 ~0.1% |
Scenario: Latitudinal distances at longitude 80
Given the node locations
| node | lat | lon |
| a | 80 | 80 |
| b | 0 | 80 |
And the ways
| nodes |
| ab |
When I route I should get
| from | to | route | distance |
| a | b | ab | 8905559 ~0.1% |

View File

@ -29,6 +29,20 @@ Given /^the node map$/ do |table|
end end
end end
Given /^the node locations$/ do |table|
table.hashes.each do |row|
name = row['node']
raise "*** node invalid name '#{name}', must be single characters" unless name.size == 1
raise "*** invalid node name '#{name}', must me alphanumeric" unless name.match /[a-z0-9]/
raise "*** duplicate node '#{name}'" if name_node_hash[name]
node = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, row['lon'].to_f, row['lat'].to_f
node << { :name => name }
node.uid = OSM_UID
osm_db << node
name_node_hash[name] = node
end
end
Given /^the nodes$/ do |table| Given /^the nodes$/ do |table|
table.hashes.each do |row| table.hashes.each do |row|
name = row.delete 'node' name = row.delete 'node'