throw new ServiceException("No SRS specified");
}
srs = SRS.getSRS(requestSrs);
}
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"));
final List<GridSubset> crsMatchingSubsets = tileLayer.getGridSubsetsForSRS(srs);
if (crsMatchingSubsets.isEmpty()) {
throw new ServiceException("Unable to match requested SRS " + srs
+ " to those supported by layer");
}
long[] tileIndexTarget = new long[3];
GridSubset gridSubset;
{
GridSubset bestMatch = findBestMatchingGrid(bbox, crsMatchingSubsets, tileWidth,
tileHeight, tileIndexTarget);
if (bestMatch == null) {
// proceed as it used to be
gridSubset = crsMatchingSubsets.get(0);
tileIndexTarget = null;
} else {
gridSubset = bestMatch;
}
}
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;
if (tileIndexTarget == null) {
try {
tileIndex = gridSubset.closestIndex(bbox);
} catch (GridMismatchException gme) {
// Do nothing, the null is info enough
}
} else {
tileIndex = tileIndexTarget;
}
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;