allow setting origin in cuke tests
This commit is contained in:
parent
caa02bbca1
commit
3cf72e93e6
@ -6,6 +6,10 @@ Given /^a grid size of (\d+) meters$/ do |meters|
|
||||
set_grid_size meters
|
||||
end
|
||||
|
||||
Given /^the origin lat\/lon (\d+),(\d+)$/ do |lat,lon|
|
||||
set_origin [lon.to_f,lat.to_f]
|
||||
end
|
||||
|
||||
Given /^the shortcuts$/ do |table|
|
||||
table.hashes.each do |row|
|
||||
shortcuts_hash[ row['key'] ] = row['value']
|
||||
|
@ -12,12 +12,12 @@ Then /^routability should be$/ do |table|
|
||||
['forw','backw','bothw'].each do |direction|
|
||||
if table.headers.include? direction
|
||||
if direction == 'forw' || direction == 'bothw'
|
||||
a = Location.new ORIGIN[0]+(1+WAY_SPACING*i)*@zoom, ORIGIN[1]
|
||||
b = Location.new ORIGIN[0]+(3+WAY_SPACING*i)*@zoom, ORIGIN[1]
|
||||
a = Location.new @origin[0]+(1+WAY_SPACING*i)*@zoom, @origin[1]
|
||||
b = Location.new @origin[0]+(3+WAY_SPACING*i)*@zoom, @origin[1]
|
||||
response = request_route [a,b]
|
||||
elsif direction == 'backw' || direction == 'bothw'
|
||||
a = Location.new ORIGIN[0]+(3+WAY_SPACING*i)*@zoom, ORIGIN[1]
|
||||
b = Location.new ORIGIN[0]+(1+WAY_SPACING*i)*@zoom, ORIGIN[1]
|
||||
a = Location.new @origin[0]+(3+WAY_SPACING*i)*@zoom, @origin[1]
|
||||
b = Location.new @origin[0]+(1+WAY_SPACING*i)*@zoom, @origin[1]
|
||||
response = request_route [a,b]
|
||||
end
|
||||
want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts
|
||||
|
@ -16,7 +16,7 @@ DEFAULT_GRID_SIZE = 100 #meters
|
||||
PROFILES_PATH = '../profiles'
|
||||
BIN_PATH = '../build'
|
||||
|
||||
ORIGIN = [1,1]
|
||||
DEFAULT_ORIGIN = [1,1]
|
||||
|
||||
class Location
|
||||
attr_accessor :lon,:lat
|
||||
@ -38,6 +38,10 @@ def set_grid_size meters
|
||||
@zoom = meters.to_f*0.8990679362704610899694577444566908445396483347536032203503E-5
|
||||
end
|
||||
|
||||
def set_origin origin
|
||||
@origin = origin
|
||||
end
|
||||
|
||||
def build_ways_from_table table
|
||||
#add one unconnected way for each row
|
||||
table.hashes.each_with_index do |row,ri|
|
||||
@ -49,11 +53,11 @@ def build_ways_from_table table
|
||||
#instead we place all lines as a string on the same y coordinate. this prevents using neightboring ways.
|
||||
|
||||
#a few nodes...
|
||||
node1 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(0+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node2 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(1+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node3 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(2+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node4 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(3+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node5 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+(4+WAY_SPACING*ri)*@zoom, ORIGIN[1]
|
||||
node1 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, @origin[0]+(0+WAY_SPACING*ri)*@zoom, @origin[1]
|
||||
node2 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, @origin[0]+(1+WAY_SPACING*ri)*@zoom, @origin[1]
|
||||
node3 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, @origin[0]+(2+WAY_SPACING*ri)*@zoom, @origin[1]
|
||||
node4 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, @origin[0]+(3+WAY_SPACING*ri)*@zoom, @origin[1]
|
||||
node5 = OSM::Node.new make_osm_id, OSM_USER, OSM_TIMESTAMP, @origin[0]+(4+WAY_SPACING*ri)*@zoom, @origin[1]
|
||||
node1.uid = OSM_UID
|
||||
node2.uid = OSM_UID
|
||||
node3.uid = OSM_UID
|
||||
@ -121,7 +125,7 @@ def build_ways_from_table table
|
||||
end
|
||||
|
||||
def table_coord_to_lonlat ci,ri
|
||||
[ORIGIN[0]+ci*@zoom, ORIGIN[1]-ri*@zoom]
|
||||
[@origin[0]+ci*@zoom, @origin[1]-ri*@zoom]
|
||||
end
|
||||
|
||||
def add_osm_node name,lon,lat
|
||||
|
@ -8,6 +8,7 @@ Before do |scenario|
|
||||
@has_logged_preprocess_info = false
|
||||
@has_logged_scenario_info = false
|
||||
set_grid_size DEFAULT_GRID_SIZE
|
||||
set_origin DEFAULT_ORIGIN
|
||||
end
|
||||
|
||||
Around('@stress') do |scenario, block|
|
||||
|
Loading…
Reference in New Issue
Block a user