| | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.ard.route.domain.*; |
| | | import com.ard.route.domain.kml.*; |
| | | import com.ard.route.domain.djuav.*; |
| | | import com.ard.route.domain.djuav.kml.*; |
| | | import com.ard.route.enums.kml.*; |
| | | import com.ard.route.constant.FileTypeConstants; |
| | | import com.thoughtworks.xstream.XStream; |
| | |
| | | */ |
| | | public static KmlInfo parseKml(InputStream inputStream) { |
| | | XStream xStream = new XStream(); |
| | | xStream.allowTypes(new Class[]{KmlInfo.class, KmlAction.class, KmlWayLineCoordinateSysParam.class, KmlPoint.class}); |
| | | xStream.allowTypes(new Class[]{ |
| | | KmlInfo.class, |
| | | KmlAction.class, |
| | | KmlWayLineCoordinateSysParam.class, |
| | | KmlPoint.class, |
| | | KmlActionGroup.class |
| | | }); |
| | | xStream.alias("kml", KmlInfo.class); |
| | | xStream.processAnnotations(KmlInfo.class); |
| | | xStream.autodetectAnnotations(true); |
| | | xStream.ignoreUnknownElements(); |
| | | xStream.addImplicitCollection(KmlActionGroup.class, "action"); |
| | | xStream.addImplicitCollection(KmlPlacemark.class, "actionGroup"); |
| | | return (KmlInfo) xStream.fromXML(inputStream); |
| | | } |
| | | |
| | |
| | | * @param wpmlInfo wpml 文件信息 |
| | | * @return 本地文件路径 |
| | | */ |
| | | public static String buildKmz(String fileName, KmlInfo kmlInfo, KmlInfo wpmlInfo, String kmzFilePath) { |
| | | public static String buildKmzA(String fileName, KmlInfo kmlInfo, KmlInfo wpmlInfo, String kmzFilePath) { |
| | | XStream xStream = new XStream(new DomDriver()); |
| | | xStream.processAnnotations(KmlInfo.class); |
| | | xStream.addImplicitCollection(KmlActionGroup.class, "action"); |
| | | xStream.addImplicitCollection(KmlPlacemark.class, "actionGroup"); |
| | | |
| | | String kml = XML_HEADER + xStream.toXML(kmlInfo); |
| | | String wpml = XML_HEADER + xStream.toXML(wpmlInfo); |
| | |
| | | }else { |
| | | kmlMissionConfig.setGlobalTransitionalSpeed("15"); |
| | | } |
| | | kmlMissionConfig.setGlobalRTHHeight("100"); |
| | | if (kmlParams.getHeightMode().equals(HeightModeEnums.RELATIVE_TO_START_POINT.getValue())){ |
| | | kmlMissionConfig.setGlobalRTHHeight("100"); |
| | | } |
| | | kmlMissionConfig.setTakeOffRefPoint(kmlParams.getTakeOffRefPoint()); |
| | | kmlMissionConfig.setDroneInfo(buildKmlDroneInfo(kmlParams.getDroneType(), kmlParams.getSubDroneType())); |
| | | kmlMissionConfig.setPayloadInfo(buildKmlPayloadInfo(kmlParams.getPayloadType(), kmlParams.getPayloadPosition())); |
| | |
| | | kmlDroneInfo.setDroneEnumValue(String.valueOf(droneType)); |
| | | if (Objects.equals(droneType, DroneEnumValueEnums.M30_M30T.getValue()) || |
| | | Objects.equals(droneType, DroneEnumValueEnums.M3D_M3TD.getValue()) || |
| | | Objects.equals(droneType, DroneEnumValueEnums.M3E_M3T_M3M.getValue())) { |
| | | Objects.equals(droneType, DroneEnumValueEnums.M3E_M3T_M3M.getValue())|| |
| | | Objects.equals(droneType, DroneEnumValueEnums.MATRICE_4D.getValue())) { |
| | | kmlDroneInfo.setDroneSubEnumValue(String.valueOf(subDroneType)); |
| | | } |
| | | return kmlDroneInfo; |
| | |
| | | kmlFolder.setAutoFlightSpeed(String.valueOf(kmlParams.getAutoFlightSpeed())); |
| | | if (StringUtils.equals(fileType, FileTypeConstants.KML)) { |
| | | kmlFolder.setTemplateType(kmlParams.getTemplateType()); |
| | | kmlFolder.setWaylineCoordinateSysParam(buildKmlWayLineCoordinateSysParam(kmlParams.getTemplateType(), HeightModeEnums.RELATIVE_TO_START_POINT.getValue(), |
| | | String.valueOf(kmlParams.getGlobalHeight()))); |
| | | if (kmlParams.getHeightMode().equals(HeightModeEnums.RELATIVE_TO_START_POINT.getValue())){ |
| | | kmlFolder.setWaylineCoordinateSysParam( |
| | | buildKmlWayLineCoordinateSysParam( |
| | | kmlParams.getTemplateType(), |
| | | HeightModeEnums.RELATIVE_TO_START_POINT.getValue(), |
| | | String.valueOf(kmlParams.getGlobalHeight()))); |
| | | }else if(kmlParams.getHeightMode().equals(HeightModeEnums.EGM96.getValue())){ |
| | | kmlFolder.setWaylineCoordinateSysParam( |
| | | buildKmlWayLineCoordinateSysParam( |
| | | kmlParams.getTemplateType(), |
| | | HeightModeEnums.EGM96.getValue(), |
| | | String.valueOf(kmlParams.getGlobalHeight()))); |
| | | } |
| | | kmlFolder.setPayloadParam(buildKmlPayloadParam(kmlParams)); |
| | | } |
| | | if (StringUtils.equals(fileType, FileTypeConstants.WPML)) { |
| | | kmlFolder.setWaylineId("0"); |
| | | kmlFolder.setExecuteHeightMode(ExecuteHeightModeEnums.RELATIVE_TO_START_POINT.getValue()); |
| | | if (kmlParams.getHeightMode().equals(HeightModeEnums.RELATIVE_TO_START_POINT.getValue())){ |
| | | kmlFolder.setExecuteHeightMode(ExecuteHeightModeEnums.RELATIVE_TO_START_POINT.getValue()); |
| | | } else if (kmlParams.getHeightMode().equals(HeightModeEnums.EGM96.getValue())) { |
| | | kmlFolder.setExecuteHeightMode(ExecuteHeightModeEnums.WGS84.getValue()); |
| | | } |
| | | if (CollectionUtil.isNotEmpty(kmlParams.getStartActionList())) { |
| | | KmlActionGroup kmlActionGroup = new KmlActionGroup(); |
| | | kmlActionGroup.setAction(getKmlActionList(kmlParams.getStartActionList(), kmlParams)); |
| | |
| | | if (CollectionUtil.isNotEmpty(routePointInfo.getActionGroupList())) { |
| | | List<KmlActionGroup> kmlActionGroupList = new ArrayList<>(); |
| | | for (ActionGroupReq actionGroupReq : routePointInfo.getActionGroupList()) { |
| | | kmlActionGroupList.add(buildKmlActionGroup(actionGroupReq, kmlParams)); |
| | | if (ObjectUtil.isNotEmpty(actionGroupReq.getActions())){ |
| | | kmlActionGroupList.add(buildKmlActionGroup(actionGroupReq, kmlParams)); |
| | | } |
| | | } |
| | | kmlPlacemark.setActionGroup(kmlActionGroupList); |
| | | } |
| | |
| | | |
| | | public static KmlActionGroup buildKmlActionGroup(ActionGroupReq actionGroupReq, KmlParams kmlParams) { |
| | | KmlActionGroup kmlActionGroup = new KmlActionGroup(); |
| | | kmlActionGroup.setActionGroupId(String.valueOf(actionGroupReq.getActionGroupId())); |
| | | kmlActionGroup.setActionGroupStartIndex(String.valueOf(actionGroupReq.getActionGroupStartIndex())); |
| | | kmlActionGroup.setActionGroupEndIndex(String.valueOf(actionGroupReq.getActionGroupEndIndex())); |
| | | kmlActionGroup.setActionGroupMode(ActionGroupModeEnums.SEQUENCE.getValue()); |
| | | kmlActionGroup.setActionGroupId(String.valueOf(actionGroupReq.getActionGroupId())); |
| | | kmlActionGroup.setActionGroupStartIndex(String.valueOf(actionGroupReq.getActionGroupStartIndex())); |
| | | kmlActionGroup.setActionGroupEndIndex(String.valueOf(actionGroupReq.getActionGroupEndIndex())); |
| | | kmlActionGroup.setActionGroupMode(ActionGroupModeEnums.SEQUENCE.getValue()); |
| | | |
| | | kmlActionGroup.setActionTrigger(buildKmlActionTrigger(actionGroupReq.getActionTriggerType(), actionGroupReq.getActionTriggerParam())); |
| | | kmlActionGroup.setAction(getKmlActionList(actionGroupReq.getActions(), kmlParams)); |
| | | kmlActionGroup.setActionTrigger(buildKmlActionTrigger(actionGroupReq.getActionTriggerType(), actionGroupReq.getActionTriggerParam())); |
| | | kmlActionGroup.setAction(getKmlActionList(actionGroupReq.getActions(), kmlParams)); |
| | | return kmlActionGroup; |
| | | } |
| | | |
| | |
| | | }else { |
| | | kmlActionActuatorFuncParam.setFileSuffix("panoramicPhoto_360"); |
| | | } |
| | | kmlActionActuatorFuncParam.setUseGlobalPayloadLensIndex(String.valueOf(pointActionReq.getUseGlobalImageFormat())); |
| | | if (pointActionReq.getUseGlobalImageFormat() != null) { |
| | | kmlActionActuatorFuncParam.setUseGlobalPayloadLensIndex(String.valueOf(pointActionReq.getUseGlobalImageFormat())); |
| | | }else { |
| | | kmlActionActuatorFuncParam.setUseGlobalPayloadLensIndex("0"); |
| | | } |
| | | if (ObjectUtil.equals(pointActionReq.getUseGlobalImageFormat(), 0)) { |
| | | kmlActionActuatorFuncParam.setPayloadLensIndex(pointActionReq.getImageFormat()); |
| | | } else { |