张洋洋
2025-02-14 a50e2b2d6f92040abfc98a027a966990fc27a278
[add]tif裁剪
已修改2个文件
74 ■■■■ 文件已修改
src/main/java/com/se/simu/controller/SimuController.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/domain/dto/GridDto.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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 = "管点转cityjson")
    @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 = "地形转sem")
    @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");
src/main/java/com/se/simu/domain/dto/GridDto.java
@@ -7,6 +7,14 @@
    private Double lat;
    private Double lon;
    public GridDto(){
    }
    public GridDto(Double lat,Double lon){
        this.lat=lat;
        this.lon=lon;
    }
    public Double getLat() {
        return lat;