| | |
| | | |
| | | import com.dji.sample.patches.model.entity.LotInfo; |
| | | import com.dji.sample.patches.utils.GeoToolsUtil; |
| | | import com.dji.sample.patches.utils.PointPO; |
| | | import com.dji.sample.patches.xml.mode.share.ActionGroup; |
| | | import com.dji.sample.patches.xml.mode.share.ActionMode; |
| | | import com.dji.sample.patches.xml.mode.share.ActionTrigger; |
| | |
| | | * @param lotInfos |
| | | * @return |
| | | */ |
| | | public static XMLTemplateModel init(Coordinate[] coordinates,List<LotInfo> lotInfos) { |
| | | public static XMLTemplateModel init(List<PointPO> coordinates, List<LotInfo> lotInfos) { |
| | | |
| | | Folder folder = FolderUtils.setFloder(); |
| | | |
| | | List<Placemark> placemarkList = new ArrayList<>(); |
| | | int i = 0; |
| | | for (Coordinate c:coordinates) { |
| | | for (PointPO pointPO:coordinates) { |
| | | if (i != 0) {//去除第一个航点 |
| | | Coordinate c = pointPO.getCoordinate(); |
| | | Placemark placemark = PlacemarkUtils.setPlacemark(c.x + "," + c.y); |
| | | |
| | | // 增加事件组 |
| | |
| | | // 开始增加事件 |
| | | List<ActionMode> list = new ArrayList<>(); |
| | | ActionMode actionMode = new ActionMode(); |
| | | actionMode.setActionId(0); |
| | | actionMode.setActionId(1); |
| | | actionMode.setActionActuatorFunc(CameraActionEnum.TAKE_PHOTO.getDescription());//拍照事件 |
| | | // 计算获取图斑编号 |
| | | int quotient = i / 4; |
| | | if (i % 4 != 0) { // 检查是否有余数 |
| | | quotient++; // 如果有余数,商加1 |
| | | } |
| | | |
| | | if (quotient == 0) quotient = 1; |
| | | |
| | | actionMode.setActionActuatorFuncParam(ActionUtils.setTakePhoto(lotInfos.get(quotient-1).getDkbh())); |
| | | list.add(actionMode); |
| | | // actionMode.setActionActuatorFuncParam(ActionUtils.setTakePhoto(lotInfos.get(quotient-1).getDkbh())); |
| | | // 设置媒体文件名称后缀 |
| | | actionMode.setActionActuatorFuncParam(ActionUtils.setTakePhoto(lotInfos.get(pointPO.getIndex()).getDkbh() + "~" + lotInfos.get(pointPO.getIndex()).getTaskId())); |
| | | // actionMode.setActionActuatorFuncParam(ActionUtils.setTakePhoto("测试")); |
| | | |
| | | ActionMode actionMode2 = new ActionMode(); |
| | | actionMode2.setActionId(1); |
| | | actionMode2.setActionActuatorFunc(CameraActionEnum.GIMBAL_ROTATE.getDescription());//拍照事件 |
| | | actionMode2.setActionActuatorFuncParam(ActionUtils.setGimbalRotate()); |
| | | list.add(actionMode2); |
| | | actionMode2.setActionId(0); |
| | | actionMode2.setActionActuatorFunc(CameraActionEnum.GIMBAL_ROTATE.getDescription());//旋转云台 |
| | | |
| | | //设置转动角度 |
| | | double bearing = GeoToolsUtil.bearing(pointPO.getCoordinate().x,pointPO.getCoordinate().y,pointPO.getCentro().x,pointPO.getCentro().y); |
| | | actionMode2.setActionActuatorFuncParam(ActionUtils.setGimbalRotate(bearing)); |
| | | |
| | | list.add(actionMode2);//添加云台旋转 |
| | | list.add(actionMode);//添加拍照 |
| | | actionGroup.setActions(list); |
| | | |
| | | placemark.setActionGroup(actionGroup); |
| | |
| | | .author("Aix") |
| | | .createTime(String.valueOf(System.currentTimeMillis())) |
| | | .updateTime(String.valueOf(System.currentTimeMillis())) |
| | | .missionConfig(MissionConfigUtils.setMissionConfig(coordinates[0].y + "," + coordinates[0].x + ",0")) |
| | | .missionConfig(MissionConfigUtils.setMissionConfig(coordinates.get(0).getCoordinate().y + "," + coordinates.get(0).getCoordinate().x + ",0")) |
| | | .folder(folder) |
| | | .build(); |
| | | |
| | |
| | | double airportLat = 28.624514734; // 机场纬度 |
| | | double airportLon = 115.856725497; // 机场经度 |
| | | // 解析图斑生成航点,按顺序返回 |
| | | Coordinate[] coordinates = GeoToolsUtil.getRoutePointOrder(list, airportLat, airportLon); |
| | | List<PointPO> coordinates = GeoToolsUtil.getRoutePointOrder(list, airportLat, airportLon); |
| | | |
| | | // 初始化模板对象 |
| | | XMLTemplateModel xmlModel = XMLTemplateModel.init(coordinates, list); |