-
Notifications
You must be signed in to change notification settings - Fork 819
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
Move rendering order road types from osm2pgsql to our SQL queries #462
Comments
@pnorman Would you be able to do a performance test of https://github.com/math1985/openstreetmap-carto/tree/road-order compared to https://github.com/gravitystorm/openstreetmap-carto/tree/7f5235b9b337aca551972b9a7188c8597c4f6dc6 ? |
@gravitystorm Do you agree with controlling render order of roads from our SQL queries, provided the performance does not degrade significantly? |
See also: |
Yes - but potentially not until post-SOTM hack day. For reference, the compare is matthijsmelissen/openstreetmap-carto@gravitystorm:7f5235b9b337aca551972b9a7188c8597c4f6dc6...road-order |
I'm not really in favour of this, but I'm open to persuasion. This takes what are already very complex and hard to work with SQL queries, and adds on even more complexity. I would rather see the problem fixed upstream in osm2pgsql, even though it will take a lot longer to work things through. If people would prefer (or if we believe our choices are style-specific rather than generically useful), we can create our own version of style.lua and control it in this repository. |
I think separation of concerns is more important than the code complexity argument (although I share @gravitystorm's worries on that aspect). So the question is: is render order something osm2pgsql should be concerned with? My intuition - but others might disagree - is that osm2pgsql is concerned with representing geospatial data in easy-readable form, and that the resulting SQL database should be independent of rendering decisions. For example, I believe that layer tags belong in the database, because that's a piece of geospatial data. However, rendering order (and the way we represent that) is not geospatial data, and thus not osm2pgsql's concern. In tilemill 2, we should at least be able to use line-breaks in the queries. |
I raised the issue here: osm2pgsql-dev/osm2pgsql#132 |
I don't like the queries either. I'll have to look at the values in a JSON editor or unescape it myself rather than look at the text file if I'm going to provide a more detailed commentary, .mml is a horrible format to read the queries in with a text editor. |
Please don't study the queries in detail yet, this is just a proof of concept to study the performance. I didn't spend any time in writing the queries in a readable way. |
There is not only code that might be relevant in style.lua, but also in tagtransform.c (from line 16). Is there anyone here around who understands the osm2pgsql code and can help me explain which of both parts of the code is relevant (if not both)? I find the osm2pgsql code rather hard to read. |
Well, I'm used to reading a lot less clear queries than anything you'll write. The issue is the queries are a large part of the performance, so I have to study them.
We're not using lua tag transforms, so nothing in there is used. |
Are you saying we're not using style.lua, or not using tagtransform.c? Code for layering seems to be duplicated in both files, and I don't see it anywhere else. |
We're not using lua tag transforms, so style.lua is never used. See README_lua.md |
Ok, so then this would be the relevant code: Unfortunately, there is no clear separation between code and rules, and having to keep an own version of tagtransform.c in the openstreetmap-carto would be rather annoying. Unfortunately, I have not received any feedback on the issue i opened on the osm2pgsql Github. |
@lonvia has commented in the osm2pgsql github repo. She is against changing the z-order in the main code as it would break break backwards compatibility on other installations. She suggests that we move away from tagtransform.c and supply our own style.lua instead. The lua support is still in beta, though. @pnorman mentions that using style.lua comes with a performance penalty of at least 10% on import. This leaves us basically with two options:
I would still be in favour of the second option, because it's much easier to maintain order changes (they wouldn't require a full new import of the database). I agree this comes with a penalty in the form of harder to read SQL queries. Alternatively, we could use the second option for now, so we get some experience with deciding what the best order is, and then move the order from SQL to style.lua at a later point when we do a new SQL import. There are quite a few issues that depend on this: https://trac.openstreetmap.org/ticket/2024 |
The performance penalty will be substantially worse with SQL than Lua, because the lua is a one-time cost on import, while SQL is every rendering |
Indeed, sorry for making that not clearer in my post. |
Changing the rendering order with osm2pgsql is a complex operation, because it requires a database reload. We don't want to do frequent database reloads, so if we change the rendering order with osm2pgsql, we must do it right the first time. However, changing the rendering order of roads can also easily have unforeseen consequences, and even with intensive testing, there is a significant risk that these consequences only show up after the changes are rolled out on the main map. Therefore, I would be hesitant to use osm2pgsql for the road order at this phase. Instead, I would propose the following:
My tests indicate that moving handling of the road order to the road does not significantly harm performance. Handling of the road order allows us to get rid of a lot of the links overhead in roads.mss, which will significantly improve performance. Note that this issue is relatively high priority: it allows simplifying roads.mss significantly (because we can get rid of the link road duplication), it significantly improves performance (for the same reason), and 6 other bugs depend on it. @gravitystorm What do you say? |
Currently, rendering order of road rendering within one layer is handled by the z_order column, which comes from osm2pgsql. As such, we have little control over road rendering without reloading the database. This PR moves control over the rendering order to the SQL query. This adds complexity to the SQL queries, but increases customizability, and simplifies the roads.mms code. This solves the following issues: * gravitystorm#462 (Move rendering order road types from osm2pgsql to our SQL queries) * gravitystorm#163 (Railways are now drawn above roads) * gravitystorm#167 (Tramway layering issues) * gravitystorm#168 (Paths are now drawn below link roads) * Trac 2024 (Service roads are now rendered below link roads) * Trac 3649 (Service roads are now rendered below race tracks) * Pedestrian and living streets are now consistently ordered * Footways are now always displayed under service ways
Currently, rendering order of road rendering within one layer is handled by the z_order column, which comes from osm2pgsql. As such, we have little control over road rendering without reloading the database. This PR moves control over the rendering order to the SQL query. This adds complexity to the SQL queries, but increases customizability, and simplifies the roads.mms code. This solves the following issues: * gravitystorm#462 (Move rendering order road types from osm2pgsql to our SQL queries) * gravitystorm#163 (Railways are now drawn above roads) * gravitystorm#167 (Tramway layering issues) * gravitystorm#168 (Paths are now drawn below link roads) * Trac 2024 (Service roads are now rendered below link roads) * Trac 3649 (Service roads are now rendered below race tracks) * Pedestrian and living streets are now consistently ordered * Footways are now always displayed under service ways
Currently, rendering order of road rendering within one layer is handled by the z_order column, which comes from osm2pgsql. As such, we have little control over road rendering without reloading the database. This PR moves control over the rendering order to the SQL query. This adds complexity to the SQL queries, but increases customizability, and simplifies the roads.mms code. This solves the following issues: * gravitystorm#462 (Move rendering order road types from osm2pgsql to our SQL queries) * gravitystorm#163 (Railways are now drawn above roads) * gravitystorm#167 (Tramway layering issues) * gravitystorm#168 (Paths are now drawn below link roads) * Trac 2024 (Service roads are now rendered below link roads) * Trac 3649 (Service roads are now rendered below race tracks) * Pedestrian and living streets are now consistently ordered * Footways are now always displayed under service ways
Currently, rendering order of road rendering within one layer is handled by the z_order column, which comes from osm2pgsql. As such, we have little control over road rendering without reloading the database. This PR moves control over the rendering order to the SQL query. This adds complexity to the SQL queries, but increases customizability, and simplifies the roads.mms code. This solves the following issues: * gravitystorm#462 (Move rendering order road types from osm2pgsql to our SQL queries) * gravitystorm#163 (Railways are now drawn above roads) * gravitystorm#167 (Tramway layering issues) * gravitystorm#168 (Paths are now drawn below link roads) * Trac 2024 (Service roads are now rendered below link roads) * Trac 3649 (Service roads are now rendered below race tracks) * Pedestrian and living streets are now consistently ordered * Footways are now always displayed under service ways
This also solves #644. |
Currently, rendering order of road rendering within one layer is handled by the z_order column, which comes from osm2pgsql. As such, we have little control over road rendering without reloading the database. This PR moves control over the rendering order to the SQL query. This adds complexity to the SQL queries, but increases customizability, and simplifies the roads.mms code. This solves the following issues: * gravitystorm#462 (Move rendering order road types from osm2pgsql to our SQL queries) * gravitystorm#163 (Railways are now drawn above roads) * gravitystorm#167 (Tramway layering issues) * gravitystorm#168 (Paths are now drawn below link roads) * Trac 2024 (Service roads are now rendered below link roads) * Trac 3649 (Service roads are now rendered below race tracks) * Pedestrian and living streets are now consistently ordered * Footways are now always displayed under service ways
Solved by #626. |
The render order of road types (defining which road types are rendered on top of which other roads) is currently hard-coded in osm2pgsl (in style.lua).
In any case, this is problematic:
It might also be possible to specify this in the osm2pgsql style file. But that's still not an ideal solution, since any changes in the rendering order are hard to implement, because they require a database change.
Therefore, I propose that we specify the rendering order within our Carto code. The most logical place to do that is the SQL query.
The largest problem with this is the performance penalty. On a small database (Luxembourg), I did not measure any performance degradation. This might be because we are currently sorting anyway (by z_order). However, it would be good to test this on a larger example as well.
The text was updated successfully, but these errors were encountered: