[GEOS-11926] Incompatibility between OGCAPI features module and WFS

Hi,

I found out that having the ogcapi features plugin in the classpath was altering the behaviour of WFS services: the WFS GetCapabilities advises an outputFormat which actually is not available for GetFeatures operations (“application/geo+json”). I opened an issue on osgeo’s JIRA in this regard (see https://osgeo-org.atlassian.net/browse/GEOS-11926 for more details), but I also had some time to dig further, and I am perplexed as how I could fix it myself.

It seems that the RFCGeoJSONGeaturesResponse implements the canHandle(Version) method from a parent class which always return true, making it appearing into the WFS GetCapabilities response. My guess was to return false when WFS is involved and true otherwise, implementing the canHandle() on the class the following way instead:

@Override public boolean canHandle(Version version) {
  // Do not interfere with WFS
  if (version.equals(WFSInfo.Version.V_10.getVersion()) ||   
     version.equals(WFSInfo.Version.V_11.getVersion()) ||
     version.equals(WFSInfo.Version.V_20.getVersion()))
   return false;
  return true;
}

But it sounds quite fragile as a fix (what if a new version of OGCAPI arises which would clash with WFS versions) ? I am not even sure if the RFC GeoJSON class could not be actually used for WFS operations (yet it comes with the ogcapi plugin), or if it should not be mentioned in the WFS operations at all, as the intent of my fix suggests.

What do you think ?

Hi,

if you check the code, it has been made to be WFS compatible, and there is nothing wrong with a WFS answering to application/geo+json.

One way to handle this, would be to change the code so that it supports WFS too, in the other canHandle:

@Override
public boolean canHandle(Operation operation) {
String operationId = operation.getId();
if (“GetFeatures”.equalsIgnoreCase(operationId)
|| “GetFeature”.equalsIgnoreCase(operationId)
|| “GetFeatureWithLock”.equalsIgnoreCase(operationId)
|| “getTile”.equalsIgnoreCase(operationId)) {
return operation.getService() != null
&& “Features”.equals(operation.getService().getId()) || “WFS”.equalsIgnoreCase(operation.getService().getId());
}
return false;
}

I believe the current restriction to “Features” was done because the code was interfering with the DGGS services during OGC Testbed 16, but with the above change, I believe it should be fine.

Cheers
Andrea

1 Like