| | |
| | | template.value = tplXmlJson.Document |
| | | return kmzRes |
| | | } |
| | | const create = (waylineBasicInfo) => { |
| | | const author = window.localStorage.getItem('username') || '' |
| | | const createTime = new Date().getTime() |
| | | // 模板 |
| | | const template = { |
| | | author, |
| | | createTime, |
| | | updateTime: createTime, |
| | | missionConfig: { |
| | | flyToWaylineMode: 'safely', |
| | | finishAction: 'goHome', |
| | | exitOnRCLost: 'goContinue', |
| | | executeRCLostAction: 'goBack', |
| | | takeOffSecurityHeight: 20, |
| | | takeOffRefPoint: '0.000000,0.000000,0.000000', |
| | | takeOffRefPointAGLHeight: 0, |
| | | globalTransitionalSpeed: 15, |
| | | globalRTHHeight: 80, |
| | | droneInfo: { |
| | | droneEnumValue: 0, |
| | | droneSubEnumValue: 0, |
| | | const create = async (waylineBasicInfo: { fileName: string; droneEnumValue: string; payloadEnumValue: string }) => { |
| | | try { |
| | | const { fileName, droneEnumValue, payloadEnumValue } = waylineBasicInfo |
| | | const author = window.localStorage.getItem('username') || '' |
| | | const createTime = new Date().getTime() |
| | | // 模板 |
| | | const droneModel: { [key: string]: string } = { |
| | | 52: '0', |
| | | 53: '1', |
| | | 66: '0', |
| | | 67: '1', |
| | | 80: '0', |
| | | 81: '1', |
| | | } as const |
| | | const templateJson = { |
| | | author, |
| | | createTime, |
| | | updateTime: createTime, |
| | | missionConfig: { |
| | | flyToWaylineMode: 'safely', |
| | | finishAction: 'goHome', |
| | | exitOnRCLost: 'goContinue', |
| | | executeRCLostAction: 'goBack', |
| | | takeOffSecurityHeight: 20, |
| | | takeOffRefPoint: '0.000000,0.000000,0.000000', |
| | | takeOffRefPointAGLHeight: 0, |
| | | globalTransitionalSpeed: 15, |
| | | globalRTHHeight: 80, |
| | | droneInfo: { |
| | | droneEnumValue, |
| | | droneSubEnumValue: droneModel[payloadEnumValue], |
| | | }, |
| | | payloadInfo: { |
| | | payloadEnumValue, |
| | | payloadSubEnumValue: droneModel[payloadEnumValue], |
| | | payloadPositionIndex: 0, |
| | | }, |
| | | }, |
| | | payloadInfo: { |
| | | payloadEnumValue: 0, |
| | | payloadSubEnumValue: 0, |
| | | payloadPositionIndex: 0, |
| | | Folder: { |
| | | templateType: 'waypoint', |
| | | useGlobalTransitionalSpeed: 0, |
| | | templateId: 0, |
| | | waylineCoordinateSysParam: { |
| | | coordinateMode: 'WGS84', |
| | | heightMode: 'EGM96', |
| | | globalShootHeight: 50, |
| | | positioningType: 'GPS', |
| | | surfaceFollowModeEnable: 1, |
| | | surfaceRelativeHeight: 100, |
| | | }, |
| | | autoFlightSpeed: 7, |
| | | gimbalPitchMode: 'usePointSetting', |
| | | globalWaypointHeadingParam: { |
| | | waypointHeadingMode: 'followWayline', |
| | | waypointHeadingAngle: 0, |
| | | waypointPoiPoint: '0.000000,0.000000,0.000000', |
| | | waypointHeadingPathMode: 'followBadArc', |
| | | }, |
| | | globalWaypointTurnMode: 'toPointAndStopWithDiscontinuityCurvature', |
| | | globalUseStraightLine: 0, |
| | | Placemark: [], |
| | | }, |
| | | }, |
| | | Folder: { |
| | | templateType: 'waypoint', |
| | | useGlobalTransitionalSpeed: 0, |
| | | templateId: 0, |
| | | waylineCoordinateSysParam: { |
| | | coordinateMode: 'WGS84', |
| | | heightMode: 'EGM96', |
| | | globalShootHeight: 50, |
| | | positioningType: 'GPS', |
| | | surfaceFollowModeEnable: 1, |
| | | surfaceRelativeHeight: 100, |
| | | }, |
| | | autoFlightSpeed: 7, |
| | | gimbalPitchMode: 'usePointSetting', |
| | | globalWaypointHeadingParam: { |
| | | waypointHeadingMode: 'followWayline', |
| | | waypointHeadingAngle: 0, |
| | | waypointPoiPoint: '0.000000,0.000000,0.000000', |
| | | waypointHeadingPathMode: 'followBadArc', |
| | | }, |
| | | globalWaypointTurnMode: 'toPointAndStopWithDiscontinuityCurvature', |
| | | globalUseStraightLine: 0, |
| | | Placemark: [], |
| | | }, |
| | | } |
| | | template.value = templateJson |
| | | return true |
| | | } catch (error) { |
| | | return error |
| | | } |
| | | } |
| | | const save = () => { |
| | |
| | | if (item === 'waylineId') { |
| | | waylinesObj[key][item] = templateJson[key].templateId |
| | | } |
| | | if (item === 'Placemark') { |
| | | const placemarks = _.cloneDeep(templateJson[key][item]) |
| | | placemarks.forEach( |
| | | (placemark: { |
| | | executeHeight: { '#text': string } |
| | | ellipsoidHeight?: { [x: string]: string } |
| | | height?: { [x: string]: string } |
| | | }) => { |
| | | placemark.executeHeight = { '#text': placemark.ellipsoidHeight?.['#text'] || '' } |
| | | delete placemark.ellipsoidHeight |
| | | delete placemark.height |
| | | }, |
| | | ) |
| | | waylinesObj[key][item] = placemarks |
| | | } |
| | | }) |
| | | } else { |
| | | waylinesObj[key] = templateJson[key] |