| java.lang.Object org.geotools.xml.transform.TransformerBase org.geotools.gml.producer.FeatureTransformer
FeatureTransformer | public class FeatureTransformer extends TransformerBase (Code) | | FeatureTransformer provides a mechanism for converting Feature objects into
(hopefully) valid gml. This is a work in progress, so please be patient. A
simple example of how to use this class follows:
FeatureCollection collection; // can also use FeatureReader!!
OutputStream out;
FeatureTransformer ft = new FeatureTransformer();
// set the indentation to 4 spaces
ft.setIndentation(4);
// this will allow Features with the FeatureType which has the namespace
// "http://somewhere.org" to be prefixed with xxx...
ft.getFeatureNamespaces().declarePrefix("xxx","http://somewhere.org");
// transform
ft.transform(collection,out);
The above example assumes a homogenous collection of Features whose
FeatureType has the namespace "http://somewhere.org" but note that not
all DataSources currently provide FeatureTypes with a namespace... There
are two other mechanisms for prefixing your Features.
1) Map a specific FeatureType by identity to prefix and nsURI
FeatureType fc;
FeatureTransformer ft = new FeatureTransformer();
ft.getFeatureTypeNamespaces().declareNamespace(fc,"xxx","http://somewhere.org");
2) Provide a default namespace for any Features whose FeatureType either has
an empty namespace, OR, has not been mapped using the previous method. This
is basically a catch-all mechanism.
FeatureTransformer ft = new FeatureTransformer();
ft.getFeatureTypeNamespaces().declareDefaultNamespace("xxx","http://somewhere.org");
The collectionNamespace and prefix property refers to the prefix and
namespace given to the document root and defualts to
wfs,http://www.opengis.wfs.
author: Ian Schneider author: Chris Holmes, TOPP version: $Id: FeatureTransformer.java 29502 2008-02-28 09:06:25Z jgarnett $ |
Inner Class :public static class FeatureTypeNamespaces | |
createTranslator | protected FeatureTranslator createTranslator(ContentHandler handler, String prefix, String ns, FeatureTypeNamespaces featureTypeNamespaces, SchemaLocationSupport schemaLocationSupport)(Code) | | Template method for creating the translator.
|
getCollectionNamespace | public String getCollectionNamespace()(Code) | | |
getCollectionPrefix | public String getCollectionPrefix()(Code) | | |
getFeatureTypeNamespaces | public FeatureTypeNamespaces getFeatureTypeNamespaces()(Code) | | |
loadGmlAttributes | protected void loadGmlAttributes(Set gmlAtts)(Code) | | Template method for determining which attributes to prefix with gml.
Parameters: gmlAtts - Set of strings corresponding to element names on a type. |
setCollectionNamespace | public void setCollectionNamespace(String nsURI)(Code) | | |
setCollectionPrefix | public void setCollectionPrefix(String prefix)(Code) | | |
setFeatureBounding | public void setFeatureBounding(boolean featureBounding)(Code) | | Sets whether a gml:boundedBy element should automatically be generated
and included. The element will not be updateable, and is simply
derived from the geometries present in the feature.
Note that the setGmlPrefixing() interacts with this
occasionally, since it will hack in a gml prefix to a boundedBy
attribute included in the featureType. If gml prefixing is on, and
featureBounding is on, then the bounds from the attribute will be used.
If gml prefixing is off, then that boundedBy attribute will
presumably be in its own namespace, and so the automatic gml boundedBy
will not conflict, so both will be printed, with the automatic one
deriving its bounds from the boundedBy attribute and any other
geometries in the feature
Parameters: featureBounding - true if the bounds of the feature shouldbe automatically calculated and included as a gml:boundedBy inthe gml output. Note this puts a good bit of bandwidth overheadon the output. Default is false |
setGmlPrefixing | public void setGmlPrefixing(boolean prefixGml)(Code) | | If Gml Prefixing is enabled then attributes with names that could be
prefixed with gml, such as description, pointProperty, and name, will
be. So if an attribute called name is encountered, instead of
prepending the default prefix (say gt2:name), it will turn out as
gml:name. Right now this is fairly hacky, as the gml:name,
gml:description, ect., should be in the first attributes by default.
The actualy geometry encodings will always be prefixed with the proper
gml, like gml:coordinates. This only applies to attributes, that could
also be part of the features normal schema (for example a pointProperty
could be declared in the gt2 namespace, instead of a gml:pointProperty
it would be a gt2:pointProperty.
Parameters: prefixGml - true if prefixing gml should be enabled.Default is disabled, no gml prefixing. |
setLockId | public void setLockId(String lockId)(Code) | | Used to set a lockId attribute after a getFeatureWithLock.
Parameters: lockId - The lockId of the lock on the WFS. |
setNumDecimals | public void setNumDecimals(int numDecimals)(Code) | | Sets the number of decimals to be used in the geometry coordinates of
the response. This allows for more efficient results, since often the
storage format itself won't specify as many decimal places as the
response might want. The default is 4, but should generally be set by
the user of this class.
Parameters: numDecimals - the number of significant digits past the decimal toinclude in the response. |
setSrsName | public void setSrsName(String srsName)(Code) | | Used to set the srsName attribute of the Geometries to be turned to xml.
For now we can only have all with the same srsName.
Parameters: srsName - This SRS names hould agree with the GML specification; example "EPSG:4326" |
Fields inherited from org.geotools.xml.transform.TransformerBase | final public static String XMLNS_NAMESPACE(Code)(Java Doc)
|
|
|