@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdWFSModelDecoderDecorator extends Object implements ILcdWFSModelDecoder, ILcdModelDecoder
ILcdModelDecoder
and ILcdWFSModelDecoder
implementation that allows to access a WFS
server and retrieve data from it.
decodeSource(com.luciad.model.ILcdDataSource)
, which expects an instance of TLcdWFSDataSource
,decode(java.lang.String)
, which expects a String referring to the WFS base URL and feature type name,
specified as a data=coverageIdentifier
key/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)
.
ILcd2DBoundsIndexedModel
.TLcdDataModelDescriptor
.
srsName
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)
.
ILcdDataObject
.
read lock
.Decoding a WFS data source:
String serverURL = "https://sampleservices.luciad.com/wfs";
String featureTypeName = "cities";
//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 = "cities";
//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);
Constructor and Description |
---|
TLcdWFSModelDecoderDecorator()
Constructs a new
TLcdWFSModelDecoderDecorator . |
TLcdWFSModelDecoderDecorator(ILcdOWSTransport aTransport)
Constructs a new
TLcdWFSModelDecoderDecorator that uses the given transport
to interact with a WFS server. |
TLcdWFSModelDecoderDecorator(ILcdWFSModelDecoder aWFSModelDecoder)
Constructs a new
TLcdWFSModelDecoderDecorator that relies on the given
ILcdWFSModelDecoder to decode data from the WFS. |
TLcdWFSModelDecoderDecorator(ILcdWFSModelDecoder aWFSModelDecoder,
ILcdOWSTransport aTransport)
Constructs a new
TLcdWFSModelDecoderDecorator that relies on the given
ILcdWFSModelDecoder to decode data from the WFS data and that uses the given transport
to interact with a WFS server. |
TLcdWFSModelDecoderDecorator(TLcdDataModel aDataModel)
Constructs a new
TLcdWFSModelDecoderDecorator which uses the given data model to configure an XML decoder
to decode data from the WFS. |
TLcdWFSModelDecoderDecorator(TLcdDataModel aDataModel,
ILcdOWSTransport aTransport)
Constructs a new
TLcdWFSModelDecoderDecorator which uses the given data model to configure an XML decoder
to decode data from the WFS. |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeModel(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.
|
boolean |
canDecodeSource(ILcdDataSource aDataSource)
Checks whether the given source represents WFS data.
|
boolean |
canDecodeSource(String aSourceName)
Checks whether the given source is a WFS server.
|
ILcdModel |
decode(String aSourceName)
Creates a new model for the WFS data in the server.
|
ILcdModel |
decodeModel(String aOutputFormat,
String aContentType,
InputStream aInputStream,
String aSourceName,
Properties aRequestProperties)
Decodes a model from the given input stream.
|
ILcdModel |
decodeModel(String aOutputFormat,
String aWFSVersion,
String aContentType,
InputStream aInputStream,
String aSourceName,
Properties aRequestProperties)
Decodes a model from the given input stream.
|
ILcdModel |
decodeSource(ILcdDataSource aDataSource)
Creates a new model for the WFS data in the server represented by a
TLcdWFSDataSource . |
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdModelReferenceParser |
getModelReferenceParser()
Returns the model reference parser that is set on this decoder.
|
boolean |
isLinearElementsUseGeodesicInterpolationForGeodeticSrs()
Returns
true if a geodesic interpolation needs to be used for linear GML elements in case of a geodetic
reference. |
boolean |
isUseLegacyXMLFramework()
Returns whether or not the backwards compatibility mode with LuciadMap
versions prior to 9.0 is enabled.
|
void |
setLinearElementsUseGeodesicInterpolationForGeodeticSrs(boolean aUseGeodesicInterpolationForGeodeticSrs)
Sets whether a geodesic interpolation needs to be used for linear GML elements in case of a geodetic reference.
|
void |
setModelReferenceParser(ILcdModelReferenceParser aModelReferenceParser)
Sets the parser that is used to create
ILcdModelReference
instances given an srsName. |
void |
setUseApplicationSchemaCache(boolean aUseCache)
Turn application schema caching on.
|
void |
setUseLegacyXMLFramework(boolean aUseLegacyXMLFramework)
Specifies whether or not the decoder should use the legacy XML framework
used in LuciadMap versions prior to 9.0.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decodeModelMetadata, decodeModelMetadata, discoverDataSources
public TLcdWFSModelDecoderDecorator()
TLcdWFSModelDecoderDecorator
.public TLcdWFSModelDecoderDecorator(ILcdOWSTransport aTransport)
TLcdWFSModelDecoderDecorator
that uses the given transport
to interact with a WFS server.aTransport
- The transport to be used to interact with a WFS server. Must not be null
.public TLcdWFSModelDecoderDecorator(ILcdWFSModelDecoder aWFSModelDecoder)
TLcdWFSModelDecoderDecorator
that relies on the given
ILcdWFSModelDecoder
to decode data from the WFS.aWFSModelDecoder
- An ILcdWFSModelDecoder
to which is delegated to decode data from the WFS,
except for service exception reports.public TLcdWFSModelDecoderDecorator(ILcdWFSModelDecoder aWFSModelDecoder, ILcdOWSTransport aTransport)
TLcdWFSModelDecoderDecorator
that relies on the given
ILcdWFSModelDecoder
to decode data from the WFS data and that uses the given transport
to interact with a WFS server.aWFSModelDecoder
- An ILcdWFSModelDecoder
to 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 be null
.public TLcdWFSModelDecoderDecorator(TLcdDataModel aDataModel)
TLcdWFSModelDecoderDecorator
which uses the given data model to configure an XML decoder
to decode data from the WFS.aDataModel
- A data model which will be used to decode XML. A union of data models can be used to support
multiple data models.public TLcdWFSModelDecoderDecorator(TLcdDataModel aDataModel, ILcdOWSTransport aTransport)
TLcdWFSModelDecoderDecorator
which 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.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 be null
.public boolean canDecodeModel(String aOutputFormat)
ILcdWFSModelDecoder
,
the method is delegated to this decoder.
Otherwise, true
is 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".canDecodeModel
in interface ILcdWFSModelDecoder
aOutputFormat
- the name of a format, e.g. "GML2"public ILcdModel decodeModel(String aOutputFormat, String aContentType, InputStream aInputStream, String aSourceName, Properties aRequestProperties) throws IOException
ILcdWFSModelDecoder
,
the method is delegated to this decoder, except when a service exception report
is received. This is detected if the content type equals application/vnd.ogc.se_xml
.decodeModel
in interface ILcdWFSModelDecoder
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).TLcdOWSServerException
- if a service exception report is receivedIOException
- if the model could not be decodedpublic ILcdModel decodeModel(String aOutputFormat, String aWFSVersion, String aContentType, InputStream aInputStream, String aSourceName, Properties aRequestProperties) throws IOException
ILcdWFSModelDecoder
decodeModel
, but you can override this to obtain the WFS version information.decodeModel
in interface ILcdWFSModelDecoder
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, null
if 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 WFS GetFeature
requestaSourceName
- the WFS server's URL, which could be used to build relative paths if needed.
Can be null
.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 be null
.IOException
- if the model could not be decodedpublic void setModelReferenceParser(ILcdModelReferenceParser aModelReferenceParser)
ILcdModelReference
instances given an srsName. This parser will not be used if a custom model
decoder is provided.aModelReferenceParser
- the model reference parser for this decoderpublic ILcdModelReferenceParser getModelReferenceParser()
setModelReferenceParser(ILcdModelReferenceParser)
public boolean isUseLegacyXMLFramework()
setUseLegacyXMLFramework(boolean)
public void setUseLegacyXMLFramework(boolean aUseLegacyXMLFramework)
aUseLegacyXMLFramework
- true if the backwards compatibility mode should be enabledpublic void setUseApplicationSchemaCache(boolean aUseCache)
aUseCache
- If true, caching is turned on. Otherwise, it's turned off and
the cache is cleared.TLcdGMLModelDecoder.isUseApplicationSchemaCache()
public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
Returns true
if 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.
canDecodeSource
in interface ILcdModelDecoder
aSourceName
- the source to be verified.true
if the source represents a WFS server, false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public ILcdModel decode(String aSourceName) throws IOException
aSourceName
is expected in the format of URI?data=FeatureTypeName
.
decode
in interface ILcdModelDecoder
aSourceName
- the source to be decoded, can be a formatted as URI?data=FeatureTypeName
to identify the server URI and feature type name.IOException
- If the connections to the server fails, or if the server is not a WFS
server, or if aSourceName
is not well formatted.ILcdModelDecoder.canDecodeSource(String)
public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException
TLcdWFSDataSource
.decodeSource
in interface ILcdModelDecoder
aDataSource
- the source to be decoded, must be a TLcdWFSDataSource
.IOException
- If the connections to the server fails, or if the server is not a WFS
server.ILcdModelDecoder.canDecodeSource(ILcdDataSource)
public boolean canDecodeSource(ILcdDataSource aDataSource)
Returns true
if the object is
a TLcdWFSDataSource
.
This call will not make a connection to the server.
canDecodeSource
in interface ILcdModelDecoder
aDataSource
- the source to be verified.true
if the source is a TLcdWFSDataSource
, false
otherwise.ILcdModelDecoder.decodeSource(ILcdDataSource)
,
ILcdModelDecoder.decodeModelMetadata(ILcdDataSource)
public void setLinearElementsUseGeodesicInterpolationForGeodeticSrs(boolean aUseGeodesicInterpolationForGeodeticSrs)
TLcdGMLModelDecoder.setLinearElementsUseGeodesicInterpolationForGeodeticSrs(boolean)
for
more information.aUseGeodesicInterpolationForGeodeticSrs
- whether a geodesic interpolation needs to be used in case of a geodetic referenceisLinearElementsUseGeodesicInterpolationForGeodeticSrs()
public boolean isLinearElementsUseGeodesicInterpolationForGeodeticSrs()
true
if a geodesic interpolation needs to be used for linear GML elements in case of a geodetic
reference. By default, true
is returned.true
if a geodesic interpolation needs to be used for linear GML elements in case of a geodetic reference.setLinearElementsUseGeodesicInterpolationForGeodeticSrs(boolean)