Package org.teiid.geo
Class GeometryTransformUtils
- java.lang.Object
-
- org.teiid.geo.GeometryTransformUtils
-
public class GeometryTransformUtils extends Object
Wrapper around proj4j library to transform geometries to different coordinate systems (ST_Transform).
-
-
Constructor Summary
Constructors Constructor Description GeometryTransformUtils()
-
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(CommandContext ctx, int srid)
static String
lookupProj4Text(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 GeometryType
transform(CommandContext ctx, 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)
-
-
-
Method Detail
-
transform
@TeiidFunction(name="st_transform", category="Geometry", nullOnNull=true, pushdown=CAN_PUSHDOWN) public static GeometryType transform(CommandContext ctx, GeometryType geom, int srid) throws 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:
FunctionExecutionException
-
lookupProj4Text
public static String lookupProj4Text(CommandContext ctx, int srid) throws FunctionExecutionException
Lookup proj4 parameters in SPATIAL_REF_SYS using SRID as key.- Parameters:
ctx
-srid
-- Returns:
- Throws:
FunctionExecutionException
-
isLatLong
public static boolean isLatLong(CommandContext ctx, int srid) throws FunctionExecutionException
- Throws:
FunctionExecutionException
-
transform
public static org.locationtech.jts.geom.Geometry transform(org.locationtech.jts.geom.Geometry geom, String srcParams, String tgtParams) throws 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:
FunctionExecutionException
-
transformGeometry
protected static org.locationtech.jts.geom.Geometry transformGeometry(org.osgeo.proj4j.CoordinateTransform ct, org.locationtech.jts.geom.Geometry geom) throws FunctionExecutionException
- Throws:
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 FunctionExecutionException
- Throws:
FunctionExecutionException
-
-