Originally posted by **geoneutrino** September 22, 2023
Hello,
way_function in lua is normally a lot of calls to sub-functions to process the different types of elements/layers needed (streets, landuse, boundaries, labels ...)
when accepting multiple type of relations the current concept is a bit unclean from a software engineering perspective:
Accessing relations in one of those sub-functions with the while .. NextRelation() loop mentioned in the docs/RELATIONS.md results in the relationSubscript variable incremented in OsmLuaProcessing::NextRelation() until the end of the list and afterwards i can never reset it to use again in another function
https://github.com/systemed/tilemaker/blob/439c6b10276a8427466a1e5f3e54df4c79361d1e/src/osm_lua_processing.cpp#L522
An easy improvement for this scenario would be to expose a simple "ResetRelationSubscript" method in osm_lua_processing to set relationSubscript to -1
A more complex but maybe also useful in the future would be to expose methods for accessing the relations in a more flexible way, kind of dictionary e.g. add a method NextRelationOfType("abc") that loops overs relations with attribute type=abc
Thanks
Discussed in https://github.com/systemed/tilemaker/discussions/540