Skip to content

Commit

Permalink
Fix postgis lua example
Browse files Browse the repository at this point in the history
Fixes #1573.
  • Loading branch information
TheMarex authored and chaupow committed Sep 1, 2015
1 parent 14e63eb commit 5e2ebf5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions profiles/examples/postgis.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function node_function(node)
end

-- ways processing, called from OSRM
function way_function (way)
function way_function (way, result)
-- only route on ways with highway=*
local highway = way.tags:Find("highway")
if (not highway or highway=='') then
Expand All @@ -65,18 +65,18 @@ function way_function (way)

local cursor = assert( sql_con:execute(sql_query) ) -- execute querty
local row = cursor:fetch( {}, "a" ) -- fetch first (and only) row
way.forward_speed = 20.0 -- default speed
result.forward_speed = 20.0 -- default speed
result.forward_mode = 1
if row then
local val = tonumber(row.val) -- read 'val' from row
local val = tonumber(row.val) -- read 'val' from row
if val > 10 then
way.forward_speed = way.forward_speed / math.log10( val ) -- reduce speed by amount of industry close by
-- reduce speed by amount of industry close by
result.forward_speed = way.forward_speed / math.log10( val )
end
end
cursor:close() -- done with this query

-- set other required info for this way
way.name = way.tags:Find("name")
way.direction = Way.bidirectional
way.type = 1
result.name = way.get_value_by_key("name")
return 1
end

0 comments on commit 5e2ebf5

Please sign in to comment.