Skip to content
Snippets Groups Projects
relation_id.py 617 B
Newer Older
from rulelib import AbstractRule


class RelationIDRule(AbstractRule):
    def __call__(self, relations, *args, **kwargs):
        """
        Determine the building relation OSM ID.

        Args:
            relations:
                List of the attributes of all relations that the building is member of.

        Returns:
            OSM ID of the first relation that the building is member of.
        """

        for relation in relations:
            osm_id = relation.get("osm_id", None)
            if osm_id is not None:
                return {"relation_id": osm_id}
        return {"relation_id": None}