# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------------------------
# -- ItentifyFeatureSettings.py
#    Creates settings file for IdentifyFeatures
#
# -- Author: flu, 16.06.2021
# -- commandline: -
# -------------------------------------------------------------------------------------------------
# -- History
# --
# -------------------------------------------------------------------------------------------------
import json

_setting_filename = "IdentifyFeatures.json"

_settings = {}
_test_t_cfg = {}
_test_i_cfg = {}
_test_p_cfg = {}

# API3
_settings.update(
    {"api3_identify": "https://api3.geo.admin.ch/rest/services/api/MapServer/identify"}
)
_settings.update(
    {"api3_find": "https://api3.geo.admin.ch/rest/services/api/MapServer/find"}
)
_settings.update(
    {"api3_search": "https://api3.geo.admin.ch/rest/services/api/SearchServer"}
)
_settings.update({"lv95towgs84": "https://geodesy.geo.admin.ch/reframe/lv95towgs84"})

# Test
_test_t_cfg.clear()
_key = "tlm_hoheitsgebiet"
_value = (
    "https://s7t2530a.adr.admin.ch/arcgis/rest/services/PRODAS/PolitischeEinteilung/"
    "FeatureServer/3/query?"
)
_test_t_cfg.update({_key: _value})

_key = "tlm_bezirksgebiet"
_value = (
    "https://s7t2530a.adr.admin.ch/arcgis/rest/services/PRODAS/PolitischeEinteilung/"
    "FeatureServer/2/query?"
)
_test_t_cfg.update({_key: _value})

_key = "tlm_kantonsgebiet"
_value = (
    "https://s7t2530a.adr.admin.ch/arcgis/rest/services/PRODAS/PolitischeEinteilung/"
    "FeatureServer/1/query?"
)
_test_t_cfg.update({_key: _value})

_key = "ebm_adminunit_1"
_value = (
    "https://s7t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "FeatureServer/5/query"
)
_test_t_cfg.update({_key: _value})

_key = "ebm_adminunit_2"
_value = (
    "https://s7t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "FeatureServer/4/query"
)
_test_t_cfg.update({_key: _value})

_key = "ebm_adminunit_3"
_value = (
    "https://s7t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "FeatureServer/3/query"
)
_test_t_cfg.update({_key: _value})

_key = "ebm_adminunit_4"
_value = (
    "https://s7t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "FeatureServer/2/query"
)
_test_t_cfg.update({_key: _value})

_key = "ebm_adminunit_5"
_value = (
    "https://s7t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "FeatureServer/1/query"
)
_test_t_cfg.update({_key: _value})

_key = "ebm_adminunit_6"
_value = (
    "https://s7t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "FeatureServer/0/query"
)
_test_t_cfg.update({_key: _value})

_settings.update({"T": _test_t_cfg})

# Integration
_test_i_cfg.clear()
_key = "tlm_hoheitsgebiet"
_value = (
    "https://s0t2530a.adr.admin.ch/arcgis/rest/services/PRODAS/PolitischeEinteilung/"
    "MapServer/3/query?"
)
_test_i_cfg.update({_key: _value})

_key = "tlm_bezirksgebiet"
_value = (
    "https://s0t2530a.adr.admin.ch/arcgis/rest/services/PRODAS/PolitischeEinteilung/"
    "MapServer/2/query?"
)
_test_i_cfg.update({_key: _value})

_key = "tlm_kantonsgebiet"
_value = (
    "https://s0t2530a.adr.admin.ch/arcgis/rest/services/PRODAS/PolitischeEinteilung/"
    "MapServer/1/query?"
)
_test_i_cfg.update({_key: _value})

_key = "ebm_adminunit_1"
_value = (
    "https://s0t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "MapServer/5/query"
)
_test_i_cfg.update({_key: _value})

_key = "ebm_adminunit_2"
_value = (
    "https://s0t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "MapServer/4/query"
)
_test_i_cfg.update({_key: _value})

_key = "ebm_adminunit_3"
_value = (
    "https://s0t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "MapServer/3/query"
)
_test_i_cfg.update({_key: _value})

_key = "ebm_adminunit_4"
_value = (
    "https://s0t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "MapServer/2/query"
)
_test_i_cfg.update({_key: _value})

_key = "ebm_adminunit_5"
_value = (
    "https://s0t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "MapServer/1/query"
)
_test_i_cfg.update({_key: _value})

_key = "ebm_adminunit_6"
_value = (
    "https://s0t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "MapServer/0/query"
)
_test_i_cfg.update({_key: _value})

_settings.update({"I": _test_i_cfg})

# Produktion
_test_p_cfg.clear()
_key = "tlm_hoheitsgebiet"
_value = (
    "https://s7t2530a.adr.admin.ch/arcgis/rest/services/PRODAS/PolitischeEinteilung/"
    "FeatureServer/3/query?"
)
_test_p_cfg.update({_key: _value})

_key = "tlm_bezirksgebiet"
_value = (
    "https://s7t2530a.adr.admin.ch/arcgis/rest/services/PRODAS/PolitischeEinteilung/"
    "FeatureServer/2/query?"
)
_test_p_cfg.update({_key: _value})

_key = "tlm_kantonsgebiet"
_value = (
    "https://s7t2530a.adr.admin.ch/arcgis/rest/services/PRODAS/PolitischeEinteilung/"
    "FeatureServer/1/query?"
)
_test_p_cfg.update({_key: _value})

_key = "ebm_adminunit_1"
_value = (
    "https://s7t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "FeatureServer/5/query"
)
_test_p_cfg.update({_key: _value})

_key = "ebm_adminunit_2"
_value = (
    "https://s7t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "FeatureServer/4/query"
)
_test_p_cfg.update({_key: _value})

_key = "ebm_adminunit_3"
_value = (
    "https://s7t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "FeatureServer/3/query"
)
_test_p_cfg.update({_key: _value})

_key = "ebm_adminunit_4"
_value = (
    "https://s7t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "FeatureServer/2/query"
)
_test_p_cfg.update({_key: _value})

_key = "ebm_adminunit_5"
_value = (
    "https://s7t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "FeatureServer/1/query"
)
_test_p_cfg.update({_key: _value})

_key = "ebm_adminunit_6"
_value = (
    "https://s7t2530a.adr.admin.ch:6443/arcgis/rest/services/PRODAS/EuroBoundaryMap/"
    "FeatureServer/0/query"
)
_test_p_cfg.update({_key: _value})

_settings.update({"P": _test_p_cfg})

with open(_setting_filename, "w") as _config:
    json.dump(_settings, _config, indent=4)
