generalized_tables:
  # etldoc: osm_landuse_polygon_gen_z7 -> osm_landuse_polygon_gen_z6
  landuse_polygon_gen_z6:
    source: landuse_polygon_gen_z7
    tolerance: ZRES6
    sql_filter: area>power(ZRES6,2)
  # etldoc: osm_landuse_polygon_gen_z8 -> osm_landuse_polygon_gen_z7
  landuse_polygon_gen_z7:
    source: landuse_polygon_gen_z8
    tolerance: ZRES7
    sql_filter: area>power(ZRES6,2)
  # etldoc: osm_landuse_polygon_gen_z9 -> osm_landuse_polygon_gen_z8
  landuse_polygon_gen_z8:
    source: landuse_polygon_gen_z9
    sql_filter: area>power(ZRES6,2) AND (landuse='residential' OR place='suburb' OR place='quarter' OR place='neighbourhood')
    tolerance: ZRES8
  # etldoc: osm_landuse_polygon_gen_z10 -> osm_landuse_polygon_gen_z9
  landuse_polygon_gen_z9:
    source: landuse_polygon_gen_z10
    sql_filter: area>power(ZRES7,2)
    tolerance: ZRES9
  # etldoc: osm_landuse_polygon_gen_z11 -> osm_landuse_polygon_gen_z10
  landuse_polygon_gen_z10:
    source: landuse_polygon_gen_z11
    sql_filter: area>power(ZRES8,2)
    tolerance: ZRES10
  # etldoc: osm_landuse_polygon_gen_z12 -> osm_landuse_polygon_gen_z11
  landuse_polygon_gen_z11:
    source: landuse_polygon_gen_z12
    sql_filter: area>power(ZRES9,2)
    tolerance: ZRES11
  # etldoc: osm_landuse_polygon_gen_z13 -> osm_landuse_polygon_gen_z12
  landuse_polygon_gen_z12:
    source: landuse_polygon_gen_z13
    sql_filter: area>power(ZRES10,2)
    tolerance: ZRES12
  # etldoc: osm_landuse_polygon -> osm_landuse_polygon_gen_z13
  landuse_polygon_gen_z13:
    source: landuse_polygon
    sql_filter: area>power(ZRES11,2) AND ST_IsValid(geometry)
    tolerance: ZRES13

tables:
  # etldoc: imposm3 -> osm_landuse_polygon
  landuse_polygon:
    type: polygon
    columns:
    - name: osm_id
      type: id
    - name: geometry
      type: validated_geometry
    - name: landuse
      key: landuse
      type: string
    - name: amenity
      key: amenity
      type: string
    - name: leisure
      key: leisure
      type: string
    - name: tourism
      key: tourism
      type: string
    - name: place
      key: place
      type: string
    - name: waterway
      key: waterway
      type: string
    - name: area
      type: area
    mapping:
      landuse:
      - railway
      - cemetery
      - military
      - quarry
      # zoning
      - residential
      - commercial
      - industrial
      - garages
      - retail
      amenity:
      - bus_station
      - school
      - university
      - kindergarten
      - college
      - library
      - hospital
      - grave_yard
      leisure:
      - stadium
      - pitch
      - playground
      - track
      tourism:
      - theme_park
      - zoo
      place:
      - suburb
      - quarter
      - neighbourhood
      waterway:
      - dam
