/**
 * 航道疏浚
 * */

import {addLayerByName} from '@/utils/map/Layer'
import {setCenter} from '@/utils/map/Common'
import {addLayer, clearMap, layerQuery, setCamera, setOpacity} from '@/utils/map/ArcgisUtil'

export function locationYjModel(id,isShow){
    if(isShow){
        // addLayerByName('yjyj',isShow)
        if(id == 1){
            setCamera({
                x:3828.9822642555864,
                y:1293.9468757685618,
                z:11133.158111727356,
                heading:79.58837854750546,
                tilt:0
            })
        }else if(id == 40){
            setCamera({
                x:2795.766454812971,
                y:-1429.0431937951837,
                z:6679.973849694631,
                heading:79.5883785488088,
                tilt:0
            })
        }
    }else{
        setCenter()
    }

}

/**
 * 数据前后对比
 * @param value
 * @param isShow
 */
let sjdbList = ['2022LjzBefore','2022LjzAfter']
let isShowSjdb = false
export function compareSjBeforeAfter(value,isShow) {
    if(isShow){
        setOpacity(0.4)
        sjdbList.forEach(item=>{
            if(item != value){
                addLayerByName(item,false,1);
            }
        })
    }else{
        if(value == null || value == ''){
            sjdbList.forEach(item=>{
                addLayerByName(item,false,1);
            })
            setOpacity(1)
        }
    }
    switch(value){
        case '2022LjzBefore':
            addLayerByName('2022LjzBefore',isShow,1);
            break
        case '2022LjzAfter':
            addLayerByName('2022LjzAfter',isShow,1);
            break
    }
}

/**
 * 维护水深面
 */
export function showWhss(isShow){
    console.log('维护水深面：'+isShow)
    addLayer({
        id: 'warterDeepsAreaLayer',
        title: 'warterDeepsAreaLayer',
        type: 'feature',
        url: 'http://10.83.68.109:6080/arcgis/rest/services/digitalTwain_3857/MapServer/8',
        visible: isShow,
        opacity: 1,
        token: '',
        is_goto: true
    })
    if(!isShow){
        locationOneWhss('',false)
    }
}

export function locationOneWhss(code,isShow){
    if(isShow){
        layerQuery({
            title: "digitalTwain",
            layerId: "8",
            where: "控制点区域='" + code + "'",
            symbol: null,
            is_draw: true,
            is_clear: false,
            callback: null
        })
    }else{
        clearMap({is_draw: true, is_search:true, layers: []})
    }
}