| | |
| | | } |
| | | |
| | | //计算带末端段落路径 |
| | | public ArrayList<ArrayList<NavigateNode>> calcEndPath(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites, int lastPathPart) { |
| | | public List<List<NavigateNode>> calcEndPath(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites, int lastPathPart) { |
| | | //计算路径 |
| | | List<NavigateNode> navigateNodes = calc(startPoint, endPoint, mapTypes, shuttlePoints, whites); |
| | | if (navigateNodes == null) { |
| | |
| | | } |
| | | |
| | | //获取分段路径 |
| | | ArrayList<ArrayList<NavigateNode>> partList = this.getSectionPath(navigateNodes); |
| | | List<List<NavigateNode>> partList = this.getSectionPath(navigateNodes); |
| | | //根据传入的末端段落路径,找到末端点位 |
| | | int partResult = partList.size() - lastPathPart; |
| | | if (partResult == 0) {//路径数量相同无需分割 |
| | |
| | | throw new CoolException("分段路径与末端路径数量计算异常"); |
| | | } |
| | | int pathIdx = partResult - 1; |
| | | ArrayList<ArrayList<NavigateNode>> filterList = new ArrayList<>(); |
| | | List<List<NavigateNode>> filterList = new ArrayList<>(); |
| | | for (int i = 0; i <= pathIdx; i++) { |
| | | filterList.add(partList.get(i)); |
| | | } |
| | |
| | | |
| | | //计算末端段落地址 |
| | | public String calcEndLocation(String startPoint, String endPoint, List<NavigationMapType> mapTypes, List<int[]> shuttlePoints, List<int[]> whites, int lastPathPart) { |
| | | ArrayList<ArrayList<NavigateNode>> endPath = calcEndPath(startPoint, endPoint, mapTypes, shuttlePoints, whites, lastPathPart); |
| | | List<List<NavigateNode>> endPath = calcEndPath(startPoint, endPoint, mapTypes, shuttlePoints, whites, lastPathPart); |
| | | if (endPath == null) { |
| | | return null; |
| | | } |
| | |
| | | return findTargetLocation(endPath); |
| | | } |
| | | |
| | | public String findTargetLocation(List<NavigateNode> nodeList) { |
| | | ArrayList<ArrayList<NavigateNode>> sectionPath = this.getSectionPath(nodeList); |
| | | return findTargetLocation(sectionPath); |
| | | } |
| | | |
| | | public String findTargetLocation(ArrayList<ArrayList<NavigateNode>> partList) { |
| | | ArrayList<NavigateNode> nodes = partList.get(partList.size() - 1); |
| | | public String findTargetLocation(List<List<NavigateNode>> partList) { |
| | | List<NavigateNode> nodes = partList.get(partList.size() - 1); |
| | | NavigateNode targetNode = nodes.get(0); |
| | | String locNo = NavigatePositionConvert.nodeToLocNo(targetNode); |
| | | return locNo; |
| | |
| | | * 加转弯节点 |
| | | * 获取分段路径,每当有一个拐点则进行一次分段,最终返回总分段数据 |
| | | */ |
| | | public ArrayList<ArrayList<NavigateNode>> getSectionPath(List<NavigateNode> mapList) { |
| | | ArrayList<ArrayList<NavigateNode>> list = new ArrayList<>(); |
| | | public List<List<NavigateNode>> getSectionPath(List<NavigateNode> mapList) { |
| | | List<List<NavigateNode>> list = new ArrayList<>(); |
| | | |
| | | ArrayList<NavigateNode> data = new ArrayList<>(); |
| | | List<NavigateNode> data = new ArrayList<>(); |
| | | String direction = mapList.get(0).getDirection();//行走方向 |
| | | |
| | | for (NavigateNode navigateNode : mapList) { |
| | |
| | | //将最后一段数据添加进入 |
| | | list.add(data); |
| | | |
| | | return list; |
| | | List<List<NavigateNode>> paths = getSectionPathToSplitOverLength(list); |
| | | return paths; |
| | | } |
| | | |
| | | //分段路径-处理超长直线段路径 |
| | | public List<List<NavigateNode>> getSectionPathToSplitOverLength(List<List<NavigateNode>> list) { |
| | | List<List<NavigateNode>> paths = new ArrayList<>(); |
| | | int overLength = 9; |
| | | for (List<NavigateNode> nodes : list) { |
| | | if (nodes.size() > overLength) { |
| | | List<NavigateNode> copy = JSON.parseArray(JSON.toJSONString(nodes), NavigateNode.class); |
| | | List<NavigateNode> tmp = new ArrayList<>(); |
| | | int tmpCount = 0; |
| | | NavigateNode lastNode = null; |
| | | for (NavigateNode node : copy) { |
| | | tmp.add(node); |
| | | tmpCount++; |
| | | |
| | | if(tmpCount >= overLength) { |
| | | if (lastNode == null) { |
| | | NavigateNode startNode = tmp.get(0); |
| | | startNode.setLinePartAllowGo(true);//直线段超长部分允许直接行走 |
| | | tmp.set(0, startNode); |
| | | } |
| | | NavigateNode targetNode = tmp.get(tmp.size() - 1); |
| | | targetNode.setLinePartAllowGo(true);//直线段超长部分允许直接行走 |
| | | if (lastNode != null) { |
| | | tmp.add(0, lastNode); |
| | | } |
| | | |
| | | paths.add(tmp); |
| | | tmp = new ArrayList<>(); |
| | | tmpCount = 0; |
| | | lastNode = targetNode; |
| | | } |
| | | } |
| | | |
| | | if (tmpCount > 0) { |
| | | tmp.add(0, lastNode); |
| | | paths.add(tmp); |
| | | } |
| | | }else { |
| | | paths.add(nodes); |
| | | } |
| | | } |
| | | return paths; |
| | | } |
| | | |
| | | //获取从x点到下一点的行走距离 |
| | |
| | | * 根据原始节点结果,计算总行走距离 |
| | | */ |
| | | public Integer getOriginPathAllDistance(List<NavigateNode> path) { |
| | | ArrayList<ArrayList<NavigateNode>> sectionPath = getSectionPath(path); |
| | | List<List<NavigateNode>> sectionPath = getSectionPath(path); |
| | | Integer allDistance = 0; |
| | | for (ArrayList<NavigateNode> navigateNodes : sectionPath) { |
| | | for (List<NavigateNode> navigateNodes : sectionPath) { |
| | | Integer distance = getCurrentPathAllDistance(navigateNodes); |
| | | allDistance += distance; |
| | | } |