1
13693261870
2024-09-30 3de813fc31fad9e4e25533b70157115ad93b475b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.se.simu.service;
 
import cn.hutool.core.io.FileUtil;
import cn.hutool.json.JSONUtil;
import com.se.simu.config.PropertiesConfig;
import com.se.simu.domain.dto.LayerDto;
import com.se.simu.domain.dto.ResultDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
 
/**
 * 处理结果服务类
 *
 * @author WWW
 * @date   2024-09-29
 */
@Slf4j
@Service
@SuppressWarnings("ALL")
public class ResultService {
    @Resource
    PropertiesConfig config;
 
    public final static double MAX_X_OFFSET = 0.002;
 
    public void process(ResultDto dto) throws Exception {
        try {
            LayerDto layer = new LayerDto(config.getVer());
 
            copeTerrain(dto, layer);
            copeBuilding(dto, layer);
            copeWater(dto, layer);
            copeFlow(dto, layer);
            copeLayerJson(dto, layer);
        } finally {
            File dir = new File(dto.getTemp());
            if (dir.exists()) {
                FileUtil.del(dir);
            }
        }
    }
 
    private void copeTerrain(ResultDto dto, LayerDto layer) {
        //
    }
 
    private void copeBuilding(ResultDto dto, LayerDto layer) {
        //
    }
 
    private void copeWater(ResultDto dto, LayerDto layer) {
        //
    }
 
    private void copeFlow(ResultDto dto, LayerDto layer) {
        //
    }
 
    private void copeLayerJson(ResultDto dto, LayerDto layer) throws IOException {
        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();
    }
 
    public String test() throws Exception {
        ResultDto dto = new ResultDto(
                "202409",
                "D:\\simu\\input\\tongzhou-local-mesh2-terrain.tif",
                "D:\\simu\\input\\tongzhou-local-mesh2-buildings.tif",
                "D:\\simu\\input\\waters",
                "D:\\simu\\input\\flows",
                "D:\\simu\\out",
                "");
        process(dto);
 
        return "OK";
    }
}