| | |
| | | |
| | | // v1 BFS ------------------------------------------------------------------------------ |
| | | public List<NavigateNode> getWaveScopeByCode(Integer lev, String code, Double radiusLen) { |
| | | double radiusLenSquared = Math.pow(radiusLen, 2); |
| | | |
| | | String[][] codeMatrix = mapDataDispatcher.getCodeMatrix(lev); |
| | | Double[][][] cdaMatrix = mapDataDispatcher.getCdaMatrix(lev); |
| | | |
| | |
| | | includeList.add(originNode); |
| | | existNodes.add(originNode); |
| | | |
| | | this.spreadWaveNode(originNode, originNode, codeMatrix, cdaMatrix, radiusLen, includeList, existNodes); |
| | | this.spreadWaveNode(originNode, originNode, codeMatrix, cdaMatrix, radiusLenSquared, includeList, existNodes); |
| | | |
| | | return includeList; |
| | | } |
| | | |
| | | public void spreadWaveNode(NavigateNode originNode, NavigateNode currNode |
| | | , String[][] codeMatrix, Double[][][] cdaMatrix, Double radiusLen |
| | | , String[][] codeMatrix, Double[][][] cdaMatrix, Double radiusLenSquared |
| | | , List<NavigateNode> includeList, Set<NavigateNode> existNodes) { |
| | | int x = currNode.getX(); |
| | | int y = currNode.getY(); |
| | | |
| | | this.extendNeighborNodes(originNode, new NavigateNode(x, y + 1), codeMatrix, cdaMatrix, radiusLen, includeList, existNodes); |
| | | this.extendNeighborNodes(originNode, new NavigateNode(x, y - 1), codeMatrix, cdaMatrix, radiusLen, includeList, existNodes); |
| | | this.extendNeighborNodes(originNode, new NavigateNode(x - 1, y), codeMatrix, cdaMatrix, radiusLen, includeList, existNodes); |
| | | this.extendNeighborNodes(originNode, new NavigateNode(x + 1, y), codeMatrix, cdaMatrix, radiusLen, includeList, existNodes); |
| | | this.extendNeighborNodes(originNode, new NavigateNode(x, y + 1), codeMatrix, cdaMatrix, radiusLenSquared, includeList, existNodes); |
| | | this.extendNeighborNodes(originNode, new NavigateNode(x, y - 1), codeMatrix, cdaMatrix, radiusLenSquared, includeList, existNodes); |
| | | this.extendNeighborNodes(originNode, new NavigateNode(x - 1, y), codeMatrix, cdaMatrix, radiusLenSquared, includeList, existNodes); |
| | | this.extendNeighborNodes(originNode, new NavigateNode(x + 1, y), codeMatrix, cdaMatrix, radiusLenSquared, includeList, existNodes); |
| | | } |
| | | |
| | | public void extendNeighborNodes(NavigateNode originNode, NavigateNode nextNode |
| | | , String[][] codeMatrix, Double[][][] cdaMatrix, Double radiusLen |
| | | , String[][] codeMatrix, Double[][][] cdaMatrix, Double radiusLenSquared |
| | | , List<NavigateNode> includeList, Set<NavigateNode> existNodes) { |
| | | |
| | | int x = nextNode.getX(); |
| | |
| | | |
| | | Double[] o1Cda = cdaMatrix[originNode.getX()][originNode.getY()]; |
| | | Double[] o2Cda = cdaMatrix[x][y]; |
| | | if (Math.pow(o1Cda[0] - o2Cda[0], 2) + Math.pow(o1Cda[1] - o2Cda[1], 2) <= Math.pow(radiusLen, 2)) { |
| | | if (Math.pow(o1Cda[0] - o2Cda[0], 2) + Math.pow(o1Cda[1] - o2Cda[1], 2) <= radiusLenSquared) { |
| | | nextNode.setCodeData(codeMatrix[x][y]); |
| | | |
| | | if (!nextNode.getCodeData().equals(CodeNodeType.NONE.val)) { |
| | | includeList.add(nextNode); |
| | | } |
| | | |
| | | this.spreadWaveNode(originNode, nextNode, codeMatrix, cdaMatrix, radiusLen, includeList, existNodes); |
| | | this.spreadWaveNode(originNode, nextNode, codeMatrix, cdaMatrix, radiusLenSquared, includeList, existNodes); |
| | | } |
| | | |
| | | } |