0

I have successfully got my cql_filter button to respond correctly in terms of filtering a WMS contour dataset served from PostGIS and GeoServer.

However, my next goal is to complete a cql_filter which filters data within a set distance of the defined object. In my case, I am trying to select all Electrical Pylons within a distance of a defined electrical pylon. Therefore, the Pylon would need to be defined by the user and also the search distance.

I understand that I should be using the 'DWITHIN' query and have again previously completed this in OpenLayers 3 but can't get my code to respond in Leaflet.

My java-script code is:

    //Pylon Search Button
    function updatePylons() {
    var pylonfilter = 'DWITHIN(geom, 
      collectGeometries(queryCollection(
        \'Inyaninga_243-198:proposed_pylons_3857\',\'geom\',\'id = \'\'' + document.getElementById('Pylon').value + '\'\' \')), '
        + document.getElementById('distance').value + ', meters)' ;
    return pylons.setParams({CQL_FILTER: pylonfilter});
    };

This will be passed to an input form with two fields:

    <form>
    Pylons:<br>
          <input type="text" id="Pylon">
          <input type="number" id="distance">
          <input type="button" value="Filter" onclick="updatePylons()">
    </form>

I have adapted my code as best I can, I'm sure its a minor issue.

1
  • please show us what is being sent to the server – Ian Turton Mar 24 '17 at 9:19
1

That's because "DWITHIN" cql_filter does not work when geom is in Degree and distance is in metric. They have to be both on a projected CRS. It should be a bug in geoserver i think... Anyway the best thing you can do is to recreate a polygon from the circle. Below i'm posting a solution for this problem using Leaflet. https://stackoverflow.com/questions/24145205/writing-a-function-to-convert-a-circle-to-a-polygon-using-leaflet-js

1
  • Also, the question is about OL3, not leaflet. @BradHards the title is Leaflet DWITHIN cql_filter The OP can do it in OpenLayers not Leaflet – nmtoken Jul 4 '17 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.