throw new ServiceException("No SRS specified");
}
srs = SRS.getSRS(requestSrs);
}
GridSubset gridSubset = tileLayer.getGridSubsetForSRS(srs);
if (gridSubset == null) {
throw new ServiceException("Unable to match requested SRS " + srs
+ " to those supported by layer");
}
final BoundingBox bbox;
{
String requestBbox = paramValues.get("bbox");
try {
bbox = new BoundingBox(requestBbox);
if (bbox == null || !bbox.isSane()) {
throw new ServiceException("The bounding box parameter (" + requestBbox
+ ") is missing or not sane");
}
} catch (NumberFormatException nfe) {
throw new ServiceException("The bounding box parameter (" + requestBbox
+ ") is invalid");
}
}
final int tileWidth = Integer.parseInt(values.get("width"));
final int tileHeight = Integer.parseInt(values.get("height"));
if (fullWMS) {
// If we support full WMS we need to do a few tests to determine whether
// this is a request that requires us to recombine tiles to respond.
long[] tileIndex = null;
try {
tileIndex = gridSubset.closestIndex(bbox);
} catch (GridMismatchException gme) {
// Do nothing, the null is info enough
}
if (tileIndex == null || gridSubset.getTileWidth() != tileWidth
|| gridSubset.getTileHeight() != tileHeight
|| !bbox.equals(gridSubset.boundsFromIndex(tileIndex), 0.02)) {
log.debug("Recombinining tiles to respond to WMS request");
ConveyorTile tile = new ConveyorTile(sb, layers, request, response);
tile.setHint("getmap");
tile.setRequestHandler(ConveyorTile.RequestHandler.SERVICE);
return tile;
}
}
long[] tileIndex = gridSubset.closestIndex(bbox);
gridSubset.checkTileDimensions(tileWidth, tileHeight);
return new ConveyorTile(sb, layers, gridSubset.getName(), tileIndex, mimeType,
fullParameters, request, response);
}