xieb
2024-05-06 066f132c523fb2d8dbcaf20ea900db061b068910
图斑航线按机场范围生成
1 files modified
24 ■■■■■ changed files
src/main/java/com/dji/sample/patches/utils/GeoToolsUtil.java 24 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/utils/GeoToolsUtil.java
@@ -176,7 +176,7 @@
//        });
        List<PointPO> pointPOS = getRoutePointOrder(list,28.624514734, 115.856725497);
        List<PointPO> pointPOS = getRoutePointOrder(list, 28.624514734, 115.856725497);
        for (PointPO c :
                pointPOS) {
@@ -194,9 +194,9 @@
    public static List<PointPO> getRoutePointOrder(List<LotInfo> list, double airportLat, double airportLon) {
        List<Coordinate> centros = new ArrayList<>();
        List<List<Coordinate>> extremePoints = new ArrayList<>();
        Map<Coordinate, List<Coordinate>> points = new HashMap<>();
        AtomicInteger numSize = new AtomicInteger();
        list.forEach(patche -> {
        for (LotInfo patche : list) {
            String wkt = patche.getDkfw();
            // 解析WKT字符串为多边形
            WKTReader wktReader = new WKTReader(JTSFactoryFinder.getGeometryFactory());
@@ -209,6 +209,13 @@
            // 开始封装中心点坐标
            Coordinate coordinateCentro = getCentro(polygon);
            double distance = DistanceCalculator.calculateDistance(airportLat, airportLon, coordinateCentro.y,coordinateCentro.x);
            // 机场范围,操作机场范围将不生成
            if (distance * 1000 > 7000) {
                continue;
            }
            centros.add(coordinateCentro);
            // 开始封装图斑4个航线
@@ -219,8 +226,8 @@
            // 保存稀释拐点之后总数量
            numSize.set(numSize.get() + coordinatePointList.size());
        }
        });
        // 开始排序
        Coordinate[] coordinates = new Coordinate[centros.size() + 1];
@@ -275,7 +282,7 @@
        List<Integer> indexs = new ArrayList<>();
        // 拿排序前的索引index 根据排序前和排序后的结果匹对------》后期优化
        for (int i = 1; i<sortedCoordinates.length; i++) {
        for (int i = 1; i < sortedCoordinates.length; i++) {
            Coordinate c1 = sortedCoordinates[i];
            for (int j = 1; j < oldCoordinateList.size(); j++) {
                Coordinate c2 = oldCoordinateList.get(j);
@@ -288,14 +295,13 @@
        // 根据排序前的索引按顺序赋值
        int i = 0;
        for (Integer index: indexs) {
            for (Coordinate coordinate:extremePoints.get(index)) {
                i = i+1;
        for (Integer index : indexs) {
            for (Coordinate coordinate : extremePoints.get(index)) {
                i = i + 1;
                retc[i] = coordinate;
                retcList.add(PointPO.builder().index(index).coordinate(coordinate).build());
            }
        }
        return retcList;