{
  "id": "bag",
  "title": {
    "nl": "BAG-importeerhulp",
    "en": "BAG import helper",
    "de": "BAG-Importhilfe",
    "fr": "Facilitateur d'import BAG",
    "nb_NO": "BAG-importhjelper",
    "ca": "Assistent d'importació del BAG",
    "es": "Herramienta de ayuda para la importación de BAG",
    "cs": "Pomocník pro import BAG",
    "zh_Hant": "BAG 匯入助手",
    "pl": "Pomocnik importowy BAG",
    "zh_Hans": "BAG 导入助手",
    "uk": "Помічник з імпорту BAG",
    "ko": "BAG 헬퍼 불러오기"
  },
  "description": {
    "nl": "Dit thema helpt het importeren van BAG data",
    "en": "This theme helps with importing data from BAG",
    "cs": "Toto téma pomáhá s importem dat ze systému BAG",
    "de": "Dieses Thema hilft beim Importieren von BAG-Daten",
    "fr": "Ce thème aide à l'importation de données depuis BAG",
    "ca": "Aquest tema ajuda amb la importació de dades del BAG",
    "zgh": "ⵉⵜⵜⴰⵡⵙ ⵉⵎⵔⵙⵉ ⴰⴷ ⴳ ⵡⴰⵎⵎⴰⵥ ⵏ ⵜⵎⵓⵛⴰ ⵙⴳ BAG",
    "es": "Este tema ayuda a importar datos de BAG",
    "eu": "Gai honek BAGeko datuak inportatzen laguntzen du",
    "pl": "Motyw ten pomaga w importowaniu danych z BAG",
    "zh_Hans": "这个主题帮助导入来自BAG的数据",
    "uk": "Ця тема допомагає імпортувати дані з BAG",
    "zh_Hant": "這個主題要感謝來自 BAG 匯入的資料",
    "ko": "이 테마는 BAG에서 데이터를 가져오는 데 도움을 줍니다"
  },
  "shortDescription": {
    "nl": "BAG-importeerhulptool",
    "en": "BAG import helper tool",
    "de": "BAG-Import-Hilfswerkzeug",
    "fr": "Outil de facilitation d'import BAG",
    "ca": "Ferramenta d'ajuda per a importar el BAG",
    "es": "Herramienta de ayuda para la importación de BAG",
    "cs": "Pomocný nástroj pro import BAG",
    "eu": "BAGak inportatzen laguntzeko tresna",
    "pl": "Narzędzie wspomagające import BAG",
    "zh_Hans": "BAG 导入辅助工具",
    "uk": "Допоміжний інструмент для імпорту BAG",
    "zh_Hant": "BAG 匯入幫助工具",
    "ko": "BAG 헬퍼 툴 불러오기"
  },
  "icon": "./assets/themes/bag/logo.svg",
  "startZoom": 9,
  "startLat": 53.1726,
  "startLon": 7.04545,
  "credits": [
    "Wouter van der Wal"
  ],
  "hideFromOverview": true,
  "layers": [
    {
      "id": "osm_buildings",
      "name": "OSM Buildings",
      "title": "OSM Building",
      "description": "Layer showing buildings that are in OpenStreetMap",
      "source": {
        "osmTags": "building~*"
      },
      "minzoom": 18,
      "isCounted": false,
      "calculatedTags": [
        "_surface:strict:=get(feat)('_surface')"
      ],
      "tagRenderings": [
        {
          "id": "Reference",
          "render": {
            "en": "The reference in BAG is <b>{ref:bag}</b>",
            "de": "Die Referenz in BAG ist <b>{ref:bag}</b>",
            "nl": "De referentie in BAG is <b>{ref:bag}</b>",
            "fr": "La référence dans le BAG est <b>{ref:bag}</b>",
            "ca": "La referència al BAG és <b>{ref:bag}</b>",
            "zgh": "ⵜⴳⴰ ⵜⵙⴰⵖⵓⵍⵜ ⴳ BAG <b>{ref:bag}</b>",
            "es": "La referencia en BAG es <b>{ref:bag}</b>",
            "cs": "Reference v BAG je <b>{ref:bag}</b>",
            "pl": "Numer referencyjny w BAG to <b>{ref:bag}</b>",
            "zh_Hans": "在 BAG 中的参考是 <b>{ref:bag}</b>",
            "fil": "Ang sanggunian sa BAG ay <b>{ref:bag}</b>",
            "uk": "Посилання у BAG має вигляд <b>{ref:bag}</b>",
            "zh_Hant": "在 BAG 的參考編號 <b>{ref:bag}</b>",
            "ko": "BAG의 레퍼런스는 <b>{ref:bag}</b>입니다"
          },
          "mappings": [
            {
              "if": "ref:bag=",
              "then": {
                "en": "This building has no reference in the BAG",
                "cs": "Tato budova nemá v BAG žádný odkaz",
                "de": "Dieses Gebäude hat keinen Verweis im BAG",
                "nl": "Dit gebouw heeft geen referentie in de BAG",
                "fr": "Ce bâtiment n'a pas de référence dans le BAG",
                "ca": "Aquest edifici no té referència al BAG",
                "zgh": "ⵜⵓⵚⴽⴰ ⴰⴷ ⵓⵔ ⵖⵓⵔⵙ ⵜⴰⵙⴰⵖⵓⵍⵜ ⴳ BAG",
                "es": "Este edificio no tiene referencia en el BAG",
                "pl": "Budynek ten nie ma odniesienia w BAG",
                "zh_Hans": "这栋建筑在BAG中没有参考信息",
                "fil": "Walang sanggunian ang gusaling ito sa BAG",
                "uk": "Ця будівля не має жодної згадки в Базі даних",
                "zh_Hant": "這棟建築在 BAG 沒有參考資訊",
                "ko": "이 건물은 BAG에 레퍼런스가 존재하지 않습니다"
              }
            }
          ]
        },
        {
          "id": "Building type",
          "freeform": {
            "key": "building",
            "type": "string",
            "addExtraTags": [
              "construction="
            ]
          },
          "render": "This building is a <b>{building}</b>",
          "question": "What kind of building is this?"
        }
      ],
      "pointRendering": null,
      "lineRendering": [
        {
          "width": {
            "render": "2",
            "mappings": [
              {
                "if": "fixme~*",
                "then": "5"
              }
            ]
          },
          "color": {
            "render": "#00c",
            "mappings": [
              {
                "if": "fixme~*",
                "then": "#ff00ff"
              },
              {
                "if": "building=house",
                "then": "#a00"
              },
              {
                "if": "building=shed",
                "then": "#563e02"
              },
              {
                "if": {
                  "or": [
                    "building=garage",
                    "building=garages"
                  ]
                },
                "then": "#f9bfbb"
              },
              {
                "if": "building=yes",
                "then": "#0774f2"
              }
            ]
          }
        }
      ],
      "allowMove": false
    },
    {
      "id": "osm_adresses",
      "name": "OSM Adresses",
      "title": "OSM Adress",
      "description": "Layer showing adresses that are in OpenStreetMap",
      "source": {
        "osmTags": {
          "and": [
            "source=BAG",
            "addr:city~*",
            "addr:housenumber~*",
            "addr:postcode~*",
            "addr:street~*"
          ]
        }
      },
      "minzoom": 18,
      "pointRendering": [
        {
          "label": {
            "render": "<div style='color: black' class='rounded-full p-1 font-bold relative'>{addr:housenumber}</div>",
            "condition": "addr:housenumber~*"
          },
          "location": [
            "point",
            "centroid"
          ]
        }
      ],
      "lineRendering": [
        {
          "width": {
            "render": 1
          }
        }
      ],
      "allowMove": false,
      "isCounted": false
    },
    {
      "id": "bag_pand",
      "name": "BAG Buildings",
      "title": "BAG Building",
      "description": {
        "en": "Buildings from BAG register",
        "de": "Gebäude aus dem BAG-Register",
        "nl": "Gebouw uit de BAG",
        "fr": "Bâtiments du registre BAG",
        "ca": "Edificis del registre BAG",
        "zgh": "ⵜⵓⵚⴽⴰⵡⵉⵏ ⵙⴳ ⵡⴰⵔⵔⴰ ⵏ BAG",
        "es": "Edificios del registro BAG",
        "cs": "Budovy z registru BAG",
        "pl": "Budynki z rejestru BAG",
        "zh_Hans": "BAG 注册中的建筑物",
        "fil": "Mga gusali mula sa rehistro ng BAG",
        "uk": "Будівлі з реєстру BAG",
        "zh_Hant": "BAG 當中有註冊的建築",
        "ko": "BAG에 등록된 건물"
      },
      "source": {
        "geoJson": "https://service.pdok.nl/lv/bag/wfs/v2_0?request=GetFeature&service=WFS&version=2.0.0&outputFormat=application%2Fjson%3B%20subtype%3Dgeojson&typeName=bag%3Apand&bbox={x_min}%2C{y_min}%2C{x_max}%2C{y_max}%2CCRS84&srsName=EPSG%3A4326",
        "geoJsonZoomLevel": 18,
        "osmTags": "identificatie~*"
      },
      "minzoom": 18,
      "calculatedTags": [
        "_overlaps_with_buildings=overlapWith(feat)('osm_buildings').filter(f => f.feat.properties.id.indexOf('-') < 0)",
        "_overlaps_with=get(feat)('_overlaps_with_buildings').find(f => f.overlap > 1 /* square meter */ )",
        "_overlaps_with_properties=get(feat)('_overlaps_with')?.feat?.properties",
        "_overlap_percentage=Math.round(100 * (get(feat)('_overlaps_with')?.overlap / get(feat)('_overlaps_with_properties')['_surface:strict']))",
        "_reverse_overlap_percentage=Math.round(100 * (get(feat)('_overlaps_with')?.overlap / get(feat)('_surface')))",
        "_bag_obj:in_construction=feat.properties.status.startsWith('Bouwvergunning verleend') || feat.properties.status.startsWith('Bouw gestart')",
        "_bag_obj:construction=(feat.properties.gebruiksdoel == 'woonfunctie') ? ((Number(feat.properties.aantal_verblijfsobjecten) == 1) ? 'house' : 'apartments') : 'yes'",
        "_bag_obj:building=(feat.properties.status.startsWith('Bouwvergunning verleend') || feat.properties.status.startsWith('Bouw gestart')) ? 'construction' : feat.properties['_bag_obj:construction']",
        "_bag_obj:ref:bag=Number(feat.properties.identificatie)",
        "_bag_obj:source:date=new Date().toISOString().split('T')[0]",
        "_bag_obj:start_date=feat.properties.bouwjaar",
        "_osm_obj:id=get(feat)('_overlaps_with_properties')?.id",
        "_osm_obj:building=get(feat)('_overlaps_with_properties')?.building",
        "_imported_osm_object_found:=Number(feat.properties.identificatie)==Number(get(feat)('_overlaps_with_properties')['ref:bag'])"
      ],
      "tagRenderings": [
        {
          "id": "Import button",
          "render": {
            "special": {
              "type": "import_way_button",
              "targetLayer": "osm_buildings",
              "tags": "building=$_bag_obj:building; ref:bag=$_bag_obj:ref:bag; source=BAG; source:date=$_bag_obj:source:date; start_date=$_bag_obj:start_date",
              "text": {
                "*": "Upload this building to OpenStreetMap"
              }
            }
          },
          "mappings": [
            {
              "#": "Something went wrong calculating the tags - don't show an import button",
              "if": {
                "or": [
                  "_bag_obj:building=",
                  "_bag_obj:ref:bag="
                ]
              },
              "then": {
                "en": "Didn't calculate the correct values yet. Refresh this page",
                "de": "Richtige Werte noch nicht berechnet. Aktualisieren Sie diese Seite",
                "nl": "Correcte waarden nog niet berekend. Herlaad deze pagina",
                "fr": "Les valeurs correctes n'ont pas encore été calculées. Rafraichissez la page",
                "ca": "El valors correctes encara no s'ha calculat. Refresca la pàgina",
                "cs": "Zatím nebyly vypočteny správné hodnoty. Aktualizujte stránku",
                "nb_NO": "Har ikke regnet ut riktige verdier enda. Gjenoppfrisk siden.",
                "es": "Aún no se calcularon los valores correctos. Actualiza esta página",
                "pl": "Jeszcze nie obliczono poprawnych wartości. Odśwież tę stronę",
                "zh_Hans": "尚未计算出正确的值。请刷新此页面",
                "uk": "Ще не розрахували правильні значення. Оновіть цю сторінку",
                "zh_Hant": "先不要計算正確數值，請重新整理這一頁",
                "ko": "값을 올바르게 계산하지 못했습니다. 페이지를 새로고침 해 주세요"
              }
            },
            {
              "if": "_overlaps_with!=",
              "then": "{conflate_button(osm_buildings, building=$_bag_obj:building; ref:bag=$_bag_obj:ref:bag; source=BAG; source:date=$_bag_obj:source:date; start_date=$_bag_obj:start_date, Replace the geometry in OpenStreetMap, , _osm_obj:id)}"
            },
            {
              "if": {
                "and": [
                  "_bag_obj:building~*",
                  "_bag_obj:ref:bag~*",
                  "_bag_obj:in_construction=true"
                ]
              },
              "then": "{import_way_button(osm_buildings, building=$_bag_obj:building; construction=$_bag_obj:construction; ref:bag=$_bag_obj:ref:bag; source=BAG; source:date=$_bag_obj:source:date; start_date=$_bag_obj:start_date, Upload this building to OpenStreetMap)}"
            }
          ]
        },
        {
          "id": "Reference",
          "render": {
            "en": "The reference in BAG is <b>{_bag_obj:ref:bag}</b>",
            "de": "Die Referenz in BAG ist <b>{_bag_obj:ref:bag}</b>",
            "nl": "De referentie in BAG is <b>{_bag_obj:ref:bag}</b>",
            "fr": "La référence dans BAG est <b>{_bag_obj:ref:bag}</b>",
            "ca": "La referència a BAG és <b>{_bag_obj:ref:bag}</b>",
            "es": "La referencia en BAG es <b>{_bag_obj:ref:bag}</b>",
            "cs": "Reference v BAG je <b>{_bag_obj:ref:bag}</b>",
            "pl": "Odniesienie w BAG to <b>{_bag_obj:ref:bag}</b>",
            "zh_Hans": "在 BAG 中的参考文献是 <b>{_bag_obj:ref:bag}</b>",
            "fil": "Ang sanggunian sa BAG ay <b>{_bag_obj:ref:bag}</b>",
            "uk": "Посилання у BAG має вигляд <b>{_bag_obj:ref:bag}</b>",
            "zh_Hant": "在 BAG 的參考編號是 <b>{_bag_obj:ref:bag}</b>",
            "ko": "BAG에서 레퍼런스는 <b>{_bag_obj:ref:bag}</b> 입니다"
          }
        },
        {
          "id": "Build year",
          "render": {
            "en": "This building was built in <b>{_bag_obj:start_date}</b>",
            "de": "Dieses Gebäude wurde gebaut in <b>{_bag_obj:start_date}</b>",
            "pt_BR": "Esta construção é de <b>{_bag_obj:start_date}</b>",
            "nl": "Dit gebouw is gebouwd in <b>{_bag_obj:start_date}</b>",
            "fr": "Le bâtiment a été construit en <b>{_bag_obj:start_date}</b>",
            "ca": "L’edifici va ser construït al <b> {_bag_obj:start_date}4</b>",
            "es": "Este edificio se construyó en <b>{_bag_obj:start_date}</b>",
            "cs": "Tato budova byla postavena v <b>{_bag_obj:start_date}</b>",
            "nb_NO": "Bygning oppført <b>{_bag_obj:start_date}</b>",
            "pl": "Ten budynek zbudowano w <b>{_bag_obj:start_date}</b>",
            "pt": "Esta construção é de <b>{_bag_obj:start_date}</b>",
            "zh_Hans": "这座建筑建于 <b>{_bag_obj:start_date}</b>",
            "fil": "Ang gusaling ito ay itinayo noong <b>{_bag_obj:start_date}</b>",
            "uk": "Ця будівля була побудована у <b>{_bag_obj:start_date}</b>",
            "zh_Hant": "這棟建築是<b>{_bag_obj:start_date}</b>建造的",
            "ko": "이 건물은 <b>{_bag_obj:start_date}</b>에 지어졌습니다"
          },
          "mappings": [
            {
              "if": "_bag_obj:in_construction=true",
              "then": {
                "en": "The building was started in <b>{_bag_obj:start_date}</b>",
                "de": "Der Bau wurde in <b>{_bag_obj:start_date}</b> begonnen",
                "nl": "De bouw van dit gebouw is gestart in <b>{_bag_obj:start_date}</b>",
                "fr": "Le bâtiment a été commencé en <b>{_bag_obj:start_date}</b>",
                "ca": "L’edifici es va començar al <b> {_bag_obj:start_date}</b>",
                "cs": "Stavba byla zahájena v <b>{_bag_obj:start_date}</b>",
                "nb_NO": "Oppføring startet <b>{_bag_obj:start_date}</b>",
                "es": "La construcción del edificio comenzó en <b>{_bag_obj:start_date}</b>",
                "pl": "Budynek został zbudowany w <b>{_bag_obj:start_date}</b>",
                "zh_Hans": "该建筑始建于 <b>{_bag_obj:start_date}</b>",
                "fil": "Sinimulan ang gusali noong <b>{_bag_obj:start_date}</b>",
                "uk": "Будівництво було розпочато у <b>{_bag_obj:start_date}</b>",
                "zh_Hant": "這棟建築的啟用時間是 <b>{_bag_obj:start_date}</b>",
                "ko": "이 건물은 <b>{_bag_obj:start_date}</b>에 착공되었습니다"
              }
            }
          ]
        },
        {
          "id": "Building type",
          "render": {
            "en": "The building type is a <b>{_bag_obj:building}</b>",
            "de": "Der Gebäudetyp ist ein <b>{_bag_obj:building}</b>",
            "nl": "Het gebouwtype is <b>{_bag_obj:building}</b>",
            "fr": "Le type de bâtiment est <b>{_bag_obj:building}</b>",
            "ca": "El tipus d'edifici és <b>{_bag_obj:building}</b>",
            "cs": "Typ budovy je <b>{_bag_obj:building}.</b>",
            "nb_NO": "Dette er en bygning av typen <b>{_bag_obj:building}</b>",
            "es": "El tipo de edificio es un <b>{_bag_obj:building}</b>",
            "pl": "Rodzaj budynku to <b>{_bag_obj:building}</b>",
            "zh_Hans": "建筑类型是 <b>{_bag_obj:building}</b>",
            "fil": "Ang uri ng gusali ay <b>{_bag_obj:building}</b>",
            "uk": "Тип будівлі - <b>{_bag_obj:building}</b>",
            "zh_Hant": "這棟建築類型是<b>{_bag_obj:building}</b>",
            "ko": "건물 유형은 <b>{_bag_obj:building}</b> 입니다"
          },
          "mappings": [
            {
              "if": "_bag_obj:in_construction=true",
              "then": {
                "en": "The building type will be a <b>{_bag_obj:construction}</b>",
                "de": "Der Gebäudetyp ist ein <b>{_bag_obj:construction}</b>",
                "nl": "Het gebouwtype wordt <b>{_bag_obj:construction}</b>",
                "fr": "Le type de bâtiment sera <b>{_bag_obj:construction}</b>",
                "ca": "El tipus d'edifici serà <b>{_bag_obj:construction}</b>",
                "cs": "Typ budovy bude <b>{_bag_obj:construction}</b>",
                "es": "El tipo de edificio será un <b>{_bag_obj:construction}</b>",
                "pl": "Budynek będzie o typie <b>{_bag_obj:construction}</b>",
                "zh_Hans": "建筑类型将是 <b>{_bag_obj:construction}</b>",
                "fil": "Ang uri ng gusali ay magiging <b>{_bag_obj:construction}</b>",
                "uk": "Типом будівлі буде <b>{_bag_obj:construction}</b>",
                "zh_Hant": "這棟建築類型將會是<b>{_bag_obj:construction}</b>",
                "ko": "건물 유형은 <b>{_bag_obj:construction}</b>로 계획되어 있습니다"
              }
            }
          ]
        },
        {
          "id": "Overlapping building",
          "render": "<div>The overlapping <a href=https://osm.org/{_osm_obj:id} target=_blank>osm_buildings</a> is a <b>{_osm_obj:building}</b> and covers <b>{_overlap_percentage}%</b> of the BAG building.<br>The BAG-building covers <b>{_reverse_overlap_percentage}%</b> of the OSM building<div><h3>BAG geometry:</h3>{minimap(21, id):height:10rem;border-radius:1rem;overflow:hidden}<h3>OSM geometry:</h3>{minimap(21,_osm_obj:id):height:10rem;border-radius:1rem;overflow:hidden}</div></div>",
          "condition": "_overlaps_with!="
        },
        {
          "id": "Building status",
          "render": "The current building status is <b>{status}</b>"
        },
        {
          "id": "Buidling function",
          "render": "The current function of the building is <b>{gebruiksdoel}</b>"
        }
      ],
      "pointRendering": [
        {
          "label": {
            "render": "<div style='color: black' class='rounded-full p-1 font-bold relative'>{_bag_obj:addr:housenumber}</div>",
            "mappings": [
              {
                "if": "_imported_osm_object_found=true",
                "then": "<div style='color: #107c10' class='rounded-full p-1 font-bold relative'>{_bag_obj:addr:housenumber}</div>"
              }
            ]
          },
          "location": [
            "point",
            "centroid"
          ]
        }
      ],
      "lineRendering": [
        {
          "width": {
            "render": 1
          }
        }
      ],
      "allowMove": false
    },
    {
      "id": "bag_verblijfsobject",
      "name": "BAG Addresses",
      "title": "BAG Address",
      "description": "Address information from the BAG register",
      "source": {
        "geoJson": "https://service.pdok.nl/lv/bag/wfs/v2_0?request=GetFeature&service=WFS&version=2.0.0&outputFormat=application%2Fjson%3B%20subtype%3Dgeojson&typeName=bag%3Averblijfsobject&bbox={x_min}%2C{y_min}%2C{x_max}%2C{y_max}%2CCRS84&srsName=EPSG%3A4326",
        "geoJsonZoomLevel": 19,
        "osmTags": "identificatie~*"
      },
      "minzoom": 18,
      "calculatedTags": [
        "_closed_osm_addr:=closest(feat)('osm_adresses').properties",
        "_bag_obj:addr:housenumber=`${feat.properties.huisnummer}${feat.properties.huisletter}${(feat.properties.toevoeging != '') ? '-' : ''}${feat.properties.toevoeging}`",
        "_bag_obj:ref:bag=Number(feat.properties.identificatie)",
        "_bag_obj:source:date=new Date().toISOString().split('T')[0]",
        "_osm_obj:addr:city:=get(feat)('_closed_osm_addr')['addr:city']",
        "_osm_obj:addr:housenumber:=get(feat)('_closed_osm_addr')['addr:housenumber']",
        "_osm_obj:addr:postcode:=get(feat)('_closed_osm_addr')['addr:postcode']",
        "_osm_obj:addr:street:=get(feat)('_closed_osm_addr')['addr:street']",
        "_imported_osm_object_found:=(feat.properties.woonplaats==get(feat)('_closed_osm_addr')['addr:city'])&&(get(feat)('_bag_obj:addr:housenumber')==get(feat)('_closed_osm_addr')['addr:housenumber'])&&(feat.properties.postcode==get(feat)('_closed_osm_addr')['addr:postcode'])&&(feat.properties.openbare_ruimte==get(feat)('_closed_osm_addr')['addr:street'])"
      ],
      "tagRenderings": [
        {
          "id": "Import button",
          "render": "{import_button(osm_adresses, addr:city=$woonplaats; addr:housenumber=$_bag_obj:addr:housenumber; addr:postcode=$postcode; addr:street=$openbare_ruimte; ref:bag=$_bag_obj:ref:bag; source=BAG; source:date=$_bag_obj:source:date, Upload this adress to OpenStreetMap)}",
          "condition": "_imported_osm_object_found=false"
        },
        {
          "id": "Address",
          "render": "{openbare_ruimte} {_bag_obj:addr:housenumber}, {woonplaats} {postcode}"
        }
      ],
      "pointRendering": [
        {
          "label": {
            "render": "<div style='color: black' class='rounded-full p-1 font-bold relative'>{_bag_obj:addr:housenumber}</div>",
            "mappings": [
              {
                "if": "_imported_osm_object_found=true",
                "then": "<div style='color: #107c10' class='rounded-full p-1 font-bold relative'>{_bag_obj:addr:housenumber}</div>"
              }
            ]
          },
          "location": [
            "point",
            "centroid"
          ]
        }
      ],
      "lineRendering": [
        {
          "width": {
            "render": 1
          }
        }
      ],
      "allowMove": false
    }
  ]
}
