public final class FeatureOperations extends Static
Feature
as input and producing an Attribute
as output.
Those operations can be used for creating dynamic properties which compute their value on-the-fly
from the values of other properties.
A flexible but relatively cumbersome way to define arbitrary computations is to subclass AbstractOperation
.
This FeatureOperations
class provides a more convenient way to get a few commonly-used operations.
Map<String,?>
.
The recognized entries are the same than the ones documented in AbstractIdentifiedType
, augmented with
entries that describe the operation result. Those entries are summarized below:
Map key | Value type | Returned by |
---|---|---|
"name" | GenericName or String |
Operation.getName() (mandatory) |
"definition" | InternationalString or String |
Operation.getDefinition() |
"designation" | InternationalString or String |
Operation.getDesignation() |
"description" | InternationalString or String |
Operation.getDescription() |
"result.name" | GenericName or String |
Attribute.getName() on the result |
"result.definition" | InternationalString or String |
Attribute.getDefinition() on the result |
"result.designation" | InternationalString or String |
Attribute.getDesignation() on the result |
"result.description" | InternationalString or String |
Attribute.getDescription() on the result |
"locale" | Locale |
(none) |
"result.*"
entry is provided, then the methods in this class will use some default name, designation
and other information for the result type. Those defaults are operation specific; they are often, but not necessarily,
the same than the operation name, designation, etc.Defined in the sis-feature
module
Modifier and Type | Method and Description |
---|---|
static AbstractOperation |
compound(Map<String,?> identification,
String delimiter,
String prefix,
String suffix,
AbstractIdentifiedType... singleAttributes)
Creates an operation concatenating the string representations of the values of multiple properties.
|
static AbstractOperation |
envelope(Map<String,?> identification,
CoordinateReferenceSystem crs,
AbstractIdentifiedType... geometryAttributes)
Creates an operation computing the envelope that encompass all geometries found in the given attributes.
|
static AbstractOperation |
link(Map<String,?> identification,
AbstractIdentifiedType referent)
Creates an operation which is only an alias for another property.
|
public static AbstractOperation link(Map<String,?> identification, AbstractIdentifiedType referent)
"identifier"
which links to whatever property is used as an identifier in an arbitrary feature.
So the definition of the Car feature could contain the following code:
AttributeType licensePlateNumber = ...; // Attribute creation omitted for brevity FeatureType car = new DefaultFeatureType(..., // Arguments omitted for brevity licensePlateNumber, model, owner, FeatureOperations.link(singletonMap(NAME_KEY, "identifier"), licensePlateNumber);
"result.*"
entries in the given identification
map.
Operation.apply(…)
method returns directly the property
identified by the referent
argument, the returned property is writable if the referenced
property is also writable.
referent
parameter will be changed to PropertyType
if and when such interface will be defined in GeoAPI.identification
- the name and other information to be given to the operation.referent
- the referenced attribute or feature association.referent
property.public static AbstractOperation compound(Map<String,?> identification, String delimiter, String prefix, String suffix, AbstractIdentifiedType... singleAttributes) throws UnconvertibleObjectException
String
that consists
of two or more attribute values that uniquely identify a feature instance.
The delimiter
, prefix
and suffix
arguments given to this method
are used in the same way than StringJoiner
, except for null values.
Null prefix, suffix and property values are handled as if they were empty strings.
If the same character sequences than the given delimiter appears in a property value,
the '\'
escape character will be inserted before that sequence.
If the '\'
character appears in a property value, it will be doubled.
Restrictions:
'\'
escape character.delimiter
and each substring will be
forwarded to the corresponding single property.
singleAttributes
elements will be changed to PropertyType
if and when such interface will be defined in GeoAPI.identification
- the name and other information to be given to the operation.delimiter
- the characters to use as delimiter between each single property value.prefix
- characters to use at the beginning of the concatenated string, or null
if none.suffix
- characters to use at the end of the concatenated string, or null
if none.singleAttributes
- identification of the single attributes (or operations producing attributes) to concatenate.UnconvertibleObjectException
- if at least one of the given singleAttributes
uses a
value class which is not convertible from a String
.IllegalArgumentException
- if singleAttributes
is an empty sequence, or contains a property which
is neither an AttributeType
or an Operation
computing an attribute, or an attribute has
a maximum number of occurrences greater than 1.public static AbstractOperation envelope(Map<String,?> identification, CoordinateReferenceSystem crs, AbstractIdentifiedType... geometryAttributes) throws FactoryException
Attribute
with values of type Envelope
. If the crs
argument given to
this method is non-null, then the
envelope CRS
will be that CRS.
Attribute.setValue(Envelope)
will result in an
IllegalStateException
to be thrown.
geometryAttributes
elements will be changed to PropertyType
if and when such interface will be defined in GeoAPI.identification
- the name and other information to be given to the operation.crs
- the Coordinate Reference System in which to express the envelope, or null
.geometryAttributes
- the operation or attribute type from which to get geometry values.
Any element which is null
or has a non-geometric value class will be ignored.FactoryException
- if a coordinate operation to the target CRS can not be created.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.