From e46790ae4ba029027d4d7784655b8a90234968ba Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期六, 02 十一月 2024 10:30:44 +0800
Subject: [PATCH] 1

---
 src/main/java/com/se/simu/domain/dto/ResultDto.java  |   26 +++++++++++++++++++++++++-
 src/main/java/com/se/simu/service/ResultService.java |    5 ++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/se/simu/domain/dto/ResultDto.java b/src/main/java/com/se/simu/domain/dto/ResultDto.java
index efd4c2f..378dfd5 100644
--- a/src/main/java/com/se/simu/domain/dto/ResultDto.java
+++ b/src/main/java/com/se/simu/domain/dto/ResultDto.java
@@ -1,6 +1,8 @@
 package com.se.simu.domain.dto;
 
 import cn.hutool.core.io.FileUtil;
+import com.se.simu.helper.GdalHelper;
+import org.gdal.osr.SpatialReference;
 
 import java.io.File;
 import java.util.*;
@@ -26,6 +28,10 @@
 
     private String temp;
 
+    private int epsg;
+
+    private SpatialReference spatialReference;
+
     private Map<String, float[]> buildings;
 
     private List<BuildingDto> buildingList;
@@ -35,7 +41,7 @@
         this.buildingList = new ArrayList<>();
     }
 
-    public ResultDto(String serviceName, String terrainFile, String buildingFile, String waterPath, String flowPath, String outPath) {
+    public ResultDto(String serviceName, String terrainFile, String buildingFile, String waterPath, String flowPath, String outPath, int epsg) {
         this();
         this.serviceName = serviceName;
         this.terrainFile = terrainFile;
@@ -44,6 +50,8 @@
         this.flowPath = flowPath;
         this.outPath = outPath + File.separator + serviceName;
         this.temp = outPath + File.separator + serviceName + File.separator + "temp";
+        this.epsg = epsg;
+        this.spatialReference = GdalHelper.createSpatialReference(epsg);
 
         File dir = new File(this.outPath);
         if (dir.exists() && dir.isDirectory()) {
@@ -129,4 +137,20 @@
     public void setBuildingList(List<BuildingDto> buildingList) {
         this.buildingList = buildingList;
     }
+
+    public int getEpsg() {
+        return epsg;
+    }
+
+    public void setEpsg(int epsg) {
+        this.epsg = epsg;
+    }
+
+    public SpatialReference getSpatialReference() {
+        return spatialReference;
+    }
+
+    public void setSpatialReference(SpatialReference spatialReference) {
+        this.spatialReference = spatialReference;
+    }
 }
diff --git a/src/main/java/com/se/simu/service/ResultService.java b/src/main/java/com/se/simu/service/ResultService.java
index 40b1634..2a58383 100644
--- a/src/main/java/com/se/simu/service/ResultService.java
+++ b/src/main/java/com/se/simu/service/ResultService.java
@@ -57,7 +57,8 @@
                 basePath + config.getBuildingFile(),
                 basePath + config.getWaterPath(),
                 basePath + config.getFlowPath(),
-                config.getOutPath());
+                config.getOutPath(),
+                data.getEpsg());
         LayerDto layer = new LayerDto(config.getVer(), data.getEpsg(), config.getSizes());
         process(dto, layer);
     }
@@ -350,6 +351,7 @@
             try {
                 ds = gdal.Open(files.get(i), gdalconst.GA_ReadOnly);
                 if (null == ds || 0 == ds.getRasterCount()) return;
+                if (null == ds.GetSpatialRef()) ds.SetSpatialRef(dto.getSpatialReference());
 
                 createWaterPng(dto, ds, layer, layer.getWaters().getData().get(i));
                 copyWaterTif(dto, ds, layer.getWaters().getData().get(i));
@@ -448,6 +450,7 @@
             try {
                 ds = gdal.Open(files.get(i), gdalconst.GA_ReadOnly);
                 if (null == ds || 0 == ds.getRasterCount()) return;
+                if (null == ds.GetSpatialRef()) ds.SetSpatialRef(dto.getSpatialReference());
 
                 createFlowPng(dto, ds, layer, layer.getWaters().getData().get(i));
             } finally {

--
Gitblit v1.9.3