tuoheng_virtualAirPlan_web/src/apis/common.js

137 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import request from '@/utils/request'
import axios from 'axios'
//机场查询
export function queryAirportApi(params) {
return request({
url: `/api/airportStatus/index`,
method: 'get',
params: params,
})
}
//无人机查询
export function queryDroneApi(params) {
return request({
url: `/api/drone/getDroneList`,
method: 'get',
params: params,
})
}
//电池查询
export function queryBatteryApi(params) {
return request({
url: `/api/batteryRecord/queryBatteryBaseInfoList`,
method: 'get',
params: params,
})
}
//航线查询
// api/airlineFile/getAirlineFileListByAirportId?airportId=67
export function queryAirLineApi(params) {
return request({
url: `api/airlineFile/getAirlineFileListByAirportId`,
method: 'get',
params: params,
})
}
//无人机飞前自检
export function beforeCheckApi(params) {
return request({
url: `/api/airportLog/virtualCockpit/progressBar`,
method: 'get',
params: params,
})
}
//获取航线文件
export async function getAirWayPointsToJson(url) {
// console.log(url)
let res = await axios.get(url)
if (res.status === 200) {
const text = res.data
let mapPointList = []
let arr = text.split('\r\n')
if (arr.length <= 1) {
arr = text.split('\n')
}
arr.shift()
arr.pop()
// console.log(arr)
arr = arr.map((text) => {
return text.split(/\s+/)
})
// 删除前两个起飞点(不使用)
arr.splice(0, 2)
// 删除最后一个降落点(不删除)
arr.pop()
// 航线节点
for (let i = 0; i < arr.length; i++) {
const stop = arr[i]
if (stop[3] == 16) {
// 地图点,用于绘制
mapPointList.push({
// id
id: mapPointList.length + 1,
// 经纬度
lngLat: [parseFloat(stop[9]), parseFloat(stop[8])],
alt: parseInt(stop[10]), // 高度
// type: Number(stop[3]), //航点类型gis需要
})
}
}
// console.log(mapPointList)
return mapPointList
}
}
export async function getAirWayPointsToJson2(url) {
// console.log(url)
let res = await axios.get(url)
if (res.status === 200) {
const text = res.data
let mapPointList = []
let arr = text.split('\r\n')
if (arr.length <= 1) {
arr = text.split('\n')
}
arr.shift()
arr.pop()
console.log(arr)
arr = arr.map((text) => {
return text.split(/\s+/)
})
// 删除前两个起飞点(不使用)
// arr.splice(0, 2)
// 删除第一个起飞点
arr.splice(0, 1)
// 删除最后一个降落点(不删除)
// arr.pop()
// 航线节点
for (let i = 0; i < arr.length; i++) {
const stop = arr[i]
if (parseInt(stop[3]) == 16 || parseInt(stop[3]) == 20 || parseInt(stop[3]) == 22) {
// 地图点,用于绘制
mapPointList.push({
// id
id: mapPointList.length + 1,
// 经纬度
lngLat: [parseFloat(stop[9]), parseFloat(stop[8])],
alt: parseInt(stop[10]), // 高度
type: Number(stop[3]), //航点类型gis需要
})
}
}
// console.log(mapPointList)
return mapPointList
}
}
//获取天气
export function getweatherApi(params) {
return request({
url: `/api/airportLog/getCallback`,
method: 'get',
params: params,
})
}