I am using leaflet with geoserver. I want to set up a CQL filter to do an intersect but having an issue with getting the geometry from leaflet polygon to cql polygon.
For instance, the feature has the following.
gemoetry.coordinates is something like this when output as a string.
CQL would need it in this format.
POLYGON((-90.89 46.67,-90.89 46.67,-90.89 46.67,-90.89 46.67,-90.89 46.67))
This would then be used to do something like this.
cql_filter=INTERSECTS(Geometry, POLYGON((-90.89 46.67,-90.89 46.67,-90.89 46.67,-90.89 46.67,-90.89 46.67))
However, it doesn't seem like leaflet has a toString or toCQL to convert a leaflet polygon to a CQL polygon. Now, one thing that comes to mind is writing a custom parser to go through and generate the CQL polygon needed to do the filter. This doesn't seem ideal to me and not sure how it would handle multipolygons. Is there an easy way to do this is leaflet?
UPDATE: Based on the answer, I used the wicket with the following code.
var wkt = new Wkt.Wkt(); wkt.fromObject(object.geometry) var filter = "INTERSECTS(Geometry," + wkt.write() + ")";