public static GeographyType geographyFromEwkb(CommandContext ctx, InputStream is) throws FunctionExecutionException { Geometry geom = getGeometry(is, null, true); return getGeographyType(geom, ctx); }
public static GeographyType geographyFromEwkb(CommandContext ctx, InputStream is) throws FunctionExecutionException { Geometry geom = getGeometry(is, null, true); return getGeographyType(geom, ctx); }
@TeiidFunction(name=SourceSystemFunctions.ST_GEOGFROMTEXT, category=FunctionCategoryConstants.GEOGRAPHY, nullOnNull=true) public static GeographyType geogFromText(CommandContext ctx, ClobType wkt) throws FunctionExecutionException { return GeometryUtils.getGeographyType(GeometryUtils.geometryFromClob(wkt, null, true), ctx); }
@TeiidFunction(name=SourceSystemFunctions.ST_GEOGFROMTEXT, category=FunctionCategoryConstants.GEOGRAPHY, nullOnNull=true) public static GeographyType geogFromText(CommandContext ctx, ClobType wkt) throws FunctionExecutionException { return GeometryUtils.getGeographyType(GeometryUtils.geometryFromClob(wkt, null, true), ctx); }
public static AbstractGeospatialType convert(Geospatial geospatial, Class<?> expectedType, String srid) { Geometry result = convertToJTS(geospatial); if (geospatial.getSrid() != null && geospatial.getSrid().isNotDefault()) { srid = geospatial.getSrid().toString(); } if (srid != null) { try { result.setSRID(Integer.valueOf(geospatial.getSrid().toString())); } catch (NumberFormatException e) { } } if (expectedType == GeographyType.class) { //assume normalization and valid srid? return GeometryUtils.getGeographyType(result); } return GeometryUtils.getGeometryType(result); }
public static AbstractGeospatialType convert(Geospatial geospatial, Class<?> expectedType, String srid) { Geometry result = convertToJTS(geospatial); if (geospatial.getSrid() != null && geospatial.getSrid().isNotDefault()) { srid = geospatial.getSrid().toString(); } if (srid != null) { try { result.setSRID(Integer.valueOf(geospatial.getSrid().toString())); } catch (NumberFormatException e) { } } if (expectedType == GeographyType.class) { //assume normalization and valid srid? return GeometryUtils.getGeographyType(result); } return GeometryUtils.getGeometryType(result); }
public static GeographyType getGeographyType(Geometry geom, CommandContext ctx) throws FunctionExecutionException { if (geom.getSRID() == GeometryType.UNKNOWN_SRID) { geom.setSRID(GeographyType.DEFAULT_SRID); } if (!GeometryTransformUtils.isLatLong(ctx, geom.getSRID())) { throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31290, geom.getSRID())); } geom.apply(new CoordinateFilter() { @Override public void filter(Coordinate coord) { if (coord.x > 180) { ctx.addWarning(new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31291))); coord.x = ((coord.x+180)%360) - 180; } else if (coord.x < -180) { ctx.addWarning(new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31291))); coord.x = ((coord.x+180)%360) + 180; } if (coord.y > 90) { ctx.addWarning(new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31291))); coord.y = (((coord.y/90)%2>=1?90:0)-(coord.y%90))*((((coord.y-90)/180)%2>=1)?-1:1); } else if (coord.y < -90) { ctx.addWarning(new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31291))); coord.y = (((coord.y/90)%2<=-1?-90:0)-(coord.y%90))*((((coord.y+90)/180)%2<=-1)?-1:1); } } }); GeographyType result = getGeographyType(geom); return result; }
public static GeographyType getGeographyType(Geometry geom, CommandContext ctx) throws FunctionExecutionException { if (geom.getSRID() == GeometryType.UNKNOWN_SRID) { geom.setSRID(GeographyType.DEFAULT_SRID); } if (!GeometryTransformUtils.isLatLong(ctx, geom.getSRID())) { throw new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31290, geom.getSRID())); } geom.apply(new CoordinateFilter() { @Override public void filter(Coordinate coord) { if (coord.x > 180) { ctx.addWarning(new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31291))); coord.x = ((coord.x+180)%360) - 180; } else if (coord.x < -180) { ctx.addWarning(new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31291))); coord.x = ((coord.x+180)%360) + 180; } if (coord.y > 90) { ctx.addWarning(new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31291))); coord.y = (((coord.y/90)%2>=1?90:0)-(coord.y%90))*((((coord.y-90)/180)%2>=1)?-1:1); } else if (coord.y < -90) { ctx.addWarning(new FunctionExecutionException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31291))); coord.y = (((coord.y/90)%2<=-1?-90:0)-(coord.y%90))*((((coord.y+90)/180)%2<=-1)?-1:1); } } }); GeographyType result = getGeographyType(geom); return result; }
if (r != null) { if (desiredType == GeographyType.class) { return GeometryUtils.getGeographyType(GeometryUtils.geometryFromGml(r, gis.getSrid()));
if (r != null) { if (desiredType == GeographyType.class) { return GeometryUtils.getGeographyType(GeometryUtils.geometryFromGml(r, gis.getSrid()));