Package org.teiid.geo

Class GeometryTransformUtils


  • public class GeometryTransformUtils
    extends Object
    Wrapper around proj4j library to transform geometries to different coordinate systems (ST_Transform).
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static org.osgeo.proj4j.ProjCoordinate[] convert​(org.locationtech.jts.geom.Coordinate[] jtsCoords)
      Convert JTS coordinates to proj4j coordinates.
      protected static org.locationtech.jts.geom.Coordinate[] convert​(org.osgeo.proj4j.ProjCoordinate[] projCoords)
      Convert proj4 coordinates to JTS coordinates.
      static boolean isLatLong​(org.teiid.CommandContext ctx, int srid)  
      static String lookupProj4Text​(org.teiid.CommandContext ctx, int srid)
      Lookup proj4 parameters in SPATIAL_REF_SYS using SRID as key.
      static org.locationtech.jts.geom.Geometry transform​(org.locationtech.jts.geom.Geometry geom, String srcParams, String tgtParams)
      Convert geometry to different coordinate system given the source/target proj4 parameters.
      static org.teiid.core.types.GeometryType transform​(org.teiid.CommandContext ctx, org.teiid.core.types.GeometryType geom, int srid)
      Convert geometry to a different coordinate system.
      protected static org.locationtech.jts.geom.Coordinate[] transformCoordinates​(org.osgeo.proj4j.CoordinateTransform ct, org.locationtech.jts.geom.Coordinate[] in)  
      protected static org.osgeo.proj4j.ProjCoordinate[] transformCoordinates​(org.osgeo.proj4j.CoordinateTransform ct, org.osgeo.proj4j.ProjCoordinate[] in)  
      protected static org.locationtech.jts.geom.Geometry transformGeometry​(org.osgeo.proj4j.CoordinateTransform ct, org.locationtech.jts.geom.Geometry geom)  
      protected static org.locationtech.jts.geom.Geometry transformGeometryCollection​(org.osgeo.proj4j.CoordinateTransform ct, org.locationtech.jts.geom.GeometryCollection geometryCollection)  
      protected static org.locationtech.jts.geom.Geometry transformLinearRing​(org.osgeo.proj4j.CoordinateTransform ct, org.locationtech.jts.geom.LinearRing linearRing)  
      protected static org.locationtech.jts.geom.Geometry transformLineString​(org.osgeo.proj4j.CoordinateTransform ct, org.locationtech.jts.geom.LineString lineString)  
      protected static org.locationtech.jts.geom.Geometry transformMultiLineString​(org.osgeo.proj4j.CoordinateTransform ct, org.locationtech.jts.geom.MultiLineString multiLineString)  
      protected static org.locationtech.jts.geom.Geometry transformMultiPoint​(org.osgeo.proj4j.CoordinateTransform ct, org.locationtech.jts.geom.MultiPoint multiPoint)  
      protected static org.locationtech.jts.geom.Geometry transformMultiPolygon​(org.osgeo.proj4j.CoordinateTransform ct, org.locationtech.jts.geom.MultiPolygon multiPolygon)  
      protected static org.locationtech.jts.geom.Geometry transformPoint​(org.osgeo.proj4j.CoordinateTransform ct, org.locationtech.jts.geom.Point point)  
      protected static org.locationtech.jts.geom.Polygon transformPolygon​(org.osgeo.proj4j.CoordinateTransform ct, org.locationtech.jts.geom.Polygon polygon)  
    • Constructor Detail

      • GeometryTransformUtils

        public GeometryTransformUtils()
    • Method Detail

      • transform

        @TeiidFunction(name="st_transform",
                       category="Geometry",
                       nullOnNull=true,
                       pushdown=CAN_PUSHDOWN)
        public static org.teiid.core.types.GeometryType transform​(org.teiid.CommandContext ctx,
                                                                  org.teiid.core.types.GeometryType geom,
                                                                  int srid)
                                                           throws org.teiid.api.exception.query.FunctionExecutionException
        Convert geometry to a different coordinate system. Geometry must have valid SRID.
        Parameters:
        ctx - Command context used to lookup proj4 parameters from table.
        geom - Geometry to transform.
        srid - Target SRID; must exist in SPATIAL_REF_SYS table.
        Returns:
        Reprojected geometry.
        Throws:
        org.teiid.api.exception.query.FunctionExecutionException
      • lookupProj4Text

        public static String lookupProj4Text​(org.teiid.CommandContext ctx,
                                             int srid)
                                      throws org.teiid.api.exception.query.FunctionExecutionException
        Lookup proj4 parameters in SPATIAL_REF_SYS using SRID as key.
        Parameters:
        ctx -
        srid -
        Returns:
        Throws:
        org.teiid.api.exception.query.FunctionExecutionException
      • isLatLong

        public static boolean isLatLong​(org.teiid.CommandContext ctx,
                                        int srid)
                                 throws org.teiid.api.exception.query.FunctionExecutionException
        Throws:
        org.teiid.api.exception.query.FunctionExecutionException
      • transform

        public static org.locationtech.jts.geom.Geometry transform​(org.locationtech.jts.geom.Geometry geom,
                                                                   String srcParams,
                                                                   String tgtParams)
                                                            throws org.teiid.api.exception.query.FunctionExecutionException
        Convert geometry to different coordinate system given the source/target proj4 parameters. Presumably these were pulled from SPATIAL_REF_SYS.
        Parameters:
        geom -
        srcParams -
        tgtParams -
        Returns:
        Throws:
        org.teiid.api.exception.query.FunctionExecutionException
      • transformGeometry

        protected static org.locationtech.jts.geom.Geometry transformGeometry​(org.osgeo.proj4j.CoordinateTransform ct,
                                                                              org.locationtech.jts.geom.Geometry geom)
                                                                       throws org.teiid.api.exception.query.FunctionExecutionException
        Throws:
        org.teiid.api.exception.query.FunctionExecutionException
      • convert

        protected static org.locationtech.jts.geom.Coordinate[] convert​(org.osgeo.proj4j.ProjCoordinate[] projCoords)
        Convert proj4 coordinates to JTS coordinates.
        Parameters:
        projCoords -
        Returns:
      • convert

        protected static org.osgeo.proj4j.ProjCoordinate[] convert​(org.locationtech.jts.geom.Coordinate[] jtsCoords)
        Convert JTS coordinates to proj4j coordinates.
        Parameters:
        jtsCoords -
        Returns:
      • transformCoordinates

        protected static org.locationtech.jts.geom.Coordinate[] transformCoordinates​(org.osgeo.proj4j.CoordinateTransform ct,
                                                                                     org.locationtech.jts.geom.Coordinate[] in)
      • transformCoordinates

        protected static org.osgeo.proj4j.ProjCoordinate[] transformCoordinates​(org.osgeo.proj4j.CoordinateTransform ct,
                                                                                org.osgeo.proj4j.ProjCoordinate[] in)
      • transformPolygon

        protected static org.locationtech.jts.geom.Polygon transformPolygon​(org.osgeo.proj4j.CoordinateTransform ct,
                                                                            org.locationtech.jts.geom.Polygon polygon)
      • transformPoint

        protected static org.locationtech.jts.geom.Geometry transformPoint​(org.osgeo.proj4j.CoordinateTransform ct,
                                                                           org.locationtech.jts.geom.Point point)
      • transformLinearRing

        protected static org.locationtech.jts.geom.Geometry transformLinearRing​(org.osgeo.proj4j.CoordinateTransform ct,
                                                                                org.locationtech.jts.geom.LinearRing linearRing)
      • transformLineString

        protected static org.locationtech.jts.geom.Geometry transformLineString​(org.osgeo.proj4j.CoordinateTransform ct,
                                                                                org.locationtech.jts.geom.LineString lineString)
      • transformMultiPolygon

        protected static org.locationtech.jts.geom.Geometry transformMultiPolygon​(org.osgeo.proj4j.CoordinateTransform ct,
                                                                                  org.locationtech.jts.geom.MultiPolygon multiPolygon)
      • transformMultiPoint

        protected static org.locationtech.jts.geom.Geometry transformMultiPoint​(org.osgeo.proj4j.CoordinateTransform ct,
                                                                                org.locationtech.jts.geom.MultiPoint multiPoint)
      • transformMultiLineString

        protected static org.locationtech.jts.geom.Geometry transformMultiLineString​(org.osgeo.proj4j.CoordinateTransform ct,
                                                                                     org.locationtech.jts.geom.MultiLineString multiLineString)
      • transformGeometryCollection

        protected static org.locationtech.jts.geom.Geometry transformGeometryCollection​(org.osgeo.proj4j.CoordinateTransform ct,
                                                                                        org.locationtech.jts.geom.GeometryCollection geometryCollection)
                                                                                 throws org.teiid.api.exception.query.FunctionExecutionException
        Throws:
        org.teiid.api.exception.query.FunctionExecutionException