| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.MapNode; |
| | |
| | | * 获取分段路径,每当有一个拐点则进行一次分段,最终返回总分段数据 |
| | | */ |
| | | public List<List<NavigateNode>> getSectionPath(List<NavigateNode> mapList) { |
| | | List<List<NavigateNode>> list = new ArrayList<>(); |
| | | NavigateNode firstNode = mapList.get(0); |
| | | //获取地图 |
| | | List<List<MapNode>> mapNodes = navigateMapData.getJsonData(firstNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); |
| | | |
| | | List<List<NavigateNode>> list = new ArrayList<>(); |
| | | List<NavigateNode> data = new ArrayList<>(); |
| | | String direction = mapList.get(0).getDirection();//行走方向 |
| | | String direction = firstNode.getDirection();//行走方向 |
| | | |
| | | for (NavigateNode navigateNode : mapList) { |
| | | data.add(navigateNode); |
| | |
| | | //直行线路 |
| | | navigateNode.setDirection(direction);//设置行走方向 |
| | | } |
| | | Integer distance = getXToNextDistance(navigateNode);//获取当前点到下一点的行走距离 |
| | | Integer distance = getXToNextDistance(mapNodes, navigateNode);//获取当前点到下一点的行走距离 |
| | | navigateNode.setMoveDistance(distance); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //获取从x点到下一点的行走距离 |
| | | public Integer getXToNextDistance(NavigateNode xNode) { |
| | | NavigateMapData mapData = SpringUtils.getBean(NavigateMapData.class); |
| | | List<List<MapNode>> lists = mapData.getJsonData(xNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); |
| | | if (lists != null) { |
| | | MapNode mapNode = lists.get(xNode.getX()).get(xNode.getY()); |
| | | if (mapNode != null) { |
| | | switch (xNode.getDirection()) { |
| | | case "top": |
| | | return mapNode.getTop(); |
| | | case "bottom": |
| | | return mapNode.getBottom(); |
| | | case "left": |
| | | return mapNode.getLeft(); |
| | | case "right": |
| | | return mapNode.getRight(); |
| | | } |
| | | } |
| | | public Integer getXToNextDistance(List<List<MapNode>> mapLists, NavigateNode xNode) { |
| | | if (mapLists == null) { |
| | | return 0; |
| | | } |
| | | |
| | | if (mapLists.isEmpty()) { |
| | | return 0; |
| | | } |
| | | |
| | | MapNode mapNode = mapLists.get(xNode.getX()).get(xNode.getY()); |
| | | if (mapNode != null) { |
| | | switch (xNode.getDirection()) { |
| | | case "top": |
| | | return mapNode.getTop(); |
| | | case "bottom": |
| | | return mapNode.getBottom(); |
| | | case "left": |
| | | return mapNode.getLeft(); |
| | | case "right": |
| | | return mapNode.getRight(); |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | |