Getting the WMTS capabilities

You can find out what the capabilities of a WMTS source are, if you provide the URL of the service.

Once you have the capabilities data, you can inspect it to customize the request for the creation of the WMTS model.

If an error occurs during the capabilities retrieval, you can inspect the returned object to learn the reason of the error.

Decoding WMTS data to a WMTS model

You create a model with the WmtsModelDecoder::decodeWmtsModelDecoder::decodeWmtsModelDecoder::decode method. This is how you set up a model for a WMTS:

Program: Creating a WMTS model
std::shared_ptr<WmtsDataSource> source = WmtsDataSource::newBuilder().url(url).layer("4ceea49c-3e7c-4e2d-973d-c608fb2fb07e").style("default").build();

luciad::expected<std::shared_ptr<IRasterModel>, ErrorInfo> wmtsModel = WmtsModelDecoder::decode(source, wmtsCapabilities);
string url = "http://sampleservices.luciad.com/wmts";
try
{
    WmtsDataSource dataSource = WmtsDataSource.NewBuilder()
        .Url(url)
        .Layer("4ceea49c-3e7c-4e2d-973d-c608fb2fb07e")
        .Style("default") // optional
        .Build();
    var rasterModel = WmtsModelDecoder.Decode(dataSource);
    // ...
}
catch (Exception exception)
{
    Console.Error.WriteLine("Failed to open WMTS data source for '" + url + "': " + exception.Message);
}
String url = "http://sampleservices.luciad.com/wmts";
try {
  WmtsDataSource dataSource = WmtsDataSource.newBuilder()
                                            .url(url)
                                            .layer("4ceea49c-3e7c-4e2d-973d-c608fb2fb07e")
                                            .style("default") // optional
                                            .build();
  IRasterModel rasterModel = WmtsModelDecoder.decode(dataSource);
  // ...
} catch (Exception exception) {
  Log.e("LUCIAD", "Failed to open WMTS data source for '" + url + "': " + exception.getMessage());
}

The result is a model created from the URL you specified as a parameter. The WMTS capabilities are automatically requested. Within the data source, you select a layer and a style for that layer.

  • Selects the layer as found in the capabilities.

  • Sets the styling to the selected style entry. The call for the style is optional. If you don’t specify a style, the default entry is used. If there is no default entry, the model creation fails.

  • Selects the default format from the format entries available for the layer.

Note that the URL is the only required parameter. All other parameters fall back to their default settings if you don’t specify them.

You can retrieve the capabilities earlier and specify them in the decode call, to prevent the need for a new query. If you don’t provide them, they’re retrieved automatically though.

The capabilities are used to cross-check the availability of data requested in the WmtsDataSourceWmtsDataSourceWmtsDataSource, and find the defaults for unavailable values.

See Visualizing Raster Data for more information about visualizing raster data.

Limitations

The support for the OGC WMTS protocol has some limitations. For details, see the WmtsModelDecoder::decodeWmtsModelDecoder::decodeWmtsModelDecoder::decode method documentation.