| | |
| | | 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; |
| | |
| | | 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) { |