From 8bceb593cd9d504d2778814c91aa503c527c9eab Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期日, 23 四月 2023 17:54:36 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/service/show/InquiryService.java | 32 ++++++++++++++++++++++++-------- 1 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/lf/server/service/show/InquiryService.java b/src/main/java/com/lf/server/service/show/InquiryService.java index 2e0e22e..207e3ba 100644 --- a/src/main/java/com/lf/server/service/show/InquiryService.java +++ b/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) { -- Gitblit v1.9.3