function TaskLandAction(context, id, ext){
    this.context = context
    this.id = id
    this.selected = {}
    this.popup = null
    this.tipLayer = null
    this.obj = new TaskLand({
        url : context.local_wfs_path,
        status : ext.status
    })
}

TaskLandAction.prototype = {
    clickLock:false,
    startStatus : false,
    createStatus : false,
    create(){
        let that = this
        this.obj.getTileLayer()
        this.popup = new Popup({map: this.context.currentMap,
            close(){
                that.clickLock = false
            },
            buttons:[
                {"name":"放大到合适","click":"fit"}
            ],
            listener: {
                info(){
                    window.location = "/field_point/info"
                },
                fit(popup, event, ext){
                    that.context.currentView.fit(ext.getGeometry(),{duration:1000})
                }
            }
        });
        this.createStatus = true;
    },
    start(){
        if(this.startStatus){
            console.log("startStatus is true")
            return
        }
        this.context.clicks[this.id] = this
        this.context.currentMap.addLayer(this.obj.layerData.layer)
        let source = this.obj.layerData.layer.getSource();
        let that = this;

        if(that.tipLayer){
            that.context.currentMap.addLayer(that.tipLayer.vector)
            that.context.currentView.fit(source.getExtent(),{duration:1000})
        }else{
            source.on("featuresloadend",function(){
                that.tipLayer = new TipLayer({features: source.getFeatures(), zIndex:3, style: globalStyle.pointStyle })
                that.context.currentMap.addLayer(that.tipLayer.vector)
                that.context.currentView.fit(source.getExtent(),{duration:1000})
            })
        }

        this.context.getSldStyleSign(this.obj.wmsData.params.STYLE)
        this.startStatus = true;
    },
    stop(){
        if(!this.startStatus){
            console.log("startStatus is false")
            return
        }
        this.context.currentMap.removeLayer(this.obj.layerData.layer)
        this.context.currentMap.removeLayer(this.tipLayer.vector)
        console.log("tempVectorLayer cleared")
        this.context.clicks[this.id] = null
        console.log("remove click")
        this.popup._close()
        console.log("close popup")
        this.startStatus = false;
    }
    ,
    landType:{
        0:"其他",
        1:"湿地",
        2:"耕地",
        3:"种植",
        4:"林地",
        5:"草地",
        6:"水域",
    },getInfoHtml(feature){
        let html = ""
        let data = {
            "地块类别":this.landType[feature.get("gridcode")],
            "地块图斑编号":feature.get("id"),
            "地块面积(亩)":feature.get("area"),
            "地块周长(米)":"10000",
        }
        for(let key in data){
            html += "<div class='layui-row'><div class='lab' >"+key+"</div><div class='val' >"+data[key]+"</div></div>"
        }
        return html
    }

}

function TaskLand(opt){

    this.name = "TaskLand"

    this.wmsData = {
        url: opt.url,
        projection: new ol.proj.Projection({
            code: 'EPSG:4326',
            units: 'degrees',
            axisOrientation: 'neu'
        }),
        params:{
            'LAYER': "wuhan:p_crop",
            'STATUS': opt.status,
            'STYLE': "wuhan:city_land",
        }
    }
    this.layerData = {
        layer : null,
        source : null,
        select : null,
        always : false
    }
}

TaskLand.prototype = {
    getTileLayer(){
        let url = this.wmsData.url +
            "?service=WFS&version=1.0.0&request=GetFeature&typeName="+this.wmsData.params["LAYER"]+"&maxFeatures=1000&outputFormat=application/json"
        url+="&Filter=(<Filter>" +
            "<ogc:PropertyIsEqualTo  xmlns:ogc=\"http://www.opengis.net/ogc\" ><ogc:PropertyName>status</ogc:PropertyName>" +
            "<ogc:Literal>"+this.wmsData.params["STATUS"]+"</ogc:Literal></ogc:PropertyIsEqualTo></Filter>)"
        console.log(url)
        let myGeoJsonLayer = new MyGeoJsonLayer({url: url, zIndex:2, style: this.style})
        this.layerData.layer = myGeoJsonLayer.vector;
    },style(f){
        return globalStyle.cityLand(f.get("gridcode"))
    },

}