Class GML
- Object
- 
- GML
 
- 
 public class GML extends Object UtilityClass for encoding GML content.This utility class uses a range of GeoTools technologies as required; if you would like finer grain control over the encoding process please review the source code of this class and take your own measures. 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classGML.VersionVersion of encoder to use
 - 
Constructor SummaryConstructors Constructor Description GML(GML.Version version)Construct a GML utility class to work with the indicated version of GML.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleFeatureCollectiondecodeFeatureCollection(InputStream in)Decodes a feature collection from the stream provided.SimpleFeatureCollectiondecodeFeatureCollection(InputStream in, boolean computeFullFeatureType)Decodes a feature collection from the stream provided.SimpleFeatureIteratordecodeFeatureIterator(InputStream in)Allow the parsing of features as a stream; the returned iterator can be used to step through the inputstream of content one feature at a time without loading everything into memory.SimpleFeatureIteratordecodeFeatureIterator(InputStream in, QName elementName)Allow the parsing of features as a stream; the returned iterator can be used to step through the inputstream of content one feature at a time without loading everything into memory.SimpleFeatureTypedecodeSimpleFeatureType(URL schemaLocation, Name typeName)Decode a typeName from the provided schemaLocation.voidencode(OutputStream out, SimpleFeatureType simpleFeatureType)Encode the provided SimpleFeatureType into an XSD file, using a target namespacevoidencode(OutputStream out, SimpleFeatureCollection collection)protected voidinit()Set up out of the box configuration for GML encoding.protected SimpleFeatureIteratoriterator(StreamingParser parser)Used to wrap up a StreamingParser as a Iterator. voidsetBaseURL(URL baseURL)Base URL to use when encodingvoidsetCoordinateReferenceSystem(CoordinateReferenceSystem crs)Coordinate reference system to use when decoding.voidsetEncoding(Charset encoding)Set the encoding to use.voidsetLegacy(boolean legacy)Engage legacy support for GML2.voidsetNamespace(String prefix, String namespace)Set the target namespace for the encoding.protected SimpleFeaturesimpleFeature(Object obj, SimpleFeatureType schema)Morph provided obj to a SimpleFeature if possible.protected SimpleFeatureTypesimpleType(Object obj)protected XSDComplexTypeDefinitionxsd(XSDSchema xsd, ComplexType type, XSDComplexTypeDefinition BASE_TYPE)Build the XSD definition for the provided type.protected XSDSchemaxsd(SimpleFeatureType simpleFeatureType)
 
- 
- 
- 
Constructor Detail- 
GMLpublic GML(GML.Version version) Construct a GML utility class to work with the indicated version of GML.Note that when working with GML2 you need to supply additional information prior to use (in order to indicate where for XSD file is located). - Parameters:
- version- Version of GML to use
 
 
- 
 - 
Method Detail- 
setLegacypublic void setLegacy(boolean legacy) Engage legacy support for GML2.The GML2 support for FeatureTransformer is much faster then that provided by the GTXML parser/encoder. This speed is at the expense of getting the up front configuration exactly correct (something you can only tell when parsing the produced result!). Setting this value to false will use the same GMLConfiguration employed when parsing and has less risk of producing invalid content. 
 - 
setNamespacepublic void setNamespace(String prefix, String namespace) Set the target namespace for the encoding.
 - 
setEncodingpublic void setEncoding(Charset encoding) Set the encoding to use.
 - 
setBaseURLpublic void setBaseURL(URL baseURL) Base URL to use when encoding
 - 
setCoordinateReferenceSystempublic void setCoordinateReferenceSystem(CoordinateReferenceSystem crs) Coordinate reference system to use when decoding.In a few cases (such as decoding a SimpleFeatureType) the file format does not include the required CooridinateReferenceSystem and you are asked to supply it. 
 - 
initprotected void init() Set up out of the box configuration for GML encoding.- GML2
- GML3
 - gml3.2 - not yet available
- wfs1.0 - not yet available
- wfs1.1 - not yet available
 
 - 
encodepublic void encode(OutputStream out, SimpleFeatureCollection collection) throws IOException - Throws:
- IOException
 
 - 
encodepublic void encode(OutputStream out, SimpleFeatureType simpleFeatureType) throws IOException Encode the provided SimpleFeatureType into an XSD file, using a target namespaceWhen encoding the simpleFeatureType: - target prefix/namespace can be provided by prefix and namespace parameters. This is the default for the entire XSD document.
- simpleFeatureType.geName().getNamespaceURI() is used for the simpleFeatureType itself, providing simpleFeatureType.getUserData().get("prefix") is defined
 - Parameters:
- simpleFeatureType- To be encoded as an XSD document
- Throws:
- IOException
 
 - 
decodeSimpleFeatureTypepublic SimpleFeatureType decodeSimpleFeatureType(URL schemaLocation, Name typeName) throws IOException Decode a typeName from the provided schemaLocation.The XMLSchema does not include CoordinateReferenceSystem we need to ask you to supply this information. - Returns:
- SimpleFeatureType
- Throws:
- IOException
 
 - 
decodeFeatureCollectionpublic SimpleFeatureCollection decodeFeatureCollection(InputStream in) throws IOException, SAXException, ParserConfigurationException Decodes a feature collection from the stream provided. It assumes the features are uniform and that all attributes are available in the first feature
 - 
decodeFeatureCollectionpublic SimpleFeatureCollection decodeFeatureCollection(InputStream in, boolean computeFullFeatureType) throws IOException, SAXException, ParserConfigurationException Decodes a feature collection from the stream provided.- Parameters:
- computeFullFeatureType- When true, all features are parsed and then a global feature type is determined that has attributes covering all feature needs, when false, the first feature attributes
- Throws:
- IOException
- SAXException
- ParserConfigurationException
 
 - 
decodeFeatureIteratorpublic SimpleFeatureIterator decodeFeatureIterator(InputStream in) throws IOException, ParserConfigurationException, SAXException Allow the parsing of features as a stream; the returned iterator can be used to step through the inputstream of content one feature at a time without loading everything into memory.The schema used by the XML is consulted to determine what element extends AbstractFeature. - Returns:
- Iterator that can be used to parse features one at a time
- Throws:
- IOException
- ParserConfigurationException
- SAXException
 
 - 
decodeFeatureIteratorpublic SimpleFeatureIterator decodeFeatureIterator(InputStream in, QName elementName) throws IOException, ParserConfigurationException, SAXException Allow the parsing of features as a stream; the returned iterator can be used to step through the inputstream of content one feature at a time without loading everything into memory.The use of an elementName is optional; and can be used as a workaround in cases where the schema is not available or correctly defined. The returned elements are wrapped up as a Feature if needed. This mehtod can be used to retrive only the Geometry elements from a GML docuemnt. - Parameters:
- in- InputStream used as a source of SimpleFeature content
- elementName- The simple feature element; the schema will be checked for an entry that extends AbstratFeatureType
- Throws:
- IOException
- ParserConfigurationException
- SAXException
 
 - 
iteratorprotected SimpleFeatureIterator iterator(StreamingParser parser) Used to wrap up a StreamingParser as a Iterator. This iterator is actually forgiving; and willing to "morph" content into a SimpleFeature if needed. - SimpleFeature - is returned as is
 
 - 
simpleTypeprotected SimpleFeatureType simpleType(Object obj) 
 - 
simpleFeatureprotected SimpleFeature simpleFeature(Object obj, SimpleFeatureType schema) Morph provided obj to a SimpleFeature if possible.- Returns:
- SimpleFeature, or null if not possible
 
 - 
xsdprotected XSDSchema xsd(SimpleFeatureType simpleFeatureType) throws IOException - Throws:
- IOException
 
 - 
xsdprotected XSDComplexTypeDefinition xsd(XSDSchema xsd, ComplexType type, XSDComplexTypeDefinition BASE_TYPE)Build the XSD definition for the provided type.The generated definition is recorded in the XSDSchema prior to being returned. - Parameters:
- xsd- The XSDSchema being worked on
- type- ComplexType to capture as an encoding, usually a SimpleFeatureType
- BASE_TYPE- definition to use as the base type, or null
- Returns:
- XSDComplexTypeDefinition generated for the provided type
 
 
- 
 
-