Class ST_Transform<R,G>

All Implemented Interfaces:
Serializable, Function<R,Object>, Expression<R,Object>, Optimization.OnExpression<R,Object>, FeatureExpression<R,Object>

final class ST_Transform<R,G> extends FunctionWithSRID<R>
Return an geometry value transformed to the specified spatial reference system, considering z and m coordinate values in the calculations and including them in the resultant geometry. This expression expects two arguments:
  1. An expression returning a geometry object. The evaluated value shall be an instance of one of the implementations enumerated in GeometryLibrary.
  2. An expression returning the target CRS. This is typically a Literal, i.e. a constant for all geometries, but this implementation allows the expression to return different CRS for different geometries for example depending on the number of dimensions. This CRS can be specified in different ways:
    • As a CoordinateReferenceSystem instance.
    • As a String instance of the form "EPSG:xxxx", a URL or a URN.
    • As an Integer instance specifying an EPSG code.

Limitation

  • Current implementation ignores the z and m values.
  • If the SRID is an integer, it is interpreted as an EPSG code. It should be a primary key in the "spatial_ref_sys" table instead.
Since:
1.1
Version:
1.1
  • Field Details

  • Constructor Details

    • ST_Transform

      ST_Transform(Expression<? super R,?>[] parameters, Geometries<G> library)
      Creates a new function with the given parameters. It is caller's responsibility to ensure that the given array is non-null and does not contain null elements.
      Throws:
      IllegalArgumentException - if CRS cannot be constructed from the second expression.
  • Method Details

    • recreate

      public Expression<R,Object> 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.
      Parameters:
      effective - the expressions to use as a replacement of this expression parameters.
      Returns:
      the new expression, or this if unsupported.
    • getGeometryLibrary

      final Geometries<?> getGeometryLibrary()
      Returns a handler for the library of geometric objects used by this expression.
      Specified by:
      getGeometryLibrary in class SpatialFunction<R>
      Returns:
      the geometry library (never null).
      See Also:
    • getParameters

      public List<Expression<? super R,?>> getParameters()
      Returns the sub-expressions that will be evaluated to provide the parameters to the function.
      Returns:
      the sub-expressions to be evaluated, or an empty list if none.
    • apply

      public Object apply(R input)
      Evaluates the first expression as a geometry object, transforms that geometry to the CRS given by the second expression and returns the result.
      Parameters:
      input - the object from which to get a geometry.
      Returns:
      the transformed geometry, or null if the given object is not an instance of a supported geometry library (JTS, ERSI, Java2D…).