| | |
| | | @JSONField(serialize = false) |
| | | private Map<String, float[]> vals; |
| | | |
| | | @JSONField(serialize = false) |
| | | private Map<String, List<XYO>> xyo; |
| | | |
| | | public TerrainDto() { |
| | | vals = new HashMap<>(); |
| | | size = new ArrayList<>(); |
| | | xyo = new HashMap<>(); |
| | | } |
| | | |
| | | public TerrainDto(List<Integer> sizes) { |
| | |
| | | |
| | | for (Integer i : sizes) { |
| | | size.add(new int[]{i, i}); |
| | | |
| | | /*List<XYO> list = new ArrayList<>(); |
| | | for (int x = 0; x < i; x++) { |
| | | for (int y = 0; y < i; y++) { |
| | | list.add(new XYO(x, y, i)); |
| | | } |
| | | } |
| | | xyo.put(i + "_" + i, list);*/ |
| | | } |
| | | } |
| | | |
| | |
| | | public void setVals(Map<String, float[]> vals) { |
| | | this.vals = vals; |
| | | } |
| | | |
| | | public Map<String, List<XYO>> getXyo() { |
| | | return xyo; |
| | | } |
| | | |
| | | public void setXyo(Map<String, List<XYO>> xyo) { |
| | | this.xyo = xyo; |
| | | } |
| | | } |
对比新文件 |
| | |
| | | package com.se.simu.domain.dto; |
| | | |
| | | @SuppressWarnings("ALL") |
| | | public class XYO { |
| | | private int x; |
| | | |
| | | private int y; |
| | | |
| | | private int offset; |
| | | |
| | | public XYO() { |
| | | } |
| | | |
| | | public XYO(int x, int y, int width) { |
| | | this.x = x; |
| | | this.y = y; |
| | | this.offset = x + y * width; |
| | | } |
| | | |
| | | public int getX() { |
| | | return x; |
| | | } |
| | | |
| | | public void setX(int x) { |
| | | this.x = x; |
| | | } |
| | | |
| | | public int getY() { |
| | | return y; |
| | | } |
| | | |
| | | public void setY(int y) { |
| | | this.y = y; |
| | | } |
| | | |
| | | public int getOffset() { |
| | | return offset; |
| | | } |
| | | |
| | | public void setOffset(int offset) { |
| | | this.offset = offset; |
| | | } |
| | | } |
| | |
| | | return file.substring(file.lastIndexOf(File.separator) + 1, file.lastIndexOf(".")); |
| | | } |
| | | |
| | | private void water2Png2(ResultDto dto, LayerDto layer, String tif, String png, int width, int height) { |
| | | Dataset ds = null; |
| | | try { |
| | | ds = gdal.Open(tif, gdalconst.GA_ReadOnly); |
| | | if (null == ds || 0 == ds.getRasterCount()) return; |
| | | |
| | | Band band = ds.GetRasterBand(1); |
| | | float[] buffer = new float[width * height]; |
| | | band.ReadRaster(0, 0, width, height, buffer); |
| | | |
| | | BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); |
| | | double differ = layer.getExtension().getDiffer(), maxHeight = layer.getExtension().getMaxHeight(), minHeight = layer.getExtension().getMinHeight(); |
| | | float[] ts = layer.getTerrain().getVals().get(width + "_" + height); |
| | | |
| | | /*layer.getTerrain().getXyo().get(width + "_" + height).stream().forEach(xyo -> { |
| | | |
| | | });*/ |
| | | for (XYO xyo : layer.getTerrain().getXyo().get(width + "_" + height)) { |
| | | float depth = buffer[xyo.getOffset()] + ts[xyo.getOffset()]; |
| | | if (Float.isNaN(depth) || depth < minHeight) continue; |
| | | |
| | | int r = 0, g, b; |
| | | if (depth > maxHeight) { |
| | | g = b = 255; |
| | | } else { |
| | | int val = (int) ((depth - minHeight) / differ * 65535); |
| | | g = val / 256; |
| | | b = val % 256; |
| | | } |
| | | |
| | | Color color = new Color(r, g, b, 127); |
| | | image.setRGB(xyo.getX(), xyo.getY(), color.getRGB()); |
| | | } |
| | | |
| | | savePng(image, png); |
| | | } finally { |
| | | if (null != ds) ds.delete(); |
| | | } |
| | | } |
| | | |
| | | private void water2Png(ResultDto dto, LayerDto layer, String tif, String png, int width, int height) { |
| | | Dataset ds = null; |
| | | try { |
| | |
| | | # 杈撳嚭鏂囦欢 |
| | | terrainFile: DEM.tif |
| | | buildingFile: buildings_inside.shp |
| | | buildingKey: seid |
| | | # buildingKey: seid |
| | | buildingKey: KJSFBM |
| | | waterPath: depth |
| | | flowPath: velocity |