import {requestGet,requestZWGet, requestNetPost, requestPost} from "./index.js";


export function getProxyToken(name,password){
    return requestZWGet({
        url:'/security/getToken',
        params:{
            "username": name,
            "key": password
        }
    })
}
//查询航线数据
export function queryPathsInfo(){
    return requestNetPost({
        url:'/pg/airLine/query',
        data:{
            "fullExport": true
        }
    })
}


//查询网格尺寸
export function gridBaseInfo(params){
    return requestPost({
        url:'/LowAltitudeGrid/gridBaseInfo',
        data:{
            "locationPoint": {
                "mapX": params.x,
                "mapY": params.y
            },
            "radiusInMeters": params.radius,
            "level":params.level,
            "type": 1
        }
    })
}

//查询权重
export function getPowerPoint(params){
    return requestNetPost({
        url:'/DataSearch/grid/search/v3/calculateWeight',
        // header:{
        //     'Content-Encoding': 'gzip'
        // },
        data:{
            "locationPoint": {
                "mapX":  params.x,
                "mapY":  params.y
            },
            "radiusInMeters": params.radius,
            "minZ": params.minZ,
            "maxZ": params.maxZ,
            "routes": [
                //  "G001133223-031112-303001.1|000000000000000000000001"
            ],
            "fields":["gridCode","x","y","z","element","boxSize","level"],
            "scrollPage": {
                "pageIndex": 1,
                "pageSize": 100000,
                "scrollId": params.scrollId
            },
            "version": "v3",
            "isShowInfo":0,
            "level":params.level
        }
    })
}

//范围查询权重网格
export function getPowerPointByPolygon(params){
    return requestNetPost({
        url:'/DataSearch/grid/search/v3/calculateWeight',
        // header:{
        //     'Content-Encoding': 'gzip'
        // },
        data:{
            "geoShapeQuery": {
                "fieldName": "locationPoint",
                "relation": "intersects",
                "shape": {
                    "type": "Polygon",
                    "coordinates":params.rings,
                }
            },
            "minZ": params.minZ,
            "maxZ": params.maxZ,
            "routes": [
                //  "G001133223-031112-303001.1|000000000000000000000001"
            ],
            "fields":["gridCode","x","y","z","element","boxSize","level"],
            "scrollPage": {
                "pageIndex": 1,
                "pageSize": 100000,
                "scrollId": params.scrollId
            },
            // "scoreMap": {
            //     "9.0": -999,
            //     "12.0": -999,
            //     "13.0": -999,
            //     "5.0": -999,
            //     "7.0": -999
            // },
            // "elementCount":{
            //     "7.0":1, //禁飞区
            //     "9.0":1,  //建筑物
            //     "12.0":1,  //起降场
            //     "13.0":1,  //航线
            // },
            "isShowInfo":0,
            "level":13
        }
    })
}



//范围查询占用网格
export function getOccupyPointByPolygon(params){
    return requestNetPost({
        url:'/DataSearch/grid/search/v3/calculateWeight',
        // header:{
        //     'Content-Encoding': 'gzip'
        // },
        data:{
            "geoShapeQuery": {
                "fieldName": "locationPoint",
                "relation": "intersects",
                "shape": {
                    "type": "Polygon",
                    "coordinates":params.rings,
                    // "coordinates": [
                    //         [
                    //             [
                    //                 4510.965178032473,
                    //                 8630.368364146465,
                    //                 0
                    //             ],
                    //             [
                    //                 5172.681364747654,
                    //                 6222.235213498214,
                    //                 0
                    //             ],
                    //             [
                    //                 3592.9849815986345,
                    //                 5788.15954811861,
                    //                 0
                    //             ],
                    //             [
                    //                 2931.26796348097,
                    //                 8196.293085792775,
                    //                 0
                    //             ],
                    //             [
                    //                 4510.965178032473,
                    //                 8630.368364146465,
                    //                 0
                    //             ]
                    //         ]
                    //     ]
                }
            },
            "minZ": params.minZ,
            "maxZ": params.maxZ,
            "routes": [
                //  "G001133223-031112-303001.1|000000000000000000000001"
            ],
            "fields":["gridCode","x","y","z","element","boxSize","level"],
            "scrollPage": {
                "pageIndex": 1,
                "pageSize": 100000,
                "scrollId": params.scrollId
            },
            // "scoreMap": {
            //     "9.0": -999,
            //     "12.0": -999,
            //     "13.0": -999,
            //     "5.0": -999,
            //     "7.0": -999
            // },
            // "elementCount":{
            //     "7.0":1, //禁飞区
            //     "9.0":1,  //建筑物
            //     "12.0":1,  //起降场
            //     "13.0":1,  //航线
            // },
            "isShowInfo":0,
            "level":13
        }
    })
}


//漏斗查询权重网格
export function getPowerPointByFunnel(params){
    return requestNetPost({
        url:'/DataSearch/grid/search/cutUsingFunnel',
        // header:{
        //     'Content-Encoding': 'gzip'
        // },
        data:{
            "level": params.level,
            "point": params.point,
            "coneHeight": params.coneHeight,
            "cylinderHeight": params.cylinderHeight,
            "topRadius": params.topRadius,
            "bottomRadius": params.bottomRadius
        }
    })
}


//圆台查询权重网格
export function getPowerPointByFrustumCone(params){
    return requestNetPost({
        url:'/DataSearch/grid/search/cutUsingFrustum',
        // header:{
        //     'Content-Encoding': 'gzip'
        // },
        data:{
            "level": params.level,
            "point": params.point,
            "height": params.height,
            "topRadius": params.topRadius,
            "bottomRadius": params.bottomRadius
        }
    })
}


//圆锥查询权重网格
export function getPowerPointByInvertedCone(params){
    return requestNetPost({
        url:'/DataSearch/grid/search/cutUsingCone',
        // header:{
        //     'Content-Encoding': 'gzip'
        // },
        data:{
            "level": params.level,
            "point": params.point,
            "height": params.height,
            "radius": params.radius,
        }
    })
}

//棱柱查询权重网格
export function getPowerPointByPrism(params){
    return requestNetPost({
        url:'/DataSearch/grid/search/cutPrism',
        // header:{
        //     'Content-Encoding': 'gzip'
        // },
        data:{
            "geoShapeQuery": {
                "fieldName": "locationPoint",
                "relation": "intersects",
                "shape": {
                    "type": "Polygon",
                    "coordinates": params.rings
                }
            },
            "minZ": 0,
            "maxZ": params.height * 1,
            "level": params.level,
        }
    })
}

//查询所有空域
export function getPrism(params){
    return requestNetPost({
        url:'/pg/airSpace/query',
        // header:{
        //     'Content-Encoding': 'gzip'
        // },
        data:{
            "fullExport": true
        }
    })
}


//查询所有航线
export function getPath(params){
    return requestNetPost({
        url:'/pg/airLine/query',
        // header:{
        //     'Content-Encoding': 'gzip'
        // },
        data:{
            "fullExport": true
        }
    })
}


//查询所有入库起降场
export function getQJC(params){
    return requestNetPost({
        url:'/pg/airPort/query',
        // header:{
        //     'Content-Encoding': 'gzip'
        // },
        data:{
            "fullExport": true
        }
    })
}


//航线查询网格
export function getPowerPointByPath(params){
    return requestNetPost({
        url:'/DataSearch/grid/search/cutUsingCylinderForPath',
        // header:{
        //     'Content-Encoding': 'gzip'
        // },
        data:{
            "paths": params.paths,
            "radius": params.radius,
            "level": params.level,
        }
    })
}


//查询规避路线
export function getAvoidRoute(params){
    return requestNetPost({
        url:'/DataSearch/routePlan/search/routeSkipPath',
        data:{
            "uavid": params.uavid,
            "skip_route_id": params.skip_route_id,
            "distance": params.distance
        }
    })
}

//查询建筑
export function getBuildingPoint(params){
    return requestNetPost({
        url:'/DataSearch/grid/search/collision/queryPageList',
        data:{
            "locationPoint": {
                "mapX":  params.x,
                "mapY": params.y
            },
            "radiusInMeters": 1000,
            "level":24,
            "minZ": 0,
            "maxZ": 120,
            "routes": [
                //  "G001133223-031112-303001.1|000000000000000000000001"
            ],
            "fields":["gridCode","x","y","z"],
            "scrollPage": {
                "pageIndex": 1,
                "pageSize": 10000,
                "scrollId": params.scrollId
            }
        }
    })
}


//查询禁飞区
export function getNoFlyPointInterface(params){
    return requestPost({
        url:'/LowAltitudeGrid/no_fly_zone/queryPageList',
        data:{
            "locationPoint": {
                "mapX":  params.x,
                "mapY": params.y
            },
            "radiusInMeters": 100000,
            "minZ": 0,
            "maxZ": 300,
            "routes": [
                //  "G001133223-031112-303001.1|000000000000000000000001"
            ],
            "level":params.level,
            "fields":["gridCode","x","y","z"],
            "scrollPage": {
                "pageIndex": 1,
                "pageSize": 10000,
                "scrollId": params.scrollId
            }
        }
    })
}

//查询权重网格
export function getPowerInterface(params){
    return requestNetPost({
        url:'/grid/search/calculateWeight',
        data:{
            "locationPoint": {
                "mapX":  params.x,
                "mapY":  params.y,
            },
            "radiusInMeters": 500,
            "minZ": 0,
            "maxZ": 120,
            "routes": [
                //  "G001133223-031112-303001.1|000000000000000000000001"
            ],
            "fields":["gridCode","x","y","z","locationPoint","element"],
            "elementFields":["collisionBuffer","demographics","green","noFlyZoneBuffer","passAbility","river","road"],
            "scrollPage": {
                "pageIndex": 1,
                "pageSize": 2000,
                "scrollId": params.scrollId
            }
        }
    })
}



//查询道路
export function getRoadPointInterface(params){
    return requestPost({
        url:'/LowAltitudeGrid/road/queryPageList',
        data:{
            "locationPoint": {
                "mapX":  params.x,
                "mapY": params.y
            },
            "radiusInMeters": 100000,
            "minZ": 0,
            "maxZ": 300,
            "routes": [
                //  "G001133223-031112-303001.1|000000000000000000000001"
            ],
            "level":params.level,
            "fields":["gridCode","x","y","z"],
            "scrollPage": {
                "pageIndex": 1,
                "pageSize": 10000,
                "scrollId": params.scrollId
            }
        }
    })
}


//查询河流
export function getRiverPointInterface(params){
    return requestPost({
        url:'/LowAltitudeGrid/river/queryPageList',
        data:{
            "locationPoint": {
                "mapX":  params.x,
                "mapY": params.y
            },
            "radiusInMeters": 100000,
            "minZ": 0,
            "maxZ": 300,
            "routes": [
                //  "G001133223-031112-303001.1|000000000000000000000001"
            ],
            "level":params.level,
            "fields":["gridCode","x","y","z"],
            "scrollPage": {
                "pageIndex": 1,
                "pageSize": 10000,
                "scrollId": params.scrollId
            }
        }
    })
}