/** Convience method for STRUCT construction. */ protected final STRUCT toSTRUCT(Datum attributes[], String dataType) throws SQLException { if (dataType.startsWith("*.")) { dataType = "DRA." + dataType.substring(2); // TODO here } StructDescriptor descriptor = StructDescriptor.createDescriptor(dataType, connection); return new STRUCT(descriptor, connection, attributes); }
/** Presents struct as a double[] */ protected double[] asDoubleArray(STRUCT struct, final double DEFAULT) throws SQLException { if (struct == null) return null; return asDoubleArray(struct.getOracleAttributes(), DEFAULT); }
ResultSetMetaData meta = sdoGeometry.getDescriptor().getMetaData(); Datum data[] = sdoGeometry.getOracleAttributes(); final int GTYPE = asInteger( data[0], 0 ); final int SRID = asInteger( data[1], SDO.SRID_NULL );
/** Convenience method for STRUCT construction. */ public static STRUCT toSTRUCT(Datum[] attributes, String dataType, OracleConnection connection) throws SQLException { //TODO: fix this to be more generic if (dataType.startsWith("*.")) { dataType = "DRA." + dataType.substring(2); } StructDescriptor descriptor = StructDescriptor.createDescriptor(dataType, connection); return new STRUCT(descriptor, connection, attributes); }
/** * @param rs result set of the dimension info query * @param column column of the dimension info * @return the envelope out of the dimension info (assumption: x before y or longitude before * latitude) or null, if no data is in the specified column * @throws SQLException if dimension info can not be parsed * @author Hendrik Peilke */ private Envelope decodeDiminfoEnvelope(ResultSet rs, int column) throws SQLException { ARRAY returnArray = (ARRAY) rs.getObject(column); if (returnArray == null) { throw new SQLException("no data inside the specified column"); } Datum data[] = returnArray.getOracleArray(); if (data.length < 2) { throw new SQLException("too little dimension information found in sdo_geom_metadata"); } Datum[] xInfo = ((STRUCT) data[0]).getOracleAttributes(); Datum[] yInfo = ((STRUCT) data[1]).getOracleAttributes(); Double minx = xInfo[1].doubleValue(); Double maxx = xInfo[2].doubleValue(); Double miny = yInfo[1].doubleValue(); Double maxy = yInfo[2].doubleValue(); return new Envelope(minx, maxx, miny, maxy); }
/** Convience method for STRUCT construction. */ protected final STRUCT toSTRUCT( Datum attributes[], String dataType ) throws SQLException { if( dataType.startsWith("*.")){ dataType = "DRA."+dataType.substring(2);//TODO here } StructDescriptor descriptor = StructDescriptor.createDescriptor( dataType, connection ); return new STRUCT( descriptor, connection, attributes ); }
/** * Convert provided SDO_GEOMETRY to JTS Geometry. * * <p>Will return <code>null</code> as <code>null</code>. * * @param sdoGeometry datum STRUCT to be converted to a double[] * @return JTS <code>Geometry</code> representing the provided <code>datum</code> * @throws SQLException * @see net.refractions.jspatial.Converter#toObject(oracle.sql.STRUCT) */ public Geometry asGeometry(STRUCT sdoGeometry) throws SQLException { // Note Returning null for null Datum if (sdoGeometry == null) return null; Datum data[] = sdoGeometry.getOracleAttributes(); final int GTYPE = asInteger(data[0], 0); final int SRID = asInteger(data[1], SDO.SRID_NULL); final double POINT[] = asDoubleArray((STRUCT) data[2], Double.NaN); final int ELEMINFO[] = asIntArray((ARRAY) data[3], 0); final double ORDINATES[] = asDoubleArray((ARRAY) data[4], Double.NaN); return SDO.create(geometryFactory, GTYPE, SRID, POINT, ELEMINFO, ORDINATES); }
/** * INTERNAL: * Platforms that support java.sql.Struct may override this method. * @return Struct */ public Struct createStruct(String structTypeName, Object[] attributes, Connection connection) throws SQLException { return new oracle.sql.STRUCT(new oracle.sql.StructDescriptor(structTypeName, connection), connection, attributes); }
/** Presents struct as a double[] */ public static double[] toDoubleArray(STRUCT struct, final double defaultValue) throws SQLException { if (struct == null) return null; return toDoubleArray(struct.getOracleAttributes(), defaultValue); }
/** * INTERNAL: * Platforms that support java.sql.Struct may override this method. * @return Struct */ @Override public Struct createStruct(String structTypeName, Object[] attributes, Connection connection) throws SQLException { return new oracle.sql.STRUCT(new oracle.sql.StructDescriptor(structTypeName, connection), connection, attributes); }
/** Presents struct as a double[] */ protected double[] asDoubleArray( STRUCT struct, final double DEFAULT ) throws SQLException { if( struct == null ) return null; return asDoubleArray( struct.getOracleAttributes(), DEFAULT ); }
public Struct createStruct(SDOGeometry geom, Connection conn) throws SQLException { OracleConnection oracleConnection = null; try { oracleConnection = connectionFinder.find(conn); } catch (FinderException e) { throw new HibernateException("Problem finding Oracle Connection", e); } StructDescriptor structDescriptor = StructDescriptor .createDescriptor(SDOGeometryType.SQL_TYPE_NAME, oracleConnection); Object[] attributes = new Datum[5]; attributes[0] = new NUMBER(geom.getGType().intValue()); if (geom.getSRID() > 0) { attributes[1] = new NUMBER(geom.getSRID()); } else { attributes[1] = null; } attributes[3] = createElemInfoArray(geom.getInfo(), oracleConnection); attributes[4] = createOrdinatesArray(geom.getOrdinates(), oracleConnection); return new STRUCT(structDescriptor, conn, attributes); }
return null; Datum data[] = struct.getOracleAttributes();