| | |
| | | import java.awt.*; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | |
| | |
| | | copeWater(dto, layer); |
| | | copeFlow(dto, layer); |
| | | copeLayerJson(dto, layer); |
| | | copeRainFallJson(dto, layer); |
| | | } finally { |
| | | File dir = new File(dto.getTemp()); |
| | | if (dir.exists()) { |
| | |
| | | if (null == ds || 0 == ds.getRasterCount()) return; |
| | | |
| | | createWaterPng(dto, ds, layer, layer.getWaters().getData().get(i)); |
| | | copyWaterTif(dto, ds, layer.getWaters().getData().get(i)); |
| | | } finally { |
| | | if (null != ds) ds.delete(); |
| | | } |
| | |
| | | String png = waterPath + File.separator + sizes[0] + "_" + sizes[1] + ".png"; |
| | | water2Png(dto, layer, tif, png, sizes[0], sizes[1]); |
| | | } |
| | | } |
| | | |
| | | private static void copyWaterTif(ResultDto dto, Dataset ds, long ticks) { |
| | | String source = ds.GetDescription(); |
| | | String target = dto.getOutPath() + File.separator + "waters" + File.separator + ticks + File.separator + "water.tif"; |
| | | FileUtil.copyFile(source, target); |
| | | } |
| | | |
| | | private static String getNameWithExt(String file) { |
| | |
| | | bw.close(); |
| | | fw.close(); |
| | | } |
| | | |
| | | /** |
| | | * 处理降水曲线文件曲线图 |
| | | */ |
| | | public void copeRainFallJson(ResultDto dto, LayerDto layer) throws IOException, ParseException { |
| | | 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"); |
| | | |
| | | BufferedReader br = new BufferedReader(new FileReader(rainGageFilePath)); |
| | | // 处理第一行数据 |
| | | if ((line = br.readLine()) != null) { |
| | | while ((line = br.readLine()) != null) { |
| | | // 处理每一行数据 |
| | | String[] rainFall = line.split(" "); |
| | | |
| | | 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()); |
| | | } |
| | | } |
| | | |
| | | FileWriter fw = new FileWriter(filePath); |
| | | BufferedWriter bw = new BufferedWriter(fw); |
| | | bw.write(JSON.toJSONString(rainFallJsons)); |
| | | bw.close(); |
| | | fw.close(); |
| | | } |
| | | } |