| | |
| | | } |
| | | |
| | | private static List<String> getFiles(String path, String suffix) { |
| | | |
| | | List<String> files = new ArrayList<>(); |
| | | getFiles(files, new File(path), suffix); |
| | | |
| | |
| | | private static void setWaterData(LayerDto layer, List<String> files) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | |
| | | for (String file : files) { |
| | | String fileName = new File(file).getName(); |
| | | String fileName = getNameWithExt(file); |
| | | int hour = Integer.parseInt(fileName.substring(0, 2)); |
| | | int minute = Integer.parseInt(fileName.substring(2, 2)); |
| | | int second = Integer.parseInt(fileName.substring(4, 2)); |
| | | int minute = Integer.parseInt(fileName.substring(2, 4)); |
| | | int second = Integer.parseInt(fileName.substring(4, 6)); |
| | | |
| | | calendar.set(Calendar.HOUR_OF_DAY, hour); |
| | | calendar.set(Calendar.MINUTE, minute); |
| | |
| | | } |
| | | |
| | | private static void setWaterHeight(LayerDto layer, List<String> files) { |
| | | for (int i = 0, c = files.size(); i < c; i++) { |
| | | files.parallelStream().forEach(file->{ |
| | | Dataset ds = null; |
| | | try { |
| | | ds = gdal.Open(files.get(i), gdalconst.GA_ReadOnly); |
| | | ds = gdal.Open(file, gdalconst.GA_ReadOnly); |
| | | if (null == ds || 0 == ds.getRasterCount() || null == ds.GetSpatialRef()) return; |
| | | |
| | | double[] mm = new double[2]; |
| | |
| | | } finally { |
| | | if (null != ds) ds.delete(); |
| | | } |
| | | } |
| | | }); |
| | | layer.getExtension().setMinHeight(getMinVal(layer.getExtension().getMinHeight() - 1, 1000)); |
| | | layer.getExtension().setMaxHeight(getMaxVal(layer.getExtension().getMaxHeight() + 1, 1000)); |
| | | } |
| | |
| | | } |
| | | |
| | | private static String getNameWithExt(String file) { |
| | | return file.substring(file.lastIndexOf(File.separator), file.lastIndexOf(".")); |
| | | return file.substring(file.lastIndexOf(File.separator) + 1, file.lastIndexOf(".")); |
| | | } |
| | | |
| | | private static void water2Png(ResultDto dto, LayerDto layer, String tif, String png, int width, int height) { |
| | |
| | | return val; |
| | | } |
| | | |
| | | /** |
| | | * 元数据 |
| | | */ |
| | | private void copeLayerJson(ResultDto dto, LayerDto layer) throws IOException { |
| | | String json = JSONUtil.toJsonPrettyStr(layer); |
| | | String filePath = dto.getOutPath() + File.separator + "layer.json"; |