How do I generate geometric OGC filters for use in a WFS GetFeature request such as:
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:Intersects>
<ogc:PropertyName>geom</ogc:PropertyName>
<gml:Box xmlns:gml="http://www.opengis.net/gml">
<gml:coordinates decimal="." cs="," ts=" ">1298543.0367787,7107400.531374 1299312.4070614,7203464.9016567</gml:coordinates>
</gml:Box>
</ogc:Intersects>
</ogc:Filter>
The OpenLayers 2 supported geometric filters (e.g., Intersections). How do I write a filter in the OL3?
ol.format.ogc.filter
seems does not support (geometric filters).
Best Answer
As the library has changed over the time, you can now provide filters for spatial operations using
ol.format.filter.*
functions (previously in the namespaceol.format.ogc.filter.*
)Using something like below will work:
where
polygon
is anol.geom.Geometry
.Be aware that I had to invert X and Y coordinates in my
polygon
to make things working correctly.You can see an example in action to illustrate (PS: working in Chrome, not in FF, didn't debug more because do not own the remote server...).