#generalized_tables:
#  # etldoc: imposm3 -> osm_building_polygon_gen1
#  building_polygon_gen1:
#    source: building_polygon
#    sql_filter: area>power(ZRES12,2) AND ST_IsValid(geometry)
#    tolerance: ZRES14

tables:
  # etldoc: imposm3 -> osm_building_polygon
  building_polygon:
    columns:
    - name: osm_id
      type: id
    - name: geometry
      type: validated_geometry
    - name: area
      type: area
    - name: material
      key: building:material
      type: string
    - name: colour
      key: building:colour
      type: string
    - name: building
      key: building
      type: string
    - name: buildingpart
      key: building:part
      type: string
    - name: buildingheight
      key: building:height
      type: string
    - name: buildingmin_height
      key: building:min_height
      type: string
    - name: buildinglevels
      key: building:levels
      type: string
    - name: buildingmin_level
      key: building:min_level
      type: string
    - name: height
      key: height
      type: string
    - name: min_height
      key: min_height
      type: string
    - name: levels
      key: levels
      type: string
    - name: min_level
      key: min_level
      type: string
    mapping:
      building:part:
      - __any__
      building:
      - __any__
      # these aeroway polygons all imply building=yes
      aeroway:
      - terminal
      - hangar
    filters:
      reject:
        building: ["no","none","No"]
        building:part: ["no","none","No"]
        man_made: ["bridge"]
    type: polygon

  # etldoc: imposm3 -> osm_building_relation
  building_relation:
    columns:
    - name: osm_id
      type: id
    - name: geometry
      type: validated_geometry
    - name: area
      type: area
    - name: building
      key: building
      type: string
      from_member: true
    - name: material
      key: building:material
      type: string
    - name: colour
      key: building:colour
      type: string
    - name: buildingpart
      key: building:part
      type: string
      from_member: true
    - name: buildingheight
      key: building:height
      type: string
      from_member: true
    - name: height
      key: height
      type: string
      from_member: true
    - name: buildingmin_height
      key: building:min_height
      type: string
      from_member: true
    - name: min_height
      key: min_height
      type: string
      from_member: true
    - name: buildinglevels
      key: building:levels
      type: string
      from_member: true
    - name: levels
      key: levels
      type: string
      from_member: true
    - name: buildingmin_level
      key: building:min_level
      type: string
      from_member: true
    - name: min_level
      key: min_level
      type: string
      from_member: true
    - name: relbuildingheight
      key: building:height
      type: string
    - name: relheight
      key: height
      type: string
    - name: relbuildingmin_height
      key: building:min_height
      type: string
    - name: relmin_height
      key: min_height
      type: string
    - name: relbuildinglevels
      key: building:levels
      type: string
    - name: rellevels
      key: levels
      type: string
    - name: relbuildingmin_level
      key: building:min_level
      type: string
    - name: relmin_level
      key: min_level
      type: string
    - name: member
      type: member_id
    - name: index
      type: member_index
    - name: role
      type: member_role
      from_member: true
    - name: type
      type: member_type
    mapping:
      type: [building]
    type: relation_member