profiles api v2
This commit is contained in:
committed by
Patrick Niklaus
parent
5ece65cade
commit
e413b25cd9
@@ -1,50 +1,10 @@
|
||||
api_version = 1
|
||||
-- Rasterbot profile
|
||||
-- Rasterbot with interpolation profile
|
||||
|
||||
-- Set to true if you need to call the node_function for every node.
|
||||
-- Generally can be left as false to avoid unnecessary Lua calls
|
||||
-- (which slow down pre-processing).
|
||||
properties.call_tagless_node_function = false
|
||||
functions = require('rasterbot')
|
||||
|
||||
-- Minimalist node_ and way_functions in order to test source_ and segment_functions
|
||||
|
||||
function node_function (node, result)
|
||||
end
|
||||
|
||||
function way_function (way, result)
|
||||
local highway = way:get_value_by_key("highway")
|
||||
local name = way:get_value_by_key("name")
|
||||
|
||||
if name then
|
||||
result.name = name
|
||||
end
|
||||
|
||||
result.forward_mode = mode.cycling
|
||||
result.backward_mode = mode.cycling
|
||||
|
||||
result.forward_speed = 15
|
||||
result.backward_speed = 15
|
||||
end
|
||||
|
||||
function source_function ()
|
||||
local path = os.getenv('OSRM_RASTER_SOURCE')
|
||||
if not path then
|
||||
path = "rastersource.asc"
|
||||
end
|
||||
raster_source = sources:load(
|
||||
path,
|
||||
0, -- lon_min
|
||||
0.1, -- lon_max
|
||||
0, -- lat_min
|
||||
0.1, -- lat_max
|
||||
5, -- nrows
|
||||
4 -- ncols
|
||||
)
|
||||
end
|
||||
|
||||
function segment_function (segment)
|
||||
local sourceData = sources:interpolate(raster_source, segment.source.lon, segment.source.lat)
|
||||
local targetData = sources:interpolate(raster_source, segment.target.lon, segment.target.lat)
|
||||
functions.process_segment = function(profile, segment)
|
||||
local sourceData = raster:interpolate(profile.raster_source, segment.source.lon, segment.source.lat)
|
||||
local targetData = raster:interpolate(profile.raster_source, segment.target.lon, segment.target.lat)
|
||||
io.write("evaluating segment: " .. sourceData.datum .. " " .. targetData.datum .. "\n")
|
||||
local invalid = sourceData.invalid_data()
|
||||
local scaled_weight = segment.weight
|
||||
@@ -64,3 +24,5 @@ function segment_function (segment)
|
||||
segment.weight = scaled_weight
|
||||
segment.duration = scaled_duration
|
||||
end
|
||||
|
||||
return functions
|
||||
Reference in New Issue
Block a user