| | |
| | | package com.ard.route.util; |
| | | |
| | | import com.ard.oss.service.impl.OssServiceContext; |
| | | import com.ard.route.domain.djuav.ActionGroupReq; |
| | | import com.ard.route.domain.djuav.PointActionReq; |
| | | import com.ard.route.domain.djuav.RoutePointReq; |
| | | import com.ard.route.domain.djuav.UavRouteReq; |
| | | import com.ard.route.domain.djuav.kml.*; |
| | | import com.ard.route.domain.route.ArdRouteInfo; |
| | | import com.ard.route.domain.vo.KmzInfoVo; |
| | | import com.ard.work.domain.dto.state.PointData; |
| | | import com.ard.work.domain.dto.wayline.PlanLineData; |
| | | import com.ard.work.domain.dto.wayline.PointAction; |
| | | import com.ard.work.domain.dto.wayline.WayLineUploadDTO; |
| | | import org.apache.commons.compress.archivers.ArchiveEntry; |
| | | import org.apache.commons.compress.archivers.ArchiveInputStream; |
| | | import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.InputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | return pointActionReq; |
| | | } |
| | | |
| | | /** |
| | | * ArdRouteInfo实体转换,WayLineUploadDTO |
| | | */ |
| | | public static WayLineUploadDTO buildWayLineUploadDTO(ArdRouteInfo ardRouteInfo){ |
| | | WayLineUploadDTO wayLineUploadDTO = new WayLineUploadDTO(); |
| | | String finishAction = ardRouteInfo.getUavRouteReq().getFinishAction(); //1 |
| | | Double autoFlightSpeed = ardRouteInfo.getUavRouteReq().getAutoFlightSpeed(); //15 |
| | | Double globalTransitionalSpeed = ardRouteInfo.getUavRouteReq().getGlobalTransitionalSpeed(); //8 |
| | | String exitOnRcLostAction = ardRouteInfo.getUavRouteReq().getExitOnRcLostAction(); //0 |
| | | |
| | | PlanLineData planLineData = new PlanLineData(); |
| | | if (finishAction != null){ |
| | | planLineData.setLoseAction(0); |
| | | } |
| | | if (autoFlightSpeed != null){ |
| | | planLineData.setAutoSpeed(8); |
| | | } |
| | | planLineData.setMaxSpeed(15); |
| | | // if (globalTransitionalSpeed != null){ |
| | | // planLineData.setMaxSpeed(15); |
| | | // } |
| | | if (exitOnRcLostAction != null){ |
| | | planLineData.setFinishedAction(1); |
| | | } |
| | | planLineData.setHomeHeight(50); |
| | | planLineData.setInterests(new ArrayList<>()); |
| | | planLineData.setIsSaveEnergyMode(0); |
| | | planLineData.setPoints(buildPointDataList(ardRouteInfo.getUavRouteReq())); |
| | | |
| | | wayLineUploadDTO.setWayLineData(planLineData); |
| | | return wayLineUploadDTO; |
| | | } |
| | | |
| | | public static List<PointData> buildPointDataList(UavRouteReq uavRouteReq){ |
| | | List<PointData> pointDataList = new ArrayList<>(); |
| | | for (RoutePointReq routePointReq : uavRouteReq.getRoutePointList()) { |
| | | PointData pointData = new PointData(); |
| | | |
| | | Integer routePointIndex = routePointReq.getRoutePointIndex(); |
| | | if (routePointIndex != null){ |
| | | pointData.setGroupIndex(routePointIndex); |
| | | } |
| | | Double height = routePointReq.getHeight(); |
| | | if (height != null){ |
| | | pointData.setHeight(height.floatValue()); |
| | | } |
| | | Double longitude = routePointReq.getLongitude(); |
| | | if (longitude != null){ |
| | | pointData.setLng(longitude.floatValue()); |
| | | } |
| | | Double latitude = routePointReq.getLatitude(); |
| | | if (latitude != null){ |
| | | pointData.setLat(latitude.floatValue()); |
| | | } |
| | | Double speed = routePointReq.getSpeed(); |
| | | if (speed != null){ |
| | | pointData.setSpeed(speed.floatValue()); |
| | | } |
| | | pointData.setDampingDistance(0); |
| | | pointData.setFlightPathMode(1); |
| | | pointData.setHeading(0); |
| | | pointData.setHeadingMode(0); |
| | | pointData.setInterestIndex(-1); |
| | | pointData.setSafeGohomeFlag(0); |
| | | pointData.setActions(buildPointActionList(routePointReq.getActionGroupList())); |
| | | pointDataList.add(pointData); |
| | | |
| | | } |
| | | return pointDataList; |
| | | } |
| | | |
| | | public static List<PointAction> buildPointActionList(List<ActionGroupReq> actionGroupList){ |
| | | List<PointAction> pointActionList = new ArrayList<>(); |
| | | for (ActionGroupReq actionGroupReq : actionGroupList) { |
| | | for (PointActionReq action : actionGroupReq.getActions()) { |
| | | PointAction pointAction = typeProcessing(action); |
| | | pointActionList.add(pointAction); |
| | | } |
| | | } |
| | | return pointActionList; |
| | | } |
| | | |
| | | public static PointAction typeProcessing(PointActionReq pointActionReq){ |
| | | PointAction pointAction = new PointAction(); |
| | | |
| | | if (pointActionReq.getZoom() != null){ |
| | | pointAction.setType(1); |
| | | pointAction.setParam(pointActionReq.getZoom().floatValue()); |
| | | pointAction.setSpeakInfo(""); |
| | | pointAction.setWaitTime(2); |
| | | } |
| | | |
| | | if (pointActionReq.getTakePhotoType() != null){ |
| | | pointAction.setType(2); |
| | | pointAction.setParam(1); |
| | | pointAction.setSpeakInfo(""); |
| | | pointAction.setWaitTime(2); |
| | | } |
| | | |
| | | if (pointActionReq.getStartRecord() != null){ |
| | | pointAction.setType(3); |
| | | pointAction.setParam(1); |
| | | pointAction.setSpeakInfo(""); |
| | | pointAction.setWaitTime(2); |
| | | } |
| | | |
| | | if (pointActionReq.getStopRecord() != null){ |
| | | pointAction.setType(4); |
| | | pointAction.setParam(1); |
| | | pointAction.setSpeakInfo(""); |
| | | pointAction.setWaitTime(2); |
| | | } |
| | | |
| | | if (pointActionReq.getAircraftHeading() != null){ |
| | | pointAction.setType(5); |
| | | pointAction.setParam(pointActionReq.getAircraftHeading().floatValue()); |
| | | pointAction.setSpeakInfo(""); |
| | | pointAction.setWaitTime(2); |
| | | } |
| | | |
| | | if (pointActionReq.getGimbalPitchRotateAngle() != null){ |
| | | pointAction.setType(6); |
| | | pointAction.setParam(pointActionReq.getGimbalPitchRotateAngle().floatValue()); |
| | | pointAction.setSpeakInfo(""); |
| | | pointAction.setWaitTime(2); |
| | | } |
| | | |
| | | if (pointActionReq.getGimbalYawRotateAngle() != null){ |
| | | pointAction.setType(7); |
| | | pointAction.setParam(pointActionReq.getGimbalYawRotateAngle().floatValue()); |
| | | pointAction.setSpeakInfo(""); |
| | | pointAction.setWaitTime(2); |
| | | } |
| | | |
| | | if (pointActionReq.getHoverTime() != null){ |
| | | pointAction.setType(9); |
| | | pointAction.setParam(pointActionReq.getHoverTime().floatValue()); |
| | | pointAction.setSpeakInfo(""); |
| | | pointAction.setWaitTime(2); |
| | | } |
| | | |
| | | return pointAction; |
| | | |
| | | } |
| | | |
| | | } |