Package org.apache.sis.internal.filter
Class GeometryConverter<R,G>
java.lang.Object
org.apache.sis.internal.filter.Node
org.apache.sis.internal.filter.GeometryConverter<R,G>
- Type Parameters:
R
- the type of resources (e.g.Feature
) used as inputs.G
- the geometry implementation type.
- All Implemented Interfaces:
Serializable
,Function<R,
,GeometryWrapper<G>> Expression<R,
,GeometryWrapper<G>> Optimization.OnExpression<R,
GeometryWrapper<G>>
final class GeometryConverter<R,G>
extends Node
implements Optimization.OnExpression<R,GeometryWrapper<G>>
Expression whose results is a geometry wrapper. This converter evaluates another expression,
which is given at construction time, potentially converts the result then wraps it.
- Since:
- 1.1
- Version:
- 1.3
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final Expression<? super R,
?> The expression to be used by this operator.(package private) final Geometries<G>
The geometry library to use.private static final org.opengis.util.ScopedName
Name of this expression.private static final long
For cross-version compatibility. -
Constructor Summary
ConstructorsConstructorDescriptionGeometryConverter
(Geometries<G> library, Expression<? super R, ?> expression) Creates a new converter expression. -
Method Summary
Modifier and TypeMethodDescriptionEvaluates the expression and converts the value to a geometry wrapper.protected Collection<?>
Returns the singleton expression tested by this operator.org.opengis.util.ScopedName
Returns an identification of this operation.List<Expression<? super R,
?>> Returns the expression used as parameters for this function.recreate
(Expression<? super R, ?>[] effective) Creates a new expression of the same type than this expression, but with an optimized geometry.<N> Expression<R,
N> toValueType
(Class<N> target) Returnsthis
if the given type is assignable from the geometry root type, or throws an exception otherwise.Methods inherited from class org.apache.sis.internal.filter.Node
createName, createType, equals, getGeometryLibrary, hashCode, symbol, toGeometryWrapper, toString, unwrap, warning
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.sis.filter.Optimization.OnExpression
optimize
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
NAME
private static final org.opengis.util.ScopedName NAMEName of this expression. -
library
The geometry library to use. -
expression
The expression to be used by this operator.- See Also:
-
-
Constructor Details
-
GeometryConverter
Creates a new converter expression.- Parameters:
library
- the geometry library to use.expression
- the expression providing source values.
-
-
Method Details
-
recreate
Creates a new expression of the same type than this expression, but with an optimized geometry. The optimization may be a geometry computed immediately if all operator parameters are literals.- Specified by:
recreate
in interfaceOptimization.OnExpression<R,
G> - Parameters:
effective
- the expressions to use as a replacement of this expression parameters.- Returns:
- the new expression, or
this
if unsupported.
-
getFunctionName
public org.opengis.util.ScopedName getFunctionName()Returns an identification of this operation.- Specified by:
getFunctionName
in interfaceExpression<R,
G> - Returns:
- name of the function to be called.
-
getParameters
Returns the expression used as parameters for this function. This is the value specified at construction time.- Specified by:
getParameters
in interfaceExpression<R,
G> - Returns:
- the sub-expressions to be evaluated, or an empty list if none.
-
getChildren
Returns the singleton expression tested by this operator.- Specified by:
getChildren
in classNode
- Returns:
- the children of this node, or an empty collection if none.
-
apply
Evaluates the expression and converts the value to a geometry wrapper. For now, only "native" geometry objects, envelope and bounding boxes are supported. No Wrap-around resolution is applied.This method is a workaround for attempting conversion of an arbitrary value to a geometry. When more context is available, the chain of
if (x instanceof y)
statements should be replaced by subclasses invoking directly the appropriate method. For example if we know that values areEnvelope
, we should useGeometries.toGeometry2D(Envelope, WraparoundMethod)
directly.- Specified by:
apply
in interfaceExpression<R,
G> - Specified by:
apply
in interfaceFunction<R,
G> - Parameters:
input
- the geometry to evaluate with this expression.- Returns:
- the geometry wrapper, or
null
if the evaluated value is null. - Throws:
IllegalArgumentException
- if the expression result is not an instance of a supported type.
-
toValueType
Returnsthis
if the given type is assignable from the geometry root type, or throws an exception otherwise.- Specified by:
toValueType
in interfaceExpression<R,
G> - Type Parameters:
N
- compile-time value oftype
.- Parameters:
target
- desired type of expression results.- Returns:
- expression doing the same operation this this expression but with results of the specified type.
-