* Handles a getfeatureinfo request
*
* @param conv
*/
private void handleGetFeatureInfo(ConveyorTile tile) throws GeoWebCacheException {
TileLayer tl = tld.getTileLayer(tile.getLayerId());
if (tl == null) {
throw new GeoWebCacheException(tile.getLayerId() + " is unknown.");
}
String[] keys = { "x", "y", "srs", "info_format", "bbox", "height", "width" };
Map<String, String> values = ServletUtils.selectedStringsFromMap(
tile.servletReq.getParameterMap(), tile.servletReq.getCharacterEncoding(), keys);
// TODO Arent we missing some format stuff here?
GridSubset gridSubset = tl.getGridSubsetForSRS(SRS.getSRS(values.get("srs")));
BoundingBox bbox = null;
try {
bbox = new BoundingBox(values.get("bbox"));
} catch (NumberFormatException nfe) {
log.debug(nfe.getMessage());
}
if (bbox == null || !bbox.isSane()) {
throw new ServiceException("The bounding box parameter (" + values.get("srs")
+ ") is missing or not sane");
}
// long[] tileIndex = gridSubset.closestIndex(bbox);
MimeType mimeType;
try {
mimeType = MimeType.createFromFormat(values.get("info_format"));
} catch (MimeException me) {
throw new GeoWebCacheException("The info_format parameter ("
+ values.get("info_format") + ")is missing or not recognized.");
}
ConveyorTile gfiConv = new ConveyorTile(sb, tl.getName(), gridSubset.getName(), null,
mimeType, null, tile.servletReq, tile.servletResp);
gfiConv.setTileLayer(tl);
int x, y;
try {
x = Integer.parseInt(values.get("x"));
y = Integer.parseInt(values.get("y"));
} catch (NumberFormatException nfe) {
throw new GeoWebCacheException(
"The parameters for x and y must both be positive integers.");
}
int height, width;
try {
height = Integer.parseInt(values.get("height"));
width = Integer.parseInt(values.get("width"));
} catch (NumberFormatException nfe) {
throw new GeoWebCacheException(
"The parameters for height and width must both be positive integers.");
}
Resource data = tl.getFeatureInfo(gfiConv, bbox, height, width, x, y);
try {
tile.servletResp.setContentType(mimeType.getMimeType());
ServletOutputStream outputStream = tile.servletResp.getOutputStream();
data.transferTo(Channels.newChannel(outputStream));