osrm-backend
osrm-backend copied to clipboard
osrm postgis.lua - "attempt to concatenate a function value"
I would like to test the routing engine using postgis.lua profiles, so check the osm data against a postgis db.
The problem is, inside way_function, I am not able to use way.id. This is the error I get when I try to print it:
terminate called after throwing an instance of 'sol::error' what(): lua: error: ../osrm-backend/profiles/postgis.lua:72: attempt to concatenate a function value (field 'id') Aborted (core dumped)
I use the following code:
function way_function (way, result)
local highway = way:get_value_by_key('highway')
if (not highway or highway=='') then
return 0
end
local sql_query = " " ..
"SELECT SUM(SQRT(area.area)) AS val " ..
"FROM import.osm_roads way " ..
"LEFT JOIN import.osm_landusages area ON ST_DWithin(way.geometry, area.geometry, 100) " ..
"WHERE area.type IN ('industrial') AND way.osm_id=" .. way.id .. " " .. --error see above
"GROUP BY way.id"`
https://github.com/Project-OSRM/osrm-backend/blob/master/profiles/examples/postgis.lua
when I change way.id to way:id() in sql-query, I get the following error:
Segmentation fault (core dumped)
Best, Simon