osm2pgsql-dev / osm2pgsql

OpenStreetMap data to PostgreSQL converter
https://osm2pgsql.org
GNU General Public License v2.0
1.51k stars 474 forks source link

Feature request: make --prefix value available to flex back end #1345

Closed kennykb closed 3 years ago

kennykb commented 3 years ago

Would you consider making the value of the --prefix option from the command line available in the flex back end, perhaps as a variable named osm2pgsql.prefix?

I occasionally wind up using osm2pgsql with two sets of tables (e.g., two different extracts, or testing vs. production). It would be convenient not to have to edit the Lua script to switch between them. (It's also an example of the 'Once and Only Once' or 'Don't Repeat Yourself' principle. Right now I have to specify the prefix both on the command line and in the Lua script, which invites having them fail to match.)

joto commented 3 years ago

osm2pgsql has far too many command line options and many are named badly. --prefix is one of those problematic ones, because it sets the table name prefix for the middle (slim) tables as well as for the database tables. These are two totally different parts of the program and logically distinct and should be kept separate. With the flex output we had the chance to disentangle a lot of this. The flex output basically doesn't interpret any command line options any more. Styling issues are now in the config file, command line options are still used for anything not related to styling. We realize that this entails some pain for people who are used to the old ways, but we believe this is the best way forward.

There is no way to get command line settings into the Lua script. This is intentional, it would open up whole other issues of compatibility, what is where etc. But you can wrap a small script around osm2pgsql and use that. Set environment variables in that script which you can access from the Lua config, see the manual for how this can be done. That would allow you to keep the DRY principle in your specific setup.

lonvia commented 3 years ago

Given that we have proper schema support with flex now, I recommend using schemas when maintaining two imports in parallel in the same database.