/**
 * 太湖一张图 ArcGIS 要素服务图层
 * 所有FeatureLayer/MapImageLayer，地图初始时预加载（visible=false）
 * 勾选图层时切换visible
 */
const ARCGIS = 'http://10.8.4.128/server/rest/services'

export const taihuServiceLayers = [
  // ===== 基础信息 =====
  { id: 'th_jcys0',     name: '河流',         type: 'feature',  url: ARCGIS + '/HHGL/HHGL_HL/MapServer' },
  { id: 'th_jcys1',     name: '湖泊',         type: 'feature',  url: ARCGIS + '/HHGL/HHGL_HP/MapServer' },
  { id: 'th_jcys2',     name: '水库',         type: 'feature',  url: ARCGIS + '/HHGL/HHGL_SK/MapServer' },
  { id: 'th_gjjbswz1', name: '水文',         type: 'mapimage',  url: ARCGIS + '/HHGL/HHGL_SW/MapServer' },
  { id: 'th_gjjbswz7', name: '水位',         type: 'feature',  url: ARCGIS + '/HHGL/HHGL_SWZ/MapServer' },
  { id: 'th_gjjbswz8', name: '雨量',         type: 'feature',  url: ARCGIS + '/HHGL/HHGL_YL/MapServer' },
  { id: 'th_dbsqsh0',  name: '取水户',       type: 'feature',  url: ARCGIS + '/HHGL/HHGL_QSH/MapServer' },
  { id: 'th_slfq',     name: '水利分区',     type: 'mapimage',  url: ARCGIS + '/HHGL/HHGL_SLFQ/MapServer' },
  { id: 'th_bz',       name: '泵站',         type: 'feature',  url: ARCGIS + '/HHGL/HHGL_BZ/MapServer' },
  // 以下暂用近似URL，后续确认
  { id: 'th_xjb',      name: '橡胶坝',       type: 'feature',  url: ARCGIS + '/HHGL/HHGL_XJB/MapServer' },
  { id: 'th_gq',       name: '灌区',         type: 'feature',  url: ARCGIS + '/HHGL/HHGL_GQ/MapServer' },
  { id: 'th_qd',       name: '渠道',         type: 'feature',  url: ARCGIS + '/HHGL/HHGL_QD/MapServer' },
  { id: 'th_ydsgc',    name: '引调水工程',   type: 'feature',  url: ARCGIS + '/HHGL/HHGL_YDSGC/MapServer' },

  // ===== 一湖两河口门 =====
  { id: 'th_slgc1',    name: '环湖口门',     type: 'feature',  url: ARCGIS + '/HHGL/HHGL_YHLHKM/MapServer/0' },
  { id: 'th_slgc2',    name: '太浦河口门',   type: 'feature',  url: ARCGIS + '/HHGL/HHGL_YHLHKM/MapServer/1' },
  { id: 'th_slgc3',    name: '望虞河口门',   type: 'feature',  url: ARCGIS + '/HHGL/HHGL_YHLHKM/MapServer/2' },

  // ===== 堤防岸段 =====
  { id: 'th_slgc15',   name: '一级堤防',     type: 'feature',  url: ARCGIS + '/HHGL/HHGL_DFAD/MapServer/0' },
  { id: 'th_slgc16',   name: '二三级堤防',   type: 'feature',  url: ARCGIS + '/HHGL/HHGL_DFAD/MapServer/1' },
  { id: 'th_slgc17',   name: '其他堤防',     type: 'feature',  url: ARCGIS + '/HHGL/HHGL_DFAD/MapServer/2' },

  // ===== 岸线 =====
  { id: 'anxian23',    name: '太湖岸线',     type: 'feature',  url: ARCGIS + '/HHGL/HHGL_AX/MapServer/0' },
  { id: 'anxian27',    name: '太湖岛屿岸线', type: 'feature',  url: ARCGIS + '/HHGL/HHGL_AX/MapServer/4' },
  { id: 'anxian24',    name: '淀山湖',       type: 'feature',  url: ARCGIS + '/HHGL/HHGL_AX/MapServer/1' },
  { id: 'anxian25',    name: '太浦河',       type: 'feature',  url: ARCGIS + '/HHGL/HHGL_AX/MapServer/2' },
  { id: 'anxian26',    name: '望虞河',       type: 'feature',  url: ARCGIS + '/HHGL/HHGL_AX/MapServer/3' },
]

// 底图 WMTS
export const taihuBaseMap = {
  id: 'taihu_basemap', title: '太湖一张图', type: 'mapserver',
  url: ARCGIS + '/OneMap/TH_XZQH_2000/MapServer', visible: true
}

export const tianditu = {
  img: { id: 'tianditu_img', title: '天地图影像',
    urlTemplate: 'http://{subDomain}.mwr.gov.cn:81/img_c/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=img&STYLE=default&FORMAT=tiles&TILEMATRIXSET=c&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}',
    subDomains: ['tdt'] },
  imgLabel: { id: 'tianditu_img_label', title: '天地图影像注记',
    urlTemplate: 'http://{subDomain}.mwr.gov.cn:81/cia_c/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=cia&STYLE=default&FORMAT=tiles&TILEMATRIXSET=c&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}',
    subDomains: ['tdt'] },
  vec: { id: 'tianditu_vec', title: '天地图矢量',
    urlTemplate: 'http://{subDomain}.mwr.gov.cn:81/vec_c/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=vec&STYLE=default&FORMAT=tiles&TILEMATRIXSET=c&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}',
    subDomains: ['tdt'] },
  vecLabel: { id: 'tianditu_vec_label', title: '天地图矢量注记',
    urlTemplate: 'http://{subDomain}.mwr.gov.cn:81/cva_c/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=cva&STYLE=default&FORMAT=tiles&TILEMATRIXSET=c&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}',
    subDomains: ['tdt'] },
}

export const supermapLabel = {
  id: 'supermap_label', title: '超图注记',
  urlTemplate: 'http://{subDomain}.mwr.gov.cn/iserver/services/XZQH_HZZR/wmts100?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=XZQH_HZZR&STYLE=Default&FORMAT=image/png&TILEMATRIXSET=Custom_XZQH_HZZR&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}',
  subDomains: ['map']
}

export const supermapRiver = {
  id: 'supermap_river', title: '超图水系',
  urlTemplate: 'http://{subDomain}.mwr.gov.cn/iserver/services/RIVER_R/wmts100?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&LAYER=RIVER_R&STYLE=Default&FORMAT=image/png&TILEMATRIXSET=Custom_RIVER_R&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}',
  subDomains: ['map']
}

export const basemapGroups = {
  taihu: {
    name: '太湖一张图',
    layers: [
      { ...taihuBaseMap, index: 0 },
      { ...supermapRiver, index: 1 },
      { ...supermapLabel, index: 2 }
    ]
  },
  tianditu_img: {
    name: '天地图影像',
    layers: [
      { ...tianditu.img, index: 0 },
      { ...tianditu.imgLabel, index: 1 },
      { ...supermapRiver, index: 2 }
    ]
  },
  tianditu_vec: {
    name: '天地图矢量',
    layers: [
      { ...tianditu.vec, index: 0 },
      { ...tianditu.vecLabel, index: 1 },
      { ...supermapRiver, index: 2 }
    ]
  }
}
