| | |
| | | zipOutputStream.closeEntry(); // 关闭条目 |
| | | } |
| | | |
| | | |
| | | public static KmlInfo buildKml(KmlParams kmlParams) { |
| | | KmlInfo kmlInfo = new KmlInfo(); |
| | | kmlInfo.setDocument(buildKmlDocument(FileTypeConstants.KML, kmlParams)); |
| | |
| | | public static KmlDocument buildKmlDocument(String fileType, KmlParams kmlParams) { |
| | | KmlDocument kmlDocument = new KmlDocument(); |
| | | if (StringUtils.equals(fileType, FileTypeConstants.KML)) { |
| | | kmlDocument.setAuthor("Cleaner"); |
| | | kmlDocument.setAuthor("Ard-Creator"); |
| | | kmlDocument.setCreateTime(String.valueOf(DateUtil.current())); |
| | | kmlDocument.setUpdateTime(String.valueOf(DateUtil.current())); |
| | | } |
| | |
| | | |
| | | public static KmlMissionConfig buildKmlMissionConfig(KmlParams kmlParams) { |
| | | KmlMissionConfig kmlMissionConfig = new KmlMissionConfig(); |
| | | if (kmlParams.getFlyToWaylineMode() != null){ |
| | | kmlMissionConfig.setFlyToWayLineMode(kmlParams.getFlyToWaylineMode()); |
| | | }else { |
| | | kmlMissionConfig.setFlyToWayLineMode(FlyToWaylineModeEnums.SAFELY.getValue()); |
| | | } |
| | | kmlMissionConfig.setFinishAction(kmlParams.getFinishAction()); |
| | | if (StringUtils.isNotBlank(kmlParams.getExitOnRcLostAction())) { |
| | | kmlMissionConfig.setExitOnRCLost(ExitOnRCLostEnums.EXECUTE_LOST_ACTION.getValue()); |
| | |
| | | kmlMissionConfig.setExitOnRCLost(ExitOnRCLostEnums.GO_CONTINUE.getValue()); |
| | | } |
| | | kmlMissionConfig.setTakeOffSecurityHeight("20"); |
| | | if (kmlParams.getGlobalTransitionalSpeed() != null){ |
| | | kmlMissionConfig.setGlobalTransitionalSpeed(String.valueOf(kmlParams.getGlobalTransitionalSpeed())); |
| | | }else { |
| | | kmlMissionConfig.setGlobalTransitionalSpeed("15"); |
| | | } |
| | | kmlMissionConfig.setGlobalRTHHeight("100"); |
| | | kmlMissionConfig.setTakeOffRefPoint(kmlParams.getTakeOffRefPoint()); |
| | | kmlMissionConfig.setDroneInfo(buildKmlDroneInfo(kmlParams.getDroneType(), kmlParams.getSubDroneType())); |
| | |
| | | kmlPayloadInfo.setPayloadEnumValue(String.valueOf(payloadType)); |
| | | kmlPayloadInfo.setPayloadPositionIndex(String.valueOf(payloadPosition)); |
| | | return kmlPayloadInfo; |
| | | |
| | | } |
| | | |
| | | |
| | | public static KmlFolder buildKmlFolder(String fileType, KmlParams kmlParams) { |
| | | KmlFolder kmlFolder = new KmlFolder(); |
| | |
| | | return kmlFolder; |
| | | } |
| | | |
| | | |
| | | public static KmlWayLineCoordinateSysParam buildKmlWayLineCoordinateSysParam(String templateType) { |
| | | KmlWayLineCoordinateSysParam kmlWayLineCoordinateSysParam = new KmlWayLineCoordinateSysParam(); |
| | | kmlWayLineCoordinateSysParam.setCoordinateMode("WGS84"); |
| | |
| | | // 0: 不上色 1: 真彩上色 |
| | | kmlPayloadParam.setModelColoringEnable("1"); |
| | | kmlPayloadParam.setImageFormat(kmlParams.getImageFormat()); |
| | | |
| | | return kmlPayloadParam; |
| | | } |
| | | |
| | |
| | | } |
| | | kmlGlobalWaypointHeadingParam.setWaypointHeadingPathMode(WaypointHeadingPathModeEnums.FOLLOW_BAD_ARC.getValue()); |
| | | return kmlGlobalWaypointHeadingParam; |
| | | |
| | | } |
| | | |
| | | public static KmlPlacemark buildKmlPlacemark(RoutePointInfo routePointInfo, KmlParams kmlParams, String fileType) { |
| | |
| | | kmlPlacemark.setIsRisky("0"); |
| | | kmlPlacemark.setKmlPoint(buildKmlPoint(String.valueOf(routePointInfo.getLongitude()), String.valueOf(routePointInfo.getLatitude()))); |
| | | kmlPlacemark.setIndex(String.valueOf(routePointInfo.getRoutePointIndex())); |
| | | |
| | | handleHeight(routePointInfo, kmlParams, fileType, kmlPlacemark); |
| | | handleSpeed(routePointInfo, kmlParams, fileType, kmlPlacemark); |
| | | handleWaypointHeadingParam(routePointInfo, kmlParams, fileType, kmlPlacemark); |
| | |
| | | private static KmlPolygon buildKmlPolygon(List<CoordinatePointReq> coordinatePointReqList) { |
| | | KmlPolygon kmlPolygon = new KmlPolygon(); |
| | | KmlLinearRing kmlLinearRing = new KmlLinearRing(); |
| | | |
| | | String coordinates = coordinatePointReqList.stream().map(point -> point.getLongitude() + "," + point.getLatitude() + "," + point.getHeight()) |
| | | .collect(Collectors.joining(", ")); |
| | | kmlLinearRing.setCoordinates(StringUtils.join(coordinates, " ")); |
| | |
| | | kmlPlacemark.setWaypointHeadingParam(buildKmlWaypointHeadingParam(globalWaypointHeading.getWaypointHeadingMode(), globalWaypointHeading.getWaypointHeadingAngle(), globalWaypointHeading.getWaypointPoiPoint())); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | private static void handleSpeed(RoutePointInfo routePointInfo, KmlParams kmlParams, String fileType, KmlPlacemark kmlPlacemark) { |
| | | if (ObjectUtil.isNotEmpty(routePointInfo.getSpeed())) { |
| | |
| | | kmlActionGroup.setActionGroupEndIndex(String.valueOf(ObjectUtil.isNotNull(routePointInfo.getEndIntervalRouteIndex()) ? |
| | | routePointInfo.getEndIntervalRouteIndex() : routePointInfo.getRoutePointIndex())); |
| | | kmlActionGroup.setActionGroupMode(ActionGroupModeEnums.SEQUENCE.getValue()); |
| | | |
| | | String actionTriggerType = ActionTriggerTypeEnums.REACH_POINT.getValue(); |
| | | Double actionTriggerParam = 0.0; |
| | | if (ObjectUtil.isNotNull(routePointInfo.getTimeInterval())) { |
| | |
| | | actionTriggerType = ActionTriggerTypeEnums.MULTIPLE_DISTANCE.getValue(); |
| | | actionTriggerParam = routePointInfo.getDistanceInterval(); |
| | | } |
| | | |
| | | kmlActionGroup.setActionTrigger(buildKmlActionTrigger(actionTriggerType, actionTriggerParam)); |
| | | List<KmlAction> kmlActionList = new ArrayList<>(); |
| | | for (PointActionReq pointActionReq : routePointInfo.getActions()) { |
| | |
| | | } else if (ObjectUtil.isNotNull(pointActionReq.getStopRecord()) && pointActionReq.getStopRecord()) { |
| | | kmlActionList.add(buildKmlAction(String.valueOf(pointActionReq.getActionIndex()), ActionActuatorFuncEnums.STOP_RECORD.getValue(), pointActionReq, kmlParams)); |
| | | } |
| | | |
| | | } |
| | | kmlActionGroup.setAction(kmlActionList); |
| | | return kmlActionGroup; |