You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
0 commit comments