【类 型】:factor 经度字段命名改为lon

【原  因】:和后端 统一命名
【过  程】:
【影  响】:
This commit is contained in:
tk 2024-09-19 13:09:43 +08:00
parent a308ab67c4
commit 7c9f899e54
7 changed files with 75 additions and 74 deletions

View File

@ -93,9 +93,9 @@ export default {
rtlRemaining () { rtlRemaining () {
let rtlTime = 0 // let rtlTime = 0 //
if (this.planePosition && this.homePosition && this.wpnavSpeed) { if (this.planePosition && this.homePosition && this.wpnavSpeed) {
const planeLngLat = { lat: this.planePosition[1], lon: this.planePosition[0] } const planeLonLat = { lat: this.planePosition[1], lon: this.planePosition[0] }
const homeLngLat = { lat: this.homePosition.lat, lon: this.homePosition.lng } const homeLonLat = { lat: this.homePosition.lat, lon: this.homePosition.lon }
const horizontalDistance = geodist(planeLngLat, homeLngLat, { unit: 'meters' }) // const horizontalDistance = geodist(planeLonLat, homeLonLat, { unit: 'meters' }) //
const verticalDistance = Math.abs(this.planePosition[2] - this.homePosition.alt) // const verticalDistance = Math.abs(this.planePosition[2] - this.homePosition.alt) //
const rtlDistance = horizontalDistance + verticalDistance // + const rtlDistance = horizontalDistance + verticalDistance // +
rtlTime = Math.floor(Number(rtlDistance) / Number(this.wpnavSpeed)) // rtlTime = Math.floor(Number(rtlDistance) / Number(this.wpnavSpeed)) //

View File

@ -959,6 +959,7 @@ export default {
} }
}, },
mounted () { mounted () {
console.log(this.$store.state.settings.host)
// //
if (this.executeOrder) { // if (this.executeOrder) { //
// //

View File

@ -15,9 +15,9 @@ export default {
return { return {
map: null, map: null,
planes: [], // planes: [], //
lngLats: [], // 线 lonLats: [], // 线
wayLngLats: [], // 线 wayLonLats: [], // 线
takeoffLngLats: [], // 线 takeoffLonLats: [], // 线
isflow: false, // isflow: false, //
currentStyleIndex: 0, // currentStyleIndex: 0, //
// //
@ -156,8 +156,8 @@ export default {
} }
}, },
computed: { computed: {
defaultLnglat () { defaultLonlat () {
return this.$store.getters['app/getDefaultLngLat'] return this.$store.getters['app/getDefaultLonLat']
}, },
defaultZoom () { defaultZoom () {
return this.$store.getters['app/getDefaultZoom'] return this.$store.getters['app/getDefaultZoom']
@ -209,17 +209,17 @@ export default {
this.map.on('mousedown', (event) => { this.map.on('mousedown', (event) => {
// pc // pc
pressTimer = setTimeout(() => { pressTimer = setTimeout(() => {
const lngLat = this.map.unproject(event.point) const lonLat = this.map.unproject(event.point)
// //
this.$emit('longPress', lngLat) this.$emit('longPress', lonLat)
}, 1000) // }, 1000) //
}) })
this.map.on('touchstart', (event) => { this.map.on('touchstart', (event) => {
// //
pressTimer = setTimeout(() => { pressTimer = setTimeout(() => {
const lngLat = this.map.unproject(event.point) const lonLat = this.map.unproject(event.point)
// //
this.$emit('longPress', lngLat) this.$emit('longPress', lonLat)
}, 1000) // }, 1000) //
}) })
// //
@ -242,7 +242,7 @@ export default {
this.map = new mapboxgl.Map({ this.map = new mapboxgl.Map({
container: 'map', container: 'map',
style: this.mapStyles[0], style: this.mapStyles[0],
center: this.defaultLnglat, center: this.defaultLonlat,
zoom: this.defaultZoom, zoom: this.defaultZoom,
pitch: 0, pitch: 0,
bearing: 0, bearing: 0,
@ -299,13 +299,13 @@ export default {
this.map.removeSource('home_point') this.map.removeSource('home_point')
this.map.removeLayer('takeoff_point_layer') this.map.removeLayer('takeoff_point_layer')
this.map.removeSource('takeoff_point') this.map.removeSource('takeoff_point')
for (let i = 2; i < this.lngLats.length - 1; i++) { for (let i = 2; i < this.lonLats.length - 1; i++) {
this.map.removeLayer('way_point_layer' + i) this.map.removeLayer('way_point_layer' + i)
this.map.removeSource('way_point' + i) this.map.removeSource('way_point' + i)
} }
this.lngLats = [] this.lonLats = []
this.wayLngLats = [] this.wayLonLats = []
this.takeoffLngLats = [] this.takeoffLonLats = []
} }
}, },
/** /**
@ -317,24 +317,24 @@ export default {
this.clearRoute() this.clearRoute()
// //
routeObj.questAss.tasks.forEach((element, index) => { routeObj.questAss.tasks.forEach((element, index) => {
const lngLat = [element.y, element.x, 100] const lonLat = [element.y, element.x, 100]
this.lngLats.push(lngLat) this.lonLats.push(lonLat)
if (index > 1 && index < routeObj.questAss.taskcount - 1) { if (index > 1 && index < routeObj.questAss.taskcount - 1) {
this.wayLngLats.push(lngLat) this.wayLonLats.push(lonLat)
} }
}) })
// home // home
this.goto(this.lngLats[0]) this.goto(this.lonLats[0])
// 线 // 线
if (routeObj.questAss.tasks[this.lngLats.length - 1].command === 20) { if (routeObj.questAss.tasks[this.lonLats.length - 1].command === 20) {
this.takeoffLngLats.push(this.lngLats[2]) this.takeoffLonLats.push(this.lonLats[2])
this.takeoffLngLats.push(this.lngLats[1]) this.takeoffLonLats.push(this.lonLats[1])
this.takeoffLngLats.push(this.lngLats[this.lngLats.length - 2]) this.takeoffLonLats.push(this.lonLats[this.lonLats.length - 2])
} else if ( } else if (
routeObj.questAss.tasks[this.lngLats.length - 1].command === 21 routeObj.questAss.tasks[this.lonLats.length - 1].command === 21
) { ) {
this.takeoffLngLats.push(this.lngLats[2]) this.takeoffLonLats.push(this.lonLats[2])
this.takeoffLngLats.push(this.lngLats[1]) this.takeoffLonLats.push(this.lonLats[1])
} }
// 线 // 线
@ -345,7 +345,7 @@ export default {
properties: {}, properties: {},
geometry: { geometry: {
type: 'LineString', type: 'LineString',
coordinates: this.takeoffLngLats coordinates: this.takeoffLonLats
} }
} }
}) })
@ -372,7 +372,7 @@ export default {
properties: {}, properties: {},
geometry: { geometry: {
type: 'LineString', type: 'LineString',
coordinates: this.wayLngLats coordinates: this.wayLonLats
} }
} }
}) })
@ -405,7 +405,7 @@ export default {
} }
}) })
// PS:home // PS:home
this.lngLats.forEach((item, index) => { this.lonLats.forEach((item, index) => {
// home // home
if (index === 0) { if (index === 0) {
// home // home
@ -441,10 +441,10 @@ export default {
// //
let takeoffPoint let takeoffPoint
// RETURN_TO_LAUNCH 20 LAND 21 // RETURN_TO_LAUNCH 20 LAND 21
if (routeObj.questAss.tasks[this.lngLats.length - 1].command === 20) { if (routeObj.questAss.tasks[this.lonLats.length - 1].command === 20) {
takeoffPoint = 'takeoffLandPoint' takeoffPoint = 'takeoffLandPoint'
} else if ( } else if (
routeObj.questAss.tasks[this.lngLats.length - 1].command === 21 routeObj.questAss.tasks[this.lonLats.length - 1].command === 21
) { ) {
takeoffPoint = 'takeoffPoint' takeoffPoint = 'takeoffPoint'
} }
@ -478,13 +478,13 @@ export default {
}) })
} else { } else {
// waypoint // waypoint
if (index !== this.lngLats.length - 1) { if (index !== this.lonLats.length - 1) {
// //
let wayPoint = 'wayPoint' let wayPoint = 'wayPoint'
if (index === this.lngLats.length - 2) { if (index === this.lonLats.length - 2) {
// LAND 21 waypoint // LAND 21 waypoint
if ( if (
routeObj.questAss.tasks[this.lngLats.length - 1].command === 21 routeObj.questAss.tasks[this.lonLats.length - 1].command === 21
) { ) {
wayPoint = 'wayLandPoint' wayPoint = 'wayLandPoint'
} }
@ -582,7 +582,7 @@ export default {
customIcon.style.height = '64px' // customIcon.style.height = '64px' //
// marker // marker
this.planes[index] = new mapboxgl.Marker(customIcon) this.planes[index] = new mapboxgl.Marker(customIcon)
.setLngLat([plane.lng, plane.lat]) .setLngLat([plane.lon, plane.lat])
.setPopup( .setPopup(
new mapboxgl.Popup({ offset: 25 }).setHTML( new mapboxgl.Popup({ offset: 25 }).setHTML(
'<h3>' + plane.name + '</h3><hr><p>macID:' + plane.macadd + '</p>' '<h3>' + plane.name + '</h3><hr><p>macID:' + plane.macadd + '</p>'
@ -601,22 +601,22 @@ export default {
}, },
/** /**
* @description: 实时更新经纬度 * @description: 实时更新经纬度
* @param {obj} lnglat lng经度 lat纬度 * @param {obj} lonLat lon经度 lat纬度
* @param {*} index 飞机序号 * @param {*} index 飞机序号
* @param {*} pathArr 飞机轨迹 痕迹坐标数组 * @param {*} pathArr 飞机轨迹 痕迹坐标数组
*/ */
setPlaneLngLat (lnglat, index, pathArr) { setPlaneLonLat (lonLat, index, pathArr) {
// //
const plane = this.planes[index] const plane = this.planes[index]
if (plane != null) { if (plane != null) {
plane.setLngLat([lnglat.lng, lnglat.lat]) plane.setLngLat([lonLat.lon, lonLat.lat])
} }
// //
this.createPathWithArray(pathArr) // this.createPathWithArray(pathArr) //
// //
if (this.isflow) { if (this.isflow) {
this.map.flyTo({ this.map.flyTo({
center: lnglat, center: lonLat,
speed: 2, speed: 2,
curve: 1, curve: 1,
easing (t) { easing (t) {
@ -627,11 +627,11 @@ export default {
}, },
/** /**
* @description: 镜头跳转 * @description: 镜头跳转
* @param {obj} lnglat {lng:lng,lat:lat} 经纬度 * @param {obj} lonLat {lon:lon,lat:lat} 经纬度
*/ */
goto (lnglat) { goto (lonLat) {
this.map.flyTo({ this.map.flyTo({
center: lnglat, center: lonLat,
speed: 2, speed: 2,
curve: 1, curve: 1,
easing (t) { easing (t) {
@ -662,7 +662,7 @@ export default {
}, },
beforeDestroy () { beforeDestroy () {
if (this.map) { if (this.map) {
this.$store.commit('app/setDefaultLngLat', this.map.getCenter()) // this.$store.commit('app/setDefaultLonLat', this.map.getCenter()) //
this.$store.commit('app/setDefaultZoom', this.map.getZoom()) // this.$store.commit('app/setDefaultZoom', this.map.getZoom()) //
this.map.remove() // this.map.remove() //
} }

View File

@ -3,7 +3,7 @@ const state = {
isCollapse: localStorage.getItem('isCollapse') ? !!+localStorage.getItem('isCollapse') : true, // 侧边导航栏 显隐 isCollapse: localStorage.getItem('isCollapse') ? !!+localStorage.getItem('isCollapse') : true, // 侧边导航栏 显隐
isMobile: null, // 是否是pc端 true电脑端 false为移动端 isMobile: null, // 是否是pc端 true电脑端 false为移动端
isWideScreen: window.innerWidth < 480, // 屏幕宽度是否小于480 isWideScreen: window.innerWidth < 480, // 屏幕宽度是否小于480
defaultLngLat: null, // 地图默认经纬度 defaultLonLat: null, // 地图默认经纬度
defaultZoom: null, // 地图默认缩放 defaultZoom: null, // 地图默认缩放
orderSerch: null// 订单列表页搜索条件 orderSerch: null// 订单列表页搜索条件
} }
@ -32,9 +32,9 @@ const mutations = {
} }
}, },
// 设置地图默认经纬度 // 设置地图默认经纬度
setDefaultLngLat (state, lngLat) { setDefaultLonLat (state, lonLat) {
state.defaultLngLat = lngLat state.defaultLonLat = lonLat
localStorage.setItem('defaultLngLat', JSON.stringify(lngLat)) localStorage.setItem('defaultLonLat', JSON.stringify(lonLat))
}, },
// 设置地图默认缩放值 // 设置地图默认缩放值
setDefaultZoom (state, zoom) { setDefaultZoom (state, zoom) {
@ -57,8 +57,8 @@ const actions = {
} }
const getters = { const getters = {
// 获取地图默认经纬度 缓存中没有从 localStorage中获取 也没有设置为0 // 获取地图默认经纬度 缓存中没有从 localStorage中获取 也没有设置为0
getDefaultLngLat () { getDefaultLonLat () {
return state.defaultLngLat !== null ? state.defaultLngLat : localStorage.getItem('defaultLngLat') !== null ? JSON.parse(localStorage.getItem('defaultLngLat')) : { lng: 0, lat: 0 } return state.defaultLonLat !== null ? state.defaultLonLat : localStorage.getItem('defaultLonLat') !== null ? JSON.parse(localStorage.getItem('defaultLonLat')) : { lon: 0, lat: 0 }
}, },
// 获取地图默认缩放值 缓存中没有从 localStorage中获取 也没有设置为1 // 获取地图默认缩放值 缓存中没有从 localStorage中获取 也没有设置为1
getDefaultZoom () { getDefaultZoom () {

View File

@ -30,9 +30,9 @@ export default {
}, },
methods: { methods: {
// //
handleDemo (lngLat) { handleDemo (lonLat) {
console.log('经度:', lngLat.lng) console.log('经度:', lonLat.lon)
console.log('维度:', lngLat.lat) console.log('维度:', lonLat.lat)
}, },
/** /**
* @description: 创建飞机图标 * @description: 创建飞机图标
@ -40,13 +40,13 @@ export default {
makePlanes (planes) { makePlanes (planes) {
this.$refs.mapbox.removePlanes()// this.$refs.mapbox.removePlanes()//
planes.forEach((plane, index) => { // planes.forEach((plane, index) => { //
let planeDefaultLngLat let planeDefaultLonLat
if (localStorage.getItem(plane.name) !== null) { // if (localStorage.getItem(plane.name) !== null) { //
planeDefaultLngLat = JSON.parse(localStorage.getItem(plane.name)) planeDefaultLonLat = JSON.parse(localStorage.getItem(plane.name))
plane.lng = planeDefaultLngLat.lng plane.lon = planeDefaultLonLat.lon
plane.lat = planeDefaultLngLat.lat plane.lat = planeDefaultLonLat.lat
} else { } else {
plane.lng = 0 plane.lon = 0
plane.lat = 0 plane.lat = 0
} }
this.$refs.mapbox.makePlane(plane, index) this.$refs.mapbox.makePlane(plane, index)

View File

@ -61,18 +61,18 @@ export default {
* @description: 创建飞机图标 * @description: 创建飞机图标
*/ */
makePlane (plane) { makePlane (plane) {
let planeDefaultLngLat let planeDefaultLonLat
if (localStorage.getItem(plane.name)) { // if (localStorage.getItem(plane.name)) { //
planeDefaultLngLat = JSON.parse(localStorage.getItem(plane.name)) planeDefaultLonLat = JSON.parse(localStorage.getItem(plane.name))
plane.lng = planeDefaultLngLat.lng plane.lon = planeDefaultLonLat.lon
plane.lat = planeDefaultLngLat.lat plane.lat = planeDefaultLonLat.lat
} else { } else {
plane.lng = 0 plane.lon = 0
plane.lat = 0 plane.lat = 0
} }
this.$refs.mapbox.removePlanes()// this.$refs.mapbox.removePlanes()//
this.$refs.mapbox.makePlane(plane)// this.$refs.mapbox.makePlane(plane)//
this.$refs.mapbox.goto({ lng: plane.lng, lat: plane.lat })// this.$refs.mapbox.goto({ lon: plane.lon, lat: plane.lat })//
}, },
/** /**
* @description: 创建航线 * @description: 创建航线
@ -111,13 +111,13 @@ export default {
handler (val) { handler (val) {
const len = val.length const len = val.length
if (len > 2) { if (len > 2) {
const lng = val[len - 1][0] const lon = val[len - 1][0]
const lat = val[len - 1][1] const lat = val[len - 1][1]
this.localCount++// this.localCount++//
if (this.localCount % 100 === 1) { if (this.localCount % 100 === 1) {
localStorage.setItem(this.plane.name, `{ "lng": ${lng}, "lat": ${lat} }`) localStorage.setItem(this.plane.name, `{ "lon": ${lon}, "lat": ${lat} }`)
} }
this.$refs.mapbox.setPlaneLngLat({ lng: lng, lat: lat }, 0, val)// this.$refs.mapbox.setPlaneLonLat({ lon: lon, lat: lat }, 0, val)//
} }
}, },
deep: true deep: true

View File

@ -94,18 +94,18 @@ export default {
} else if (key === 'position') { } else if (key === 'position') {
// 便 // 便
const position = JSON.parse(jsonData.position) const position = JSON.parse(jsonData.position)
// lng, lat, alt // lon, lat, alt
if (position.lng !== 0 && position.lat !== 0 && if (position.lon !== 0 && position.lat !== 0 &&
position.lng !== null && position.lat !== null && position.lon !== null && position.lat !== null &&
position.lng !== '' && position.lat !== '') { position.lon !== '' && position.lat !== '') {
plane.planeState.position.push([position.lng / 10e6, position.lat / 10e6, Number(position.alt)]) plane.planeState.position.push([position.lon / 10e6, position.lat / 10e6, Number(position.alt)])
} }
if (plane.planeState.position.length > 1000) { if (plane.planeState.position.length > 1000) {
plane.planeState.position.shift() // plane.planeState.position.shift() //
} }
} else if (key === 'homePosition') { } else if (key === 'homePosition') {
const homePosition = JSON.parse(jsonData.homePosition)// home const homePosition = JSON.parse(jsonData.homePosition)// home
homePosition.lng = homePosition.lng / 10e6 homePosition.lon = homePosition.lon / 10e6
homePosition.lat = homePosition.lat / 10e6 homePosition.lat = homePosition.lat / 10e6
homePosition.alt = Number(homePosition.alt) homePosition.alt = Number(homePosition.alt)
plane.planeState[key] = homePosition plane.planeState[key] = homePosition