public GridGeometry getGrid() { return delegate.getGrid(); }
if (projectionPolicy != ProjectionPolicy.NONE && bounds != null) { final GridGeometry grid = cinfo.getGrid(); cinfo.setGrid(new GridGeometry2D(grid.getGridRange(), grid.getGridToCRS(), resourceInfo.getCRS()));
if (projectionPolicy != ProjectionPolicy.NONE && bounds != null) { final GridGeometry grid = cinfo.getGrid(); cinfo.setGrid( new GridGeometry2D(
if (cinfo.getGrid() == null) { GridEnvelope originalRange = reader.getOriginalGridRange(); cinfo.setGrid(
MathTransform crsToGrid = meta.getGrid().getGridToCRS().inverse(); GeneralEnvelope requestedGrid = CRS.transform(crsToGrid, requestedEnvelope); double[] spans = new double[requestedGrid.getDimension()];
GridEnvelope2D guessGridLimits() { try { String coverageName = coverage.getModelObject(); Catalog catalog = GeoServerApplication.get().getCatalog(); CoverageInfo ci = catalog.getCoverageByName(coverageName); ReferencedEnvelope boundsNative = getCoverage.bounds.transform(ci.getCRS(), true); MathTransform w2g = ci.getGrid().getGridToCRS().inverse(); Envelope ge = JTS.transform(boundsNative, w2g); GridEnvelope2D grid = new GridEnvelope2D(new Rectangle(0, 0, (int) ge.getWidth(), (int) ge.getHeight())); return grid; } catch(Exception e) { LOGGER.log(Level.SEVERE, "Failed to guess native grid", e); error("Failed to guess native grid: " + e.getMessage()); return null; } }
GridEnvelope2D guessGridLimits() { try { String coverageName = coverage.getModelObject(); Catalog catalog = GeoServerApplication.get().getCatalog(); CoverageInfo ci = catalog.getCoverageByName(coverageName); ReferencedEnvelope boundsNative = getCoverage.bounds.transform(ci.getCRS(), true); MathTransform w2g = ci.getGrid().getGridToCRS().inverse(); Envelope ge = JTS.transform(boundsNative, w2g); GridEnvelope2D grid = new GridEnvelope2D( new Rectangle(0, 0, (int) ge.getWidth(), (int) ge.getHeight())); return grid; } catch (Exception e) { LOGGER.log(Level.SEVERE, "Failed to guess native grid", e); error("Failed to guess native grid: " + e.getMessage()); return null; } }
final GridGeometry originalGrid = ci.getGrid(); final GridEnvelope gridRange = originalGrid.getGridRange(); final AffineTransform2D gridToCRS = (AffineTransform2D) originalGrid.getGridToCRS();
protected void handleGridCRS(CoverageInfo ci) throws Exception { start("wcs:GridCRS"); element("wcs:GridBaseCRS", urnIdentifier(ci.getCRS())); element("wcs:GridType", GridType.GT2dGridIn2dCrs.getXmlConstant()); // TODO: go back to using the metadata once they can be trusted final LinearTransform tx = (LinearTransform) ci.getGrid().getGridToCRS(); final Matrix matrix = tx.getMatrix(); // origin StringBuffer origins = new StringBuffer(); for (int i = 0; i < matrix.getNumRow() - 1; i++) { origins.append(matrix.getElement(i, matrix.getNumCol() - 1)); if (i < matrix.getNumRow() - 2) origins.append(" "); } element("wcs:GridOrigin", origins.toString()); // offsets StringBuffer offsets = new StringBuffer(); for (int i = 0; i < matrix.getNumRow() - 1; i++) { for (int j = 0; j < matrix.getNumCol() - 1; j++) { offsets.append(matrix.getElement(i, j)); if (j < matrix.getNumCol() - 2) offsets.append(" "); } if (i < matrix.getNumRow() - 2) offsets.append(" "); } element("wcs:GridOffsets", offsets.toString()); element("wcs:GridCS", "urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS"); end("wcs:GridCRS"); }
@Test public void testTinyRasterBboxContained() throws Exception { CoverageInfo coverageInfo = addRasterToMap(MockData.TASMANIA_DEM); Envelope env = coverageInfo.boundingBox(); Coordinate center = env.centre(); GridEnvelope range = coverageInfo.getGrid().getGridRange(); double offset = (env.getMaxX() - env.getMinX()) / range.getSpan(0) / 10.0; Rectangle imageBounds = produceMap( center.x + offset, center.x + 2 * offset, center.y + offset, center.y + 2 * offset); assertNotBlank("testTinyRasterBboxContained", this.image); assertEquals("Mosaic", this.op.getOperationName()); Rectangle roiBounds = getRoiBounds(); assertTrue( "Expected " + imageBounds + " to contain " + roiBounds, imageBounds.contains(roiBounds)); }
/** * This method returns {@code true} in case we have POSTed a Coverage object with the name only, * as an instance when configuring a new coverage which has just been harvested. * * @param coverage */ private boolean isNewCoverage(CoverageInfo coverage) { return coverage.getName() != null && (coverage.isAdvertised()) && (!coverage.isEnabled()) && (coverage.getAlias() == null) && (coverage.getCRS() == null) && (coverage.getDefaultInterpolationMethod() == null) && (coverage.getDescription() == null) && (coverage.getDimensions() == null) && (coverage.getGrid() == null) && (coverage.getInterpolationMethods() == null) && (coverage.getKeywords() == null) && (coverage.getLatLonBoundingBox() == null) && (coverage.getMetadata() == null) && (coverage.getNativeBoundingBox() == null) && (coverage.getNativeCRS() == null) && (coverage.getNativeFormat() == null) && (coverage.getProjectionPolicy() == null) && (coverage.getSRS() == null) && (coverage.getResponseSRS() == null) && (coverage.getRequestSRS() == null); }
@Test public void testTinyRasterBboxIntersection() throws Exception { CoverageInfo coverageInfo = addRasterToMap(MockData.TASMANIA_DEM); Envelope env = coverageInfo.boundingBox(); GridEnvelope range = coverageInfo.getGrid().getGridRange(); double offset = (env.getMaxX() - env.getMinX()) / range.getSpan(0) / 20.0; Rectangle imageBounds = produceMap( env.getMinX() - offset, env.getMinX() + offset, env.getMaxY() - offset, env.getMaxY() + offset); assertNotBlank("testTinyRasterBboxIntersection", this.image); assertEquals("Mosaic", this.op.getOperationName()); Rectangle roiBounds = getRoiBounds(); assertTrue( "Expected " + imageBounds + " to contain " + roiBounds, imageBounds.contains(roiBounds)); }
@Test public void testTinyRasterBboxNoIntersection() throws Exception { CoverageInfo coverageInfo = addRasterToMap(MockData.TASMANIA_DEM); Envelope env = coverageInfo.boundingBox(); GridEnvelope range = coverageInfo.getGrid().getGridRange(); double offset = (env.getMaxX() - env.getMinX()) / range.getSpan(0) / 10.0; Rectangle imageBounds = produceMap( env.getMaxX() + offset, env.getMaxX() + 2 * offset, env.getMinY() - 2 * offset, env.getMinY() - offset); assertNotBlank("testTinyRasterBboxNoIntersection", this.image); assertEquals("Mosaic", this.op.getOperationName()); Rectangle roiBounds = getRoiBounds(); assertTrue( "Expected " + imageBounds + " to contain " + roiBounds, imageBounds.contains(roiBounds)); }