[OSM-dev] osm2pgsql lua transforms

Andy Townsend ajt1047 at gmail.com
Thu Oct 22 09:46:14 UTC 2015


On 21/10/2015 20:27, Paul Norman wrote:
> ...
> https://github.com/SomeoneElseOSM/designation-style

An evolution of that is 
https://github.com/SomeoneElseOSM/SomeoneElse-style , which emits key 
combinations as pseudo-values, to be used by 
https://github.com/SomeoneElseOSM/openstreetmap-carto-AJT .  For example:

https://github.com/SomeoneElseOSM/SomeoneElse-style/blob/master/style.lua#L97

if (( keyvalues["highway"] == "footway" ) or
     ( keyvalues["highway"] == "steps" ) or
     ( keyvalues["highway"] == "bridleway" ) or
     ( keyvalues["highway"] == "cycleway" )) then
   if (( keyvalues["width"] == "2" ) or
       ( keyvalues["width"] == "2.5" ) or
       ( keyvalues["width"] == "3" ) or
       ( keyvalues["width"] == "4" )) then
     keyvalues["highway"] = "pathwide"
   else
     keyvalues["highway"] = "path"
   end
end

sets "highway=pathwide" in some cases.  That means that the styling in:

https://github.com/SomeoneElseOSM/openstreetmap-carto-AJT/blob/master/roads.mss#L1426

can be much simpler - no need for horrible SQL statements combining 
keys, just handling of extra values where needed in:

https://github.com/SomeoneElseOSM/openstreetmap-carto-AJT/blob/master/project.mml#L403

It's also easy to assign other tags:

https://github.com/SomeoneElseOSM/SomeoneElse-style/blob/master/style.lua#L255

which means that e.g. "man_made=petroleum_well" gets rendered as it's 
own industrial area (with name), even if it's part of a larger 
industrial area.

Cheers,

Andy




More information about the dev mailing list