To simply load and visualize data from a WCS, you can creata a model through TLcdWCSDataSource and TLcdWCSCoverageModelDecoder, as explained in the Basics. The information in this guide is only needed if you want to have additional customization options to load WCS data, such as the configuration of the image structure.

Using a proxy model

LuciadLightspeed uses proxy models for connections with OGC services. When added to a layer in a view, they automatically obtain the data (features, images …​) from the OGC service, making the service connection transparent to the user. The OGC client APIs create these proxy models by default, using a data source and model decoder.

To support customization possibilities, the OGC clients offer additional API related to the proxy model. Examples include the configuration of constraints on what data should be retrieved or which data exchange format should be used.

Creating a WCS proxy model

Use the class TLcdWCSProxyModelFactory to create and customize a WCS proxy model. The required input parameters of the proxy factory are: a TLcdWCSClient instance, representing the service in question, and the name of the requested coverage.

The proxy factory will return a TLcdWCSProxyModel, which contains a single TLcdWCSProxy object. This object has an ALcdImage which can be accessed using ALcdImage.fromDomainObject(TLcdWCSProxy), for use with the imaging API. It is also is an implementation of ILcdMultilevelRaster for use with the legacy raster API. The proxy object obtains data from the WCS transparently. The following code fragment illustrates the creation and configuration of a WCS proxy model.

Program: Creating and configuring a WCS proxy model
// Create a proxy factory
TLcdWCSProxyModelFactory factory = new TLcdWCSProxyModelFactory();
// Create a proxy model for the selected service and coverage
TLcdWCSProxyModel model;
try {
  model = factory.createProxyModel(fWCSClient, fSelectedCoverage);
} catch (IOException e) {
// Obtain the proxy object from the model; it holds a set of configuration parameters
// that can be used to customize the WCS data retrieval and appearance.
TLcdWCSProxy proxy = model.getWCSProxy();
// Optional: configure the desired raster interpolation method
try {
  // Optional: apply an area of interest
  ILcdBounds wgs84bounds = fAreaOfInterestLayer.getLonLatBounds();
  TLcdGeoReference2GeoReference transform = new TLcdGeoReference2GeoReference(
      (ILcdGeoReference) fAreaOfInterestLayer.getModel().getModelReference(),
      (ILcdGeoReference) model.getModelReference()
  ILcd3DEditableBounds proxyBounds =
  transform.sourceBounds2destinationSFCT(wgs84bounds, proxyBounds);

  // Add the proxy model to the map
  fWCSLayer = new AsynchronousLayerFactory(fLayerFactory).createGXYLayer(model);
  GXYLayerUtil.addGXYLayer(fMapJPanel, fWCSLayer, true, false);
} catch (Exception e) {
  fWCSLayer = null;
  JOptionPane.showMessageDialog(fMapJPanel, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);

When using the imaging API, all access through the ALcdImage object happens synchronously. The ALcdImage element is a read-only incarnation of the proxy object. Operations on the ALcdImage object will never trigger model changes. Every time you make changes to the TLcdWCSProxy object, the model may change, and you should to get the proxy object’s ALcdImage object again to obtain the updated state.

When using the raster API, TLcdWCSProxy supports asynchronous retrieval of data, which means that the application does not stop while the proxy is downloading data from the WCS. You can switch this property on and off using the setAsynchronousUpdates method of TLcdWCSProxy. The proxy model will use TLcdModelChangedEvent objects to notify clients of any changes to its internal state. In practice, this means that an ILcdGXYView displaying a WCS proxy model will repaint itself automatically and incrementally as new data becomes available in the proxy model.