|
@@ -6,9 +6,10 @@ import * as layer from "ol/layer";
|
|
import * as source from "ol/source";
|
|
import * as source from "ol/source";
|
|
import MapStyle from "./map-style";
|
|
import MapStyle from "./map-style";
|
|
import * as ol from "ol";
|
|
import * as ol from "ol";
|
|
-import {randomColor, YMDHms} from "@/utils/util";
|
|
|
|
|
|
+import {formatGetParam, randomColor, YMDHms} from "@/utils/util";
|
|
import {formatPosition, getShapeView} from "@/utils/easyMap";
|
|
import {formatPosition, getShapeView} from "@/utils/easyMap";
|
|
import { v4 } from "uuid";
|
|
import { v4 } from "uuid";
|
|
|
|
+import {shipArchiveDetail} from "@/api/modules/web/archive";
|
|
|
|
|
|
export const useShipMapStore = defineStore('shipMap', () => {
|
|
export const useShipMapStore = defineStore('shipMap', () => {
|
|
const state: any = reactive({
|
|
const state: any = reactive({
|
|
@@ -25,7 +26,7 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
overlayTrack: null,
|
|
overlayTrack: null,
|
|
},
|
|
},
|
|
trackHoverData: null,
|
|
trackHoverData: null,
|
|
- trackMap: new Map()
|
|
|
|
|
|
+ trackMap: new Map(),
|
|
// [['123', {
|
|
// [['123', {
|
|
// data: {
|
|
// data: {
|
|
// targetSourceJson: '[]'
|
|
// targetSourceJson: '[]'
|
|
@@ -52,6 +53,19 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
// tab: 1,
|
|
// tab: 1,
|
|
// }
|
|
// }
|
|
// }]]
|
|
// }]]
|
|
|
|
+ trackKeys: {
|
|
|
|
+ lon: 'target_longitude',
|
|
|
|
+ lat: 'target_latitude',
|
|
|
|
+ speed: 'target_speed',
|
|
|
|
+ course: 'target_course',
|
|
|
|
+ mergeType: 'merge_type',
|
|
|
|
+ mergeTime: 'merge_time',
|
|
|
|
+ mergeTarget: 'merge_target',
|
|
|
|
+ mergeId: 'merge_id',
|
|
|
|
+ targetName: 'target_name',
|
|
|
|
+ targetSourceJson: 'target_source',
|
|
|
|
+ shipId: 'ship_archive_id',
|
|
|
|
+ }
|
|
})
|
|
})
|
|
const initMap = (map, mapFunc, {trackPointDom}) => {
|
|
const initMap = (map, mapFunc, {trackPointDom}) => {
|
|
state.map = map
|
|
state.map = map
|
|
@@ -109,11 +123,11 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
real: [d],
|
|
real: [d],
|
|
trackId: feature.get('_trackId'),
|
|
trackId: feature.get('_trackId'),
|
|
moveToTrack: () => {
|
|
moveToTrack: () => {
|
|
- const position = []
|
|
|
|
|
|
+ const position: any = []
|
|
const t = state.trackMap.get(feature.get('_id'))
|
|
const t = state.trackMap.get(feature.get('_id'))
|
|
const arr = [...t.history, ...t.real]
|
|
const arr = [...t.history, ...t.real]
|
|
arr.forEach(v => {
|
|
arr.forEach(v => {
|
|
- position.push([v.targetLongitude, v.targetLatitude])
|
|
|
|
|
|
+ position.push([v[state.trackKeys.lon], v[state.trackKeys.lat]])
|
|
})
|
|
})
|
|
getShapeView(state.map, position)
|
|
getShapeView(state.map, position)
|
|
},
|
|
},
|
|
@@ -141,13 +155,13 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
if (arr.length > 1) {
|
|
if (arr.length > 1) {
|
|
arr.forEach((v, i) => {
|
|
arr.forEach((v, i) => {
|
|
if (i === 0) {
|
|
if (i === 0) {
|
|
- lineWkt += `LINESTRING(${v.targetLongitude} ${v.targetLatitude}`
|
|
|
|
|
|
+ lineWkt += `LINESTRING(${v[state.trackKeys.lon]} ${v[state.trackKeys.lat]}`
|
|
} else if (i === arr.length - 1) {
|
|
} else if (i === arr.length - 1) {
|
|
- lineWkt += `,${v.targetLongitude} ${v.targetLatitude})`
|
|
|
|
|
|
+ lineWkt += `,${v[state.trackKeys.lon]} ${v[state.trackKeys.lat]})`
|
|
} else {
|
|
} else {
|
|
- lineWkt += `,${v.targetLongitude} ${v.targetLatitude}`
|
|
|
|
|
|
+ lineWkt += `,${v[state.trackKeys.lon]} ${v[state.trackKeys.lat]}`
|
|
}
|
|
}
|
|
- v.wkt = `POINT(${v.targetLongitude} ${v.targetLatitude})`
|
|
|
|
|
|
+ v.wkt = `POINT(${v[state.trackKeys.lon]} ${v[state.trackKeys.lat]})`
|
|
})
|
|
})
|
|
}
|
|
}
|
|
if (lineWkt) {
|
|
if (lineWkt) {
|
|
@@ -190,8 +204,19 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
},
|
|
},
|
|
archiveParams: {
|
|
archiveParams: {
|
|
tab: 1,
|
|
tab: 1,
|
|
|
|
+ data: null
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+ if (d[state.trackKeys.shipId]) {
|
|
|
|
+ // shipArchiveDetail(formatGetParam({id: d[state.trackKeys.shipId]})).then(res => {
|
|
|
|
+ shipArchiveDetail(formatGetParam({id: '01d64e98bd904d2880ecd0e74d35383c'})).then(res => {
|
|
|
|
+ if (res.code == 0) {
|
|
|
|
+ state.trackMap.get(feature.get('_id')).archiveParams.data = res.data
|
|
|
|
+ } else {
|
|
|
|
+ ElMessage.error(res.msg)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
const lineLayer = new layer.Vector({
|
|
const lineLayer = new layer.Vector({
|
|
zIndex: 4000,
|
|
zIndex: 4000,
|
|
__layerName: state.trackMap.get(feature.get('_id')).lineLayer
|
|
__layerName: state.trackMap.get(feature.get('_id')).lineLayer
|
|
@@ -203,38 +228,38 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
})
|
|
})
|
|
state.map.addLayer(lineLayer)
|
|
state.map.addLayer(lineLayer)
|
|
state.map.addLayer(pointsLayer)
|
|
state.map.addLayer(pointsLayer)
|
|
- const ws = new WebSocket(`ws://${location.host}/history-track-ws-api/history-fkShips-track`)
|
|
|
|
- ws.onopen = (e) => {
|
|
|
|
- const str = {
|
|
|
|
- shipId: feature.get('_id'),
|
|
|
|
- startTime: YMDHms(new Date(d.mergeTime).getTime() - 1000 * 60 * 60),
|
|
|
|
- endTime: YMDHms(d.mergeTime),
|
|
|
|
- searchType: 1,
|
|
|
|
- sendInterval: 1
|
|
|
|
- }
|
|
|
|
- ws.send(JSON.stringify(str))
|
|
|
|
- }
|
|
|
|
- ws.onmessage = (e) => {
|
|
|
|
- try {
|
|
|
|
- const json = JSON.parse(e.data)
|
|
|
|
- if (json.message === '查询结束') {
|
|
|
|
- ws.close()
|
|
|
|
- } else if (json.data?.length > 0) {
|
|
|
|
- state.trackMap.get(feature.get('_id')).history.push(...json.data.map(v => ({
|
|
|
|
- targetName: v.shipName,
|
|
|
|
- mergeTarget: v.shipId,
|
|
|
|
- targetLongitude: v.shipLon,
|
|
|
|
- targetLatitude: v.shipLat,
|
|
|
|
- targetCourse: v.shipCourse,
|
|
|
|
- targetSpeed: v.shipSpeed,
|
|
|
|
- mergeTime: v.trackTime,
|
|
|
|
- targetSourceJson: v.targetSource,
|
|
|
|
- })))
|
|
|
|
- state.trackMap.get(feature.get('_id')).refreshTrackStyle()
|
|
|
|
- }
|
|
|
|
- } catch (e) {
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // const ws = new WebSocket(`ws://${location.host}/history-track-ws-api/history-fkShips-track`)
|
|
|
|
+ // ws.onopen = (e) => {
|
|
|
|
+ // const str = {
|
|
|
|
+ // shipId: feature.get('_id'),
|
|
|
|
+ // startTime: YMDHms(new Date(d[state.trackKeys.mergeTime]).getTime() - 1000 * 60 * 60),
|
|
|
|
+ // endTime: YMDHms(d[state.trackKeys.mergeTime]),
|
|
|
|
+ // searchType: 1,
|
|
|
|
+ // sendInterval: 1
|
|
|
|
+ // }
|
|
|
|
+ // ws.send(JSON.stringify(str))
|
|
|
|
+ // }
|
|
|
|
+ // ws.onmessage = (e) => {
|
|
|
|
+ // try {
|
|
|
|
+ // const json = JSON.parse(e.data)
|
|
|
|
+ // if (json.message === '查询结束') {
|
|
|
|
+ // ws.close()
|
|
|
|
+ // } else if (json.data?.length > 0) {
|
|
|
|
+ // state.trackMap.get(feature.get('_id')).history.push(...json.data.map(v => ({
|
|
|
|
+ // targetName: v.shipName,
|
|
|
|
+ // mergeTarget: v.shipId,
|
|
|
|
+ // targetLongitude: v.shipLon,
|
|
|
|
+ // targetLatitude: v.shipLat,
|
|
|
|
+ // targetCourse: v.shipCourse,
|
|
|
|
+ // targetSpeed: v.shipSpeed,
|
|
|
|
+ // mergeTime: v.trackTime,
|
|
|
|
+ // targetSourceJson: v.targetSource,
|
|
|
|
+ // })))
|
|
|
|
+ // state.trackMap.get(feature.get('_id')).refreshTrackStyle()
|
|
|
|
+ // }
|
|
|
|
+ // } catch (e) {
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
initWebSocket()
|
|
initWebSocket()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -299,8 +324,8 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
const getWSParams = () => {
|
|
const getWSParams = () => {
|
|
const param = {
|
|
const param = {
|
|
cql: '',
|
|
cql: '',
|
|
- realCql: '',
|
|
|
|
- userId: "18889231165"
|
|
|
|
|
|
+ // realCql: '',
|
|
|
|
+ // userId: "18889231165"
|
|
}
|
|
}
|
|
let idCql = ''
|
|
let idCql = ''
|
|
if (state.trackMap.size > 0) {
|
|
if (state.trackMap.size > 0) {
|
|
@@ -308,27 +333,29 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
state.trackMap.forEach((v, k) => {
|
|
state.trackMap.forEach((v, k) => {
|
|
arr.push(`'${k}'`)
|
|
arr.push(`'${k}'`)
|
|
})
|
|
})
|
|
- idCql = `mergeTarget in (${arr.join(',')})`
|
|
|
|
|
|
+ idCql = `${state.trackKeys.mergeTarget} in (${arr.join(',')})`
|
|
}
|
|
}
|
|
if (zoomWMS.value) {
|
|
if (zoomWMS.value) {
|
|
param.cql = idCql
|
|
param.cql = idCql
|
|
} else {
|
|
} else {
|
|
param.cql = getBBOX()
|
|
param.cql = getBBOX()
|
|
- param.realCql = idCql
|
|
|
|
|
|
+ // if (idCql) {
|
|
|
|
+ // param.cql += ` or (${idCql})`
|
|
|
|
+ // }
|
|
|
|
+ // param.realCql = idCql
|
|
}
|
|
}
|
|
return JSON.stringify(param)
|
|
return JSON.stringify(param)
|
|
}
|
|
}
|
|
const initWebSocket = () => {
|
|
const initWebSocket = () => {
|
|
if (!state.ws.instance) {
|
|
if (!state.ws.instance) {
|
|
- state.ws.instance = new WebSocket(`ws://${location.host}/rh-ws-api/webSocket`)
|
|
|
|
|
|
+ state.ws.instance = new WebSocket(`ws://${location.host}/ws-api/realtimeshiptrack`)
|
|
state.ws.instance.onopen = (e) => {
|
|
state.ws.instance.onopen = (e) => {
|
|
state.ws.instance.send(getWSParams())
|
|
state.ws.instance.send(getWSParams())
|
|
}
|
|
}
|
|
state.ws.instance.onmessage = (e) => {
|
|
state.ws.instance.onmessage = (e) => {
|
|
try {
|
|
try {
|
|
const json = JSON.parse(e.data)
|
|
const json = JSON.parse(e.data)
|
|
- const shipData = json.data
|
|
|
|
- initShip(shipData)
|
|
|
|
|
|
+ initShip(json)
|
|
} catch (e) {
|
|
} catch (e) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -357,13 +384,13 @@ export const useShipMapStore = defineStore('shipMap', () => {
|
|
// 动态拼接数据的唯一标识DATA,不可修改
|
|
// 动态拼接数据的唯一标识DATA,不可修改
|
|
const features = data.map(v => {
|
|
const features = data.map(v => {
|
|
try {
|
|
try {
|
|
- const feat: any = new format.WKT().readFeature(`POINT(${v.targetLongitude} ${v.targetLatitude})`)
|
|
|
|
- feat.set('_course', v.targetCourse || 0)
|
|
|
|
- feat.set('_speed', v.targetSpeed || 0)
|
|
|
|
- feat.set('_head', v.targetHeading)
|
|
|
|
- feat.set('_mergeType', v.mergeType)
|
|
|
|
- feat.set('_id', v.mergeTarget)
|
|
|
|
- feat.set('_trackId', v.mergeId)
|
|
|
|
|
|
+ const feat: any = new format.WKT().readFeature(`POINT(${v[state.trackKeys.lon]} ${v[state.trackKeys.lat]})`)
|
|
|
|
+ feat.set('_course', v[state.trackKeys.course] || 0)
|
|
|
|
+ feat.set('_speed', v[state.trackKeys.speed] || 0)
|
|
|
|
+ // feat.set('_head', v.targetHeading)
|
|
|
|
+ feat.set('_mergeType', v[state.trackKeys.mergeType])
|
|
|
|
+ feat.set('_id', v[state.trackKeys.mergeTarget])
|
|
|
|
+ feat.set('_trackId', v[state.trackKeys.mergeId])
|
|
feat.set('_data', v)
|
|
feat.set('_data', v)
|
|
feat.set('_featureType', 'ship')
|
|
feat.set('_featureType', 'ship')
|
|
// 实时轨迹
|
|
// 实时轨迹
|