In a lua style file called from osm2pgsql, the following code works exactly as expected - the comparison of the two numbers works as expected:
-- ----------------------------------------------------------------------------
-- Big peaks
-- ----------------------------------------------------------------------------
if ( keyvalues["natural"] == "peak" ) then
keyvalues["name"] = "before"
if ( keyvalues["ele"] == nil ) then
keyvalues["name"] = "elenil"
else
keyvalues["name"] = "elenotnil"
if ( tonumber( keyvalues["ele"] ) == 900 ) then
keyvalues["name"] = "bigpeak"
else
keyvalues["name"] = "notabigpeak"
end
end
end
However, if I change the comparison to the following:
if ( tonumber( keyvalues["ele"] ) > 900 ) then
then the following error occurs:
Using lua based tag processing pipeline with script /home/renderaccount/src/SomeoneElse-style/style.lua
Using projection SRS 3857 (Spherical Mercator)
Setting up table: planet_osm_point
Osm2pgsql failed due to ERROR: SELECT * FROM planet_osm_point LIMIT 0 failed: ERROR: relation "planet_osm_point" does not exist
LINE 1: SELECT * FROM planet_osm_point LIMIT 0
I'd expect this to work, because the "tonumber" seems to work OK and this page suggests to me that ">" ought to work there. osm2pgsql is "osm2pgsql version 0.96.0 (64 bit id space)", lua according to "dpkg -l" seems to be 5.1 or 5.2.
Any ideas?
asked 25 Oct '19, 22:04

SomeoneElse ♦
36.9k●71●370●866
accept rate: 16%
Often the easiest way to get round this is by adding an
or 0
, so(tonumber(keyvalues["ele"]) or 0)>900
.