11
13693261870
2024-11-01 b6899cd6d1bafb1c349f1fbd190e6632183719f5
11
已修改1个文件
52 ■■■■■ 文件已修改
src/main/java/com/se/simu/service/ResultService.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/simu/service/ResultService.java
@@ -8,6 +8,7 @@
import com.se.simu.domain.dto.LayerDto;
import com.se.simu.domain.dto.ResultDto;
import com.se.simu.domain.po.DataPo;
import com.se.simu.domain.vo.BuildingDepthVo;
import com.se.simu.helper.GdalHelper;
import lombok.extern.slf4j.Slf4j;
import org.gdal.gdal.Band;
@@ -44,6 +45,8 @@
    PropertiesConfig config;
    public final static double MAX_X_OFFSET = 0;
    private final static SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    public void process(DataPo data) throws Exception {
        String basePath = config.getInPath() + File.separator + data.getInPath() + File.separator;
@@ -528,14 +531,10 @@
        layer.getTerrain().setEpsg(null);
        String json = JSON.toJSONString(layer);
        //String json = JSONUtil.toJsonPrettyStr(layer);
        // String json = JSONUtil.toJsonPrettyStr(layer);
        String filePath = dto.getOutPath() + File.separator + "layer.json";
        FileWriter fw = new FileWriter(filePath);
        BufferedWriter bw = new BufferedWriter(fw);
        bw.write(json);
        bw.close();
        fw.close();
        writeJson(filePath, json);
    }
    /**
@@ -545,28 +544,37 @@
        String rainGageFilePath = config.getInPath() + File.separator + dto.getServiceName() + File.separator + "RainGage.dat";
        String filePath = dto.getOutPath() + File.separator + "rainfall.json";
        String line;
        Map<String, Double> rainFallJsons = new LinkedHashMap<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        Map<String, Double> map = new LinkedHashMap<>();
        FileReader fr = new FileReader(rainGageFilePath);
        BufferedReader br = new BufferedReader(fr);
        BufferedReader br = new BufferedReader(new FileReader(rainGageFilePath));
        // 处理第一行数据
        if ((line = br.readLine()) != null) {
            while ((line = br.readLine()) != null) {
                // 处理每一行数据
                String[] rainFall = line.split(" ");
        String line = br.readLine();
        while ((line = br.readLine()) != null) {
            String[] rainFall = line.split(" ");
            if (rainFall.length < 7) continue;
                if (rainFall.length < 7) continue;
                String sdt = rainFall[1] + "-" + rainFall[2] + "-" + rainFall[3] + " " + rainFall[4] + ":" + rainFall[5];
                BigDecimal num = new BigDecimal(rainFall[6]);
                rainFallJsons.put("" + sdf.parse(sdt).getTime(), num.setScale(2, RoundingMode.HALF_UP).doubleValue());
            }
            String sdt = rainFall[1] + "-" + rainFall[2] + "-" + rainFall[3] + " " + rainFall[4] + ":" + rainFall[5];
            BigDecimal num = new BigDecimal(rainFall[6]);
            map.put("" + SDF.parse(sdt).getTime(), num.setScale(2, RoundingMode.HALF_UP).doubleValue());
        }
        br.close();
        fr.close();
        String json = JSON.toJSONString(map);
        writeJson(filePath, json);
    }
    private void copeBuildingDepthJson(ResultDto dto, List<BuildingDepthVo> list) throws IOException {
        String json = JSON.toJSONString(list);
        String filePath = dto.getOutPath() + File.separator + "building.json";
        writeJson(filePath, json);
    }
    private void writeJson(String filePath, String json) throws IOException {
        FileWriter fw = new FileWriter(filePath);
        BufferedWriter bw = new BufferedWriter(fw);
        bw.write(JSON.toJSONString(rainFallJsons));
        bw.write(json);
        bw.close();
        fw.close();
    }