| | |
| | | package com.ard.route.util; |
| | | |
| | | import com.ard.route.domain.*; |
| | | import com.ard.route.domain.djuav.*; |
| | | import com.ard.route.domain.sixhe.ArdRouteActions; |
| | | import com.ard.route.domain.sixhe.ArdRouteChange; |
| | | import com.ard.route.domain.sixhe.ArdRoutePoints; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import static com.ard.route.enums.kml.DroneEnumValueEnums.M350_RTK; |
| | | import static com.ard.route.util.ToolUtils.getDoublePoint; |
| | | |
| | | /** |
| | | * 初始化数据 |
| | |
| | | */ |
| | | public class InitializationUtils { |
| | | |
| | | private static final Double CHANSI_H20 = 23.76237623; |
| | | // 禅思H20T 公倍数 |
| | | private static final Double CHANSI_H20T = 23.76237623; |
| | | |
| | | // 禅思H20T 焦距值 |
| | | private static final Double CHANSI_H20_FOCUS = 6.83; |
| | | |
| | | private static final String WAYPOINT_TURN_MODE_DEFAULT = "toPointAndStopWithDiscontinuityCurvature"; |
| | | |
| | | /** |
| | |
| | | public UavRouteReq initialization(UavRouteReq uavRouteReq){ |
| | | uavRouteReq.setTemplateType("waypoint"); |
| | | // 起始点默认航线第一个点 |
| | | uavRouteReq.setTakeOffRefPoint( |
| | | uavRouteReq.getRoutePointList().get(0).getLatitude() + "," + |
| | | uavRouteReq.getRoutePointList().get(0).getLongitude() + "," + "0"); |
| | | if (uavRouteReq.getTakeOffRefPoint() == null){ |
| | | uavRouteReq.setTakeOffRefPoint( |
| | | uavRouteReq.getRoutePointList().get(0).getLatitude() + "," + |
| | | uavRouteReq.getRoutePointList().get(0).getLongitude() + "," + |
| | | uavRouteReq.getRoutePointList().get(0).getHeight()); |
| | | } |
| | | //uavRouteReq.setDroneType(89); |
| | | uavRouteReq.setSubDroneType(0); |
| | | uavRouteReq.setPayloadType(43); |
| | |
| | | if (uavRouteReq.getGlobalWaypointTurnMode() != null){ |
| | | waypointTurnReq.setWaypointTurnMode(uavRouteReq.getGlobalWaypointTurnMode()); |
| | | }else { |
| | | waypointTurnReq.setWaypointTurnMode("toPointAndStopWithDiscontinuityCurvature"); |
| | | waypointTurnReq.setWaypointTurnMode(WAYPOINT_TURN_MODE_DEFAULT); |
| | | } |
| | | uavRouteReq.setWaypointTurnReq(waypointTurnReq); |
| | | uavRouteReq.setGimbalPitchMode("usePointSetting"); |
| | | //buildZoom(uavRouteReq); |
| | | if (M350_RTK.getValue().equals(uavRouteReq.getDroneType())) { |
| | | // 变焦数值加工 |
| | | buildZoom(uavRouteReq); |
| | | } |
| | | // 修改每个航点的高度 |
| | | buildHeight(uavRouteReq); |
| | | // 动作组编号数据加工 |
| | | buildActionGroupReq(uavRouteReq); |
| | | return uavRouteReq; |
| | | } |
| | | |
| | | /** |
| | | * 构建动作组编号 |
| | | */ |
| | | public void buildActionGroupReq(UavRouteReq uavRouteReq){ |
| | | int pointActionCounter = 0; |
| | | for (RoutePointReq routePointReq : uavRouteReq.getRoutePointList()) { |
| | | if (routePointReq.getActionGroupList() != null){ |
| | | for (ActionGroupReq actionGroupReq : routePointReq.getActionGroupList()) { |
| | | actionGroupReq.setActionGroupId(pointActionCounter++); |
| | | actionGroupReq.setActionGroupStartIndex(routePointReq.getRoutePointIndex()); |
| | | actionGroupReq.setActionGroupEndIndex(routePointReq.getRoutePointIndex()); |
| | | actionGroupReq.setActionTriggerType("reachPoint"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改每个航点的高度 |
| | | * 根据起飞点高度减去当前航点高度 |
| | | */ |
| | | public void buildHeight(UavRouteReq uavRouteReq){ |
| | | if (!"EGM96".equals(uavRouteReq.getHeightMode())){ |
| | | double takeOffHeight = getDoublePoint(uavRouteReq.getTakeOffRefPoint(),"alt"); |
| | | for (RoutePointReq routePointReq : uavRouteReq.getRoutePointList()) { |
| | | routePointReq.setHeight(routePointReq.getHeight() - takeOffHeight); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 变焦动作加工 |
| | | */ |
| | | private UavRouteReq buildZoom(UavRouteReq uavRouteReq){ |
| | | private void buildZoom(UavRouteReq uavRouteReq){ |
| | | for (RoutePointReq routePointReq : uavRouteReq.getRoutePointList()) { |
| | | for (ActionGroupReq actionGroupReq : routePointReq.getActionGroupList()) { |
| | | for (PointActionReq action : actionGroupReq.getActions()) { |
| | | if (action.getZoom() != null){ |
| | | action.setZoom(action.getZoom() * CHANSI_H20); |
| | | if (!routePointReq.getActionGroupList().isEmpty()){ |
| | | for (ActionGroupReq actionGroupReq : routePointReq.getActionGroupList()) { |
| | | for (PointActionReq action : actionGroupReq.getActions()) { |
| | | if (action.getZoom() != null){ |
| | | action.setZoom(multiple23(action.getZoom())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return uavRouteReq; |
| | | } |
| | | |
| | | public static Double multiple23(Double zoom){ |
| | | return zoom * CHANSI_H20T; |
| | | } |
| | | |
| | | public static Double divided23(Double zoom){ |
| | | return zoom / CHANSI_H20T; |
| | | } |
| | | |
| | | } |