[GIS] do Intersection queries in ECQL

asp.netcql-filtergeoprocessinggeoserver

I am building a statistical analysis project using ASP.NET, Geoserver, and OpenLayers.
I need to let the user draw a polygon on OpenLayers then find geometries(villages etc.) that intersects this polygon. Then get their attributes like temperature, population etc., make some mathematical calculations and present this information to user.

My question is can I do the following operation:

(SELECT population,temperature,humidity,height FROM villages WHERE geometry INTERSECTS userDrawnPolygon,
SELECT data1,data2,data3 FROM tableX WHERE geometry INTERSECTS userDrawnPolygon …. goes on for multiple tables)
with ECQL or CQL or some filter on Geoserver or do I need to develop this algorithm in my ASP.NET code – connecting to MSSQL?

Thanks already.

Best Answer

You can use WFS GetFeature, either encoding the filter in CQL or Filter.

Something like:

http://host:port/geoserver/wfs?service=WFS&version=1.0&request=GetFeature&typeName=myLayer&CQL_FILTER=INTERSECTS(the_geom, POLYGON((...)))&propertyName=data1,data2,data3

more here: http://docs.geoserver.org/2.7.1/user/filter/ecql_reference.html#spatial-predicate