/** * Sets the envelope to the specified values, which must be the lower corner coordinates * followed by upper corner coordinates. The number of arguments provided shall be twice the * envelope dimension, and minimum shall not be greater than maximum. * * <p><b>Example:</b> (<var>x</var><sub>min</sub>, <var>y</var><sub>min</sub>, * <var>z</var><sub>min</sub>, <var>x</var><sub>max</sub>, <var>y</var><sub>max</sub>, * <var>z</var><sub>max</sub>) */ public void setEnvelope(final double... ordinates) throws IllegalArgumentException { GeneralEnvelope envelope = this.envelope; if (envelope == null) { envelope = new GeneralEnvelope(ordinates.length / 2); } envelope.setEnvelope(ordinates); this.envelope = envelope; // Assigns only if successful. }
result.setEnvelope( envelope.getMinX() + step, envelope.getMinY() + step,
CRS.transform(requestedEnvelope2D, spatialReferenceSystem2D); } else { adjustedRequestedEnvelope.setEnvelope(requestedEnvelope2D);
private GeneralEnvelope computeImageSpatialExtent( final int level, final SeRasterAttr rasterAttributes, final CoordinateReferenceSystem crs, final GridEnvelope gridRange) throws SeException { /* * To get the actual resolution we use an image width and height diminished by one pixel, * since the extent represents the covered area from the center of the top left to the * center of the bottom right pixel */ int imageWidth = -1 + rasterAttributes.getImageWidthByLevel(level); int imageHeight = -1 + rasterAttributes.getImageHeightByLevel(level); SeExtent levelExtent = rasterAttributes.getExtentByLevel(level); double minx = levelExtent.getMinX(); double miny = levelExtent.getMinY(); double maxx = levelExtent.getMaxX(); double maxy = levelExtent.getMaxY(); double w = maxx - minx; double h = maxy - miny; double resx = w / imageWidth; double resy = h / imageHeight; minx -= resx / 2; miny -= resy / 2; maxx += resx / 2; maxy += resy / 2; GeneralEnvelope spatialExtent = new GeneralEnvelope(crs); spatialExtent.setEnvelope(minx, miny, maxx, maxy); return spatialExtent; }
private GeneralEnvelope getResultEnvelope( final List<RasterQueryInfo> queryInfos, final GridEnvelope mosaicGeometry) { // use the same queryInfo used by setMosaicLocations final RasterQueryInfo baseQueryInfo = RasterUtils.findLowestResolution(queryInfos); GeneralEnvelope finalEnvelope = null; int rasterIndex = baseQueryInfo.getRasterIndex(); int pyramidLevel = baseQueryInfo.getPyramidLevel(); MathTransform rasterToModel = rasterInfo.getRasterToModel(rasterIndex, pyramidLevel); CoordinateReferenceSystem coverageCrs = rasterInfo.getCoverageCrs(); GeneralEnvelope mosaicGeometryEnv = new GeneralEnvelope(coverageCrs); mosaicGeometryEnv.setEnvelope( mosaicGeometry.getLow(0), mosaicGeometry.getLow(1), 1 + mosaicGeometry.getHigh(0), 1 + mosaicGeometry.getHigh(1)); try { finalEnvelope = CRS.transform(rasterToModel, mosaicGeometryEnv); finalEnvelope.setCoordinateReferenceSystem(coverageCrs); } catch (TransformException e) { throw new RuntimeException(e); } return finalEnvelope; }
double deltaX = resolution[0] / 2; double deltaY = resolution[1] / 2; env.setEnvelope( env.getMinimum(0) + deltaX, env.getMinimum(1) + deltaY,
originalEnvelope.setEnvelope(-9000000, -9000000, 900000, 9000000);
/** * Sets the envelope to the specified values, which must be the lower corner coordinates * followed by upper corner coordinates. The number of arguments provided shall be twice * the envelope dimension, and minimum shall not be greater than maximum. * <p> * <b>Example:</b> * (<var>x</var><sub>min</sub>, <var>y</var><sub>min</sub>, <var>z</var><sub>min</sub>, * <var>x</var><sub>max</sub>, <var>y</var><sub>max</sub>, <var>z</var><sub>max</sub>) */ public void setEnvelope(final double... ordinates) throws IllegalArgumentException { GeneralEnvelope envelope = this.envelope; if (envelope == null) { envelope = new GeneralEnvelope(ordinates.length / 2); } envelope.setEnvelope(ordinates); this.envelope = envelope; // Assigns only if successful. }
cropEnvelope.getCoordinateReferenceSystem()); GeneralEnvelope ge = new GeneralEnvelope((org.opengis.geometry.Envelope) e2d); cropEnvelope.setEnvelope(ge); } catch (TopologyException e) { cropROIEnvelope.intersection( ReferencedEnvelope.reference(cropEnvelope)); cropEnvelope.setEnvelope( new GeneralEnvelope( new ReferencedEnvelope(
envelope.setEnvelope(895817.968, 4439270.710, 1081186.865, 4617454.766);
envelope.setEnvelope(minx, miny, maxx, maxy);
private GeneralEnvelope toPixelCenter(double[] resolution, GeneralEnvelope pixelCornerEnv) { double deltaX = resolution[0] / 2; double deltaY = resolution[1] / 2; GeneralEnvelope env = new GeneralEnvelope(pixelCornerEnv.getCoordinateReferenceSystem()); env.setEnvelope(pixelCornerEnv.getMinimum(0) + deltaX, pixelCornerEnv.getMinimum(1) + deltaY, pixelCornerEnv.getMaximum(0) - deltaX, pixelCornerEnv.getMaximum(1) - deltaY); return env; }
CRS.transform(requestedEnvelope2D, spatialReferenceSystem2D); } else { adjustedRequestedEnvelope.setEnvelope(requestedEnvelope2D);
private GeneralEnvelope computeImageSpatialExtent(final int level, final SeRasterAttr rasterAttributes, final CoordinateReferenceSystem crs, final GridEnvelope gridRange) throws SeException { /* * To get the actual resolution we use an image width and height diminished by one pixel, * since the extent represents the covered area from the center of the top left to the * center of the bottom right pixel */ int imageWidth = -1 + rasterAttributes.getImageWidthByLevel(level); int imageHeight = -1 + rasterAttributes.getImageHeightByLevel(level); SeExtent levelExtent = rasterAttributes.getExtentByLevel(level); double minx = levelExtent.getMinX(); double miny = levelExtent.getMinY(); double maxx = levelExtent.getMaxX(); double maxy = levelExtent.getMaxY(); double w = maxx - minx; double h = maxy - miny; double resx = w / imageWidth; double resy = h / imageHeight; minx -= resx / 2; miny -= resy / 2; maxx += resx / 2; maxy += resy / 2; GeneralEnvelope spatialExtent = new GeneralEnvelope(crs); spatialExtent.setEnvelope(minx, miny, maxx, maxy); return spatialExtent; }
private GeneralEnvelope getResultEnvelope(final List<RasterQueryInfo> queryInfos, final GridEnvelope mosaicGeometry) { // use the same queryInfo used by setMosaicLocations final RasterQueryInfo baseQueryInfo = RasterUtils.findLowestResolution(queryInfos); GeneralEnvelope finalEnvelope = null; // if (queryInfos.size() == 1) { // finalEnvelope = queryInfos.get(0).getResultEnvelope(); // } else { int rasterIndex = baseQueryInfo.getRasterIndex(); int pyramidLevel = baseQueryInfo.getPyramidLevel(); MathTransform rasterToModel = rasterInfo.getRasterToModel(rasterIndex, pyramidLevel); CoordinateReferenceSystem coverageCrs = rasterInfo.getCoverageCrs(); GeneralEnvelope mosaicGeometryEnv = new GeneralEnvelope(coverageCrs); mosaicGeometryEnv.setEnvelope(mosaicGeometry.getLow(0), mosaicGeometry.getLow(1), 1 + mosaicGeometry.getHigh(0), 1 + mosaicGeometry.getHigh(1)); try { finalEnvelope = CRS.transform(rasterToModel, mosaicGeometryEnv); finalEnvelope.setCoordinateReferenceSystem(coverageCrs); } catch (TransformException e) { throw new RuntimeException(e); } // } // double[] resolution = baseQueryInfo.getResolution(); // finalEnvelope = toPixelCenter(resolution, finalEnvelope); return finalEnvelope; }
if ( /* TODO: ignore 3D CRS for now !hasVerticalCRS */ bbox.getDimension() == 2) envelope.setEnvelope( bbox.getLowerCorner().getOrdinate(0), bbox.getLowerCorner().getOrdinate(1),
final GeneralEnvelope originalEnvelope = (GeneralEnvelope) baseCoverage.getEnvelope(); final GeneralEnvelope newEnvelope=new GeneralEnvelope(originalEnvelope); newEnvelope.setEnvelope( originalEnvelope.getMinimum(0), originalEnvelope.getMaximum(1)-originalEnvelope.getSpan(1)/2,
final GeneralEnvelope originalEnvelope = (GeneralEnvelope) baseCoverage.getEnvelope(); final GeneralEnvelope newEnvelope = new GeneralEnvelope(originalEnvelope); newEnvelope.setEnvelope( originalEnvelope.getMinimum(0), originalEnvelope.getMaximum(1) - originalEnvelope.getSpan(1) / 2,
/** * @param pixelAnchor * @return the originalEnvelope */ public GeneralEnvelope getOriginalEnvelope(final PixelInCell pixelAnchor) { GeneralEnvelope env = null; if (1 == getNumRasters()) { env = getGridEnvelope(0, 0); } else { for (RasterInfo raster : subRasterInfo) { int rasterIndex = getRasterIndex(raster.getRasterId()); GeneralEnvelope rasterEnvelope = getGridEnvelope(rasterIndex, 0); if (env == null) { env = new GeneralEnvelope(rasterEnvelope); } else { env.add(rasterEnvelope); } } } if (PixelInCell.CELL_CENTER.equals(pixelAnchor)) { double[] resolution = getResolution(0, 0); double deltaX = resolution[0] / 2; double deltaY = resolution[1] / 2; env.setEnvelope(env.getMinimum(0) + deltaX, env.getMinimum(1) + deltaY, env.getMaximum(0) - deltaX, env.getMaximum(1) - deltaY); } return env; }
private GridCoverage2D extractCoverageSubset() throws IOException { // get the coverage CoverageInfo dem = getCatalog().getCoverageByName(DEM.getLocalPart()); GridCoverage2D gc = (GridCoverage2D) dem.getGridCoverage(null, GeoTools.getDefaultHints()); // extract only a small part of it Envelope fullEnvelope = gc.getEnvelope(); GeneralEnvelope subset = new GeneralEnvelope( fullEnvelope.getCoordinateReferenceSystem()); double minX = fullEnvelope.getMinimum(0); double minY = fullEnvelope.getMinimum(1); double offsetX = fullEnvelope.getSpan(0) / 5; double offsetY = fullEnvelope.getSpan(1) / 5; subset.setEnvelope(minX + offsetX, minY + offsetY, minX + offsetX * 2, minY + offsetY * 2); gc = (GridCoverage2D) new Operations(null).crop(gc, subset); return gc; }