Refine search
new GeneralGridEnvelope( CRS.transform( requestedWorldToGrid, new GeneralEnvelope(cropBBox)), PixelInCell.CELL_CORNER, false) .toRectangle(); } catch (IllegalStateException e) { throw new DataSourceException(e); final GeneralEnvelope cropBBOXInRequestCRS = CRS.transform(cropBBox, requestedBBox.getCoordinateReferenceSystem()); cropBBOXInRequestCRS.setCoordinateReferenceSystem( requestedBBox.getCoordinateReferenceSystem()); new GeneralGridEnvelope( CRS.transform(requestedWorldToGrid, cropBBOXInRequestCRS), PixelInCell.CELL_CORNER, false) .toRectangle();
/** * Constructs a multi-dimensional grid envelope. We keep this constructor private because the * arguments order can be confusing. Forcing usage of {@link Rectangle} in public API is * probably safer. */ private GeneralGridEnvelope(int x, int y, int width, int height, int dimension) { if (dimension < 2) { throw new IllegalArgumentException( Errors.format(ErrorKeys.ILLEGAL_ARGUMENT_$2, "dimension", dimension)); } index = new int[dimension * 2]; index[0] = x; index[1] = y; index[dimension + 0] = x + width; // Reminder: upper values in index[] are exclusive. index[dimension + 1] = y + height; // So there is no +1 offset to add here. Arrays.fill(index, dimension + 2, index.length, 1); checkCoherence(); }
/** * Returns a {@link Rectangle} with the same bounds as this {@code GeneralGridEnvelope}. This is * a convenience method for interoperability with Java2D. * * @return A rectangle with the same bounds than this grid envelope. * @throws IllegalStateException if this grid envelope is not two-dimensional. */ public Rectangle toRectangle() throws IllegalStateException { if (index.length == 4) { return new Rectangle(index[0], index[1], index[2] - index[0], index[3] - index[1]); } else { throw new IllegalStateException( Errors.format(ErrorKeys.NOT_TWO_DIMENSIONAL_$1, getDimension())); } }
private Rectangle computeRasterArea( ReferencedEnvelope computedBBox, MathTransform2D requestedWorldToGrid) throws TransformException, FactoryException { final ReferencedEnvelope cropBBOXInRequestCRS = Utils.reprojectEnvelope(computedBBox, requestCRS, requestedBBox); // make sure it falls within the requested envelope cropBBOXInRequestCRS.intersection((org.locationtech.jts.geom.Envelope) requestedBBox); // now go back to raster space Rectangle computedRasterArea = new GeneralGridEnvelope( CRS.transform(requestedWorldToGrid, cropBBOXInRequestCRS), PixelInCell.CELL_CORNER, false) .toRectangle(); // intersect with the original requested raster space to be sure that we stay within // the requested raster area XRectangle2D.intersect(computedRasterArea, requestedRasterArea, computedRasterArea); return computedRasterArea; }
throw new IllegalArgumentException(sb.toString()); GeneralEnvelope adjustedRequestedEnvelope = new GeneralEnvelope(2); final CoordinateReferenceSystem requestedEnvelopeCRS2D = requestedEnvelope2D.getCoordinateReferenceSystem(); boolean tryWithWGS84 = false; CRS.transform(requestedEnvelope2D, spatialReferenceSystem2D); } else { adjustedRequestedEnvelope.setEnvelope(requestedEnvelope2D); CRS.transform(readGridToWorld.inverse(), requestedEnvelopeCropped) .toRectangle2D(); final GeneralGridEnvelope finalRange = new GeneralGridEnvelope(ordinates.getBounds()); final Rectangle tempRect = finalRange.toRectangle();
new GeneralGridEnvelope( CRS.transform( requestedWorldToGrid, new GeneralEnvelope(computedBBox)), PixelInCell.CELL_CORNER, false) .toRectangle();
return; this.envelope = new GeneralEnvelope(envelope); if (gridToCRS == null) { this.gridRange = null; gridRange = new GeneralGridEnvelope(transformed, PixelInCell.CELL_CORNER, gridMaxInclusive); throw new RuntimeException(e); tempEnvelope.setCoordinateReferenceSystem(envelope.getCoordinateReferenceSystem()); this.envelope = tempEnvelope; } else { final double xScale = transformed.getSpan(0) / gridRange.getSpan(0); final double yScale = transformed.getSpan(1) / gridRange.getSpan(1); final double xTrans = transformed.getMinimum(0) - xScale * gridRange.getLow(0);
final AffineTransform2D expectedTx = (AffineTransform2D) baseCoverage.getGridGeometry().getGridToCRS(); final GeneralEnvelope originalEnvelope = (GeneralEnvelope) baseCoverage.getEnvelope(); final GeneralEnvelope newEnvelope=new GeneralEnvelope(originalEnvelope); newEnvelope.setEnvelope( originalEnvelope.getMinimum(0), originalEnvelope.getMaximum(1)-originalEnvelope.getSpan(1)/2, originalEnvelope.getMinimum(0)+originalEnvelope.getSpan(0)/2, final GeneralGridEnvelope expectedGridEnvelope = new GeneralGridEnvelope(CRS.transform(cornerWorldToGrid.inverse(), newEnvelope),PixelInCell.CELL_CORNER,false); final StringBuilder envelopeBuilder= new StringBuilder(); envelopeBuilder.append(newEnvelope.getMinimum(0)).append(",");
final GeneralEnvelope e = new GeneralEnvelope(envelope); e.setCoordinateReferenceSystem(getDefaultCRS(e.getDimension())); envelope = e; new GeneralGridEnvelope(image, envelope.getDimension()), envelope); return create(name, image, gm, bands, sources, properties);
targetGG = new GridGeometry2D( new GeneralGridEnvelope(gridRange, PixelInCell.CELL_CORNER), targetGG.getGridToCRS(PixelInCell.CELL_CENTER), targetCRS); sourceEnvelope = sourceCoverage.getEnvelope(); // Don't force this one to 2D. targetEnvelope = CRS.transform(operation, sourceEnvelope); targetEnvelope.setCoordinateReferenceSystem(targetCRS); new GeneralGridEnvelope(gridRange, PixelInCell.CELL_CENTER), step1, targetCRS); source = targetGG.reduce(source); target = targetGG.reduce(target); if (!(new GeneralEnvelope(source).contains(target, true))) { if (interpolation != null && !(interpolation instanceof InterpolationNearest)) { upper[targetGG.gridDimensionX] = targetImage.getMaxX(); upper[targetGG.gridDimensionY] = targetImage.getMaxY(); final GridEnvelope actualGR = new GeneralGridEnvelope(lower, upper); if (!targetGR.equals(actualGR)) { targetGG =
CoverageStoreUtils.getWGS84LonLatEnvelope(new GeneralEnvelope(bounds)); coverage.setLatLonBoundingBox(new ReferencedEnvelope(boundsLatLon)); GeneralEnvelope gridEnvelope = new GeneralEnvelope(bounds); Map grid = cInfoReader.grid(); if (grid != null) { int[] high = (int[]) grid.get("high"); GeneralGridEnvelope range = new GeneralGridEnvelope(low, high); GeneralGridEnvelope range = new GeneralGridEnvelope(new int[] {0, 0}, new int[] {1, 1}); coverage.setGrid(new GridGeometry2D(range, gridEnvelope));
StaticRasterReader(Object source) { coverageFactory = new GridCoverageFactory(); crs = DefaultGeographicCRS.WGS84; // instantiate the bounds based on the default CRS originalEnvelope = new GeneralEnvelope(CRS.getEnvelope(crs)); originalEnvelope.setCoordinateReferenceSystem(crs); originalGridRange = new GeneralGridEnvelope(originalEnvelope, PixelInCell.CELL_CENTER); // create a default layout based on the static image setlayout(new ImageLayout(STATIC_IMAGE)); }
throws DataSourceException { GeneralEnvelope adjustedRequestedEnvelope = new GeneralEnvelope(2); GeneralGridEnvelope baseGridRange = (GeneralGridEnvelope) originalGridRange; if (!sourceRegion.intersects(baseGridRange.toRectangle()) || sourceRegion.isEmpty()) throw new DataSourceException("The crop region is invalid."); sourceRegion.setRect(sourceRegion.intersection(baseGridRange.toRectangle())); .append(adjustedRequestedEnvelope.toString()) .append("\n") .append("Requested raster dimension = ")
minx = Math.min(minx, (int) Math.floor(rasterGridRangeInDataSet.getMinimum(0))); miny = Math.min(miny, (int) Math.floor(rasterGridRangeInDataSet.getMinimum(1))); maxx = Math.max(maxx, (int) Math.ceil(rasterGridRangeInDataSet.getMaximum(0))); maxy = Math.max(maxy, (int) Math.ceil(rasterGridRangeInDataSet.getMaximum(1))); int height = maxy - miny; Rectangle range = new Rectangle(0, 0, width, height); originalGridRange = new GeneralGridEnvelope(range, 2);
gridRange = new GeneralGridEnvelope(low, high);
final GridEnvelope r = new GeneralGridEnvelope(image, dimension); if (gridGeometry.isDefined(GridGeometry2D.GRID_TO_CRS_BITMASK)) { gridGeometry = || !(gridGeometry.envelope.getSpan(gridGeometry.axisDimensionX) > 0) || !(gridGeometry.envelope.getSpan(gridGeometry.axisDimensionY) > 0)) { throw new IllegalArgumentException(Errors.format(ErrorKeys.EMPTY_ENVELOPE));
throw new IllegalArgumentException(sb.toString()); GeneralEnvelope adjustedRequestedEnvelope = new GeneralEnvelope(2); final CoordinateReferenceSystem requestedEnvelopeCRS2D = requestedEnvelope2D.getCoordinateReferenceSystem(); boolean tryWithWGS84 = false; CRS.transform(requestedEnvelope2D, spatialReferenceSystem2D); } else { adjustedRequestedEnvelope.setEnvelope(requestedEnvelope2D); CRS.transform(readGridToWorld.inverse(), requestedEnvelopeCropped) .toRectangle2D(); final GeneralGridEnvelope finalRange = new GeneralGridEnvelope(ordinates.getBounds()); final Rectangle tempRect = finalRange.toRectangle();
return; this.envelope = new GeneralEnvelope(envelope); if (gridToCRS == null) { this.gridRange = null; gridRange = new GeneralGridEnvelope(transformed, PixelInCell.CELL_CORNER,gridMaxInclusive); throw new RuntimeException(e); tempEnvelope.setCoordinateReferenceSystem(envelope.getCoordinateReferenceSystem()); this.envelope=tempEnvelope; }else final double xScale=transformed.getSpan(0)/gridRange.getSpan(0); final double yScale=transformed.getSpan(1)/gridRange.getSpan(1); final double xTrans=transformed.getMinimum(0)-xScale*gridRange.getLow(0);
(AffineTransform2D) baseCoverage.getGridGeometry().getGridToCRS(); final GeneralEnvelope originalEnvelope = (GeneralEnvelope) baseCoverage.getEnvelope(); final GeneralEnvelope newEnvelope = new GeneralEnvelope(originalEnvelope); newEnvelope.setEnvelope( originalEnvelope.getMinimum(0), originalEnvelope.getMaximum(1) - originalEnvelope.getSpan(1) / 2, originalEnvelope.getMinimum(0) + originalEnvelope.getSpan(0) / 2, expectedTx, PixelInCell.CELL_CENTER, PixelInCell.CELL_CORNER); final GeneralGridEnvelope expectedGridEnvelope = new GeneralGridEnvelope( CRS.transform(cornerWorldToGrid.inverse(), newEnvelope), PixelInCell.CELL_CORNER,
final GeneralEnvelope e = new GeneralEnvelope(envelope); e.setCoordinateReferenceSystem(getDefaultCRS(e.getDimension())); envelope = e; new GeneralGridEnvelope(image, envelope.getDimension()), envelope); return create(name, image, gm, bands, sources, properties);