| | |
| | | } |
| | | } |
| | | |
| | | // 拆分航线 |
| | | async splitWayLine (data, dronePosition = null, isShowDock = false, isShowPointBillboard = true) { |
| | | const { |
| | | pointPlacemark, |
| | | polygonList, |
| | | pointList, |
| | | templateType, |
| | | startPoint, |
| | | execute_height_mode, |
| | | auto_flight_speed, |
| | | take_off_security_height, |
| | | buffer_distance_meters, |
| | | missionConfig, |
| | | waylinesXMLObjR, |
| | | } = await analysisPointLineKmz(`${data.domain_url}${data.object_key}`) |
| | | const { positionArray, filePositions } = this.disposeData( |
| | | waylinesXMLObjR, |
| | | missionConfig, |
| | | null, |
| | | data, |
| | | startPoint, |
| | | 0 |
| | | ) |
| | | let bigPointList = handlePointListForKmz({ |
| | | placemark: pointPlacemark, |
| | | startPoint: startPoint, |
| | | execute_height_mode: execute_height_mode, |
| | | auto_flight_speed: auto_flight_speed, |
| | | }) |
| | | // 路径线 |
| | | let entityConfig |
| | | bigPointList.shift() |
| | | let flyPositions = bigPointList.map(i => [Number(i.longitude), Number(i.latitude), Number(i.height)]) |
| | | // 渲染多个点 |
| | | let firstTopPosition = null |
| | | let resultPosotions = [] |
| | | await Promise.all(data.wayline_file_list.map(async (item, index) => { |
| | | // 小航线渲染线 |
| | | const kmzUrl = import.meta.env.VITE_APP_AIRLINE_URL + item.object_key |
| | | const { pointList } = await analysisPointLineKmz(kmzUrl) |
| | | resultPosotions.push(pointList) |
| | | })).then(res => { |
| | | // 目的是区分大航线点属于哪条小航线 |
| | | bigPointList.forEach(bigObj => { |
| | | let foundIndex = -1 |
| | | // 遍历 resultPositions 查找匹配项 |
| | | resultPosotions.some((subArray, subIndex) => { |
| | | const found = subArray.some(obj => |
| | | obj.latitude === bigObj.latitude && |
| | | obj.longitude === bigObj.longitude |
| | | ) |
| | | if (found) { |
| | | foundIndex = subIndex |
| | | return true // 找到就停止搜索 |
| | | } |
| | | return false |
| | | }) |
| | | // 如果找到了,给 bigPointList 的对象添加标记 |
| | | if (foundIndex !== -1) { |
| | | bigObj.log = foundIndex // 或 bigObj.index = foundIndex |
| | | } |
| | | }) |
| | | console.log(bigPointList, '查看结果值') // 现在 bigPointList 会有 log 属性 |
| | | bigPointList.map(async (i, index) => { |
| | | firstTopPosition = i |
| | | const position = Cesium.Cartesian3.fromDegrees(Number(i.longitude), Number(i.latitude), Number(findHeightByCoordinates(resultPosotions, i.longitude, i.latitude))) |
| | | const combinedImage = await createCombinedSVG(index, i.log % 2 ? newStartPoint : newStartPointMore) |
| | | |
| | | entityConfig = { |
| | | name: 'work-drone-route-point-split', |
| | | position: position, |
| | | billboard: { |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY, |
| | | image: combinedImage, |
| | | width: 50, |
| | | height: 50, |
| | | verticalOrigin: Cesium.VerticalOrigin.CENTER, |
| | | horizontalOrigin: Cesium.HorizontalOrigin.CENTER, |
| | | } |
| | | } |
| | | |
| | | // 只在第一个点添加 label |
| | | if (index === 0) { |
| | | entityConfig.label = { |
| | | text: data.task_name || '', |
| | | font: 'bold 16px sans-serif', |
| | | fillColor: data.status === 2 ? runningTextColor : pendingTextColor, |
| | | pixelOffset: data.status === 2 ? runningTextOffset : pendingTextOffset, |
| | | style: Cesium.LabelStyle.FILL_AND_OUTLINE, |
| | | outlineWidth: 2, |
| | | outlineColor: Cesium.Color.BLACK, |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY, |
| | | } |
| | | } |
| | | |
| | | this.viewer.entities.add(entityConfig) |
| | | }) |
| | | }) |
| | | |
| | | // 渲染航线 |
| | | data.wayline_file_list.map(async (item, index) => { |
| | | // 小航线渲染线 |
| | | const kmzUrl = import.meta.env.VITE_APP_AIRLINE_URL + item.object_key |
| | | const { pointList } = await analysisPointLineKmz(kmzUrl) |
| | | // if (curRouteLineData.value.droneData && splitLines.length === 1) { |
| | | // // 把pointList的第一个点替换为无人机位置 |
| | | // pointList[0] = curRouteLineData.value.droneData[0] |
| | | // } |
| | | if (take_off_security_height + pointList[0].height > firstTopPosition.height) { |
| | | // 安全高度+机巢高度 > 第一个点高度 |
| | | const positionTest = { |
| | | longitude: pointList[0].longitude, |
| | | latitude: pointList[0].latitude, |
| | | height: take_off_security_height + pointList[0].height, |
| | | } |
| | | |
| | | const positionTest1 = { |
| | | longitude: pointList[1].longitude, |
| | | latitude: pointList[1].latitude, |
| | | height: take_off_security_height + pointList[0].height, |
| | | } |
| | | pointList.splice(1, 0, positionTest) |
| | | // 往数组中插入元素 |
| | | pointList.splice(2, 0, positionTest1) |
| | | // console.log(pointList, 'pointList') |
| | | } else if (take_off_security_height + pointList[0].height < firstTopPosition.height) { |
| | | const positionTest = { |
| | | longitude: pointList[0].longitude, |
| | | latitude: pointList[0].latitude, |
| | | height: firstTopPosition.height, |
| | | } |
| | | pointList.splice(1, 0, positionTest) |
| | | } |
| | | const routePositions = pointList.map(i => |
| | | Cesium.Cartesian3.fromDegrees(Number(i.longitude), Number(i.latitude), Number(i.height)) |
| | | ) |
| | | |
| | | this.viewer.entities.add({ |
| | | name: 'work-drone-route-line-split', |
| | | polyline: { |
| | | width: 4, |
| | | positions: routePositions, |
| | | material: data.status === 1 ? arrowLineMaterialPropertyGray : getLineColor(index + 1), |
| | | clampToGround: false, |
| | | }, |
| | | }) |
| | | }) |
| | | // 落点线 |
| | | ; (bigPointList || [])?.forEach((item, index) => { |
| | | const topPosition = Cesium.Cartesian3.fromDegrees( |
| | | Number(item.longitude), |
| | | Number(item.latitude), |
| | | Number(item.height) |
| | | ) |
| | | let setting = { |
| | | name: 'work-drone-route--planar-polyline-split', |
| | | position: topPosition, |
| | | polyline: getPolyLine(this.viewer, { value: bigPointList }, index), |
| | | } |
| | | this.viewer.entities.add(setting) |
| | | }) |
| | | return { |
| | | entity: entityConfig, |
| | | routeLinePositions: positionArray, |
| | | filePositions: |
| | | dronePosition != null |
| | | ? [{ lng: dronePosition.longitude, lat: dronePosition.latitude, alt: dronePosition.height }, ...filePositions] |
| | | : filePositions, |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 绘制面状航线 |
| | | * @param {*} lineObj 航线文件中的 |