public class DataUtilities extends Object
These methods fall into several categories:
Conversion between common data structures.
collection(org.opengis.feature.simple.SimpleFeature[])
methods: creating/converting a SimpleFeatureCollection
from a
range of input.
simple(org.geotools.feature.FeatureCollection<org.opengis.feature.simple.SimpleFeatureType, org.opengis.feature.simple.SimpleFeature>)
methods: adapting from generic Feature use to SimpleFeature. Used to
convert to SimpleFeature, SimpleFeatureCollection,SimpleFeatureSource
list(org.geotools.feature.FeatureCollection<?, F>)
to quickly copy features into a memory based list
reader(org.opengis.feature.simple.SimpleFeature[])
methods to convert to FeatureReader
#expression
setup a FeatureSource wrapper around the provided data
SimpleFeatureType and SimpleFeature encoding/decoding from String as used by the PropertyDataStore tutorials.
createType(java.lang.String, java.lang.String)
methods: to create a SimpleFeatureType from a one line text string
encodeType(org.opengis.feature.simple.SimpleFeatureType)
: text string representation of a SimpleFeaturerType
createFeature(org.opengis.feature.simple.SimpleFeatureType, java.lang.String)
: create a SimpleFeature from a one line text String
encodeFeature(org.opengis.feature.simple.SimpleFeature)
: encode a feature as a single line text string
Working with SimpleFeatureType (this class is immutable so we always have to make a modified copy):
createSubType(SimpleFeatureType, String[])
methods return a modified copy of an
origional feature type. Used to cut down an exsiting feature type to reflect only the
attributes requested when using SimpleFeatureSource.getFeatures(Filter)
.
compare(org.opengis.feature.simple.SimpleFeatureType, org.opengis.feature.simple.SimpleFeatureType)
and isMatch(AttributeDescriptor, AttributeDescriptor)
are used to
check for types compatible with createSubType(org.opengis.feature.simple.SimpleFeatureType, java.lang.String[], org.opengis.referencing.crs.CoordinateReferenceSystem)
used to verify that feature values
can be copied across
Manipulating individual features and data values:
reType(org.opengis.feature.simple.SimpleFeatureType, org.opengis.feature.simple.SimpleFeature)
generates a cut down version of an original feature in the same manners as
createSubType(org.opengis.feature.simple.SimpleFeatureType, java.lang.String[], org.opengis.referencing.crs.CoordinateReferenceSystem)
template(org.opengis.feature.simple.SimpleFeatureType)
and defaultValue(org.opengis.feature.type.AttributeDescriptor)
methods which uses AttributeDescriptor.getDefaultValue()
when creating new empty features
duplicate(Object)
used for deep copy of feature data
includeFilters(java.io.FilenameFilter, java.io.FilenameFilter...)
and excludeFilters(java.io.FilenameFilter, java.io.FilenameFilter...)
work as a compound FileFilter
making File.listFiles()
easier to use
propertyNames(org.opengis.filter.Filter, org.opengis.feature.simple.SimpleFeatureType)
, fidSet(org.geotools.feature.FeatureCollection<?, ?>)
, attributeNames(org.opengis.feature.simple.SimpleFeatureType)
methods are used to double
check a provided query and ensure it can be correctly handed. sortComparator(org.opengis.filter.sort.SortBy)
,
resolvePropertyNames(org.geotools.data.Query, org.opengis.feature.simple.SimpleFeatureType)
and mixQueries(org.geotools.data.Query, org.geotools.data.Query, java.lang.String)
are used to prep a Query
prior to use
Constructor and Description |
---|
DataUtilities() |
Modifier and Type | Method and Description |
---|---|
static List<PropertyName> |
addMandatoryProperties(SimpleFeatureType type,
List<PropertyName> oldProps)
Returns a list of properties of a simple feature type, including all properties from a given
list, and all mandatory (minoccurs > 0) added.
|
static String[] |
attributeNames(Expression expression)
Traverses the expression and returns any encountered property names.
|
static String[] |
attributeNames(Expression expression,
SimpleFeatureType featureType)
Traverses the expression and returns any encountered property names.
|
static String[] |
attributeNames(Filter filter)
Traverses the filter and returns any encountered property names.
|
static String[] |
attributeNames(Filter filter,
SimpleFeatureType featureType)
Traverses the filter and returns any encountered property names.
|
static String[] |
attributeNames(SimpleFeatureType featureType)
Retrieve the attributeNames defined by the featureType
|
static boolean |
attributesEqual(Object att,
Object otherAtt)
Used to compare if two values are equal.
|
static ReferencedEnvelope |
bounds(FeatureCollection<? extends FeatureType,? extends Feature> collection)
Manually calculates the bounds of a feature collection using
FeatureCollection.features() . |
static ReferencedEnvelope |
bounds(FeatureIterator<?> iterator)
Manually calculate the bounds from the provided FeatureIteator.
|
static boolean |
canProcess(Map params,
DataAccessFactory.Param[] arrayParameters)
Verifies a Map of parameters against the Param information.
|
static URL |
changeUrlExt(URL url,
String postfix)
Deprecated.
|
static File |
checkDirectory(File file)
Checks that the provided directory path refers to an existing/readable directory.
|
static boolean |
checkFileReadable(File file,
Logger logger)
Checks that a
File is a real file, exists and is readable. |
static void |
close(Iterator<?> iterator)
Checks if the provided iterator implements
Closeable . |
static DefaultFeatureCollection |
collection(FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection)
Copies the provided features into a FeatureCollection.
|
static SimpleFeatureCollection |
collection(FeatureReader<SimpleFeatureType,SimpleFeature> reader)
Copies the provided reader into a FeatureCollection, reader will be closed.
|
static SimpleFeatureCollection |
collection(List<SimpleFeature> list)
Copies the provided features into a FeatureCollection.
|
static SimpleFeatureCollection |
collection(SimpleFeature feature)
Copies the provided features into a FeatureCollection.
|
static SimpleFeatureCollection |
collection(SimpleFeature[] features)
Copies the provided features into a FeatureCollection.
|
static SimpleFeatureCollection |
collection(SimpleFeatureIterator reader)
Copies the provided reader into a FeatureCollection, reader will be closed.
|
static <F extends Feature> |
collectionCast(FeatureCollection<?,F> featureCollection)
Used to quickly cast to a java.util.Collection.
|
static int |
compare(SimpleFeatureType typeA,
SimpleFeatureType typeB)
Compare attribute coverage between two feature types (allowing the identification of
subTypes).
|
static int |
count(FeatureCollection<? extends FeatureType,? extends Feature> collection)
Manually count the number of features in a feature collection using using
FeatureCollection.features() . |
static int |
count(FeatureIterator<?> iterator)
Manually count the number of features from the provided FeatureIterator.
|
static SimpleFeature |
createFeature(SimpleFeatureType featureType,
String line)
Reads in SimpleFeature that has been encoded into a line of text.
|
static SimpleFeatureType |
createSubType(SimpleFeatureType featureType,
String[] properties)
Create a type limited to the named properties provided.
|
static SimpleFeatureType |
createSubType(SimpleFeatureType featureType,
String[] properties,
CoordinateReferenceSystem override)
Create a derived FeatureType
|
static SimpleFeatureType |
createSubType(SimpleFeatureType featureType,
String[] properties,
CoordinateReferenceSystem override,
String typeName,
URI namespace)
Create a derived FeatureType
|
static SimpleFeatureType |
createType(String typeName,
String typeSpec)
Utility method for FeatureType construction.
|
static SimpleFeatureType |
createType(String namespace,
String name,
String typeSpec)
Utility method for FeatureType construction.
|
static SimpleFeatureSource |
createView(DataStore store,
Query query)
Return a 'view' of the given
DataStore constrained by a Query . |
static SimpleFeatureSource |
createView(SimpleFeatureSource source,
Query query)
Return a 'view' of the given
FeatureSource constrained by a Query . |
static DataStore |
dataStore(SimpleFeatureCollection features)
Adapt a feature collection as a read-only DataStore.
|
static DataStore |
dataStore(SimpleFeatureSource source)
Adapt a single FeatureSource as a read-only DataStore.
|
static Object |
defaultValue(AttributeDescriptor attributeType)
Deprecated.
|
static Object |
defaultValue(Class type)
Returns a non-null default value for the class that is passed in.
|
static Object[] |
defaultValues(SimpleFeatureType featureType)
Produce a set of default values for the provided FeatureType
|
static Object[] |
defaultValues(SimpleFeatureType featureType,
Object[] values)
Create default values matching the provided feature type.
|
static Object |
duplicate(Object src)
Performs a deep copy of the provided object.
|
static String |
encodeFeature(SimpleFeature feature)
Produce a String encoding of SimpleFeature for use with
createFeature(org.opengis.feature.simple.SimpleFeatureType, java.lang.String) . |
static String |
encodeFeature(SimpleFeature feature,
boolean includeFid)
Produce a String encoding of SimpleFeature for use with
createFeature(org.opengis.feature.simple.SimpleFeatureType, java.lang.String) . |
static String |
encodeType(SimpleFeatureType featureType)
Encode the provided featureType as a String suitable for use with
createType(java.lang.String, java.lang.String) . |
static FilenameFilter |
excludeFilters(FilenameFilter inputFilter,
FilenameFilter... filters)
Returns a
IOFileFilter obtained by excluding from the first input filter argument,
the additional filter arguments. |
static URL |
extendURL(URL base,
String extension)
Deprecated.
Use {@link URLs#extendUrl(URL, String)
|
static Set<String> |
fidSet(FeatureCollection<?,?> featureCollection)
Copies the feature ids from each and every feature into a set.
|
static URL |
fileToURL(File file)
Deprecated.
|
static <F extends Feature> |
first(FeatureCollection<?,F> featureCollection)
Obtain the first feature from the collection as an exemplar.
|
static URL |
getParentUrl(URL url)
Deprecated.
|
static FilenameFilter |
includeFilters(FilenameFilter inputFilter,
FilenameFilter... filters)
Returns a
IOFileFilter obtained by adding to the first input filter argument, the
additional filter arguments. |
static boolean |
isMatch(AttributeDescriptor a,
AttributeDescriptor b)
Quickly check if two descriptors are at all compatible.
|
static <F extends Feature> |
iterator(FeatureIterator<F> featureIterator)
Iteator wrapped around the provided FeatureIterator, implementing
Closeable . |
static <F extends Feature> |
list(FeatureCollection<?,F> featureCollection)
Copies the provided features into a List.
|
static <F extends Feature> |
list(FeatureCollection<?,F> featureCollection,
int maxFeatures)
Copies the provided fetaures into a List.
|
static Query |
mixQueries(Query firstQuery,
Query secondQuery,
String handle)
Takes two
Query objects and produce a new one by mixing the restrictions of both of
them. |
static SimpleFeature |
parse(SimpleFeatureType type,
String fid,
String[] text)
Uses
Converters to parse the provided text into the correct values to create a
feature. |
static Set<PropertyName> |
propertyNames(Expression expression)
Traverses the expression and returns any encountered property names.
|
static Set<PropertyName> |
propertyNames(Expression expression,
SimpleFeatureType featureType)
Traverses the expression and returns any encountered property names.
|
static Set<PropertyName> |
propertyNames(Filter filter)
Traverses the filter and returns any encountered property names.
|
static Set<PropertyName> |
propertyNames(Filter filter,
SimpleFeatureType featureType)
Traverses the filter and returns any encountered property names.
|
static FeatureReader<SimpleFeatureType,SimpleFeature> |
reader(Collection<SimpleFeature> collection)
Adapt a collection to a reader for use with FeatureStore.setFeatures( reader ).
|
static FeatureReader<SimpleFeatureType,SimpleFeature> |
reader(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
Adapt a collection to a reader for use with FeatureStore.setFeatures( reader ).
|
static FeatureReader<SimpleFeatureType,SimpleFeature> |
reader(SimpleFeature[] features)
Creates a FeatureReader
|
static Filter |
resolvePropertyNames(Filter filter,
SimpleFeatureType schema)
Transform provided filter; resolving property names
|
static Query |
resolvePropertyNames(Query query,
SimpleFeatureType schema)
This method changes the query object so that all propertyName references are resolved to
simple attribute names against the schema of the feature source.
|
static SimpleFeature |
reType(SimpleFeatureType featureType,
SimpleFeature feature)
Creates duplicate of feature adjusted to the provided featureType.
|
static SimpleFeature |
reType(SimpleFeatureType featureType,
SimpleFeature feature,
boolean duplicate)
Retypes the feature to match the provided featureType.
|
static SimpleFeatureCollection |
simple(FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection)
A safe cast to SimpleFeatureCollection; that will introduce a wrapper if it has to.
|
static SimpleFeatureLocking |
simple(FeatureLocking locking)
A safe cast to SimpleFeatureLocking; that will introduce a wrapper if it has to.
|
static SimpleFeatureReader |
simple(FeatureReader<SimpleFeatureType,SimpleFeature> reader) |
static SimpleFeatureSource |
simple(FeatureSource source)
A safe cast to SimpleFeatureSource; that will introduce a wrapper if it has to.
|
static SimpleFeatureStore |
simple(FeatureStore store)
A safe cast to SimpleFeatureStore; that will introduce a wrapper if it has to.
|
static SimpleFeatureType |
simple(FeatureType featureType)
Go through FeatureType description and convert to a SimpleFeatureType.
|
static Query |
simplifyFilter(Query query)
This method changes the query object by simplifying the filter using SimplifyingFilterVisitor
|
static Comparator<SimpleFeature> |
sortComparator(SortBy sortBy)
Factory method to produce Comparator based on provided Query SortBy information.
|
static SimpleFeatureSource |
source(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
Wraps up the provided feature collection in as a SimpleFeatureSource.
|
static SimpleFeatureSource |
source(SimpleFeature[] featureArray)
Wrap up an array of features as a FeatureSource.
|
static String |
spec(FeatureType featureType)
Deprecated.
Renamed to
encodeType(org.opengis.feature.simple.SimpleFeatureType) for concistency with createType(java.lang.String, java.lang.String) |
static SimpleFeature |
template(SimpleFeatureType featureType)
Constructs an empty feature to use as a Template for new content.
|
static SimpleFeature |
template(SimpleFeatureType featureType,
Object[] providedValues)
Create a new feature from the provided values, using appropriate default values for any nulls
provided.
|
static SimpleFeature |
template(SimpleFeatureType featureType,
String featureID)
Use the provided featureType to create an empty feature.
|
static SimpleFeature |
template(SimpleFeatureType featureType,
String featureID,
Object[] providedValues)
Create a new feature from the provided values, using appropriate default values for any nulls
provided.
|
static Feature |
templateFeature(FeatureType schema)
Create a non-simple template feature from feature type schema
|
static File |
urlToFile(URL url)
Deprecated.
|
static void |
visit(FeatureCollection<?,?> collection,
FeatureVisitor visitor,
ProgressListener progress)
Manually visit each feature using
FeatureCollection.features() . |
public static String[] attributeNames(SimpleFeatureType featureType)
featureType
- public static URL fileToURL(File file)
URLs.fileToUrl(File)
public static File urlToFile(URL url)
URLs.urlToFile(URL)
public static String[] attributeNames(Filter filter, SimpleFeatureType featureType)
The feature type is supplied as contexts used to lookup expressions in cases where the attributeName does not match the actual name of the type.
public static Set<PropertyName> propertyNames(Filter filter, SimpleFeatureType featureType)
The feature type is supplied as contexts used to lookup expressions in cases where the attributeName does not match the actual name of the type.
public static String[] attributeNames(Filter filter)
public static Set<PropertyName> propertyNames(Filter filter)
public static String[] attributeNames(Expression expression, SimpleFeatureType featureType)
The feature type is supplied as contexts used to lookup expressions in cases where the attributeName does not match the actual name of the type.
public static Set<PropertyName> propertyNames(Expression expression, SimpleFeatureType featureType)
The feature type is supplied as contexts used to lookup expressions in cases where the attributeName does not match the actual name of the type.
public static String[] attributeNames(Expression expression)
public static Set<PropertyName> propertyNames(Expression expression)
public static int compare(SimpleFeatureType typeA, SimpleFeatureType typeB)
The comparison results in a number with the following meaning:
Comparison is based on AttributeDescriptor
- the isMatch(AttributeDescriptor, AttributeDescriptor)
method is used to quickly confirm that
the local name and java binding are compatible.
Namespace is not considered in this opperations. You may still need to reType to get the correct namesapce, or reorder.
Please note this method will not result in a stable sort if used in a Comparator
as -1 is used to indicate incompatiblity (rather than simply "before").
typeA
- FeatureType beind comparedtypeB
- FeatureType being compared againstpublic static boolean isMatch(AttributeDescriptor a, AttributeDescriptor b)
This method checks the descriptors name and class binding to see if the values have any chance of being compatible.
a
- descriptor to compareb
- descriptor to comparepublic static SimpleFeature reType(SimpleFeatureType featureType, SimpleFeature feature) throws IllegalAttributeException
Please note this implementation provides "deep copy" using duplicate(Object)
to
copy each attribute.
featureType
- FeatureType requestedfeature
- Origional Feature from DataStoreIllegalAttributeException
- If opperation could not be performedpublic static SimpleFeature reType(SimpleFeatureType featureType, SimpleFeature feature, boolean duplicate) throws IllegalAttributeException
The duplicate parameter indicates how the new feature is to be formed:
featureType
- feature
- duplicate
- True to perform duplicate(Object)
on each attributeIllegalAttributeException
public static Object duplicate(Object src)
A number of tricks are used to make this as fast as possible:
src
- Source objectpublic static SimpleFeature template(SimpleFeatureType featureType) throws IllegalAttributeException
We may move this functionality to FeatureType.create( null )?
featureType
- Type of feature we wish to createIllegalAttributeException
public static SimpleFeature template(SimpleFeatureType featureType, String featureID)
The defaultValues(SimpleFeatureType)
method is used to generate the intial values
(making use of AttributeDescriptor.getDefaultValue()
as required.
featureType
- featureID
- public static Object[] defaultValues(SimpleFeatureType featureType)
featureType
- public static SimpleFeature template(SimpleFeatureType featureType, Object[] providedValues)
featureType
- providedValues
- ArrayIndexOutOfBoundsException
- If the number of provided values does not match the
featureTypepublic static SimpleFeature template(SimpleFeatureType featureType, String featureID, Object[] providedValues)
featureType
- featureID
- providedValues
- provided attributesArrayIndexOutOfBoundsException
- If the number of provided values does not match the
featureTypepublic static Object[] defaultValues(SimpleFeatureType featureType, Object[] values)
featureType
- values
- ArrayIndexOutOfBoundsException
- If the number of provided values does not match the
featureTypepublic static Object defaultValue(AttributeDescriptor attributeType) throws IllegalAttributeException
AttributeDescriptor.getDefaultValue()
Will return null if attributeType isNillable(), or attempt to use Reflection, or attributeType.parse( null )
attributeType
- IllegalAttributeException
public static Object defaultValue(Class type)
type
- public static FeatureReader<SimpleFeatureType,SimpleFeature> reader(SimpleFeature[] features) throws IOException
features
- Array of featuresIOException
- If provided features Are null or emptyNoSuchElementException
- DOCUMENT ME!public static SimpleFeatureSource source(SimpleFeature[] featureArray)
featureArray
- Array of featuresIOException
RuntimeException
public static SimpleFeatureSource source(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
This is usually done for use by the renderer; allowing it to query the feature collection as required.
collection
- Feature collection providing contentNullPointerException
- if any of the features are nullIllegalArgumentException
- If the provided collection is inconsistent (perhaps
containing mixed feature types)public static SimpleFeatureSource createView(DataStore store, Query query) throws IOException, SchemaException
DataStore
constrained by a Query
.store
- the data storequery
- the queryIOException
- if the data store cannot be accessedSchemaException
- if the query is incompatible with the store's contentspublic static SimpleFeatureSource createView(SimpleFeatureSource source, Query query) throws IOException, SchemaException
FeatureSource
constrained by a Query
.source
- feature sourcequery
- the queryIOException
- if the data store cannot be accessedSchemaException
- if the query is incompatible with the store's contentspublic static DataStore dataStore(SimpleFeatureCollection features)
See UserLayer
for example use.
features
- feature collection to adappublic static DataStore dataStore(SimpleFeatureSource source)
See UserLayer
for example use.
source
- Feature source to adaptpublic static FeatureReader<SimpleFeatureType,SimpleFeature> reader(Collection<SimpleFeature> collection) throws IOException
collection
- Collection of SimpleFeatureIOException
- IOException if there is any problem reading the content.public static FeatureReader<SimpleFeatureType,SimpleFeature> reader(FeatureCollection<SimpleFeatureType,SimpleFeature> collection) throws IOException
collection
- Collection of SimpleFeatureIOException
- IOException if there is any problem reading the content.public static SimpleFeatureCollection collection(SimpleFeature[] features)
Often used when gathering features for FeatureStore:
featureStore.addFeatures( DataUtilities.collection(array));
features
- Array of featurespublic static DefaultFeatureCollection collection(FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection)
Often used when gathering a SimpleFeatureCollection into memory.
SimpleFeatureCollection
- the features to add to a new feature collection.public static void close(Iterator<?> iterator)
Closeable
.
Any problems are logged at Level.FINE
.
public static <F extends Feature> F first(FeatureCollection<?,F> featureCollection)
featureCollection
- public static SimpleFeatureCollection simple(FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection)
Please keep the use of this class to a minimum; if you are expecting a
FeatureCollection So when are you stuck using this class?:
featureCollection
- will be returned as a SimpleFeatureCollection and wrapped only if
neededpublic static SimpleFeatureReader simple(FeatureReader<SimpleFeatureType,SimpleFeature> reader)
public static SimpleFeatureSource simple(FeatureSource source)
Please keep the use of this class to a minimum; if you are expecting a
FeatureSource
public static SimpleFeatureStore simple(FeatureStore store)
Please keep the use of this class to a minimum; if you are expecting a
FeatureStore
public static SimpleFeatureType simple(FeatureType featureType) throws DataSourceException
featureType
- FeatureType being convertedDataSourceException
public static SimpleFeatureLocking simple(FeatureLocking locking)
Please keep the use of this class to a minimum; if you are expecting a
FeatureLocking
public static <F extends Feature> List<F> list(FeatureCollection<?,F> featureCollection)
featureCollection
- public static <F extends Feature> List<F> list(FeatureCollection<?,F> featureCollection, int maxFeatures)
featureCollection
- maxFeatures
- Maximum number of features to loadpublic static <F extends Feature> Iterator<F> iterator(FeatureIterator<F> featureIterator)
Closeable
.featureIterator
- close(Iterator)
public static Set<String> fidSet(FeatureCollection<?,?> featureCollection)
This method can be slurp an in memory record of the contents of a
featureCollection
- public static <F extends Feature> Collection<F> collectionCast(FeatureCollection<?,F> featureCollection)
featureCollection
- public static SimpleFeatureCollection collection(List<SimpleFeature> list)
Often used when gathering a SimpleFeatureCollection into memory.
list
- features to add to a new FeatureCollectionpublic static SimpleFeatureCollection collection(SimpleFeature feature)
Often used when gathering features for FeatureStore:
featureStore.addFeatures( DataUtilities.collection(feature));
feature
- a feature to add to a new collectionpublic static SimpleFeatureCollection collection(FeatureReader<SimpleFeatureType,SimpleFeature> reader) throws IOException
Often used when gathering features for FeatureStore:
featureStore.addFeatures( DataUtilities.collection(reader));
IOException
public static SimpleFeatureCollection collection(SimpleFeatureIterator reader) throws IOException
Often used when gathering features for FeatureStore:
featureStore.addFeatures( DataUtilities.collection(reader));
IOException
public static boolean attributesEqual(Object att, Object otherAtt)
This method is here to work around the fact that JTS Geometry requires a specific method to be called rather than object.equals.
This method uses:
Geometry.equalsExact(Geometry)
att
- Attribute valueotherAtt
- Other valuepublic static SimpleFeatureType createSubType(SimpleFeatureType featureType, String[] properties, CoordinateReferenceSystem override) throws SchemaException
featureType
- Original feature type to derive from.properties
- If null, every property of the featureType in input will be usedoverride
- Intended CoordinateReferenceSystem, if null original will be usedSchemaException
public static SimpleFeatureType createSubType(SimpleFeatureType featureType, String[] properties, CoordinateReferenceSystem override, String typeName, URI namespace) throws SchemaException
featureType
- Original feature type to derive from.properties
- If null, every property of the featureType in input will be usedoverride
- Intended CoordinateReferenceSystem, if null original will be usedtypeName
- Type name overridenamespace
- Namespace overrideSchemaException
public static SimpleFeatureType createSubType(SimpleFeatureType featureType, String[] properties) throws SchemaException
featureType
- properties
- SchemaException
public static SimpleFeatureType createType(String typeName, String typeSpec) throws SchemaException
Will parse a String of the form: "name:Type,name2:Type2,..."
Where Type is defined by createAttribute
:
nillable
srid=<#>
Examples:
name:"",age:0,geom:Geometry,centroid:Point,url:java.io.URL"
id:String,polygonProperty:Polygon:srid=32615
identifier:UUID,location:Point,*area:MultiPolygon,created:Date
uuid:UUID,name:String,description:String,time:java.sql.Timestamp
typeName
- identification of FeatureType: (namesapce).typeNametypeSpec
- Specification of FeatureType attributes "name:Type,name2:Type2,..."SchemaException
public static SimpleFeatureType createType(String namespace, String name, String typeSpec) throws SchemaException
namespace
- Typename namespace used to qualify the provided namename
- Typename name, as qualified by namespacetypeSpec
- Definition of attributes, for details see createType(String, String)
SchemaException
public static String encodeType(SimpleFeatureType featureType)
createType(java.lang.String, java.lang.String)
.
The format of this string acts as the "header" information for the PropertyDataStore implementations.
Example:
String header = "_="+DataUtilities.encodeType(schema);
For more information please review the PropertyDataStore tutorials.
featureType
- createType(java.lang.String, java.lang.String)
public static String spec(FeatureType featureType)
encodeType(org.opengis.feature.simple.SimpleFeatureType)
for concistency with createType(java.lang.String, java.lang.String)
This string representation may be used with createType( name, spec ).
featureType
- FeatureType to representpublic static SimpleFeature createFeature(SimpleFeatureType featureType, String line)
Example:
SimpleFeatureType featureType = DataUtilities.createType("FLAG","id:Integer|name:String|geom:Geometry:4326"); SimpleFeature feature = DataUtilities.createFeature( featureType, "fid1=1|Jody Garnett\\nSteering Committee|POINT(1,2)" );This format is used by the PropertyDataStore tutorials. It amounts to:
WKTReader2
featureType
- line
- public static String encodeFeature(SimpleFeature feature)
createFeature(org.opengis.feature.simple.SimpleFeatureType, java.lang.String)
.
This method inlcudes the full featureId information.
feature
- feature to encode, only SimpleFeature is supported at this timecreateFeature(org.opengis.feature.simple.SimpleFeatureType, java.lang.String)
public static String encodeFeature(SimpleFeature feature, boolean includeFid)
createFeature(org.opengis.feature.simple.SimpleFeatureType, java.lang.String)
.
This method inlcudes the full featureId information.
feature
- feature to encode, only SimpleFeature is supported at this timeincludeFid
- true to include the optional feature idcreateFeature(org.opengis.feature.simple.SimpleFeatureType, java.lang.String)
public static SimpleFeature parse(SimpleFeatureType type, String fid, String[] text) throws IllegalAttributeException
Converters
to parse the provided text into the correct values to create a
feature.type
- FeatureTypefid
- Feature ID for new featuretext
- Text representation of valuesIllegalAttributeException
public static Comparator<SimpleFeature> sortComparator(SortBy sortBy)
This method handles:
SortBy.NATURAL_ORDER
: As sorting by FeatureID
sortBy
- public static Query mixQueries(Query firstQuery, Query secondQuery, String handle)
Query
objects and produce a new one by mixing the restrictions of both of
them.
The policy to mix the queries components is the following:
Query.ALL
)
retrieveAllProperties()
of some of the queries
returns true
it does not means that all the properties will be joined. You
must create the query with the names of the properties you want to load.
firstQuery
- Query against this DataStoresecondQuery
- DOCUMENT ME!handle
- DOCUMENT ME!NullPointerException
- if some of the queries is nullIllegalArgumentException
- if the type names of both queries do not matchpublic static Query simplifyFilter(Query query)
public static Query resolvePropertyNames(Query query, SimpleFeatureType schema)
For example, this method ensures that propertyName's such as "gml:name" are rewritten as simply "name". This method will not rewrite empty PropertyNames.
public static Filter resolvePropertyNames(Filter filter, SimpleFeatureType schema)
public static List<PropertyName> addMandatoryProperties(SimpleFeatureType type, List<PropertyName> oldProps)
type
- feature typepropNames
- given list of propertiesIOException
public static int count(FeatureIterator<?> iterator)
FeatureCollection.size()
collection
- public static int count(FeatureCollection<? extends FeatureType,? extends Feature> collection)
FeatureCollection.features()
.
This implementation is intended for FeatureCollection implementors and test case
verification. Client code should always call FeatureCollection.size()
collection
- public static ReferencedEnvelope bounds(FeatureIterator<?> iterator)
FeatureCollection.getBounds()
.iterator
- public static ReferencedEnvelope bounds(FeatureCollection<? extends FeatureType,? extends Feature> collection)
FeatureCollection.features()
.
This implementation is intended for FeatureCollection implementors and test case
verification. Client code should always call FeatureCollection.getBounds()
.
collection
- public static void visit(FeatureCollection<?,?> collection, FeatureVisitor visitor, ProgressListener progress) throws IOException
FeatureCollection.features()
.
This method is intended to assist FeatureCollection implementors, and used to verify
test-case results. Client code should always call FeatureCollection.accepts(FeatureVisitor, ProgressListener)
collection
- IOException
public static URL changeUrlExt(URL url, String postfix) throws IllegalArgumentException
URLs.changeUrlExt(URL, String)
IllegalArgumentException
public static URL getParentUrl(URL url) throws MalformedURLException
URLs.getParentUrl(URL)
.MalformedURLException
public static URL extendURL(URL base, String extension) throws MalformedURLException
MalformedURLException
public static boolean checkFileReadable(File file, Logger logger)
File
is a real file, exists and is readable.public static File checkDirectory(File file) throws IllegalArgumentException
'/'
On UNIX systems; '\\
on
Microsoft Windows systems.directoryPath
- the input directory path. Must not be null.IllegalArgumentException
- in case the specified path doesn't rely on a
existing/readable directory.public static boolean canProcess(Map params, DataAccessFactory.Param[] arrayParameters)
It will ensure that:
params
- arrayParameters
- Array of parameters returned by DataAccessFactory.getParametersInfo()public static FilenameFilter excludeFilters(FilenameFilter inputFilter, FilenameFilter... filters)
IOFileFilter
obtained by excluding from the first input filter argument,
the additional filter arguments.inputFilter
- the initial filter from which to exclude other ones.filters
- additional filters to be excludedIOFileFilter
public static FilenameFilter includeFilters(FilenameFilter inputFilter, FilenameFilter... filters)
IOFileFilter
obtained by adding to the first input filter argument, the
additional filter arguments.inputFilter
- the initial filter to which to add other ones.filters
- additional filters to be included in the main filter.IOFileFilter
public static Feature templateFeature(FeatureType schema)
schema
- the feature typeCopyright © 1996–2019 Geotools. All rights reserved.