Thursday, November 12, 2020

2020-11-09 Lua module for highway shields committed

Today, I tidied up, tested and committed a Lua module for processing highway shields in osm2pgsql.

Sample highway shield

I've tried to keep the design as non-intrusive as possible to people's existing workflow, assuming they already use the flex backend. There are just four changes needed to the Lua style file.

  • In initialization, add the lines:
          local shieldtables = require("shieldtables")
          local shieldt = shieldtables.new(prefix)
          
    where prefix is the prefix (e.g., planet_osm) being used in the database for the OSM tables.
  • In the osm2pgsql.process_way function, add the line:
          shieldt:process_way(object);
          
  • In the osm2pgsql.process_relation function, add the line:
          shieldt:process_way(object);
          
  • Create a osm2pgsql.select_relation_members function if you don't already have one. There's a call:
          shieldt:select_relation_members(object)
          
    with the same API that returns the necessary selection. For all the style sheets that I was using, I was able just to use:
          function osm2pgsql.select_relation_members(object)
    	     return shieldt:select_relation_members(object)
          end
          
  • And that's pretty much it, for how to use it. The database tables prefix_shieldroute and prefix_shieldway are managed entirely by those procedures.

    I still need to test to make sure that incremental update works with the new setup. If it does, that's half the job of making minutely updates work, I think.

    No comments: