*
* @throws WmsException For any problems.
*/
protected void execute(FeatureTypeInfo[] requestedLayers, Query[] queries,
int x, int y) throws WmsException {
GetFeatureInfoRequest request = getRequest();
this.format = request.getInfoFormat();
GetMapRequest getMapReq = request.getGetMapRequest();
int width = getMapReq.getWidth();
int height = getMapReq.getHeight();
Envelope bbox = getMapReq.getBbox();
Coordinate upperLeft = pixelToWorld(x - 2, y - 2, bbox, width, height);
Coordinate lowerRight = pixelToWorld(x + 2, y + 2, bbox, width, height);
Coordinate[] coords = new Coordinate[5];
coords[0] = upperLeft;
coords[1] = new Coordinate(lowerRight.x, upperLeft.y);
coords[2] = lowerRight;
coords[3] = new Coordinate(upperLeft.x, lowerRight.y);
coords[4] = coords[0];
//DJB:
//TODO: this should probably put a max features restriction on the query
// unforunately, this queryies by filter not by query, so this is a slightly more difficult problem
// Its not a big deal not to do this because the writer will ensure that the correct # of items
// are actually printed out.
//DJB: DONE - see "q", below
// NOTE: you can ask for results from multiple layers at once. So, if max features is 2 (after you add max features query to above) and you
// query 10 layers, you could still get 20 features being sent on.
// Thats why max features is handled at the query portion!
GeometryFactory geomFac = new GeometryFactory();
LinearRing boundary = geomFac.createLinearRing(coords);
Polygon pixelRect = geomFac.createPolygon(boundary, null);
FilterFactory filterFac = FilterFactory.createFilterFactory();
GeometryFilter getFInfoFilter = null;
try {
getFInfoFilter = filterFac.createGeometryFilter(AbstractFilter.GEOMETRY_INTERSECTS);
getFInfoFilter.addLeftGeometry(filterFac.createLiteralExpression(
pixelRect));
} catch (IllegalFilterException e) {
e.printStackTrace();
throw new WmsException(null, "Internal error : " + e.getMessage());
}
int layerCount = requestedLayers.length;
results = new ArrayList(layerCount);
metas = new ArrayList(layerCount);
try {
for (int i = 0; i < layerCount; i++) {
FeatureTypeInfo finfo = requestedLayers[i];
Query q = new DefaultQuery( finfo.getTypeName(), null, getFInfoFilter,request.getFeatureCount(), Query.ALL_NAMES, null );
FeatureResults match = finfo.getFeatureSource().getFeatures(q);
//this was crashing Gml2FeatureResponseDelegate due to not setting
//the featureresults, thus not being able of querying the SRS
//if (match.getCount() > 0) {