In the code below,
<ogc:Filter>
<ogc:Intersects>
<ogc:PropertyName>the_geom</ogc:PropertyName>
<ogc:Function name="querySingle">
<ogc:Literal>sf:restricted</ogc:Literal>
<ogc:Literal>the_geom</ogc:Literal>
<ogc:Literal>cat = 3</ogc:Literal>
</ogc:Function>
</ogc:Intersects>
</ogc:Filter>
i'd like to replace
<ogc:Literal>sf:restricted</ogc:Literal>
<ogc:Literal>the_geom</ogc:Literal>
<ogc:Literal>cat = 3</ogc:Literal>
with a polygon selected by a user. I get the polygon from a selection event. I've tried a number of options, but none is working, yet. Any assistance will be highly appreciated.
My environment: GeoServer 2.1.3, OpenLayers 2.11.
UPDATE:
I've transformed my geometry to EPSG:4326, the one used by my layers in GeoServer:
var geometry = event.feature.geometry.transform(new OpenLayers.Projection("900913"), new OpenLayers.Projection("EPSG:4326"));
The event.feature.geometry represents a polygon selected by a user. I've also converted the geometry to WKT format as shown:
var wktParser = new OpenLayers.Format.WKT();
var feature = new OpenLayers.Feature.Vector();
feature.geometry = geometry;
var wktGeom = wktParser.write(feature);
I've then passed the geometry in WKT format to the filter as shown below:
'<ogc:Filter>' +
'<ogc:Intersects>' +
'<ogc:PropertyName>the_geom</ogc:PropertyName>' +
'<ogc:Function name="querySingle">' +
'<ogc:Literal>ws:layer_2</ogc:Literal>' +
'<ogc:Literal>the_geom</ogc:Literal>' +
'<ogc:Literal>INTERSECTS(the_geom,' + wktGeom + ')</ogc:Literal>' +
'</ogc:Function>' +
'</ogc:Intersects>' +
'</ogc:Filter>';
But when I send a request, the following error is returned:
<ows:ExceptionText>Process failed during execution
java.lang.ClassCastException: org.geotools.filter.AttributeExpressionImpl cannot be cast to org.opengis.filter.Filter
org.geotools.filter.AttributeExpressionImpl cannot be cast to org.opengis.filter.Filter</ows:ExceptionText>.
Any idea on what I may be doing wrong.
