Contributor(s): Tom Benner
To create a control with which the user can draw an area to find features intersecting with that area, one approach is to create a OpenLayers.Control.DrawFeature control, and pass a custom function as the value for the featureAdded option. The user will draw an area (either by clicking to create a polygon, or by holding Shift to draw continuously) and double-click to close it. Once it is closed, the DrawFeature control will pass the geometry to to the function specified in featureAdded. This function should, optionally, remove the drawn vector, and then construct a GeoServer request to find features that intersect with the drawn area. To get the geometry into the proper string format for a CQL filter, one should call .geometry, then .transform() (if necessary), then .toString() on the geometry. This string can then be inserted to a CQL filter statement, like "'INTERSECT(geometry,'+geometry_string+')'". To find only features of a certain feature type, one would, of course, just need to add another clause to this, like "'+AND+object_type='+feature_type_id".