First of all I am new to Geoserver and Openlayers. I have been trying to get this working on the Geoserver side using the Layer preview page to view my layer using the Openlayer viewer. I would be implementing it as an Openlayers WFS GET request in the end.
What I am trying to accomplish is to return features that are within a certain distance of different points. (ie. within 5km of a school)
I am using the Layer preview page on Geoserver . I have added the CQL filter of "DWITHIN(GEOM, POINT(-60.2 46.1), 0.05, kilometers)". It has limited the amount of points that were returned but I am unsure if it is filtering correctly.
My questions are as follows:
After spending some time with this I was able to answer my own question.
First of all doing some searching I determined 1 degree = 111.325 kms approximately. https://answers.yahoo.com/question/index?qid=20060905051639AAWGjH9
To add multiple DWITHIN filters all you have to do is add an AND between each one. If it is in the WFS format you may have to add %20AND%20 so the spaces are included.
To do a DWITHIN of a certain location you would append the following to your wfs. The point is the long/lat, 0.05 is the degrees from the point, kilometers is the unit that is passed in. When using geoserver it will default to degrees as the link in the original question states.
This will return any of the features from your WFS layer that are within the degrees of the point specified.
To filter off of another layer I used info from the following URL http://docs.geoserver.org/2.6.x/en/user/extensions/querylayer/index.html
Firs you must install the proper querylayer module to your version of Geoserer as the link states.
To do the filter based of feature name I used the following CQL_filter:
This will return any features from the WFS layer you are requesting that are within the degrees specified of a feature with the AssetID of 1 from the layer 'Workspace:AssetLayer'.
ie if school had an AssetTypeID of 1, this would return all features from the original layer that were within 0.02 degrees of a school on the 'Workspace:AssetLayer' layer.
The "GEOM" value should be the name of column that holds your geometry data in SQL.
Also, I encoded the last parenthesis in the CQL_Filter "%29" because I found when making the request through openlayers it was stripping it off.
As I said I am new to openlayers/geoserver so this may not work in every case but this is how I figured it out. I am thinking in different projections there may be some changes. Hope this can get you on the right track.