@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); }
@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); }
@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); }
/** * Convert geometry to a different coordinate system. Geometry must have valid * SRID. * * @param ctx Command context used to lookup proj4 parameters from table. * @param geom Geometry to transform. * @param srid Target SRID; must exist in SPATIAL_REF_SYS table. * @return Reprojected geometry. * @throws FunctionExecutionException */ public static GeometryType transform(CommandContext ctx, GeometryType geom, int srid) throws FunctionExecutionException { Geometry jtsGeomSrc = GeometryUtils.getGeometry(geom); Geometry jtsGeomTgt = transform(ctx, jtsGeomSrc, srid); return GeometryUtils.getGeometryType(jtsGeomTgt, srid); }
/** * Convert geometry to a different coordinate system. Geometry must have valid * SRID. * * @param ctx Command context used to lookup proj4 parameters from table. * @param geom Geometry to transform. * @param srid Target SRID; must exist in SPATIAL_REF_SYS table. * @return Reprojected geometry. * @throws FunctionExecutionException */ public static GeometryType transform(CommandContext ctx, GeometryType geom, int srid) throws FunctionExecutionException { Geometry jtsGeomSrc = GeometryUtils.getGeometry(geom); Geometry jtsGeomTgt = transform(ctx, jtsGeomSrc, srid); return GeometryUtils.getGeometryType(jtsGeomTgt, srid); }
/** * Convert geometry to a different coordinate system. Geometry must have valid * SRID. * * @param ctx Command context used to lookup proj4 parameters from table. * @param geom Geometry to transform. * @param srid Target SRID; must exist in SPATIAL_REF_SYS table. * @return Reprojected geometry. * @throws FunctionExecutionException */ public static GeometryType transform(CommandContext ctx, GeometryType geom, int srid) throws FunctionExecutionException { Geometry jtsGeomSrc = GeometryUtils.getGeometry(geom); Geometry jtsGeomTgt = transform(ctx, jtsGeomSrc, srid); return GeometryUtils.getGeometryType(jtsGeomTgt, srid); }
/** * 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; }
/** * 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; }
/** * 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; }
@Test public void testTransform() throws Exception { Geometry g0 = new WKTReader().read("POINT(426418.89 4957737.37)"); Geometry g1 = GeometryTransformUtils.transform(g0, "+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs", // EPSG:32632 "+proj=longlat +datum=WGS84 +no_defs" // EPSG:4326 ); assertEquals("POINT (8.07013599546795 44.76924401481436)", g1.toText()); }
public static ClobType geometryToGml(CommandContext ctx, GeometryType geometry, boolean withGmlPrefix) throws FunctionExecutionException { Geometry jtsGeometry = getGeometry(geometry); GMLWriter writer = new GMLWriter(); if (!withGmlPrefix) { if (geometry.getSrid() != SRID_4326) { if (geometry.getSrid() == GeometryType.UNKNOWN_SRID) { throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31161)); } jtsGeometry = GeometryTransformUtils.transform(ctx, jtsGeometry, SRID_4326); } writer.setPrefix(null); } else if (geometry.getSrid() != GeometryType.UNKNOWN_SRID) { //TODO: should include the srsName //writer.setSrsName(String.valueOf(geometry.getSrid())); } String gmlText = writer.write(jtsGeometry); return new ClobType(new ClobImpl(gmlText)); }
public static ClobType geometryToGml(CommandContext ctx, GeometryType geometry, boolean withGmlPrefix) throws FunctionExecutionException { Geometry jtsGeometry = getGeometry(geometry); GMLWriter writer = new GMLWriter(); if (!withGmlPrefix) { if (geometry.getSrid() != SRID_4326) { if (geometry.getSrid() == GeometryType.UNKNOWN_SRID) { throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31161)); } jtsGeometry = GeometryTransformUtils.transform(ctx, jtsGeometry, SRID_4326); } writer.setPrefix(null); } else if (geometry.getSrid() != GeometryType.UNKNOWN_SRID) { writer.setSrsName(SRS_PREFIX + geometry.getSrid()); } String gmlText = writer.write(jtsGeometry); return new ClobType(new ClobImpl(gmlText)); }
public static ClobType geometryToGml(CommandContext ctx, GeometryType geometry, boolean withGmlPrefix) throws FunctionExecutionException { Geometry jtsGeometry = getGeometry(geometry); GMLWriter writer = new GMLWriter(); if (!withGmlPrefix) { if (geometry.getSrid() != SRID_4326) { if (geometry.getSrid() == GeometryType.UNKNOWN_SRID) { throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31161)); } jtsGeometry = GeometryTransformUtils.transform(ctx, jtsGeometry, SRID_4326); } writer.setPrefix(null); } else if (geometry.getSrid() != GeometryType.UNKNOWN_SRID) { writer.setSrsName(SRS_PREFIX + geometry.getSrid()); } String gmlText = writer.write(jtsGeometry); return new ClobType(new ClobImpl(gmlText)); }