管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-04-23 8bceb593cd9d504d2778814c91aa503c527c9eab
1
已修改1个文件
32 ■■■■ 文件已修改
src/main/java/com/lf/server/service/show/InquiryService.java 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/show/InquiryService.java
@@ -10,7 +10,6 @@
import com.lf.server.helper.*;
import com.lf.server.service.data.DownloadService;
import com.lf.server.service.data.PublishService;
import com.lf.server.service.sys.DownlogService;
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.model.ZipParameters;
import org.springframework.stereotype.Service;
@@ -125,18 +124,35 @@
            return;
        }
        int x = 0;
        int y = 0;
        // 关键算法
        int[] leftTop = deg2num(zoom, dt.getXmin(), dt.getYmax());
        int[] rightBottom = deg2num(zoom, dt.getXmax(), dt.getYmin());
        String pngPath = String.format("%s\\%d\\%d.png", pub.getPath(), x, y);
        File pngFile = new File(pngPath);
        if (pngFile.exists()) {
            list.add(pngFile);
        for (int x = leftTop[0]; x <= rightBottom[0]; x++) {
            for (int y = leftTop[1]; y <= rightBottom[1]; y++) {
                String pngPath = String.format("%s\\%d\\%d.png", pub.getPath(), x, y);
                File pngFile = new File(pngPath);
                if (pngFile.exists()) {
                    list.add(pngFile);
                }
            }
        }
    }
    /**
     * 角度转数值
     */
    private int[] deg2num(int zoom, double x, double y) {
        double yRad = Math.toRadians(y);
        double n = Math.pow(2.0, zoom);
        int xTile = (int) ((x + 180.0) / 360.0 * n);
        int yTile = (int) ((1.0 - Math.log(Math.tan(yRad) + (1 / Math.cos(yRad))) / Math.PI) / 2.0 * n);
        return new int[]{xTile, yTile};
    }
    /**
     * 添加文件至压缩包
     */
    private void addFiles(ZipFile zip, ZipParameters params, List<File> list, String basePath) {