Replies: 1 comment 1 reply
-
And that's something you can already do with osm2pgsql, just not very efficiently. You can create one table with, say, all nodes tagged with The problem for osm2pgsql is: It can only see one object at a time. For a node it imports it can know whether it contains a A way to solve this with current osm2pgsql is to just import that huge table as described above and then run an SQL query after the import removing all the node/way combinations that are no interesting. Not great either, but it would work. An alternative would be to add a trigger to that table connection nodes with ways that will check whether a node added has a And another possibility: When you have an updatable database, ie. in slim mode, you aready have the list of member nodes for all ways available in the database. So you can run an SQL query after import that finds all ways having a The way to think about this is: Osm2pgsql can only work on one object at a time, but after the import (or update) you do have a database with all sorts of clever functions in it. So you can prepare the data in osm2pgsql in a useful way but then in a second step So this is already something that can arguably be solved with current osm2pgsql and some basic SQL and doesn't necessarily need spatial joins or other complex spatial queries. A way to make this easier could be to add some functionality in osm2pgsql that would allow you to query member nodes from Lua when importing ways. But that adds a huge overhead because of the many database queries needed, not a great solution either, but certainly something we are considering. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As discussed in the development Roadmap, there is currently limited "linkage" between different geometry types.
This isn't a problem for 95% of rendering, but there are cases where it is necessary to cross-reference between a node and the way(s) it is part of. Currently, for example, the turning circle / loop / mini-roundabout rendering in OSM Carto requires a relatively expensive and inelegant spatial join (
ST_DWithin) to (re)determine the types of highways that a turning circle is connected to and then render with the correct colour etc. There are other places where we would like to do similar things, e.g. resolve problems with level crossings where the starting zoom level should be adjusted based on the type of railway it attached to, adjust station rendering depending on railway type etc.As I understand, "linkage" between ways and multipolygons is achieved with callback functions so that relevant tags from the MP can be attached to constituent ways. You can imagine a similar mechanism for nodes / ways, where specific node types register a callback for further tag processing. That said, I don't think this callback mechanism is the most flexible / elegant solution, not least because you would need to make decisions about combining tags from multiple ways at import time.
I think the most flexible approach would be an explicit "node/way correlation table" with a row for every "connection of interest" e.g. turning circles, level crossings, railway stations etc. You would probably need to add primary key (serial-like type) to the node and way tables, rather than use the OSM ID as key/index. But having done this, the spatial joins would be simply replaced by normal SQL joins.
In the longer term, I'm sure there would be other applications of linking ways and nodes e.g. site-like relations where you would then know which nodes were contained within which bounding area.
[There was some related, but unresolved discussion in #2311.]
Beta Was this translation helpful? Give feedback.
All reactions