GridCoverage2D getMap(ReferencedEnvelope requestedEnvelope, int width, int height, String time)
throws IOException {
ReferencedEnvelope gridEnvelope = initTileRequest(requestedEnvelope, width, height, time);
try {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(
Level.FINE,
"Issuing request: " + getTileRequest().getFinalURL(),
new RuntimeException("TRACE!"));
}
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
getTileRequest().setCRS(gridEnvelope.getCoordinateReferenceSystem());
Set<Tile> responses = wmts.issueRequest(getTileRequest());
double xscale = width / requestedEnvelope.getWidth();
double yscale = height / requestedEnvelope.getHeight();
double scale = Math.min(xscale, yscale);
double xoff = requestedEnvelope.getMedian(0) * scale - width / 2;
double yoff = requestedEnvelope.getMedian(1) * scale + height / 2;
AffineTransform worldToScreen = new AffineTransform(scale, 0, 0, -scale, -xoff, yoff);
renderTiles(responses, image.createGraphics(), requestedEnvelope, worldToScreen);
return gcf.create(layer.getTitle(), image, gridEnvelope);
} catch (ServiceException e) {
throw new IOException("GetMap failed", e);
}
}