| | |
| | | double[] transform = ds.GetGeoTransform(); |
| | | // double rotationX = transform[2]; double rotationY = transform[4] |
| | | double minX = transform[0], pixelWidth = transform[1], maxY = transform[3], pixelHeight = transform[5]; |
| | | double[] env = new double[4]; |
| | | polyline.GetEnvelope(env); |
| | | |
| | | double[] bounds = new double[4]; |
| | | polyline.GetEnvelope(bounds); |
| | | double startX = bounds[0], endX = bounds[1], startY = bounds[2], endY = bounds[3]; |
| | | int xMinPixel = (int) Math.floor((env[0] - minX) / pixelWidth); |
| | | int yMinPixel = (int) Math.floor((maxY - env[3]) / Math.abs(pixelHeight)); |
| | | int xMaxPixel = (int) Math.floor((env[1] - minX) / pixelWidth); |
| | | int yMaxPixel = (int) Math.floor((maxY - env[2]) / Math.abs(pixelHeight)); |
| | | |
| | | int bandCount = ds.getRasterCount(); |
| | | int xStartPixel = (int) Math.floor((startX - minX) / pixelWidth); |
| | | int yStartPixel = (int) Math.floor((maxY - startY) / Math.abs(pixelHeight)); |
| | | int xEndPixel = (int) Math.floor((endX - minX) / pixelWidth); |
| | | int yEndPixel = (int) Math.floor((maxY - endY) / Math.abs(pixelHeight)); |
| | | int xMin = Math.min(xMinPixel, xMaxPixel); |
| | | int xMax = Math.max(xMinPixel, xMaxPixel); |
| | | int yMin = Math.min(yMinPixel, yMaxPixel); |
| | | int yMax = Math.max(yMinPixel, yMaxPixel); |
| | | |
| | | List<Double> list = new ArrayList<>(); |
| | | for (int y = Math.min(yStartPixel, yEndPixel); y <= Math.max(yStartPixel, yEndPixel); y++) { |
| | | for (int x = Math.min(xStartPixel, xEndPixel); x <= Math.max(xStartPixel, xEndPixel); x++) { |
| | | for (int y = yMin; y <= yMax; y++) { |
| | | for (int x = xMin; x <= xMax; x++) { |
| | | Geometry point = new Geometry(ogr.wkbPoint); |
| | | point.AddPoint(minX + pixelWidth * x, maxY - pixelHeight * y); |
| | | if (polyline.Contains(point)) { |
| | |
| | | polygon.GetEnvelope(env); |
| | | |
| | | int xMinPixel = (int) Math.floor((env[0] - minX) / pixelWidth); |
| | | int yMinPixel = (int) Math.floor((maxY - env[2]) / Math.abs(pixelHeight)); |
| | | int yMinPixel = (int) Math.floor((maxY - env[3]) / Math.abs(pixelHeight)); |
| | | int xMaxPixel = (int) Math.floor((env[1] - minX) / pixelWidth); |
| | | int yMaxPixel = (int) Math.floor((maxY - env[3]) / Math.abs(pixelHeight)); |
| | | int yMaxPixel = (int) Math.floor((maxY - env[2]) / Math.abs(pixelHeight)); |
| | | |
| | | int bandCount = ds.getRasterCount(); |
| | | int geoWidth = Math.abs(xMaxPixel - xMinPixel); |
| | |
| | | * 处理结果 |
| | | */ |
| | | private void processResult(List<Double> rs, AnalysisResultEntity entity) { |
| | | double avg = rs.stream().mapToDouble(Double::valueOf).average().getAsDouble(); |
| | | if (null == rs || rs.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | double avg = rs.stream().mapToDouble(Double::valueOf).average().getAsDouble(); |
| | | entity.setMin(Collections.min(rs)); |
| | | entity.setMax(Collections.max(rs)); |
| | | entity.setAvg(avg); |