Class SpatialFunction<R>

java.lang.Object
org.apache.sis.internal.filter.Node
org.apache.sis.internal.filter.sqlmm.SpatialFunction<R>
Type Parameters:
R - the type of resources (e.g. Feature) used as inputs.
All Implemented Interfaces:
Serializable, Function<R,Object>, Expression<R,Object>, Optimization.OnExpression<R,Object>, FeatureExpression<R,Object>
Direct Known Subclasses:
FunctionWithSRID, OneGeometry, TwoGeometries

abstract class SpatialFunction<R> extends Node implements FeatureExpression<R,Object>, Optimization.OnExpression<R,Object>
Base class of SQLMM spatial functions.
Since:
1.1
Version:
1.2
  • Field Details

    • serialVersionUID

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

      private static final org.opengis.util.LocalName SCOPE
      Scope of all names defined by SQLMM standard.
      See Also:
    • operation

      final SQLMM operation
      Identification of the SQLMM operation.
    • NAMES

      private static final EnumMap<SQLMM,org.opengis.util.ScopedName> NAMES
      All operation names as ScopedName instances. Values are created when first needed.
  • Constructor Details

    • SpatialFunction

      SpatialFunction(SQLMM operation, Expression<? super R,?>[] parameters)
      Creates a new function. This constructor verifies that the number of parameters is between SQLMM.minParamCount and SQLMM.maxParamCount inclusive, but does not store the parameters. Parameters shall be stored by subclasses.
      Parameters:
      operation - identification of the SQLMM operation.
      parameters - sub-expressions that will be evaluated to provide the parameters to the function.
      Throws:
      IllegalArgumentException - if the number of parameters is not in the expected range.
  • Method Details

    • getGeometryLibrary

      abstract Geometries<?> getGeometryLibrary()
      Returns a handler for the library of geometric objects used by this expression. This is typically implemented by a call to getGeometryLibrary(geometry) where geometry as the first expression returning a geometry object.
      Returns:
      the geometry library (never null).
      See Also:
    • getFunctionName

      public final org.opengis.util.ScopedName getFunctionName()
      Returns the name of the function to be called. This method returns a scoped name with the SQLMM function name in the local part.
      Specified by:
      getFunctionName in interface Expression<R,Object>
      Returns:
      name of the function to be called.
    • createName

      private static org.opengis.util.ScopedName createName(SQLMM operation)
      Invoked by getFunctionName() when a name needs to be created.
    • getChildren

      protected final Collection<?> getChildren()
      Returns the children of this node, which are the parameters list. This is used for information purpose only, for example in order to build a string representation.
      Specified by:
      getChildren in class Node
      Returns:
      the children of this node.
    • getSyntax

      public String getSyntax()
      Returns a Backus-Naur Form (BNF) of this function.
    • getValueClass

      public final Class<?> getValueClass()
      Returns the kind of objects evaluated by this expression.
      Specified by:
      getValueClass in interface FeatureExpression<R,Object>
      Returns:
      the type of values computed by this expression.
    • toValueType

      public final <N> Expression<R,N> toValueType(Class<N> target)
      Returns this if this expression provides values of the specified type, or throws an exception otherwise.
      Specified by:
      toValueType in interface Expression<R,Object>
      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.
    • expectedType

      public PropertyTypeBuilder expectedType(DefaultFeatureType valueType, FeatureTypeBuilder addTo)
      Provides the type of values produced by this expression when a feature of the given type is evaluated. There are two cases:
      • If the operation expects at least one geometric parameter and returns a geometry, then the characteristics of the first parameter (in particular the CRS) are copied. The first parameter is used as a template for compliance with SQLMM specification.
      • Otherwise an attribute is created with the return value specified by the operation.
      Specified by:
      expectedType in interface FeatureExpression<R,Object>
      Parameters:
      valueType - the type of features on which to apply this expression.
      addTo - where to add the type of properties evaluated by this expression.
      Returns:
      builder of type resulting from expression evaluation (never null).
      Throws:
      IllegalArgumentException - if the given feature type does not contain the expected properties, or if this method cannot determine the result type of the expression. It may be because that expression is backed by an unsupported implementation.