Class FunctionWithSRID<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:
GeometryConstructor, ST_Point, ST_Transform

abstract class FunctionWithSRID<R> extends SpatialFunction<R>
A function where the last argument is the identifier of a Coordinate Reference System. The first argument may be a geometry or data (WKT, WKT, GML…) for creating a geometry.
Since:
1.1
Version:
1.3
  • Field Details

    • serialVersionUID

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

      final Expression<? super R,?> srid
      The expression giving the spatial reference system identifier, or null if none.
    • lastSRID

      private transient Object lastSRID
      Identifier of the coordinate reference system in which to represent the geometry. This identifier is specified by the second expression and is stored in order to avoid computing targetCRS many times when the SRID does not change.
    • targetCRS

      private transient org.opengis.referencing.crs.CoordinateReferenceSystem targetCRS
      The coordinate reference system in which to represent the geometry, or null if not yet determined. This field is recomputed when the lastSRID changed. If literalCRS is true, then targetCRS shall be effectively final.
    • literalCRS

      final boolean literalCRS
      Whether the getTargetCRS(Object) value is defined by a literal.
    • PRESENT

      static final int PRESENT
      Whether the SRID is present, absent, or may be present or absent depending on the value. If ABSENT then the srid field will be null. In all other cases that field will be non-null.
      See Also:
    • ABSENT

      static final int ABSENT
      Whether the SRID is present, absent, or may be present or absent depending on the value. If ABSENT then the srid field will be null. In all other cases that field will be non-null.
      See Also:
    • MAYBE

      static final int MAYBE
      Whether the SRID is present, absent, or may be present or absent depending on the value. If ABSENT then the srid field will be null. In all other cases that field will be non-null.
      See Also:
  • Constructor Details

    • FunctionWithSRID

      FunctionWithSRID(SQLMM operation, Expression<? super R,?>[] parameters, int hasSRID)
      Creates a new function for a geometry represented by the given parameter.
      Parameters:
      operation - identification of the SQLMM operation.
      parameters - sub-expressions that will be evaluated to provide the parameters to the function.
      hasSRID - whether the SRID is expected as one of PRESENT, ABSENT or MAYBE.
  • Method Details

    • readObject

      private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
      Invoked on deserialization for restoring the targetCRS field.
      Parameters:
      in - the input stream from which to deserialize an attribute.
      Throws:
      IOException - if an I/O error occurred while reading or if the stream contains invalid data.
      ClassNotFoundException - if the class serialized on the stream is not on the classpath.
    • isCRS

      private static boolean isCRS(Class<?> type)
      Returns whether the given type is a CRS or may be a SRID.
    • setTargetCRS

      private void setTargetCRS(Object crs) throws org.opengis.util.FactoryException
      Sets targetCRS to a coordinate reference system inferred from the given value. The CRS argument shall be the result of parameters.get(1).apply(object).
      Parameters:
      crs - the object evaluated by the srid expression.
      Throws:
      org.opengis.util.FactoryException - if no CRS can be created from the given object.
    • getTargetCRS

      final org.opengis.referencing.crs.CoordinateReferenceSystem getTargetCRS(R input) throws org.opengis.util.FactoryException
      Gets the coordinate reference system for the input resources. The input argument is used only if the SRID is not a literal (which is rare). If the srid parameter is optional, then it is caller's responsibility to verify that it is non-null.
      Parameters:
      input - the resource for which to get the CRS. This is often ignored.
      Returns:
      the CRS for the given resource.
      Throws:
      org.opengis.util.FactoryException - if the CRS can be created.
    • 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.
      Specified by:
      expectedType in interface FeatureExpression<R,Object>
      Overrides:
      expectedType in class SpatialFunction<R>
      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.