| | |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.concurrent.CopyOnWriteArrayList; |
| | | import java.util.stream.DoubleStream; |
| | | |
| | | /** |
| | | * 处理结果服务类 |
| | |
| | | if (files.size() == 0 || files.size() != layer.getWaters().getData().size()) return null; |
| | | |
| | | processWaters(dto, files, layer); |
| | | |
| | | |
| | | return processBuilding(dto, files, layer); |
| | | } |
| | | |
| | |
| | | double[] env = new double[4]; |
| | | building.getGeom().GetEnvelope(env); |
| | | |
| | | int xMinPixel = Math.max((int) Math.floor((env[0] - minX) / pixelWidth), 1); |
| | | int yMinPixel = Math.max((int) Math.floor((maxY - env[3]) / pixelHeight), 1); |
| | | int xMaxPixel = Math.min((int) Math.floor((env[1] - minX) / pixelWidth), xSize); |
| | | int yMaxPixel = Math.min((int) Math.floor((maxY - env[2]) / pixelHeight), ySize); |
| | | if (xMaxPixel < 1 || yMaxPixel < 1 || xMaxPixel - xMinPixel < 0 || yMaxPixel - yMinPixel < 0) { |
| | | return null; |
| | | } |
| | | int startX = (int) Math.floor((env[0] - minX) / pixelWidth); |
| | | int endX = (int) Math.floor((env[1] - minX) / pixelWidth); |
| | | int startY = (int) Math.floor((maxY - env[3]) / Math.abs(pixelHeight)); |
| | | int endY = (int) Math.floor((maxY - env[2]) / Math.abs(pixelHeight)); |
| | | if (startX < 0) startX = 0; |
| | | if (startY < 0) startY = 0; |
| | | if (endX > ds.getRasterXSize()) endX = ds.getRasterXSize(); |
| | | if (endY > ds.getRasterYSize()) endY = ds.getRasterYSize(); |
| | | if (endX - startX < 1 || endY - startY < 1) return null; |
| | | |
| | | int width = xMaxPixel - xMinPixel; |
| | | int height = yMaxPixel - yMinPixel; |
| | | int width = endX - startX; |
| | | int height = endY - startY; |
| | | double[] pixelValues = new double[width * height]; |
| | | ds.GetRasterBand(1).ReadRaster(xMinPixel, yMinPixel, width, height, pixelValues); |
| | | ds.GetRasterBand(1).ReadRaster(startX, startY, width, height, pixelValues); |
| | | |
| | | Double val = Arrays.stream(pixelValues).max().getAsDouble(); |
| | | |