Class TLcdGMLModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable,ILcdModelDecoder
Input files
| File | Required | Entry point | Description |
|---|---|---|---|
| *.gml, *.gml2, *.gml31, *.gml32, *.xml | x | x |
GML data file |
| *.xsd | x | Application schema (XML Schema) |
Supported file transfer protocols
- This model decoder supports all transfer protocols that are supported by
the
ILcdInputStreamFactoryof this decoder.
Model structure
- This model decoder creates a model per GML file.
- A model represents a GML feature collection. A feature collection is any GML feature with a property element
derived from
AbstractFeatureMemberType. Elements of the deprecatedAbstractFeatureCollectionTypetypes also supported. - All models returned by this model decoder implement
ILcd2DBoundsIndexedModel. - Hierarchic feature collections are decoded as a hierarchical
ILcdModelTreeNodestructure. For example, the following document:
will be decoded as the followed model/element structure:<my:featureCollectionA> <my:featureCollectionB> <my:featureA> ... </my:featureA> </my:featureCollectionB> <my:featureCollectionC> <my:featureB> ... </my:featureB> </my:featureCollectionC> <my:featureC> ... </my:featureC> </my:featureCollectionA>ILcdModelTreeNode (myFeatureCollectionA) +- ILcdModelTreeNode (myFeatureCollectionB) | +- ILcdShape (myFeatureA) +- ILcdModelTreeNode (myFeatureCollectionC) | +- ILcdShape (myFeatureB) +- ILcdShape (myFeatureC)
Model descriptor
- All models returned by this model decoder have a
TLcdGMLModelDescriptor. - The type name of the model descriptor is the display name of the chosen version specific decoder (see above).
Model reference
- This model decoder supports all model references which can be parsed by the
TLcdOGCModelReferenceParser. - This model decoder retrieves its model references from the
srsNameattribute specified within the GML files. The first coordinate reference system (CRS) that is encountered is used as the model reference. Geographic data defined in other CRS'es are transformed during decoding to this model reference CRS.
Model elements
All domain objects used within this library implementILcdDataObject.
Refer to the javadoc of the version specific GML decoders for more information.
Useful settings
- an
EntityResolver2can beconfiguredon this model decoder, to control how to resolve external entities (such as XSD schemas). By default, an entity resolver is configured which resolves references to all OGC schemas supported by LuciadLightspeed.
Sample code
ILcdModelDecoder decoder = new TLcdGMLModelDecoder();
ILcdModel model = decoder.decode("world.gml32");
Performance tips
GML is a verbose format, both on disk and in memory, and cannot be lazily accessed. It is perfectly suited for data exchange, but less so for opening and visualizing large datasets. Consider using a geospatial database if you want to store and access large vector datasets.Thread safety
- The decoding of models is thread-safe, as long as no properties are changed during the decoding.
- The decoded models are thread-safe for read access.
Supported versions and specifications
- GML 2.x
- GML 3.0.x, 3.1.x
- GML 3.2.1
- Since:
- 9.0
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a newTLcdGMLModelDecoder.TLcdGMLModelDecoder(TLcdDataModel aDataModel) Creates a newTLcdGMLModelDecoderconfigured for the given data model. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDecodeSource(String aSourceName) Checks whether this model decoder can decode the specified data source.Creates a new model from the given data source.Creates a new model from the given data source.Get the default srsName for this instance.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder.Returns theorg.xml.sax.ext.EntityResolver2that is used for creating input sources for XSD schemas.Returns theILcdInputStreamFactorythat is used for creating input streams.Returns the model reference parser that is used to createILcdModelReferenceinstances when decoding an srsName.Returns thejavax.xml.stream.XMLInputFactorythat is used by this decoder for creatingjavax.xml.stream.XMLStreamReaderinstances.booleanReturnstrueif a geodesic interpolation needs to be used for linear GML elements in case of a geodetic reference.booleanReturns if application schemas are cached.voidsetDefaultSrsName(String aDefaultSrsName) Set the default srsName that will be used to determine the model reference if neither the first feature, its possible envelope or the possible envelope of the feature collection has a srsName attribute set.voidsetEntityResolver(EntityResolver2 aEntityResolver) Sets theorg.xml.sax.ext.EntityResolver2to be used for creating input sources for XSD schemas.voidsetInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory) Sets theILcdInputStreamFactoryto be used for creating input streams.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) Enables or disables application schema caching depending on the parameter value.voidsetXMLInputFactory(XMLInputFactory aXMLInputFactory) Sets thejavax.xml.stream.XMLInputFactoryto be used by this decoder for creatingjavax.xml.stream.XMLStreamReaderinstances.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Constructor Details
-
TLcdGMLModelDecoder
public TLcdGMLModelDecoder()Constructs a newTLcdGMLModelDecoder. -
TLcdGMLModelDecoder
Creates a newTLcdGMLModelDecoderconfigured for the given data model.- Parameters:
aDataModel- the data model for which the decoder is to be configured- Throws:
IllegalArgumentException- if the data model does not depend on either the GML 2, GML 31 or GML32 data model
-
-
Method Details
-
canDecodeSource
Description copied from interface:ILcdModelDecoderChecks whether this model decoder can decode the specified data source. It is acceptable for this method to returntruefor a source name whiledecodethrows an exception for that same source name.For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.
- Parameters:
aSourceName- the data source to be verified; typically a file name or a URL.- Returns:
trueif this decoder can likely decode the data specified by the source name,falseotherwise.- See Also:
-
decode
Description copied from interface:ILcdModelDecoderCreates a new model from the given data source.- Parameters:
aSourceName- the data source to be decoded; typically a file name or a URL.- Returns:
- A model containing the decoded data. While
nullis allowed, implementors are advised to throw an error instead. - Throws:
IOException- for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, ...) on unexpected places, implementations are advised to catch RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated in the code snippet below.public ILcdModel decode( String aSourceName ) throws IOException { try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) { // Perform decoding ... } catch (RuntimeException e) { throw new IOException(e); } }- See Also:
-
getDisplayName
Description copied from interface:ILcdModelDecoderReturns a short, displayable name for the format that is decoded by thisILcdModelDecoder.- Returns:
- the displayable name of this
ILcdModelDecoder.
-
getEntityResolver
Description copied from class:ALcdXMLModelDecoderReturns theorg.xml.sax.ext.EntityResolver2that is used for creating input sources for XSD schemas. This entity resolver will only be used to resolve extension schemas that are not already configured on this decoder.- Specified by:
getEntityResolverin classALcdXMLModelDecoder- Returns:
- the entity resolver to be used for creating input sources for XSD schemas.
-
getInputStreamFactory
Description copied from class:ALcdXMLModelDecoderReturns theILcdInputStreamFactorythat is used for creating input streams.- Specified by:
getInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- Specified by:
getInputStreamFactoryin classALcdXMLModelDecoder- Returns:
- the
ILcdInputStreamFactorythat is used for creating input streams. - See Also:
-
getXMLInputFactory
Description copied from class:ALcdXMLModelDecoderReturns thejavax.xml.stream.XMLInputFactorythat is used by this decoder for creatingjavax.xml.stream.XMLStreamReaderinstances.- Specified by:
getXMLInputFactoryin classALcdXMLModelDecoder- Returns:
- the
javax.xml.stream.XMLInputFactorythat is used by this decoder for creatingjavax.xml.stream.XMLStreamReaderinstances.
-
isUseApplicationSchemaCache
public boolean isUseApplicationSchemaCache()Description copied from class:ALcdXMLModelDecoderReturns if application schemas are cached. When application schemas are cached, the decoder caches all applications schemas it encounters. When a certain schema is referenced during decoding, only if the schema is not found in the cache, it will be resolved. The default is not to cache.
Note that in case multiple application schemas use the same namespace URI, it is not possible to turn on application schema caching because the decoder will not be able to discern between the different schemas.
- Specified by:
isUseApplicationSchemaCachein classALcdXMLModelDecoder- Returns:
- if application schemas are cached
-
setEntityResolver
Description copied from class:ALcdXMLModelDecoderSets the
org.xml.sax.ext.EntityResolver2to be used for creating input sources for XSD schemas.When the entity resolver is unable to find a schema (i.e. the
resolveEntitymethod returnsnull), theALcdXMLModelDecoder.getInputStreamFactory()is used to create an appropriate input stream for the given system id of the schema.- Specified by:
setEntityResolverin classALcdXMLModelDecoder- Parameters:
aEntityResolver- the entity resolver to be used for creating input sources for XSD schemas.
-
setInputStreamFactory
Description copied from class:ALcdXMLModelDecoderSets theILcdInputStreamFactoryto be used for creating input streams. If the configuredentity resolverimplementsILcdInputStreamFactoryCapable, it is also configured with this factory.- Specified by:
setInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- Specified by:
setInputStreamFactoryin classALcdXMLModelDecoder- Parameters:
aInputStreamFactory- the input stream factory to be used by this model decoder.- See Also:
-
setUseApplicationSchemaCache
public void setUseApplicationSchemaCache(boolean aUseCache) Description copied from class:ALcdXMLModelDecoderEnables or disables application schema caching depending on the parameter value.- Specified by:
setUseApplicationSchemaCachein classALcdXMLModelDecoder- Parameters:
aUseCache- if true, application schema caching is turned on. If false, caching is turned off.
-
setXMLInputFactory
Sets thejavax.xml.stream.XMLInputFactoryto be used by this decoder for creatingjavax.xml.stream.XMLStreamReaderinstances. If the configuredentity resolverimplementsILcdInputStreamFactoryCapable, it is also configured with this factory.- Specified by:
setXMLInputFactoryin classALcdXMLModelDecoder- Parameters:
aXMLInputFactory- thejavax.xml.stream.XMLInputFactoryto be used by this decoder
-
toString
-
getModelReferenceParser
Returns the model reference parser that is used to createILcdModelReferenceinstances when decoding an srsName.- Returns:
- the model reference parser of this decoder
-
setModelReferenceParser
Sets the parser that is used to createILcdModelReferenceinstances given an srsName.- Parameters:
aModelReferenceParser- the model reference parser for this decoder
-
setDefaultSrsName
Set the default srsName that will be used to determine the model reference if neither the first feature, its possible envelope or the possible envelope of the feature collection has a srsName attribute set. Further elements with no srsName will be assumed to be in the same reference as the model.By default, the model decoder uses CRS84.
- Parameters:
aDefaultSrsName- the default srsName- Throws:
IllegalArgumentException- if the srsName can not be parsed.- Since:
- 2018.0
-
getDefaultSrsName
Get the default srsName for this instance.- Returns:
- the default srsName.
- Since:
- 2018.0
- See Also:
-
decode
Creates a new model from the given data source.
This implementation only supports
StreamSourcesources. In case other types of sources are required, the version-specific GML decoders should be used directly.- Overrides:
decodein classALcdXMLModelDecoder- Parameters:
aSource- the source to read the model from- Throws:
UnsupportedOperationException- in case the decoder is not able to decode from the sourceIOException- 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. This applies to the following linear GML elements:LinearRing,LineStringandLineStringSegment.Although these GML elements conceptually represent geometries with a linear interpolation, they are often used to represent geometries with lon/lat coordinates and a geodesic interpolation.. Setting this flag to
trueenables this use case by determining the interpolation based on the coordinate reference.- Parameters:
aUseGeodesicInterpolationForGeodeticSrs- whether a geodesic interpolation needs to be used in case of a geodetic reference- Since:
- 2019.0
- 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:
- 2019.0
- See Also:
-