-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update openstreetmap-carto-hstore-only-l10n.lua - Switching from add_row()
to insert()
for osm2pgsql
#40
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you mention there is still quite some code duplication here. Two (mutually exclusive) ideas for you to consider:
- All the
add_*
functions have atags
and a newobject
. If you keep the object parameter, then the tags parameter is superfluous, because you can just callobject.tags
to get it. - Consider using a
geom
parameter instead of theobject
parameter. This is initialized outside the function withobject:as_linestring()
orobject:as_multipolygon()
or whatever. Then there are fewer versions of those functions, because inside you can use that geometry and do the merging and segmentizing and so on. So you don't need two sets of functions for the non-multi and the multi case.
Also the basic settings of the cols
should really go into its own function, it seems to be the same everywhere. But that was already a problem in the old code.
Thanks for the tip @joto . I have tackled the second variant here: Why do you mean/suggest that it is better to place the basic settings of the column in a separate function? |
It looks to me that this here is the same in all functions, it it not?
So it makes sense to factor this out and do it in one function for all cases. |
Just for your info. This code is derived from an earlier version of a legacy compatible flex output port which @pnorman did for upstream osm-carto adapted to the hstore-only setup I use in German style. |
I do. However, the database layout of German style predates the upstream usage of hstore. It differs in the way that I moved everything to hstore while upstream kept the columns it had before just adding hstore for the rest. I liked my version more and while I was working with views anyway I just kept what I had. I am still able to render upstream though. |
Background:
I came across the open question in Issue #4977 regarding the potential impact on the German style of OpenStreetMap. To investigate further, I set up a test environment and tested the installation of the openstreetmap.de tile server using the latest version of
osm2pgsql
.During the data import process using the following command:
I encountered the following error:
Solution:
Sarah pointed me to this tutorial, which I have now integrated into the Lua script.
Notes:
This version is likely not perfect; there is redundant code, specifically in the functions
add_multiroads
andadd_roads
(add_polygons
andadd_polygons
), which could potentially be combined into a single function by checking the type. However, the current implementation works because the "multi"-function is always called from process_relation, ensuring that the types align correctly and my knowledge of the types is limited, and since this solution works, I'm submitting it for your review as is.