Package com.luciad.ogc.wfs.client
Class TLcdWFSModelDecoderDecorator
java.lang.Object
com.luciad.ogc.wfs.client.TLcdWFSModelDecoderDecorator
- All Implemented Interfaces:
ILcdModelDecoder,ILcdWFSModelDecoder
@LcdService(service=ILcdModelDecoder.class,
priority=20000)
public class TLcdWFSModelDecoderDecorator
extends Object
implements ILcdWFSModelDecoder, ILcdModelDecoder
An
ILcdModelDecoder and ILcdWFSModelDecoder implementation that allows to access a WFS
server and retrieve data from it.
Input
To load data from a WFS server, two parameters are generally required: the URL pointing to a WFS server and a WFS feature type name identifying the desired data set. This information can be supplied in two ways:- through
decodeSource(com.luciad.model.ILcdDataSource), which expects an instance ofTLcdWFSDataSource, - through
decode(java.lang.String), which expects a String referring to the WFS base URL and feature type name, specified as adata=coverageIdentifierkey/value pair.
ILcdWFSModelDecoder can be supplied to support other
feature type data formats. If the format is XML-based and you have a corresponding data model
representation, you can also supply the data model instead of a ILcdWFSModelDecoder. This decoder
automatically handles WFS service exception reports, regardless whether support for a custom format is supplied.
Additionally, this decoder can also be used decode raw WFS GetFeature response data represented by
an InputStream, through decodeModel(java.lang.String, java.lang.String, java.io.InputStream, java.lang.String, java.util.Properties).
Supported transfer protocols
- This model decoder supports http and https protocols.
Model structure
- This model decoder creates a model per WFS feature type name.
- All models returned by this model decoder implement
ILcd2DBoundsIndexedModel.
Model descriptor
All models returned by this decoder have aTLcdDataModelDescriptor.
Model reference
The model reference is obtained from the GML-based feature data, which relies onsrsName XML attributes to
represent a reference. The parsing of this srsName reference is delegated to a default
ILcdModelReferenceParser, which can optionally be set through setModelReferenceParser(com.luciad.model.ILcdModelReferenceParser).
Model elements
The model elements represent the feature type's features and are of typeILcdDataObject.
Thread safety
- The decoded models are thread-safe for read access when taking a
read lock.
Sample code
Decoding a WFS data source:
String serverURL = "https://sampleservices.luciad.com/wfs";
String featureTypeName = "t_rivers__c__1212";
//Create the data source
TLcdWFSDataSource dataSource = TLcdWFSDataSource.newBuilder()
.uri(serverURL)
.featureTypeName(featureTypeName)
.build();
//Decode the model
ILcdModelDecoder decoder = new TLcdWFSModelDecoderDecorator();
ILcdModel model = decoder.decodeSource(dataSource);
Decoding a string containing the server URL and WFS feature type name
String serverURL = "https://sampleservices.luciad.com/wfs";
String featureTypeName = "t_rivers__c__1212";
//Concat the url and layer name to a single string
String sourceName = String.format("%s?data=%s", serverURL, featureTypeName);
//Decode the model
ILcdModelDecoder decoder = new TLcdWFSModelDecoderDecorator();
ILcdModel model = decoder.decode(sourceName);
Supported versions and specifications
- This model decoder supports WFS servers that comply with the OGC WFS 1.0, 1.1 or 2.0 specification. For more information about the OGC WFS specification, please refer to http://www.opengeospatial.org.
- Since:
- 8.2
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newTLcdWFSModelDecoderDecorator.TLcdWFSModelDecoderDecorator(TLcdDataModel aDataModel) Constructs a newTLcdWFSModelDecoderDecoratorwhich uses the given data model to configure an XML decoder to decode data from the WFS.TLcdWFSModelDecoderDecorator(TLcdDataModel aDataModel, ILcdOWSTransport aTransport) Constructs a newTLcdWFSModelDecoderDecoratorwhich uses the given data model to configure an XML decoder to decode data from the WFS.TLcdWFSModelDecoderDecorator(ILcdOWSTransport aTransport) Constructs a newTLcdWFSModelDecoderDecoratorthat uses the given transport to interact with a WFS server.TLcdWFSModelDecoderDecorator(ILcdWFSModelDecoder aWFSModelDecoder) Constructs a newTLcdWFSModelDecoderDecoratorthat relies on the givenILcdWFSModelDecoderto decode data from the WFS.TLcdWFSModelDecoderDecorator(ILcdWFSModelDecoder aWFSModelDecoder, ILcdOWSTransport aTransport) Constructs a newTLcdWFSModelDecoderDecoratorthat relies on the givenILcdWFSModelDecoderto decode data from the WFS data and that uses the given transport to interact with a WFS server. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDecodeModel(String aOutputFormat) Given the name of an output format advertised by a WFS, determines whether or not that format can be read by this decoder.booleancanDecodeSource(ILcdDataSource aDataSource) Checks whether the given source represents WFS data.booleancanDecodeSource(String aSourceName) Checks whether the given source is a WFS server.Creates a new model for the WFS data in the server.decodeModel(String aOutputFormat, String aContentType, InputStream aInputStream, String aSourceName, Properties aRequestProperties) Decodes a model from the given input stream.decodeModel(String aOutputFormat, String aWFSVersion, String aContentType, InputStream aInputStream, String aSourceName, Properties aRequestProperties) Decodes a model from the given input stream.decodeSource(ILcdDataSource aDataSource) Creates a new model for the WFS data in the server represented by aTLcdWFSDataSource.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder.Returns the model reference parser that is set on this decoder.booleanReturnstrueif a geodesic interpolation needs to be used for linear GML elements in case of a geodetic reference.booleanReturns whether or not the backwards compatibility mode with LuciadMap versions prior to 9.0 is enabled.voidsetLinearElementsUseGeodesicInterpolationForGeodeticSrs(boolean aUseGeodesicInterpolationForGeodeticSrs) Sets whether a geodesic interpolation needs to be used for linear GML elements in case of a geodetic reference.voidsetModelReferenceParser(ILcdModelReferenceParser aModelReferenceParser) Sets the parser that is used to createILcdModelReferenceinstances given an srsName.voidsetUseApplicationSchemaCache(boolean aUseCache) Turn application schema caching on.voidsetUseLegacyXMLFramework(boolean aUseLegacyXMLFramework) Specifies whether or not the decoder should use the legacy XML framework used in LuciadMap versions prior to 9.0.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.model.ILcdModelDecoder
decodeModelMetadata, decodeModelMetadata, discoverDataSources
-
Constructor Details
-
TLcdWFSModelDecoderDecorator
public TLcdWFSModelDecoderDecorator()Constructs a newTLcdWFSModelDecoderDecorator. -
TLcdWFSModelDecoderDecorator
Constructs a newTLcdWFSModelDecoderDecoratorthat uses the given transport to interact with a WFS server.- Parameters:
aTransport- The transport to be used to interact with a WFS server. Must not benull.- Since:
- 2019.0
-
TLcdWFSModelDecoderDecorator
Constructs a newTLcdWFSModelDecoderDecoratorthat relies on the givenILcdWFSModelDecoderto decode data from the WFS.- Parameters:
aWFSModelDecoder- AnILcdWFSModelDecoderto which is delegated to decode data from the WFS, except for service exception reports.
-
TLcdWFSModelDecoderDecorator
public TLcdWFSModelDecoderDecorator(ILcdWFSModelDecoder aWFSModelDecoder, ILcdOWSTransport aTransport) Constructs a newTLcdWFSModelDecoderDecoratorthat relies on the givenILcdWFSModelDecoderto decode data from the WFS data and that uses the given transport to interact with a WFS server.- Parameters:
aWFSModelDecoder- AnILcdWFSModelDecoderto which is delegated to decode data from the WFS, except for service exception reports.aTransport- The transport to be used to interact with a WFS server. Must not benull.- Since:
- 2019.0
-
TLcdWFSModelDecoderDecorator
Constructs a newTLcdWFSModelDecoderDecoratorwhich uses the given data model to configure an XML decoder to decode data from the WFS.- Parameters:
aDataModel- A data model which will be used to decode XML. A union of data models can be used to support multiple data models.
-
TLcdWFSModelDecoderDecorator
Constructs a newTLcdWFSModelDecoderDecoratorwhich uses the given data model to configure an XML decoder to decode data from the WFS. The given transport is used to interact with a WFS server.- Parameters:
aDataModel- A data model which will be used to decode XML. A union of data models can be used to support multiple data models.aTransport- The transport to be used to interact with a WFS server. Must not benull.- Since:
- 2019.0
-
-
Method Details
-
canDecodeModel
Given the name of an output format advertised by a WFS, determines whether or not that format can be read by this decoder. In case this decoder is decorated with anotherILcdWFSModelDecoder, the method is delegated to this decoder. Otherwise,trueis returned if the output format equals "GML2", "GML.2", "GML3", "GML.3", "GML32", "text/xml; subtype=gml/2.1.2", "text/xml; subtype=gml/3.1.1" or "application/gml+xml; version=3.2".- Specified by:
canDecodeModelin interfaceILcdWFSModelDecoder- Parameters:
aOutputFormat- the name of a format, e.g. "GML2"- Returns:
- true if the specified format can be read
-
decodeModel
public ILcdModel decodeModel(String aOutputFormat, String aContentType, InputStream aInputStream, String aSourceName, Properties aRequestProperties) throws IOException Decodes a model from the given input stream. In case this decoder is decorated with anotherILcdWFSModelDecoder, the method is delegated to this decoder, except when a service exception report is received. This is detected if the content type equalsapplication/vnd.ogc.se_xml.- Specified by:
decodeModelin interfaceILcdWFSModelDecoder- Parameters:
aOutputFormat- the format of the dataaContentType- the mime content type of the data obtained from the WFS in response to a GetFeature requestaInputStream- the stream from which the model is readaSourceName- the base source name that could be used to build relative paths if needed.aRequestProperties- the request properties that could be used for following additional links (e.g. XML schema links).- Returns:
- a model
- Throws:
TLcdOWSServerException- if a service exception report is receivedIOException- if the model could not be decoded
-
decodeModel
public ILcdModel decodeModel(String aOutputFormat, String aWFSVersion, String aContentType, InputStream aInputStream, String aSourceName, Properties aRequestProperties) throws IOException Description copied from interface:ILcdWFSModelDecoderDecodes a model from the given input stream. This default method delegates todecodeModel, but you can override this to obtain the WFS version information.- Specified by:
decodeModelin interfaceILcdWFSModelDecoder- Parameters:
aOutputFormat- the format of the data contained in the given input stream, as advertised in the WFS capabilities (e.g. "GML32)aWFSVersion- the WFS version of the response,nullif unknownaContentType- the MIME content type of the data contained in the given input stream (e.g. "text/xml")aInputStream- the input stream containing the response of a WFSGetFeaturerequestaSourceName- the WFS server's URL, which could be used to build relative paths if needed. Can benull.aRequestProperties- an optional set of request properties that could be used for additional web service connections (e.g. XML Schema links contained in the WFS feature data). Can benull.- Returns:
- a model
- Throws:
IOException- if the model could not be decoded
-
setModelReferenceParser
Sets the parser that is used to createILcdModelReferenceinstances given an srsName. This parser will not be used if a custom model decoder is provided.- Parameters:
aModelReferenceParser- the model reference parser for this decoder- Since:
- 10.1
-
getModelReferenceParser
Returns the model reference parser that is set on this decoder. By default no model reference parser is set, which means that a default set of known model references is supported.- Returns:
- A model reference parser or null
- Since:
- 10.1
- See Also:
-
isUseLegacyXMLFramework
public boolean isUseLegacyXMLFramework()Returns whether or not the backwards compatibility mode with LuciadMap versions prior to 9.0 is enabled.- Returns:
- whether or not the legacy XML framework is used
- See Also:
-
setUseLegacyXMLFramework
public void setUseLegacyXMLFramework(boolean aUseLegacyXMLFramework) Specifies whether or not the decoder should use the legacy XML framework used in LuciadMap versions prior to 9.0. This option is available for backwards compatibility purposes but is switched off by default.- Parameters:
aUseLegacyXMLFramework- true if the backwards compatibility mode should be enabled
-
setUseApplicationSchemaCache
public void setUseApplicationSchemaCache(boolean aUseCache) Turn application schema caching on. This is not supported when using the legacy xml framework or a custom WFS model decoder.- Parameters:
aUseCache- If true, caching is turned on. Otherwise, it's turned off and the cache is cleared.- See Also:
-
getDisplayName
Description copied from interface:ILcdModelDecoderReturns a short, displayable name for the format that is decoded by thisILcdModelDecoder.- Specified by:
getDisplayNamein interfaceILcdModelDecoder- Returns:
- the displayable name of this
ILcdModelDecoder.
-
canDecodeSource
Checks whether the given source is a WFS server.Returns
trueif the source is a HTTP or HTTPS url referring to a WFS server. The WFS server test is done by performing a GetCapabilities operation and verifying the result.- Specified by:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aSourceName- the source to be verified.- Returns:
trueif the source represents a WFS server,falseotherwise.- Since:
- 2018.0
- See Also:
-
decode
Creates a new model for the WFS data in the server.aSourceNameis expected in the format ofURI?data=FeatureTypeName.- If you only provide the server URI, the feature type list is requested from the server and the first feature type is used to make a request from the WFS server.
- If you provide both URI and feature type name, it will return the model for specified feature type name.
- Specified by:
decodein interfaceILcdModelDecoder- Parameters:
aSourceName- the source to be decoded, can be a formatted asURI?data=FeatureTypeNameto identify the server URI and feature type name.- Returns:
- The decoded model
- Throws:
IOException- If the connections to the server fails, or if the server is not a WFS server, or ifaSourceNameis not well formatted.- Since:
- 2018.0
- See Also:
-
decodeSource
Creates a new model for the WFS data in the server represented by aTLcdWFSDataSource.- Specified by:
decodeSourcein interfaceILcdModelDecoder- Parameters:
aDataSource- the source to be decoded, must be aTLcdWFSDataSource.- Returns:
- The decoded model
- Throws:
IOException- If the connections to the server fails, or if the server is not a WFS server.- Since:
- 2018.0
- See Also:
-
canDecodeSource
Checks whether the given source represents WFS data.Returns
trueif the object is aTLcdWFSDataSource.This call will not make a connection to the server.
- Specified by:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aDataSource- the source to be verified.- Returns:
trueif the source is aTLcdWFSDataSource,falseotherwise.- Since:
- 2018.0
- See Also:
-
setLinearElementsUseGeodesicInterpolationForGeodeticSrs
public void setLinearElementsUseGeodesicInterpolationForGeodeticSrs(boolean aUseGeodesicInterpolationForGeodeticSrs) Sets whether a geodesic interpolation needs to be used for linear GML elements in case of a geodetic reference. Please refer toTLcdGMLModelDecoder.setLinearElementsUseGeodesicInterpolationForGeodeticSrs(boolean)for more information.- Parameters:
aUseGeodesicInterpolationForGeodeticSrs- whether a geodesic interpolation needs to be used in case of a geodetic reference- Since:
- 2020.1
- See Also:
-
isLinearElementsUseGeodesicInterpolationForGeodeticSrs
public boolean isLinearElementsUseGeodesicInterpolationForGeodeticSrs()Returnstrueif a geodesic interpolation needs to be used for linear GML elements in case of a geodetic reference. By default,trueis returned.- Returns:
trueif a geodesic interpolation needs to be used for linear GML elements in case of a geodetic reference.- Since:
- 2020.1
- See Also:
-