To retrieve and display data from a WMS server with ECDIS data, you need to take into account the presence of S-52 display settings. To make sure that these styling settings are passed along and rendered, you need to make use of SLD and embed the settings in your request.

Working with S-52 display settings

Maritime ECDIS data is typically rendered according to the International Hydrographic Organisation (IHO) S-52 specification, which provides a detailed list of icons, line styles and other styling information to use for the visualization of buoys, lightmarks and other maritime features.

The S-52 specification defines a set of parameters that you can use to optimize the displaying of maritime data for a specific environment. These parameters include color scheme settings, ship depth settings, several object filters, and other customizations.

In an end user application where the rendering of the data is done in the client application itself, these settings can be provided immediately to the rendering engine.

In a client-server setup where the data is rendered on a remote server, such as the WMS, these parameters should be passed from the client to the server, to allow the server to render its images according to the client’s preferences.

The WMS protocol does not provide out-of-the-box support for the modeling of S-52 parameters, making it impossible to use this type of customizations in a default WMS client-server setup. Therefore, LuciadLightspeed defines a custom WMS extension for the exchange of S-52 settings between WMS clients and servers, which is described in the next sections.

Embedding S-52 display settings in a WMS GetMap request using SLD

The WMS protocol allows embedding an SLD Feature Type Style in GetMap request. You can use this as a mechanism to pass custom styling parameters to a WMS server, and tell the WMS server how to render its images. LuciadLightspeed products use this styling mechanism to support S-52 customization, via a custom S-52 SLD extension.

LuciadLightspeed defines two XML schemas to embed S-52 display settings in a GetMap request via an SLD extension:

  • The S-52 XSD Schema is an SLD-independent XML representation of S-52 display settings

  • The SLD S-52 XSD Schema is a thin wrapper around the S-52 XSD Schema, allowing you to embed the S-52 display settings into an SLD symbolizer extension.

Both schemas are available as resources in the LuciadLightspeed distribution, and can be found in the samples/wms/client/ecdis folder of the resources JAR file in the OGC Web Client Suite component.

The following steps describe how to embed S-52 display settings into a valid WMS GetMap request. The full source is available in the samples/wms/client/ecdis/gxy sample folder.

  1. Create the S-52 data model: you can automatically create the S-52 data model from the XSD Schema using the TLcdXMLDataModelBuilder, as illustrated below.

    Program: Setting up the S-52 data model
    String namespace = "http://www.luciad.com/ecdis/s52/1.0";
    String schemaLocation = getClass().getClassLoader()
                                      .getResource("samples/wms/client/ecdis/s52.xsd")
                                      .toString();
    
    TLcdDataModelBuilder dataModelBuilder = new TLcdDataModelBuilder(namespace);
    
    // Initialize the model using the XML Schema information
    TLcdXMLDataModelBuilder xmlDataModelBuilder = new TLcdXMLDataModelBuilder();
    xmlDataModelBuilder.buildDataModel(dataModelBuilder, namespace, schemaLocation);
    
    TLcdDataModel dataModel = dataModelBuilder.createDataModel();

    For the S-52 display settings, you can either use the default TLcdDataObject, or you can create a custom class extending TLcdDataObject that allows you to add functionality to the object. In the sample, support for property change events was added.

  2. Create the S-52 - SLD data model: the SLD wrapper data model can be created in a similar way to the S-52 data model, as shown below.

    Program: Creating an S-52- SLD wrapper data model
    String namespace = "http://www.luciad.com/ecdis/s52-sld/1.0";
    String schemaLocation = getClass().getClassLoader()
                                      .getResource("com/luciad/format/s52/s52-sld.xsd")
                                      .toString();
    
    TLcdDataModelBuilder dataModelBuilder = new TLcdDataModelBuilder(namespace);
    
    // Initialize the model using the XML Schema information
    TLcdXMLDataModelBuilder xmlDataModelBuilder =
        new TLcdXMLDataModelBuilder(TLcdSEDataTypes.getDataModel(),
                                    S52DataTypes.getDataModel());
    xmlDataModelBuilder.setEntityResolver(new TLcdXMLEntityResolver());
    xmlDataModelBuilder.buildDataModel(dataModelBuilder, schemaLocation);
    
    // Configure the Java instance class for the Symbolizer type
    dataModelBuilder.typeBuilder("S52SymbolizerType")
                    .instanceClass(S52SLDDataTypes.S52Symbolizer.class);
    
    TLcdDataModel dataModel = dataModelBuilder.createDataModel();

    On the Java side, you need to create an S-52 extension of the ALcdSLDSymbolizer class, encapsulating the S-52 display settings, as shown in Program: A custom S-52 SLD symbolizer.

    Program: A custom S-52 SLD symbolizer (from samples/wms/client/ecdis/gxy/s52/S52SLDDataTypes)
    public static class S52Symbolizer extends ALcdSLDSymbolizer {
    
      public S52Symbolizer() {
        super(S52_SYMBOLIZER_TYPE);
      }
    
      public S52Symbolizer(TLcdDataType aType) {
        super(aType);
      }
    
      public S52DataTypes.S52DisplaySettings getDisplaySettings() {
        return (S52DataTypes.S52DisplaySettings) getValue(DISPLAY_SETTINGS_STRING);
      }
    
      public void setDisplaySettings(S52DataTypes.S52DisplaySettings aDisplaySettings) {
        setValue(DISPLAY_SETTINGS_STRING, aDisplaySettings);
      }
    
    }
  3. Create and configure an S-52 display settings object: once you have set up the data models, you can create an S-52 display settings object and configure its settings using the data model API. In the sample, the display settings are configured via the user interface, using the S52DisplaySettingsCustomizer class.

  4. Once the configuration is complete, embed the S-52 display settings object in an S-52 symbolizer, which is itself embedded in an SLD Feature Type Style. This is illustrated in Program: Embedding S-52 display settings in an SLD Feature Type Style.

    Program: Embedding S-52 display settings in an SLD Feature Type Style (from samples/wms/client/ecdis/gxy/MainPanel)
    S52SLDDataTypes.S52Symbolizer symbolizer = new S52SLDDataTypes.S52Symbolizer();
    symbolizer.setDisplaySettings(aDisplaySettings);
    
    TLcdSLDRule rule = new TLcdSLDRule();
    rule.addSymbolizer(symbolizer);
    
    TLcdSLDFeatureTypeStyle featureTypeStyle = new TLcdSLDFeatureTypeStyle();
    featureTypeStyle.addRule(rule);
    
    TLcdSLDUserStyle layerStyle = new TLcdSLDUserStyle();
    layerStyle.setDefault(true);
    layerStyle.addFeatureTypeStyle(featureTypeStyle);
  5. Create a Styled Layer Descriptor, and add an SLD Named Layer with a reference to the Feature Type Style for each layer you want to include in your GetMap request. This is shown in Program: Creating a Styled Layer Descriptor.

    Program: Creating a Styled Layer Descriptor (from samples/wms/client/ecdis/gxy/MainPanel)
    TLcdSLDStyledLayerDescriptor styledLayerDescriptor = new TLcdSLDStyledLayerDescriptor();
    
    for (ALcdWMSNamedLayer aS52SLDLayer : aS52SLDLayers) {
      TLcdSLDNamedLayer layer = new TLcdSLDNamedLayer();
      layer.setName(aS52SLDLayer.getNamedLayerName());
      layer.addLayerStyle(layerStyle);
      styledLayerDescriptor.addLayer(layer);
    }
  6. Set the Styled Layer Descriptor on the ALcdWMSProxy object, using the setStyledLayerDescriptor() method, so that the WMS client includes the S-52 style in your GetMap requests.

Detecting which layers support S-52/SLD styling

A WMS server may serve a mixed set of layers: some layers contain ECDIS data, others containing different sorts of data. To allow WMS clients to discover which layers support S-52/SLD styling, LuciadFusion WMS servers include the ‘S52-SLD’ keyword in the layer description. Such a layer description is provided for each layer in the GetCapabilities request. Program: Detection of WMS layers supporting the S-52/SLD styling extension shows how to detect whether a WMS layer supports S-52/SLD styling.

Program: Detection of WMS layers supporting the S-52/SLD styling extension (from samples/wms/client/ecdis/gxy/MainPanel)
private static boolean isS52SLDLayer(ALcdWMSNamedLayer aLayer) {
  for (int i = 0; i < aLayer.getKeywordCount(); i++) {
    if (aLayer.getKeyword(i).equals("S52-SLD")) {
      return true;
    }
  }
  return false;
}

Note that ECDIS layers that are fused to raster tiles on a LuciadFusion server do not support S-52 styling: their styling can no longer be adjusted once the S-57 data has been fused. These layers are visible as ECDIS data on WMS clients, but they do not include the S52-SLD keyword in their keyword list.