com.vividsolutions.jts.io.oracle
Class OraWriter

java.lang.Object
  extended bycom.vividsolutions.jts.io.oracle.OraWriter

public class OraWriter
extends java.lang.Object

Translates a JTS Geometry into an Oracle STRUCT representing an MDSYS.GEOMETRY object. A connection to an oracle instance with access to the definition of the MDSYS.GEOMETRY object is required by the oracle driver.

Version:
9i
Author:
David Zwiers, Vivid Solutions.

Constructor Summary
OraWriter(oracle.jdbc.OracleConnection con)
          Initialize the Oracle MDSYS.GEOMETRY Encoder with a valid oracle connection.
OraWriter(oracle.jdbc.OracleConnection con, int dimension)
          Initialize the Oracle MDSYS.GEOMETRY Encoder with a valid oracle connection.
 
Method Summary
 void setDimension(int dimension)
           
 void setSRID(int srid)
          Provides the oppotunity to force all geometries written using this writter to be written using the specified srid.
 oracle.sql.STRUCT write(Geometry geom)
          This routine will translate the JTS Geometry into an Oracle MDSYS.GEOMETRY STRUCT.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OraWriter

public OraWriter(oracle.jdbc.OracleConnection con)
Initialize the Oracle MDSYS.GEOMETRY Encoder with a valid oracle connection. The connection should have sufficient priveledges to view the description of the MDSYS.GEOMETRY type. The dimension is set to 2

Parameters:
con -

OraWriter

public OraWriter(oracle.jdbc.OracleConnection con,
                 int dimension)
Initialize the Oracle MDSYS.GEOMETRY Encoder with a valid oracle connection. The connection should have sufficient priveledges to view the description of the MDSYS.GEOMETRY type.

Parameters:
con -
dimension -
Method Detail

setSRID

public void setSRID(int srid)
Provides the oppotunity to force all geometries written using this writter to be written using the specified srid. This is useful in two cases: 1) when you do not want the geometry's srid to be over-written or 2) when you want to ensure an entire layer is always written using a constant srid.

Parameters:
srid -

write

public oracle.sql.STRUCT write(Geometry geom)
                        throws java.sql.SQLException
This routine will translate the JTS Geometry into an Oracle MDSYS.GEOMETRY STRUCT. Although invalid geometries may be encoded, and inserted into an Oracle DB, this is not recomended. It is the responsibility of the user to ensure the geometry is valid prior to calling this method. The user should also ensure the the geometry's SRID field contains the correct value, if an SRID is desired. An incorrect SRID value may cause index exceptions during an insert or update. When a null Geometry is passed in, a non-null, empty STRUCT is returned. Therefore, inserting the the result of calling this method directly into a table will never result in null insertions. (March 2006) To pass a NULL Geometry into an oracle geometry parameter using jdbc, use java.sql.CallableStatement.setNull(index,java.sql.Types.STRUCT,"MDSYS.SDO_GEOMETRY") (April 2006)

Parameters:
geom - JTS Geometry to encode
Returns:
Oracle MDSYS.GEOMETRY STRUCT
Throws:
java.sql.SQLException

setDimension

public void setDimension(int dimension)
Parameters:
dimension - The dimension to set.