#
vincentlu
昨天 f076136ab3d84d0129a2b5898ee92dc1b70a4a30
zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java
@@ -9,6 +9,7 @@
import com.zy.acs.manager.core.domain.LaneDto;
import com.zy.acs.manager.core.domain.SortCodeDto;
import com.zy.acs.manager.core.domain.UnlockPathTask;
import com.zy.acs.manager.core.domain.VehicleFootprint;
import com.zy.acs.manager.core.service.astart.*;
import com.zy.acs.manager.core.service.astart.domain.AStarNavigateNode;
import com.zy.acs.manager.core.service.astart.domain.DynamicNode;
@@ -294,6 +295,35 @@
        return includeList;
    }
    public List<NavigateNode> getWaveScopeByCode(Integer lev, String code, VehicleFootprint footprint, double headingRad, double buffer) {
        int[] centerIdx = mapDataDispatcher.getCodeMatrixIdx(lev, code);
        if (centerIdx == null) {
            throw new CoolException(code + " does not exist in codeMatrix");
        }
        Double[][][] cdaMatrix = mapDataDispatcher.getCdaMatrix(lev);
        Double centerX = cdaMatrix[centerIdx[0]][centerIdx[1]][0];
        Double centerY = cdaMatrix[centerIdx[0]][centerIdx[1]][1];
        if (centerX == null || centerY == null) {
            throw new CoolException(code + " does not exist in cdaMatrix");
        }
        double searchRadius = footprint.maxExtent() + buffer;
        List<NavigateNode> candidates = this.getWaveScopeByCode(lev, code, searchRadius);
        List<NavigateNode> includeList = new ArrayList<>();
        for (NavigateNode node : candidates) {
            Double px = cdaMatrix[node.getX()][node.getY()][0];
            Double py = cdaMatrix[node.getX()][node.getY()][1];
            if (isInsideExpandedFootprint(px, py, centerX, centerY, footprint, headingRad, buffer)) {
                includeList.add(node);
            }
        }
        return includeList;
    }
    public void spreadWaveNode(NavigateNode originNode, NavigateNode currNode
            , String[][] codeMatrix, Double[][][] cdaMatrix, Double radiusLenSquared
            , List<NavigateNode> includeList, Set<NavigateNode> existNodes) {
@@ -338,6 +368,36 @@
    }
    private boolean isInsideExpandedFootprint(double px, double py, double centerX, double centerY
            , VehicleFootprint footprint, double headingRad, double buffer) {
        double dx = px - centerX;
        double dy = py - centerY;
        double localX = dx * Math.cos(headingRad) + dy * Math.sin(headingRad);
        double localY = -dx * Math.sin(headingRad) + dy * Math.cos(headingRad);
        double xMin = -footprint.getTail();
        double xMax = footprint.getHead();
        double yMin = -footprint.getHalfWidth();
        double yMax = footprint.getHalfWidth();
        double excessX = 0D;
        if (localX < xMin) {
            excessX = xMin - localX;
        } else if (localX > xMax) {
            excessX = localX - xMax;
        }
        double excessY = 0D;
        if (localY < yMin) {
            excessY = yMin - localY;
        } else if (localY > yMax) {
            excessY = localY - yMax;
        }
        return excessX * excessX + excessY * excessY <= buffer * buffer;
    }
    // v2 BFS ------------------------------------------------------------------------------
//    public List<NavigateNode> getWaveScopeByCode0(Integer lev, String code, Double radiusLen) {
//        String[][] codeMatrix = mapDataDispatcher.getCodeMatrix(lev);