[Tile-serving] [osm2pgsql-dev/osm2pgsql] Get information of nearby roads / How setup processing for the cycling quality index (Discussion #2146)

Sarah Hoffmann notifications at github.com
Sun Mar 24 22:10:39 UTC 2024


Two-stage processing can in theory do what you want:

* during the first stage you import all the large roads that can be potentially parallel roads. All roads that need a check for such a parallel road, you mark to be processed in the second stage.
* for the second stage, open a connection to the database from lua (look for a lua-dbi module) and when you get the cycleway, query parallel roads before computing the complex quality index.

In practice, you might fail to get the way geometry necessary for the query in the second stage. I don't think there are good functions to access them right now. I also don't know how fast this approach would be.

I'd probably rather go for a post-processing script that runs after import/update to osm2pgsql is completely done. The good news is that you can do almost all the post-processing in, say Python:

* on import/update set a marker in the table where data has been added or changed. That can be some 'needs_indexing' column that always gets set to true in the Lua script.
* create a SELECT query that selects the entries that need indexing and for each computes the potential parallel road returning its properties with the result
* in your Python script go over the results of the SELECT query one by one, make the quality computations, and write the results back using an UPDATE that also resets your marker

You don't need to have any quality-index related code in Lua. Just make sure that the flex script imports all the tags needed for the calculation. (If you encapsulate the actual index calculation in the right way in a Python library, you can even use the same code for the QGIS plugin and the osm2pgsql postprocessing. But I'm getting ahead of myself.)

Both approaches kind-of work for updates. The catch is that you'd usually would want to update the quality measure of your cycle way when the properties of the parallel road change. To cover that case you would need a trigger that marks surrounding cycleways as 'needs update' when a large road changes.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/discussions/2146#discussioncomment-8895416
You are receiving this because you are subscribed to this thread.

Message ID: <osm2pgsql-dev/osm2pgsql/repo-discussions/2146/comments/8895416 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20240324/cac5ea7e/attachment.htm>


More information about the Tile-serving mailing list