The instruction in this article apply to a WFS server created through WFS Server API code. For an explanation, see Configure a WFS server.

By default, the WFS server supports sending WFS clients data that is encoded using either a GML application schema — following GML version 2, 3.1, or 3.2 — or GeoJSON. Sometimes, you may need to customize the default GeoJSON output, to turn on or off pretty JSON output for example, or to choose between 2D and 3D coordinates. To do so, override TLcdWFSClientModelEncoderFactory and create your own WFS GeoJSON model encoder.

This program illustrates the creation of the default WFS GeoJSON encoder, which you can use as a basis to customize its options.

Program: Defining a custom WFS GeoJSON encoder
ILcdWFSModelEncoder createGeoJSONEncoder(ILcdModelReferenceFormatter aModelReferenceFormatter,
                                         ILcdOutputStreamFactory aOutputStreamFactory,
                                         ILcdWFSFeatureType aFeatureType,
                                         String aContentMimeType) {
  TLcdGeoJsonModelEncoder encoder = new TLcdGeoJsonModelEncoder();
  encoder.setFeatureMetaDataProvider(new TLcdFeatureMetaDataProvider() {
    public Object getId(Object aDomainObject) {
      return aFeatureType.getFeatureIDRetriever().retrieveFeatureID(aDomainObject);
  return new TLcdWFSModelEncoder(encoder, aContentMimeType);