2

I have a parametric SQL view for a WFS layer in GeoServer with the simplified form:

SELECT pts.id AS id, pts.geom as geom
FROM schema_name.points_table pts
WHERE ST_Contains(%g%, pts.geom);

I want to use this query as a filter for a Leaflet app, in which the user can edit a polygon to get only points in a defined area. Which steps are necessary to pass the geometry of my L.polygon object through the viewparams parameter into the %g% placeholder in my query?

  • You simply need to get the WKT or WKB of the polygon from Leaflet, then wrap it in the relevant st_geometryfromwkt function in your where clause. - Alternatively you could use a CQL filter on a normal layer with the same input – Ian Turton Jan 31 at 9:21

Your Answer

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

Browse other questions tagged or ask your own question.