use of org.apache.sis.coverage.grid.GridGeometry in project sis by apache.
the class GridAdjustment method scale.
/**
* Creates a new grid geometry with a scale factor applied in grid coordinates before the "grid to CRS" conversion.
*
* @param grid the grid geometry to scale.
* @param extent the extent to allocate to the new grid geometry.
* @param anchor the transform to adjust: "center to CRS" or "corner to CRS".
* @param dataToGridIndices value of {@link #dataToGridIndices()}.
* @return scaled grid geometry.
*/
static GridGeometry scale(final GridGeometry grid, final GridExtent extent, final PixelInCell anchor, final double[] dataToGridIndices) {
MathTransform gridToCRS = grid.getGridToCRS(anchor);
final LinearTransform scale = MathTransforms.scale(dataToGridIndices);
gridToCRS = MathTransforms.concatenate(scale, gridToCRS);
return new GridGeometry(extent, anchor, gridToCRS, grid.isDefined(GridGeometry.CRS) ? grid.getCoordinateReferenceSystem() : null);
}
use of org.apache.sis.coverage.grid.GridGeometry in project sis by apache.
the class CoverageQuery method setSelection.
/**
* Sets the approximate area of cells or pixels to include in the subset.
* This convenience method creates a grid geometry containing only the given envelope.
* Note that the given envelope is approximate:
* Coverages may expand the envelope to an integer amount of tiles.
*
* @param domain the approximate area of interest, or {@code null} if none.
*/
@Override
public void setSelection(final Envelope domain) {
GridGeometry g = null;
if (domain != null) {
g = new GridGeometry(null, null, domain, GridRoundingMode.NEAREST);
}
setSelection(g);
}
use of org.apache.sis.coverage.grid.GridGeometry in project sis by apache.
the class MemoryGridResourceTest method testRead.
/**
* Tests {@link MemoryGridResource#read(GridGeometry, int...)}.
*/
@Test
public void testRead() {
final GridGeometry request = createSubGrid();
final GridCoverage coverage = resource.read(request);
/*
* Note: following lines work only with JDK 16 or above.
* https://bugs.openjdk.java.net/browse/JDK-8166038
*/
assertEqualsIgnoreMetadata(request, coverage.getGridGeometry());
assertInstanceOf("render(null)", BufferedImage.class, coverage.render(null));
}
use of org.apache.sis.coverage.grid.GridGeometry in project sis by apache.
the class CoverageQueryTest method testWithExpansion.
/**
* Tests with a sub-grid geometry and a source domain expansion.
*
* @throws DataStoreException if query execution failed.
*/
@Test
public void testWithExpansion() throws DataStoreException {
final int expansion = 3;
final GridGeometry subGrid = createSubGrid(0);
final CoverageQuery query = new CoverageQuery();
query.setSelection(subGrid);
query.setSourceDomainExpansion(expansion);
final GridCoverageResource subset = resource.subset(query);
assertEquals(createSubGrid(expansion), subset.getGridGeometry());
verifyRead(subset, expansion);
}
use of org.apache.sis.coverage.grid.GridGeometry in project sis by apache.
the class CoverageQueryTest method testQueryMethods.
/**
* Tests using only the methods defined in the {@link Query} base class.
*
* @throws DataStoreException if query execution failed.
*/
@Test
public void testQueryMethods() throws DataStoreException {
final GridGeometry subGrid = createSubGrid(0);
final Query query = new CoverageQuery();
query.setSelection(subGrid.getEnvelope());
query.setProjection("0");
final GridCoverageResource subset = resource.subset(query);
assertEquals(subGrid, subset.getGridGeometry());
verifyRead(subset, 0);
}
Aggregations