Add bearing filter support to viaroute, trip, nearest, and distance

table plugins.
Make bearing range configurable by adding a comma-separated second part
to the bearing paramenter, like so:

    b=<bearing:0-359>(,<range:0-180>)

If no range is supplied, it defaults to +/- 10 degrees.
This commit is contained in:
Daniel Patterson
2015-11-10 18:54:11 -05:00
parent 16b6c26d6e
commit 1536d1c044
11 changed files with 326 additions and 282 deletions
+12 -12
View File
@@ -8,6 +8,17 @@ When /^I match I should get$/ do |table|
response = request_url row['request']
else
params = @query_params
got = {}
row.each_pair do |k,v|
if k =~ /param:(.*)/
if v=='(nil)'
params[$1]=nil
elsif v!=nil
params[$1]=v
end
got[k]=v
end
end
trace = []
timestamps = []
if row['trace']
@@ -19,24 +30,13 @@ When /^I match I should get$/ do |table|
if row['timestamps']
timestamps = row['timestamps'].split(" ").compact.map { |t| t.to_i}
end
got = {'trace' => row['trace'] }
got = got.merge({'trace' => row['trace'] })
response = request_matching trace, timestamps, params
else
raise "*** no trace"
end
end
row.each_pair do |k,v|
if k =~ /param:(.*)/
if v=='(nil)'
params[$1]=nil
elsif v!=nil
params[$1]=v
end
got[k]=v
end
end
if response.body.empty? == false
json = JSON.parse response.body
end
+13 -13
View File
@@ -8,6 +8,17 @@ When /^I route I should get$/ do |table|
response = request_url row['request']
else
params = @query_params
got = {}
row.each_pair do |k,v|
if k =~ /param:(.*)/
if v=='(nil)'
params[$1]=nil
elsif v!=nil
params[$1]=v
end
got[k]=v
end
end
waypoints = []
if row['from'] and row['to']
node = find_node_by_name(row['from'])
@@ -18,7 +29,7 @@ When /^I route I should get$/ do |table|
raise "*** unknown to-node '#{row['to']}" unless node
waypoints << node
got = {'from' => row['from'], 'to' => row['to'] }
got = got.merge({'from' => row['from'], 'to' => row['to'] })
response = request_route waypoints, params
elsif row['waypoints']
row['waypoints'].split(',').each do |n|
@@ -26,24 +37,13 @@ When /^I route I should get$/ do |table|
raise "*** unknown waypoint node '#{n.strip}" unless node
waypoints << node
end
got = {'waypoints' => row['waypoints'] }
got = got.merge({'waypoints' => row['waypoints'] })
response = request_route waypoints, params
else
raise "*** no waypoints"
end
end
row.each_pair do |k,v|
if k =~ /param:(.*)/
if v=='(nil)'
params[$1]=nil
elsif v!=nil
params[$1]=v
end
got[k]=v
end
end
if response.body.empty? == false
json = JSON.parse response.body
end