@TeiidFunction(name=SourceSystemFunctions.ST_TRANSFORM, category=FunctionCategoryConstants.GEOMETRY, nullOnNull=true, pushdown=PushDown.CAN_PUSHDOWN) public static GeometryType transform(CommandContext context, GeometryType geom, int srid) throws FunctionExecutionException { return GeometryTransformUtils.transform(context, geom, srid); }
protected static Coordinate[] transformCoordinates(CoordinateTransform ct, Coordinate[] in) { return convert(transformCoordinates(ct, convert(in))); }
/** * Convert the raw geometry to the target srid coordinate system. * @param ctx Command context used to lookup proj4 parameters from table. * @param jtsGeomSrc Geometry to transform. * @param srid Target SRID; must exist in SPATIAL_REF_SYS table. * @return * @throws FunctionExecutionException */ static Geometry transform(CommandContext ctx, Geometry jtsGeomSrc, int srid) throws FunctionExecutionException { String srcParam = lookupProj4Text(ctx, jtsGeomSrc.getSRID()); String tgtParam = lookupProj4Text(ctx, srid); Geometry jtsGeomTgt = transform(jtsGeomSrc, srcParam, tgtParam); return jtsGeomTgt; }
protected static Geometry transformGeometry(CoordinateTransform ct, Geometry geom) throws FunctionExecutionException { if (geom instanceof Polygon) { return transformPolygon(ct, (Polygon) geom); } else if (geom instanceof Point) { return transformPoint(ct, (Point) geom); } else if (geom instanceof LinearRing) { return transformLinearRing(ct, (LinearRing) geom); } else if (geom instanceof LineString) { return transformLineString(ct, (LineString) geom); } else if (geom instanceof MultiPolygon) { return transformMultiPolygon(ct, (MultiPolygon) geom); } else if (geom instanceof MultiPoint) { return transformMultiPoint(ct, (MultiPoint) geom); } else if (geom instanceof MultiLineString) { return transformMultiLineString(ct, (MultiLineString) geom); } else if (geom instanceof GeometryCollection) { return transformGeometryCollection(ct, (GeometryCollection) geom); } else { throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31164, geom.getGeometryType())); } }
protected static Geometry transformPoint(CoordinateTransform ct, Point point) { return point.getFactory().createPoint(transformCoordinates(ct, point.getCoordinates())[0]); }
protected static Geometry transformGeometryCollection(CoordinateTransform ct, GeometryCollection geometryCollection) throws FunctionExecutionException { Geometry[] geometry = new Geometry[geometryCollection.getNumGeometries()]; for (int i = 0; i < geometry.length; ++i) { geometry[i] = transformGeometry(ct, geometryCollection.getGeometryN(i)); } return geometryCollection.getFactory().createGeometryCollection(geometry); } }
protected static Geometry transformGeometry(CoordinateTransform ct, Geometry geom) throws FunctionExecutionException { if (geom instanceof Polygon) { return transformPolygon(ct, (Polygon) geom); } else if (geom instanceof Point) { return transformPoint(ct, (Point) geom); } else if (geom instanceof LinearRing) { return transformLinearRing(ct, (LinearRing) geom); } else if (geom instanceof LineString) { return transformLineString(ct, (LineString) geom); } else if (geom instanceof MultiPolygon) { return transformMultiPolygon(ct, (MultiPolygon) geom); } else if (geom instanceof MultiPoint) { return transformMultiPoint(ct, (MultiPoint) geom); } else if (geom instanceof MultiLineString) { return transformMultiLineString(ct, (MultiLineString) geom); } else if (geom instanceof GeometryCollection) { return transformGeometryCollection(ct, (GeometryCollection) geom); } else { throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31164, geom.getGeometryType())); } }
protected static Geometry transformPoint(CoordinateTransform ct, Point point) { return point.getFactory().createPoint(transformCoordinates(ct, point.getCoordinates())[0]); }
protected static Geometry transformGeometryCollection(CoordinateTransform ct, GeometryCollection geometryCollection) throws FunctionExecutionException { Geometry[] geometry = new Geometry[geometryCollection.getNumGeometries()]; for (int i = 0; i < geometry.length; ++i) { geometry[i] = transformGeometry(ct, geometryCollection.getGeometryN(i)); } return geometryCollection.getFactory().createGeometryCollection(geometry); } }
protected static Geometry transformGeometry(CoordinateTransform ct, Geometry geom) throws FunctionExecutionException { if (geom instanceof Polygon) { return transformPolygon(ct, (Polygon) geom); } else if (geom instanceof Point) { return transformPoint(ct, (Point) geom); } else if (geom instanceof LinearRing) { return transformLinearRing(ct, (LinearRing) geom); } else if (geom instanceof LineString) { return transformLineString(ct, (LineString) geom); } else if (geom instanceof MultiPolygon) { return transformMultiPolygon(ct, (MultiPolygon) geom); } else if (geom instanceof MultiPoint) { return transformMultiPoint(ct, (MultiPoint) geom); } else if (geom instanceof MultiLineString) { return transformMultiLineString(ct, (MultiLineString) geom); } else if (geom instanceof GeometryCollection) { return transformGeometryCollection(ct, (GeometryCollection) geom); } else { throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31164, geom.getGeometryType())); } }
@TeiidFunction(name=SourceSystemFunctions.ST_TRANSFORM, category=FunctionCategoryConstants.GEOMETRY, nullOnNull=true, pushdown=PushDown.CAN_PUSHDOWN) public static GeometryType transform(CommandContext context, GeometryType geom, int srid) throws FunctionExecutionException { return GeometryTransformUtils.transform(context, geom, srid); }
protected static Geometry transformPoint(CoordinateTransform ct, Point point) { return point.getFactory().createPoint(transformCoordinates(ct, point.getCoordinates())[0]); }
/** * Convert the raw geometry to the target srid coordinate system. * @param ctx Command context used to lookup proj4 parameters from table. * @param jtsGeomSrc Geometry to transform. * @param srid Target SRID; must exist in SPATIAL_REF_SYS table. * @return * @throws FunctionExecutionException */ static Geometry transform(CommandContext ctx, Geometry jtsGeomSrc, int srid) throws FunctionExecutionException { String srcParam = lookupProj4Text(ctx, jtsGeomSrc.getSRID()); String tgtParam = lookupProj4Text(ctx, srid); Geometry jtsGeomTgt = transform(jtsGeomSrc, srcParam, tgtParam); return jtsGeomTgt; }
protected static Coordinate[] transformCoordinates(CoordinateTransform ct, Coordinate[] in) { return convert(transformCoordinates(ct, convert(in))); }
protected static Geometry transformGeometryCollection(CoordinateTransform ct, GeometryCollection geometryCollection) throws FunctionExecutionException { Geometry[] geometry = new Geometry[geometryCollection.getNumGeometries()]; for (int i = 0; i < geometry.length; ++i) { geometry[i] = transformGeometry(ct, geometryCollection.getGeometryN(i)); } return geometryCollection.getFactory().createGeometryCollection(geometry); } }
@TeiidFunction(name=SourceSystemFunctions.ST_TRANSFORM, category=FunctionCategoryConstants.GEOMETRY, nullOnNull=true, pushdown=PushDown.CAN_PUSHDOWN) public static GeometryType transform(CommandContext context, GeometryType geom, int srid) throws FunctionExecutionException { return GeometryTransformUtils.transform(context, geom, srid); }
protected static Geometry transformLinearRing(CoordinateTransform ct, LinearRing linearRing) { return linearRing.getFactory().createLinearRing(transformCoordinates(ct, linearRing.getCoordinates())); }
/** * Convert the raw geometry to the target srid coordinate system. * @param ctx Command context used to lookup proj4 parameters from table. * @param jtsGeomSrc Geometry to transform. * @param srid Target SRID; must exist in SPATIAL_REF_SYS table. * @return * @throws FunctionExecutionException */ static Geometry transform(CommandContext ctx, Geometry jtsGeomSrc, int srid) throws FunctionExecutionException { String srcParam = lookupProj4Text(ctx, jtsGeomSrc.getSRID()); String tgtParam = lookupProj4Text(ctx, srid); Geometry jtsGeomTgt = transform(jtsGeomSrc, srcParam, tgtParam); return jtsGeomTgt; }
protected static Coordinate[] transformCoordinates(CoordinateTransform ct, Coordinate[] in) { return convert(transformCoordinates(ct, convert(in))); }
/** * Convert geometry to different coordinate system given the source/target * proj4 parameters. Presumably these were pulled from SPATIAL_REF_SYS. * * @param geom * @param srcParams * @param tgtParams * @return * @throws FunctionExecutionException */ public static Geometry transform(Geometry geom, String srcParams, String tgtParams) throws FunctionExecutionException { CoordinateTransformFactory ctFactory = new CoordinateTransformFactory(); CRSFactory crsFactory = new CRSFactory(); CoordinateReferenceSystem srcCrs = crsFactory.createFromParameters(null, srcParams); CoordinateReferenceSystem tgtCrs = crsFactory.createFromParameters(null, tgtParams); CoordinateTransform coordTransform = ctFactory.createTransform(srcCrs, tgtCrs); return transformGeometry(coordTransform, geom); }