From a50e2b2d6f92040abfc98a027a966990fc27a278 Mon Sep 17 00:00:00 2001 From: 张洋洋 <10611411+yang-yang-z@user.noreply.gitee.com> Date: 星期五, 14 二月 2025 13:36:19 +0800 Subject: [PATCH] [add]tif裁剪 --- src/main/java/com/se/simu/controller/SimuController.java | 66 ++++++++++++++++++++++----------- 1 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/se/simu/controller/SimuController.java b/src/main/java/com/se/simu/controller/SimuController.java index cc52949..555d33f 100644 --- a/src/main/java/com/se/simu/controller/SimuController.java +++ b/src/main/java/com/se/simu/controller/SimuController.java @@ -244,10 +244,6 @@ Double minY = jsonObject.getDouble("minX"); Double maxY = jsonObject.getDouble("maxX"); // 3 鍒ゆ柇鑼冨洿鍊兼槸鍚︿负绌� - // vo.setMinx(jsonObject.getDouble("minX")); - // vo.setMaxx(jsonObject.getDouble("maxX")); - // vo.setMiny(jsonObject.getDouble("minY")); - // vo.setMaxy(jsonObject.getDouble("maxY")); vo.setMinx(jsonObject.getDouble("minY")); vo.setMaxx(jsonObject.getDouble("maxY")); vo.setMiny(jsonObject.getDouble("minX")); @@ -340,12 +336,36 @@ return fail("闃叉睕鑼冨洿涓嶈兘涓虹┖", false); } } + List<GridDto> dtos = new ArrayList<>(); + dtos.add(new GridDto(vo.getMinx(), vo.getMiny())); + dtos.add(new GridDto(vo.getMinx(), vo.getMaxy())); + dtos.add(new GridDto(vo.getMaxx(), vo.getMaxy())); + dtos.add(new GridDto(vo.getMaxx(), vo.getMiny())); + createSem(tableName, dtos); // 寮�濮嬫ā鎷熻绠� boolean flag = simuFilesService.createByfiles(vo); return success(flag, flag ? "鎴愬姛" : "澶辫触"); } catch (Exception ex) { return fail(ex, null); } + } + + public R<Boolean> createSem(String tableName, List<GridDto> dtos) throws Exception { + //闄嶉洦鏂囦欢鐢熸垚 + saveZarr(tableName); + //绠$偣鐢熸垚 + pointTosem(dtos); + //绠$嚎鐢熸垚 + lineToSem(dtos); + //鍦板舰鐢熸垚 + terrainToSem(dtos); + //鑼冨洿鐢熸垚 + gridToCityJson(dtos); + //娌虫祦鐢熸垚 + riverToSem(); + //鍦熷湴鍒╃敤鐢熸垚 + landuseToSem(); + return success(true); } @ApiOperation(value = "tarr鏂囦欢缁勮") @@ -492,6 +512,7 @@ SemUtils.cityJsonToSem(pointPath, filePatn + "node.sem"); return success(filePatn + "node.sem"); } + @ApiOperation(value = "绠$偣杞琧ityjson") @GetMapping(value = "/pointToCityJson", produces = "application/json; charset=UTF-8") public R<String> pointToCityJson(@RequestParam("shpPath") String shpPath) throws Exception { @@ -696,6 +717,7 @@ SemUtils.cityJsonToSem(pointPath, filePatn + "link.sem"); return success(filePatn + "link.sem"); } + @ApiOperation(value = "鍦板舰杞瑂em") @PostMapping(value = "/terrainToSem", produces = "application/json; charset=UTF-8") public R<String> terrainToSem(@RequestBody List<GridDto> dtos) throws Exception { @@ -705,29 +727,29 @@ if (!dirFile.exists()) { dirFile.mkdirs(); } - double minx=180.0; - double maxx=0.0; - double miny=180.0; - double maxy=0.0; - for (GridDto dto:dtos - ) { - if (dto.getLon()>maxx){ - maxx=dto.getLon(); + double minx = 180.0; + double maxx = 0.0; + double miny = 180.0; + double maxy = 0.0; + for (GridDto dto : dtos + ) { + if (dto.getLon() > maxx) { + maxx = dto.getLon(); } - if (dto.getLon()<minx){ - minx=dto.getLon(); + if (dto.getLon() < minx) { + minx = dto.getLon(); } - if (dto.getLat()>maxy){ - maxy=dto.getLat(); + if (dto.getLat() > maxy) { + maxy = dto.getLat(); } - if (dto.getLat()<miny){ - miny=dto.getLat(); + if (dto.getLat() < miny) { + miny = dto.getLat(); } } - JSONArray min= ProjectionToGeographicUtil.get4548Point(minx,miny); - JSONArray max=ProjectionToGeographicUtil.get4548Point(maxx,maxy); - String tifPath=path+"terrain.tif"; - TiffClipper.cropTiffByLatLon(config.getTifPath(),tifPath,min.getDouble(0),min.getDouble(1),max.getDouble(0),max.getDouble(1)); + JSONArray min = ProjectionToGeographicUtil.get4548Point(minx, miny); + JSONArray max = ProjectionToGeographicUtil.get4548Point(maxx, maxy); + String tifPath = path + "terrain.tif"; + TiffClipper.cropTiffByLatLon(config.getTifPath(), tifPath, min.getDouble(0), min.getDouble(1), max.getDouble(0), max.getDouble(1)); String pngPath = path + "appearance\\terrain.png"; TiffToRGBUtil.tifToPng(tifPath, pngPath); JSONObject jsonObject = getModule("terrainmodule.json"); -- Gitblit v1.9.3