if (tilematrixset == null) {
throw new OWSException(400, "MissingParameterValue", "TILEMATRIXSET",
"No TILEMATRIXSET specified");
}
GridSubset gridSubset = tileLayer.getGridSubset(tilematrixset);
if (gridSubset == null) {
throw new OWSException(400, "InvalidParameterValue", "TILEMATRIXSET",
"Unable to match requested TILEMATRIXSET " + tilematrixset
+ " to those supported by layer");
}
final String tileMatrix = values.get("tilematrix");
if (tileMatrix == null) {
throw new OWSException(400, "MissingParameterValue", "TILEMATRIX",
"No TILEMATRIX specified");
}
long z = gridSubset.getGridIndex(tileMatrix);
if (z < 0) {
throw new OWSException(400, "InvalidParameterValue", "TILEMATRIX",
"Unknown TILEMATRIX " + tileMatrix);
}
// WMTS has 0 in the top left corner -> flip y value
final String tileRow = values.get("tilerow");
if (tileRow == null) {
throw new OWSException(400, "MissingParameterValue", "TILEROW", "No TILEROW specified");
}
long[] gridExtent = gridSubset.getGridSetExtent((int) z);
long y = gridExtent[1] - Long.parseLong(tileRow) - 1;
String tileCol = values.get("tilecol");
if (tileCol == null) {
throw new OWSException(400, "MissingParameterValue", "TILECOLUMN",
"No TILECOLUMN specified");
}
long x = Long.parseLong(tileCol);
long[] gridCov = gridSubset.getCoverage((int) z);
if (x < gridCov[0] || x > gridCov[2]) {
throw new OWSException(400, "TileOutOfRange", "TILECOLUMN", "Column " + x
+ " is out of range, min: " + gridCov[0] + " max:" + gridCov[2]);
}
if (y < gridCov[1] || y > gridCov[3]) {
long minRow = gridExtent[1] - gridCov[3] - 1;
long maxRow = gridExtent[1] - gridCov[1] - 1;
throw new OWSException(400, "TileOutOfRange", "TILEROW", "Row " + tileRow
+ " is out of range, min: " + minRow + " max:" + maxRow);
}
long[] tileIndex = { x, y, z };
try {
gridSubset.checkCoverage(tileIndex);
} catch (OutsideCoverageException e) {
}
ConveyorTile convTile = new ConveyorTile(sb, layer, gridSubset.getName(), tileIndex,
mimeType, fullParameters, request, response);
convTile.setTileLayer(tileLayer);
return convTile;