Float.valueOf(crop.getLow(0)), // x origin for each band Float.valueOf(crop.getLow(1)), // y origin for each band Float.valueOf(crop.getSpan(0)), // width for each band Float.valueOf(crop.getSpan(1))); // height for each band assert crop.getLow(0) == image.getMinX(); assert crop.getLow(1) == image.getMinY(); assert crop.getSpan(0) == image.getWidth(); assert crop.getSpan(1) == image.getHeight();
/** * Transforms a rectangle represented by a GridEnvelope2D object from grid to world coordinates. * The bounds of the Envelope2D object returned correspond to the outer edges of the grid cells * within the input envelope. * * <p>Users needing more control over the nature of the conversion can use the {@code * MathsTransform} provided by {@linkplain GridGeometry2D#getGridToCRS2D(PixelOrientation) } * which is accessed via {@linkplain #getGridGeometry()}. * * @param gridEnv The rectangle of grid coordinates to convert * @return World coordinates of the rectangle as a new Envelope2D object * @throws TransformException if the transformation failed. * @throws IllegalArgumentException if the input rectangle lies outside the coverage * @since 2.6 */ public final Envelope2D gridToWorld(final GridEnvelope2D gridEnv) throws TransformException { MathTransform2D mt = getGridToCRS2D(); if (getGridRange2D().contains(gridEnv)) { GridCoordinates2D low = gridEnv.getLow(); Point2D trLow = mt.transform(new Point2D.Double(low.x - 0.5, low.y - 0.5), null); GridCoordinates2D high = gridEnv.getHigh(); Point2D trHigh = mt.transform(new Point2D.Double(high.x + 0.5, high.y + 0.5), null); return new Envelope2D( new DirectPosition2D(crs2D, trLow.getX(), trLow.getY()), new DirectPosition2D(crs2D, trHigh.getX(), trHigh.getY())); } else { throw new IllegalArgumentException( Errors.format(ErrorKeys.POINT_OUTSIDE_COVERAGE_$1, gridEnv)); } }
@Override public String toString() { return "[level: " + pyramidLevel + " size: " + gridEnvelope.getSpan(0) + "x" + gridEnvelope.getSpan(1) + " Grid: " + gridEnvelope + " xRes: " + getXRes() + " yRes: " + getYRes() + " xOffset: " + gridEnvelope.getLow(0) + " yOffset: " + gridEnvelope.getLow(1) + " extent: " + spatialExtent.getMinimum(0) + "," + spatialExtent.getMinimum(1) + "," + spatialExtent.getMaximum(0) + "," + spatialExtent.getMaximum(1) + " tilesWide: " + xTiles + " tilesHigh: " + yTiles + "]"; } }
cropParams.add(Float.valueOf(crop.getLow(0))); // x origin for each band cropParams.add(Float.valueOf(crop.getLow(1))); // y origin for each band cropParams.add(Float.valueOf(crop.getSpan(0)));// width for each band cropParams.add(Float.valueOf(crop.getSpan(1)));// height for each band assert crop.getLow(0) == image.getMinX(); assert crop.getLow(1) == image.getMinY(); assert crop.getSpan(0) == image.getWidth(); assert crop.getSpan(1) == image.getHeight();
GridCoordinates2D low = gridEnv.getLow(); Point2D trLow = mt.transform(new Point2D.Double(low.x - 0.5, low.y - 0.5), null);