| | |
| | | return navigateNodeList; |
| | | } |
| | | |
| | | public List<List<NavigateNode>> getRgvTrackMap() { |
| | | BasMapService basMapService = SpringUtils.getBean(BasMapService.class); |
| | | BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", 1)); |
| | | if (basMap == null) { |
| | | throw new CoolException("地图不存在"); |
| | | } |
| | | |
| | | List<List<JSONObject>> dataList = JSON.parseObject(basMap.getData(), List.class); |
| | | |
| | | List<List<NavigateNode>> navigateNodeList = new ArrayList<>(); |
| | | for (int i = 0; i < dataList.size(); i++) { |
| | | List<JSONObject> row = dataList.get(i); |
| | | List<NavigateNode> navigateNodeRow = new ArrayList<>(); |
| | | for (int j = 0; j < row.size(); j++) { |
| | | JSONObject map = row.get(j); |
| | | NavigateNode navigateNode = new NavigateNode(i, j); |
| | | |
| | | String nodeType = map.getString("type"); |
| | | if(nodeType == null) { |
| | | navigateNode.setValue(MapNodeType.DISABLE.id); |
| | | }else if(nodeType.equals("rgv")){ |
| | | navigateNode.setValue(MapNodeType.NORMAL_PATH.id); |
| | | JSONObject valueObj = JSON.parseObject(map.getString("value")); |
| | | |
| | | //RGV暂不控制行走方向,默认上下左右都可走 |
| | | List<String> directionList = new ArrayList<>(); |
| | | directionList.add("top"); |
| | | directionList.add("bottom"); |
| | | directionList.add("left"); |
| | | directionList.add("right"); |
| | | navigateNode.setDirectionList(directionList); |
| | | }else { |
| | | navigateNode.setValue(MapNodeType.DISABLE.id); |
| | | } |
| | | |
| | | navigateNode.setNodeType(nodeType); |
| | | navigateNode.setNodeValue(map.getString("value")); |
| | | navigateNodeRow.add(navigateNode); |
| | | } |
| | | navigateNodeList.add(navigateNodeRow); |
| | | } |
| | | |
| | | return navigateNodeList; |
| | | } |
| | | |
| | | public NavigateNode astarSearchJava(List<List<NavigateNode>> map, NavigateNode start, NavigateNode end) { |
| | | // 清理上次搜索的状态,防止复用实例导致记录残留 |
| | | this.Open.clear(); |
| | |
| | | return null; |
| | | } |
| | | |
| | | public NavigateNode findTrackSiteNoNavigateNode(List<List<NavigateNode>> map, int trackSiteNo) { |
| | | for(int x = 0; x < map.size(); x++) { |
| | | for(int y = 0; y < map.get(0).size(); y++) { |
| | | NavigateNode node = map.get(x).get(y); |
| | | if("rgv".equals(node.getNodeType())) { |
| | | JSONObject valueObj = JSON.parseObject(node.getNodeValue()); |
| | | if(valueObj.getInteger("trackSiteNo") == trackSiteNo) { |
| | | return node; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | //------------------A*启发函数------------------// |
| | | |
| | | //计算通过现在的结点的位置和最终结点的位置计算H值(曼哈顿法:坐标分别取差值相加) |