fix some indentation and spelling
This commit is contained in:
parent
aa0927911d
commit
67c5e3966a
2
Rakefile
2
Rakefile
@ -6,7 +6,7 @@ require 'sys/proctable'
|
|||||||
|
|
||||||
BUILD_FOLDER = 'build'
|
BUILD_FOLDER = 'build'
|
||||||
DATA_FOLDER = 'sandbox'
|
DATA_FOLDER = 'sandbox'
|
||||||
PROFILE = 'bicycle'
|
PROFILE = 'examples/postgis'
|
||||||
OSRM_PORT = 5000
|
OSRM_PORT = 5000
|
||||||
PROFILES_FOLDER = '../profiles'
|
PROFILES_FOLDER = '../profiles'
|
||||||
|
|
||||||
|
@ -31,13 +31,13 @@ sql_con = assert( sql_env:connect("imposm") ) -- you can add db user/password he
|
|||||||
print("PostGIS connection opened")
|
print("PostGIS connection opened")
|
||||||
|
|
||||||
-- these settings are read directly by osrm
|
-- these settings are read directly by osrm
|
||||||
take_minimum_of_speeds = true
|
take_minimum_of_speeds = true
|
||||||
obey_oneway = true
|
obey_oneway = true
|
||||||
obey_bollards = true
|
obey_bollards = true
|
||||||
use_restrictions = true
|
use_restrictions = true
|
||||||
ignore_areas = true -- future feature
|
ignore_areas = true -- future feature
|
||||||
traffic_signal_penalty = 7 -- seconds
|
traffic_signal_penalty = 7 -- seconds
|
||||||
u_turn_penalty = 20
|
u_turn_penalty = 20
|
||||||
|
|
||||||
-- nodes processing, called from OSRM
|
-- nodes processing, called from OSRM
|
||||||
function node_function(node)
|
function node_function(node)
|
||||||
@ -47,22 +47,22 @@ end
|
|||||||
-- ways processing, called from OSRM
|
-- ways processing, called from OSRM
|
||||||
function way_function (way)
|
function way_function (way)
|
||||||
-- only route on ways with highway=*
|
-- only route on ways with highway=*
|
||||||
local highway = way.tags:Find("highway")
|
local highway = way.tags:Find("highway")
|
||||||
if (not highway or highway=='') then
|
if (not highway or highway=='') then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Query PostGIS for industrial areas close to the way, then groups by way and sums the areas.
|
-- Query PostGIS for industrial areas close to the way, then group by way and sum the areas.
|
||||||
-- We take the square root of the area to get a estimate of the length of the side of the area,
|
-- We take the square root of the area to get a estimate of the length of the side of the area,
|
||||||
-- and thus a rough guess of how far we might be travelling along the area.
|
-- and thus a rough guess of how far we might be travelling along the area.
|
||||||
|
|
||||||
local sql_query = " " ..
|
local sql_query = " " ..
|
||||||
"SELECT SUM(SQRT(area.area)) AS val " ..
|
"SELECT SUM(SQRT(area.area)) AS val " ..
|
||||||
"FROM osm_ways way " ..
|
"FROM osm_ways way " ..
|
||||||
"LEFT JOIN osm_landusages area ON ST_DWithin(way.geometry, area.geometry, 100) " ..
|
"LEFT JOIN osm_landusages area ON ST_DWithin(way.geometry, area.geometry, 100) " ..
|
||||||
"WHERE area.type IN ('industrial') AND way.osm_id=" .. way.id .. " " ..
|
"WHERE area.type IN ('industrial') AND way.osm_id=" .. way.id .. " " ..
|
||||||
"GROUP BY way.id"
|
"GROUP BY way.id"
|
||||||
|
|
||||||
local cursor = assert( sql_con:execute(sql_query) ) -- execute querty
|
local cursor = assert( sql_con:execute(sql_query) ) -- execute querty
|
||||||
local row = cursor:fetch( {}, "a" ) -- fetch first (and only) row
|
local row = cursor:fetch( {}, "a" ) -- fetch first (and only) row
|
||||||
way.speed = 20.0 -- default speed
|
way.speed = 20.0 -- default speed
|
||||||
@ -73,10 +73,10 @@ function way_function (way)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
cursor:close() -- done with this query
|
cursor:close() -- done with this query
|
||||||
|
|
||||||
-- set other required info for this way
|
-- set other required info for this way
|
||||||
way.name = way.tags:Find("name")
|
way.name = way.tags:Find("name")
|
||||||
way.direction = Way.bidirectional
|
way.direction = Way.bidirectional
|
||||||
way.type = 1
|
way.type = 1
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user