MSDK中kmz 设置返航高度
已完成你好,我在MSDK中设置了globalRTHHeight 和isGlobalRTHHeightSet 两个值后最后执行航线的返航高度还是当前航点的高度
-
public static List<WaylineActionGroup> transformActionsFrom(List<WaylineActionInfo> waypointInfoModels, int actionNum) {
List<WaylineActionGroup> actionGroups = new ArrayList<>();
for (int i = 0; i < actionNum; i++) {
WaylineActionGroup actionGroup = new WaylineActionGroup();
WaylineActionTrigger trigger = new WaylineActionTrigger();
trigger.setTriggerType(WaylineActionTriggerType.REACH_POINT);
actionGroup.setTrigger(trigger);
actionGroup.setGroupId(i);
actionGroup.setStartIndex(i);
actionGroup.setEndIndex(i);
actionGroups.add(actionGroup);
actionGroup.setActions(waypointInfoModels);
List<WaylineActionNodeList> nodeLists = new ArrayList<>();
WaylineActionNodeList root = new WaylineActionNodeList();
List<WaylineActionTreeNode> treeNodes = new ArrayList<>();
WaylineActionTreeNode rootNode = new WaylineActionTreeNode();
rootNode.setNodeType(WaylineActionsRelationType.SEQUENCE);
rootNode.setChildrenNum(1);
treeNodes.add(rootNode);
root.setNodes(treeNodes);
nodeLists.add(root);
actionGroup.setNodeLists(nodeLists);
}
return actionGroups;
}public static String clearKmzActions(String kmzPath, String kmzName) {
if (TextUtils.isEmpty(kmzPath)) {
return "";
}
File file = new File(kmzPath, kmzName);
if (!file.exists()) {
return "";
}
String filePath = kmzPath + kmzName;
KmzFileVersion kmzFileVersion = JNIWPMZManager.getKmzFileVersion(filePath);
String versionFormat = "%d.%d.%d";
WpmzVersion version = kmzFileVersion.getWaylineFileVersion().getVersion();
String versionStr = String.format(versionFormat, version.getMajor(), version.getMinor(), version.getPatch());
Logger.e("航线版本:%s", versionStr);
WaylineMission mission = JNIWPMZManager.getWaylineMission(versionStr, filePath).getMission();
mission.setUpdateTime(System.currentTimeMillis() + 0.0);
WaylineMissionConfig config = JNIWPMZManager.getWaylineMissionConfig(versionStr, filePath).getConfig();
// 将航线结束动作改为无动作
config.setFinishAction(WaylineFinishedAction.NO_ACTION);
WaylineTemplatesParseInfo waylineTemplates =
JNIWPMZManager.getWaylineTemplates(versionStr, filePath);
if (waylineTemplates.getTemplates().isEmpty()) {
// ToastUtils.showToast(this, "解析航线失败,请重试")
Logger.e("解析航线文件失败:%s", filePath);
return "";
}
WaylineTemplate waylineTemplate = waylineTemplates.getTemplates().get(0);
// TODO 添加航点动作
// List<WaylineActionGroup> actionGroups = waylineTemplate.getWaypointInfo().getActionGroups();
//
// List<WaylineActionInfo> actionInfos = new ArrayList<>();
//
// actionInfos.add(transHover());
//
// Logger.e(waylineTemplate.getWaypointInfo().getActionGroups().toString());
//
// List<WaylineActionGroup> waylineActionGroups = transformActionsFrom(actionInfos, actionGroups.size());
// waylineTemplate.getWaypointInfo().setActionGroups(waylineActionGroups);
waylineTemplate.getWaypointInfo().setGlobalAction(null);
waylineTemplate.getWaypointInfo().setActionGroups(new ArrayList<>());
// waylineTemplate.getWaypointInfo().setIsGlobalActionSet(true);
Template mTemplate = TemplateTransform.INSTANCE.transFromWaylineTemplate(waylineTemplate);
String json1 = mission.toJson().toString();
Logger.json(json1);
String json2 = config.toJson().toString();
Logger.json(json2);
String json = waylineTemplate.toJson().toString();
Logger.json(json);
// file.delete();
// 构建航线文件
WPMZManager.getInstance()
.generateKMZFile(kmzPath + "d.kmz", mission, config, mTemplate);
return kmzPath;
}转换前:https://ent.qingniao.cloud:9000/qn-cloud/KMZ/e09e72af-ee19-4779-9843-58c4bc062c96.kmz
转换后:https://ent.qingniao.cloud:9000/qn-cloud/KMZ/c19efbd3-b037-40fe-9a8b-7f8b468f29da.kmz
打开 TODO 添加航点这几行的注释转换后的文件:
https://ent.qingniao.cloud:9000/qn-cloud/KMZ/29666e92-b349-4477-b610-babf5e458e07.kmz
我尝试将上面的文件删除航点动作后,上面两个文件分别代表了对应的文件
请先登录再写评论。
评论
6 条评论