public class FeatureTypes extends Object
Many methods from DataUtilities should be refractored here.
Responsibilities:
Modifier and Type | Field and Description |
---|---|
static SimpleFeatureType |
ABSTRACT_FEATURE_TYPE
abstract base type for all feature types
|
static int |
ANY_LENGTH
represent an unbounded field length
|
static URI |
DEFAULT_NAMESPACE
the default namespace for feature types
|
static NameImpl |
DEFAULT_TYPENAME
default feature collection name
|
static SimpleFeatureType |
EMPTY
An feature type with no attributes
|
protected static FilterFactory |
FF |
Constructor and Description |
---|
FeatureTypes() |
Modifier and Type | Method and Description |
---|---|
static Set<FeatureType> |
ancestors(SimpleFeatureType featureType) |
static Filter |
createFieldOptions(Collection<?> options)
Creates a restriction limiting an attribute to a given list of values.
|
static Filter |
createLengthRestriction(int length)
Creates a restriction based on the attribute value length
|
static boolean |
equals(AttributeDescriptor[] attributesA,
AttributeDescriptor[] attributesB) |
static boolean |
equals(AttributeDescriptor a,
AttributeDescriptor b) |
static boolean |
equals(List<AttributeDescriptor> attributesA,
List<AttributeDescriptor> attributesB) |
static boolean |
equals(SimpleFeatureType typeA,
SimpleFeatureType typeB)
Exact equality based on typeNames, namespace, attributes and ancestors
|
static boolean |
equalsAncestors(SimpleFeatureType typeA,
SimpleFeatureType typeB)
This method depends on the correct implementation of FeatureType equals
We may need to write an implementation that can detect cycles,
|
static boolean |
equalsExact(AttributeDescriptor[] attributesA,
AttributeDescriptor[] attributesB) |
static boolean |
equalsExact(AttributeDescriptor a,
AttributeDescriptor b) |
static boolean |
equalsExact(List<AttributeDescriptor> attributesA,
List<AttributeDescriptor> attributesB) |
static boolean |
equalsExact(SimpleFeatureType typeA,
SimpleFeatureType typeB)
Exact equality based on typeNames, namespace, attributes and ancestors, including the user
maps contents
|
static boolean |
equalsId(SimpleFeatureType typeA,
SimpleFeatureType typeB)
Quick check of namespace and typename
|
static List<FeatureType> |
getAncestors(FeatureType featureType)
Walks up the type hierarchy of the feature returning all super types of the specified feature
type.
|
static int |
getFieldLength(PropertyDescriptor descriptor)
This is a 'suitable replacement for extracting the expected field length of an attribute
absed on its "facets" (ie Filter describing type restrictions);
This code is copied from the ShapefileDataStore where it was written (probably by
dzwiers).
|
static List<?> |
getFieldOptions(PropertyDescriptor descriptor)
Returns the eventual list of possible values accepted by this
|
static boolean |
isDecendedFrom(FeatureType featureType,
FeatureType isParentType) |
static boolean |
isDecendedFrom(FeatureType featureType,
URI namespace,
String typeName)
A query of the the types ancestor information.
|
static boolean |
matches(FeatureType featureType,
Name name)
Whether the feature type has the specified name, or is a descendent from it
|
static SimpleFeatureType |
newFeatureType(AttributeDescriptor[] types,
String name)
Create a new FeatureType with the given AttributeTypes.
|
static SimpleFeatureType |
newFeatureType(AttributeDescriptor[] types,
String name,
URI ns)
Create a new FeatureType with the given AttributeTypes.
|
static SimpleFeatureType |
newFeatureType(AttributeDescriptor[] types,
String name,
URI ns,
boolean isAbstract)
Create a new FeatureType with the given AttributeTypes.
|
static SimpleFeatureType |
newFeatureType(AttributeDescriptor[] types,
String name,
URI ns,
boolean isAbstract,
SimpleFeatureType[] superTypes)
The most specific way to create a new FeatureType.
|
static SimpleFeatureType |
newFeatureType(AttributeDescriptor[] types,
String name,
URI ns,
boolean isAbstract,
SimpleFeatureType[] superTypes,
AttributeDescriptor defaultGeometry)
The most specific way to create a new FeatureType.
|
static SimpleFeatureType |
newFeatureType(AttributeDescriptor[] types,
String name,
URI ns,
boolean isAbstract,
SimpleFeatureType[] superTypes,
GeometryDescriptor defaultGeometry)
The most specific way to create a new FeatureType.
|
static boolean |
shouldReproject(SimpleFeatureType schema,
CoordinateReferenceSystem crs)
Tells if there is any work to be done for reprojection, i.e. if there are any CRS that differ
but are compatible.
|
static SimpleFeature |
transform(SimpleFeature feature,
SimpleFeatureType schema,
MathTransform transform)
Applies transform to all geometry attribute.
|
static SimpleFeatureType |
transform(SimpleFeatureType schema,
CoordinateReferenceSystem crs)
Forces the specified CRS on all geometry attributes
|
static SimpleFeatureType |
transform(SimpleFeatureType schema,
CoordinateReferenceSystem crs,
boolean forceOnlyMissing)
Forces the specified CRS on geometry attributes (all or some, depends on the parameters).
|
static SimpleFeatureType |
transform(SimpleFeatureType schema,
CoordinateReferenceSystem crs,
boolean forceOnlyMissing,
boolean onlyIfCompatible)
Forces the specified CRS on geometry attributes (all or some, depends on the parameters).
|
public static final URI DEFAULT_NAMESPACE
public static final SimpleFeatureType ABSTRACT_FEATURE_TYPE
public static final NameImpl DEFAULT_TYPENAME
public static final int ANY_LENGTH
public static final SimpleFeatureType EMPTY
protected static FilterFactory FF
public static Filter createLengthRestriction(int length)
length
- The maximum allowed lengthpublic static int getFieldLength(PropertyDescriptor descriptor)
This code is copied from the ShapefileDataStore where it was written (probably by dzwiers). Cholmes is providing documentation.
descriptor
- the descriptor whose lenght is to be investigatedpublic static List<?> getFieldOptions(PropertyDescriptor descriptor)
descriptor
- public static Filter createFieldOptions(Collection<?> options)
options
- The list of all possible valuespublic static SimpleFeatureType transform(SimpleFeatureType schema, CoordinateReferenceSystem crs) throws SchemaException
schema
- the original schemacrs
- the forced crsSchemaException
public static SimpleFeatureType transform(SimpleFeatureType schema, CoordinateReferenceSystem crs, boolean forceOnlyMissing) throws SchemaException
schema
- the original schemacrs
- the forced crsforceOnlyMissing
- if true, will force the specified crs only on the attributes that do
miss oneSchemaException
public static SimpleFeatureType transform(SimpleFeatureType schema, CoordinateReferenceSystem crs, boolean forceOnlyMissing, boolean onlyIfCompatible) throws SchemaException
schema
- the original schemacrs
- the forced crsforceOnlyMissing
- if true, will force the specified crs only on the attributes that do
miss oneonlyIfCompatible
- if true, will force the specified crs only if the original CRS is
compatible with it. This property is ignored if forceOnlyMissing is true.SchemaException
public static SimpleFeature transform(SimpleFeature feature, SimpleFeatureType schema, MathTransform transform) throws MismatchedDimensionException, TransformException, IllegalAttributeException
feature
- Feature to be transformedschema
- Schema for target transformation - transform( schema, crs )transform
- MathTransform used to transform coordinates - reproject( crs, crs )MismatchedDimensionException
TransformException
IllegalAttributeException
public static boolean shouldReproject(SimpleFeatureType schema, CoordinateReferenceSystem crs)
schema
- the schema to be reprojectedcrs
- the crs to reproject topublic static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns, boolean isAbstract, SimpleFeatureType[] superTypes) throws FactoryRegistryException, SchemaException
types
- The AttributeTypes to create the FeatureType with.name
- The typeName of the FeatureType. Required, may not be null.ns
- The namespace of the FeatureType. Optional, may be null.isAbstract
- True if this created type should be abstract.superTypes
- A Collection of types the FeatureType will inherit from. Currently, all
types inherit from feature in the opengis namespace.FactoryRegistryException
- If there are problems creating a factory.SchemaException
- If the AttributeTypes provided are invalid in some way.public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns, boolean isAbstract, SimpleFeatureType[] superTypes, AttributeDescriptor defaultGeometry) throws FactoryRegistryException, SchemaException
types
- The AttributeTypes to create the FeatureType with.name
- The typeName of the FeatureType. Required, may not be null.ns
- The namespace of the FeatureType. Optional, may be null.isAbstract
- True if this created type should be abstract.superTypes
- A Collection of types the FeatureType will inherit from. Currently, all
types inherit from feature in the opengis namespace.FactoryRegistryException
- If there are problems creating a factory.SchemaException
- If the AttributeTypes provided are invalid in some way.public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns, boolean isAbstract, SimpleFeatureType[] superTypes, GeometryDescriptor defaultGeometry) throws FactoryRegistryException, SchemaException
types
- The AttributeTypes to create the FeatureType with.name
- The typeName of the FeatureType. Required, may not be null.ns
- The namespace of the FeatureType. Optional, may be null.isAbstract
- True if this created type should be abstract.superTypes
- A Collection of types the FeatureType will inherit from. Currently, all
types inherit from feature in the opengis namespace.FactoryRegistryException
- If there are problems creating a factory.SchemaException
- If the AttributeTypes provided are invalid in some way.public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns, boolean isAbstract) throws FactoryRegistryException, SchemaException
newFeatureType(types,name,ns,isAbstract,null)
.types
- The AttributeTypes to create the FeatureType with.name
- The typeName of the FeatureType. Required, may not be null.ns
- The namespace of the FeatureType. Optional, may be null.isAbstract
- True if this created type should be abstract.FactoryRegistryException
- If there are problems creating a factory.SchemaException
- If the AttributeTypes provided are invalid in some way.public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name, URI ns) throws FactoryRegistryException, SchemaException
newFeatureType(types,name,ns,false,null)
.types
- The AttributeTypes to create the FeatureType with.name
- The typeName of the FeatureType. Required, may not be null.ns
- The namespace of the FeatureType. Optional, may be null.FactoryRegistryException
- If there are problems creating a factory.SchemaException
- If the AttributeTypes provided are invalid in some way.public static SimpleFeatureType newFeatureType(AttributeDescriptor[] types, String name) throws FactoryRegistryException, SchemaException
newFeatureType(types,name,null,false,null)
. Useful for test cases or datasources which
may not allow a namespace.types
- The AttributeTypes to create the FeatureType with.name
- The typeName of the FeatureType. Required, may not be null.FactoryRegistryException
- If there are problems creating a factory.SchemaException
- If the AttributeTypes provided are invalid in some way.public static List<FeatureType> getAncestors(FeatureType featureType)
public static boolean matches(FeatureType featureType, Name name)
featureType
- typeName with parentage in questionname
- name to match againstpublic static boolean isDecendedFrom(FeatureType featureType, URI namespace, String typeName)
This utility method may be used as common implementation for
FeatureType.isDecendedFrom( namespace, typeName )
, however for specific uses, such as
GML, an implementor may be able to provide a more efficient implemenation based on prior
knolwege.
This is a proper check, if the provided FeatureType matches the given namespace and typename it is not considered to be decended from itself.
featureType
- typeName with parentage in questionnamespace
- namespace to match against, or null for a "wildcard"typeName
- typename to match against, or null for a "wildcard"public static boolean isDecendedFrom(FeatureType featureType, FeatureType isParentType)
public static boolean equals(SimpleFeatureType typeA, SimpleFeatureType typeB)
public static boolean equalsExact(SimpleFeatureType typeA, SimpleFeatureType typeB)
public static boolean equals(List<AttributeDescriptor> attributesA, List<AttributeDescriptor> attributesB)
public static boolean equalsExact(List<AttributeDescriptor> attributesA, List<AttributeDescriptor> attributesB)
public static boolean equals(AttributeDescriptor[] attributesA, AttributeDescriptor[] attributesB)
public static boolean equalsExact(AttributeDescriptor[] attributesA, AttributeDescriptor[] attributesB)
public static boolean equalsAncestors(SimpleFeatureType typeA, SimpleFeatureType typeB)
We may need to write an implementation that can detect cycles,
public static Set<FeatureType> ancestors(SimpleFeatureType featureType)
public static boolean equals(AttributeDescriptor a, AttributeDescriptor b)
public static boolean equalsExact(AttributeDescriptor a, AttributeDescriptor b)
public static boolean equalsId(SimpleFeatureType typeA, SimpleFeatureType typeB)
Copyright © 1996–2022 Geotools. All rights reserved.