| | |
| | | import com.se.nsl.helper.GdalHelper; |
| | | import com.se.nsl.helper.StringHelper; |
| | | import com.se.nsl.helper.WebHelper; |
| | | import com.se.nsl.utils.AreaType; |
| | | import lombok.SneakyThrows; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.gdal.gdal.Band; |
| | |
| | | createNsl(data); |
| | | |
| | | update(simu, 10, "完成"); |
| | | log.info("模拟完成"); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | | update(simu, 20, ex.getMessage()); |
| | |
| | | createDir(inPath + File.separator + "velocity"); |
| | | createDir(config.getOutPath() + File.separator + data.getOutPath()); |
| | | |
| | | Short areaType = simu.getAreaType(); |
| | | AreaType at = AreaType.of(areaType); |
| | | String terrainTif = config.getSourceDem(); |
| | | String landuseTif = config.getSourceLanduse(); |
| | | if (at == AreaType.KEY_DITCH) { |
| | | File keyDitchDir = new File(config.getKeyDitch()); |
| | | String areaName = simu.getAreaName(); |
| | | Optional<File> first = Arrays.stream(keyDitchDir.listFiles()).filter(f -> f.getName().equals(areaName)).findFirst(); |
| | | if (first.isPresent()) { |
| | | File targetTifDir = first.get(); |
| | | File[] files = targetTifDir.listFiles(); |
| | | for (File file : files) { |
| | | String name = file.getName(); |
| | | if (name.toLowerCase().contains("dem")) { |
| | | terrainTif = file.getAbsolutePath(); |
| | | } |
| | | if (name.toLowerCase().contains("landuse")) { |
| | | landuseTif = file.getAbsolutePath(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | Geometry geom = Geometry.CreateFromWkt(simu.getGeom()); |
| | | if (geom.GetGeometryType() == ogr.wkbMultiPolygon) geom = geom.GetGeometryRef(0); |
| | | SpatialReference dstSR = GdalHelper.createSpatialReference(config.getEpsg()); |
| | |
| | | String wkt = geom.ExportToWkt(); |
| | | |
| | | String terrainFile = inPath + File.separator + config.getTerrainFile(); |
| | | Dataset dsDem = gdal.Open(config.getSourceDem(), gdalconstConstants.GA_ReadOnly); |
| | | |
| | | Dataset dsDem = gdal.Open(terrainTif, gdalconstConstants.GA_ReadOnly); |
| | | ComHelper.Resample(dsDem, null, terrainFile, null, wkt, null, null); |
| | | dsDem.delete(); |
| | | |
| | | String landuseFile = inPath + File.separator + config.getLanduseFile(); |
| | | Dataset dsLanduse = gdal.Open(config.getSourceLanduse(), gdalconstConstants.GA_ReadOnly); |
| | | |
| | | Dataset dsLanduse = gdal.Open(landuseTif, gdalconstConstants.GA_ReadOnly); |
| | | ComHelper.Resample(dsLanduse, null, landuseFile, null, wkt, null, null); |
| | | dsLanduse.delete(); |
| | | } |
| | |
| | | } |
| | | //list.add(prefix + YYYYMDHM.format(rainfalls.get(c).getTime()) + getMinVal(rainfalls.get(c).getIntensity() / unit, DIGIT)); |
| | | list.add(String.format("%s%s%f", prefix, YYYYMDHM.format(rainfalls.get(c).getTime()), getMinVal(rainfalls.get(c).getIntensity() / unit, DIGIT))); |
| | | list.add(0, "1 " + (list.size() - 1)); |
| | | // list.add(0, "1 " + (list.size() - 1)); |
| | | |
| | | Files.write(Paths.get(rainfallFile), list, StandardCharsets.UTF_8); |
| | | } |
| | |
| | | try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"))) { |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | System.out.println(line); |
| | | // System.out.println(line); |
| | | //sb.append(line); |
| | | log.info(line); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | cal.add(Calendar.MINUTE, 1); |
| | | } |
| | | list.add(0, "1 " + (list.size() - 1)); |
| | | // list.add(0, "1 " + (list.size() - 1)); |
| | | |
| | | Files.write(Paths.get(dat), list, StandardCharsets.UTF_8); |
| | | } |