Implement raster source feature to read data from third-party sources, to be used in lua profiles.

* Adds a data structure, RasterSource, to store parsed + queryable data
* Adds bindings for that and relevant data structures as well as source_function and segment_function
* Adds relevant unit tests and cucumber tests
* Bring-your-own-data feature
This commit is contained in:
Lauren Budorick
2015-05-29 17:28:29 -07:00
parent 6cbbd1e5a1
commit bac6703f8e
19 changed files with 744 additions and 12 deletions
+18
View File
@@ -0,0 +1,18 @@
@raster @extract
Feature: osrm-extract with a profile containing raster source
# expansions:
# {osm_base} => path to current input file
# {profile} => path to current profile script
Scenario: osrm-extract on a valid profile
Given the profile "rasterbot"
And the node map
| a | b |
And the ways
| nodes |
| ab |
And the data has been saved to disk
When I run "osrm-extract {osm_base}.osm -p {profile}"
Then stderr should be empty
And stdout should contain "source loader"
And it should exit with code 0
+78
View File
@@ -0,0 +1,78 @@
@routing @speed @raster
Feature: Raster - weights
Background: Use specific speeds
Given the node locations
| node | lat | lon |
| a | 0.1 | 0.1 |
| b | .05 | 0.1 |
| c | 0.0 | 0.1 |
| d | .05 | .03 |
| e | .05 | .066 |
| f | .075 | .066 |
And the ways
| nodes | highway |
| ab | primary |
| ad | primary |
| bc | primary |
| dc | primary |
| de | primary |
| eb | primary |
| df | primary |
| fb | primary |
And the raster source
"""
0 0 0 0
0 0 0 250
0 0 250 500
0 0 0 250
0 0 0 0
"""
Scenario: Weighting not based on raster sources
Given the profile "testbot"
When I run "osrm-extract {osm_base}.osm -p {profile}"
And I run "osrm-prepare {osm_base}.osm"
And I route I should get
| from | to | route | speed |
| a | b | ab | 36 km/h |
| a | c | ab,bc | 36 km/h |
| b | c | bc | 36 km/h |
| a | d | ad | 36 km/h |
| d | c | dc | 36 km/h |
Scenario: Weighting based on raster sources
Given the profile "rasterbot"
When I run "osrm-extract {osm_base}.osm -p {profile}"
Then stdout should contain "evaluating segment"
And I run "osrm-prepare {osm_base}.osm"
And I route I should get
| from | to | route | speed |
| a | b | ab | 8 km/h |
| a | c | ad,dc | 15 km/h |
| b | c | bc | 8 km/h |
| a | d | ad | 15 km/h |
| d | c | dc | 15 km/h |
| d | e | de | 10 km/h |
| e | b | eb | 10 km/h |
| d | f | df | 15 km/h |
| f | b | fb | 7 km/h |
| d | b | de,eb | 10 km/h |
Scenario: Weighting based on raster sources
Given the profile "rasterbot-interp"
When I run "osrm-extract {osm_base}.osm -p {profile}"
Then stdout should contain "evaluating segment"
And I run "osrm-prepare {osm_base}.osm"
And I route I should get
| from | to | route | speed |
| a | b | ab | 8 km/h |
| a | c | ad,dc | 15 km/h |
| b | c | bc | 8 km/h |
| a | d | ad | 15 km/h |
| d | c | dc | 15 km/h |
| d | e | de | 10 km/h |
| e | b | eb | 10 km/h |
| d | f | df | 15 km/h |
| f | b | fb | 7 km/h |
| d | b | de,eb | 10 km/h |
+6
View File
@@ -134,6 +134,12 @@ Given /^the input file ([^"]*)$/ do |file|
@osm_str = File.read file
end
Given /^the raster source$/ do |data|
Dir.chdir TEST_FOLDER do
File.open("rastersource.asc", "w") {|f| f.write(data)}
end
end
Given /^the data has been saved to disk$/ do
begin
write_input_data
+2 -1
View File
@@ -14,6 +14,7 @@ DEFAULT_SPEEDPROFILE = 'bicycle'
WAY_SPACING = 100
DEFAULT_GRID_SIZE = 100 #meters
PROFILES_PATH = File.join ROOT_FOLDER, 'profiles'
FIXTURES_PATH = File.join ROOT_FOLDER, 'unit_tests/fixtures'
BIN_PATH = File.join ROOT_FOLDER, 'build'
DEFAULT_INPUT_FORMAT = 'osm'
DEFAULT_ORIGIN = [1,1]
@@ -71,7 +72,7 @@ def verify_osrm_is_not_running
end
def verify_existance_of_binaries
["osrm-extract", "osrm-prepare", "osrm-routed"].each do |bin|
["osrm-extract", "osrm-prepare", "osrm-routed"].each do |bin|
unless File.exists? "#{BIN_PATH}/#{bin}#{EXE}"
raise "*** #{BIN_PATH}/#{bin}#{EXE} is missing. Build failed?"
end