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 Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • NAME

      private static final org.opengis.util.ScopedName NAME
      Name of this expression.
    • library

      final Geometries<G> library
      The geometry library to use.
    • expression

      final Expression<? super R,?> expression
      The expression to be used by this operator.
      See Also:
  • Constructor Details

    • GeometryConverter

      public GeometryConverter(Geometries<G> library, Expression<? super R,?> expression)
      Creates a new converter expression.
      Parameters:
      library - the geometry library to use.
      expression - the expression providing source values.
  • Method Details

    • recreate

      public Expression<R,GeometryWrapper<G>> recreate(Expression<? super R,?>[] effective)
      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 interface Optimization.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 interface Expression<R,G>
      Returns:
      name of the function to be called.
    • getParameters

      public List<Expression<? super R,?>> getParameters()
      Returns the expression used as parameters for this function. This is the value specified at construction time.
      Specified by:
      getParameters in interface Expression<R,G>
      Returns:
      the sub-expressions to be evaluated, or an empty list if none.
    • getChildren

      protected Collection<?> getChildren()
      Returns the singleton expression tested by this operator.
      Specified by:
      getChildren in class Node
      Returns:
      the children of this node, or an empty collection if none.
    • apply

      public GeometryWrapper<G> apply(R input)
      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 are Envelope, we should use Geometries.toGeometry2D(Envelope, WraparoundMethod) directly.

      Specified by:
      apply in interface Expression<R,G>
      Specified by:
      apply in interface Function<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

      public <N> Expression<R,N> toValueType(Class<N> target)
      Returns this if the given type is assignable from the geometry root type, or throws an exception otherwise.
      Specified by:
      toValueType in interface Expression<R,G>
      Type Parameters:
      N - compile-time value of type.
      Parameters:
      target - desired type of expression results.
      Returns:
      expression doing the same operation this this expression but with results of the specified type.