| | |
| | | } |
| | | |
| | | /** |
| | | * 分析点 |
| | | */ |
| | | public void analysisPoint2(AnalysisResultEntity entity, Dataset ds, Geometry geo, int size) { |
| | | double x = geo.GetX(), y = geo.GetY(); |
| | | 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]; |
| | | |
| | | int bandCount = ds.getRasterCount(); |
| | | int xPixel = (int) Math.floor((x - minX) / pixelWidth); |
| | | int yPixel = (int) Math.floor((maxY - y) / Math.abs(pixelHeight)); |
| | | |
| | | for (int i = 1; i <= bandCount; i++) { |
| | | double[] pixelValues = new double[size * size]; |
| | | Band band = ds.GetRasterBand(i); |
| | | band.ReadRaster(xPixel, yPixel, size, size, pixelValues); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 分析线 |
| | | */ |
| | | public void analysisPolyline(AnalysisResultEntity entity, Dataset ds, Geometry geo, int size) { |
| | |
| | | } |
| | | entity.addPoint(xy[0], xy[1], len, vals); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 分析线 |
| | | */ |
| | | public void analysisPolyline2(AnalysisResultEntity entity, Dataset ds, Geometry geo, int size) { |
| | | double[] transform = ds.GetGeoTransform(); |
| | | // double rotationX = transform[2]; double rotationY = transform[4] |
| | | double minX = transform[0], pixelWidth = transform[1], maxY = transform[3], pixelHeight = Math.abs(transform[5]); |
| | | |
| | | double buffer = Math.max(pixelWidth, pixelHeight) * size; |
| | | double[] env = new double[4]; |
| | | geo = geo.Buffer(buffer); |
| | | geo.GetEnvelope(env); |
| | | |
| | | int xMinPixel = (int) Math.floor((env[0] - minX) / pixelWidth); |
| | | int yMinPixel = (int) Math.floor((maxY - env[3]) / pixelHeight); |
| | | int xMaxPixel = (int) Math.floor((env[1] - minX) / pixelWidth); |
| | | int yMaxPixel = (int) Math.floor((maxY - env[2]) / pixelHeight); |
| | | |
| | | int bandCount = ds.getRasterCount(); |
| | | 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 = 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 (geo.Intersects(point)) { |
| | | for (int i = 1; i <= bandCount; i++) { |
| | | double[] values = new double[1]; |
| | | ds.GetRasterBand(i).ReadRaster(x, y, 1, 1, values); |
| | | list.add(values[0]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // processResult(list, entity) |
| | | } |
| | | |
| | | /** |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 分析点 2 |
| | | */ |
| | | public void analysisPoint2(AnalysisResultEntity entity, Dataset ds, Geometry geo, int size) { |
| | | double x = geo.GetX(), y = geo.GetY(); |
| | | 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]; |
| | | |
| | | int bandCount = ds.getRasterCount(); |
| | | int xPixel = (int) Math.floor((x - minX) / pixelWidth); |
| | | int yPixel = (int) Math.floor((maxY - y) / Math.abs(pixelHeight)); |
| | | |
| | | for (int i = 1; i <= bandCount; i++) { |
| | | double[] pixelValues = new double[size * size]; |
| | | Band band = ds.GetRasterBand(i); |
| | | band.ReadRaster(xPixel, yPixel, size, size, pixelValues); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 分析线 2 |
| | | */ |
| | | public void analysisPolyline2(AnalysisResultEntity entity, Dataset ds, Geometry geo, int size) { |
| | | double[] transform = ds.GetGeoTransform(); |
| | | // double rotationX = transform[2]; double rotationY = transform[4] |
| | | double minX = transform[0], pixelWidth = transform[1], maxY = transform[3], pixelHeight = Math.abs(transform[5]); |
| | | |
| | | double buffer = Math.max(pixelWidth, pixelHeight) * size; |
| | | double[] env = new double[4]; |
| | | geo = geo.Buffer(buffer); |
| | | geo.GetEnvelope(env); |
| | | |
| | | int xMinPixel = (int) Math.floor((env[0] - minX) / pixelWidth); |
| | | int yMinPixel = (int) Math.floor((maxY - env[3]) / pixelHeight); |
| | | int xMaxPixel = (int) Math.floor((env[1] - minX) / pixelWidth); |
| | | int yMaxPixel = (int) Math.floor((maxY - env[2]) / pixelHeight); |
| | | |
| | | int bandCount = ds.getRasterCount(); |
| | | 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 = 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 (geo.Intersects(point)) { |
| | | for (int i = 1; i <= bandCount; i++) { |
| | | double[] values = new double[1]; |
| | | ds.GetRasterBand(i).ReadRaster(x, y, 1, 1, values); |
| | | list.add(values[0]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // processResult(list, entity) |
| | | } |
| | | |
| | | private void processClippedDataByLine(String imagePath, String geometryString) { |
| | | // 注册GDAL驱动 |
| | | gdal.AllRegister(); |