[Tile-serving] [osm2pgsql-dev/osm2pgsql] Introduce new "id cache" for node tables (PR #2460)
Jochen Topf
notifications at github.com
Tue Apr 7 12:24:46 UTC 2026
It is sometimes useful to know whether a way contains nodes of a certain type, i.e. with certain tags. This commit adds a new functionality called "id caches" that allows to find out.
When defining a node table in Lua with `define_table` the `ids` section can now contain a field `cache = true`. If this is set the ids of all nodes written to that table are stored in memory. Later, when processing ways, that cache can be queried with `tablename:in_id_cache()`. Usually this would be used to query all the member nodes of a way: `...:in_id_cache(object.nodes)`. The `in_id_cache()` function returns the indexes into the `object.nodes` array where the id matches. From there it is possible to get the id of the matching node (with `object.nodes[idx]`) or the location of that node (with `object:as_point(idx)`. This information can be stored in a way table which will be correctly updated in append mode. (In append mode the in-memory id cache is populated with all the ids of the table for which the cache was defined.)
The whole thing only works for node tables and querying only works in the process_way() function. It can possibly be extended later to work in other contexts.
You can view, comment on, or merge this pull request online at:
https://github.com/osm2pgsql-dev/osm2pgsql/pull/2460
-- Commit Summary --
* Introduce new "id cache" for node tables
-- File Changes --
A flex-config/turning-circles.lua (69)
M src/debug-output.cpp (1)
M src/flex-lua-table.cpp (12)
M src/flex-table.cpp (4)
M src/flex-table.hpp (7)
M src/idlist.cpp (5)
M src/idlist.hpp (7)
M src/output-flex.cpp (85)
M src/output-flex.hpp (19)
A tests/bdd/flex/id-cache.feature (132)
A tests/bdd/flex/lua-table-ids.feature (254)
-- Patch Links --
https://github.com/osm2pgsql-dev/osm2pgsql/pull/2460.patchhttps://github.com/osm2pgsql-dev/osm2pgsql/pull/2460.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/osm2pgsql-dev/osm2pgsql/pull/2460
You are receiving this because you are subscribed to this thread.
Message ID: <osm2pgsql-dev/osm2pgsql/pull/2460 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20260407/944c307b/attachment.htm>
More information about the Tile-serving
mailing list