Search code examples
leafletpostgis

Geoserver: LWGEOM_dwithin: Operation on mixed SRID geometries (MultiPolygon, 4326) != (Point, 0)


I got this response executing a cql filter over a parametric SQL View in Geoserver.

<ows:ExceptionReport version="1.0.0" xsi:schemaLocation="http://www.opengis.net/ows http://localhost:8080/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd">
 <ows:Exception exceptionCode="NoApplicableCode">
  <ows:ExceptionText>
    java.lang.RuntimeException: java.io.IOException java.io.IOExceptionERROR: LWGEOM_dwithin: Operation on mixed SRID geometries (MultiPolygon, 4326) != (Point, 0)
  </ows:ExceptionText>
 </ows:Exception>
</ows:ExceptionReport>

The paramas of the request are correct:

 var wfsParams = {
    service: "WFS",
    version: "1.1.0",
    request: "GetFeature",
    typeName: `${workspace}:${layer}`,
    outputFormat: "application/json",
    srs: "EPSG:4326",
    cql_filter: `DWITHIN(geom, POINT(${latitud} ${longitud}), ${radio}, meters)`
  };

 axios.get(wfsUrl, { params: wfsParams }).then((res)=>{...})

Solution

  • The code above is correct. The problem was that in the SQL View I had the geometry field with a default SRID of -1. Changing the SRID to 4326 fixed the problem.