public class OraWriter extends Object
MDSYS.SDO_GEOMETRY object.
Supports writing all JTS geometry types into an equivalent Oracle representation.
To write an Oracle STRUCT a connection to an Oracle instance with access to the definition of the MDSYS.SDO_GEOMETRY
type is required. Oracle SDO_GEOMETRY SQL strings may be written without a connection, however.
By default, a single Point is written using the optimized SDO_POINT_TYPE attribute.
This can be overridden to use the (less compact) SDO_ELEM_INFO/SDOORDINATES representation
by using setOptimizePoint(boolean).
By default, rectangular polygons are written as regular 5-point polygons.
This can be changed to use the optimized RECTANGLE points
by using setOptimizeRectangle(boolean).
Note that RECTANGLEs do not support LRS Measure ordinate values.
Also, this class only writes RECTANGLEs for polygons containing a single ring (i.e. the shell).
Oracle cannot represent MultiPolygons or MultiLineStrings directly as elements
of a GeometryCollection. Instead, their components are written individually.
MultiPoints are represented directly, however.
The dimension of the output SDO_GEOMETRY is determined as follows:
NaN, the coordinate dimension is assumed to be 2.
(In the future this will be determined from the underlying CoordinateSequences.
setDimension(int) method.
This allows forcing Z output even if the Z values are NaN.
Conversely, if Z values are present this allows forcing 2D output.
| Constructor and Description |
|---|
OraWriter()
Creates a writer for Oracle geometry formats.
|
OraWriter(int outputDimension)
Creates a writer for Oracle geometry formats,
specifying the maximum output dimension.
|
OraWriter(oracle.jdbc.OracleConnection con)
Deprecated.
use
OraWriter() instead |
OraWriter(oracle.jdbc.OracleConnection con,
int outputDimension)
Deprecated.
use
OraWriter(int) instead |
| Modifier and Type | Method and Description |
|---|---|
void |
setDimension(int outputDimension)
Sets the coordinate dimension for the created Oracle geometries.
|
void |
setOptimizePoint(boolean isOptimizePoint)
Sets whether points should be written using the
optimized SDO_POINT_TYPE format.
|
void |
setOptimizeRectangle(boolean isOptimizeRectangle)
Sets whether rectangle polygons should be written using the
optimized 4-coordinate RECTANGLE format
(ETYPE=1003, INTERPRETATION=3).
|
void |
setSRID(int srid)
Forces geometries to be written using the specified SRID.
|
oracle.sql.STRUCT |
write(Geometry geom)
Deprecated.
|
oracle.sql.STRUCT |
write(Geometry geom,
oracle.jdbc.OracleConnection connection)
Converts a
Geometry into an Oracle MDSYS.SDO_GEOMETRY STRUCT. |
String |
writeSQL(Geometry geom)
Writes a Geometry in Oracle SDO_GEOMETRY SQL literal format.
|
public OraWriter()
public OraWriter(int outputDimension)
outputDimension - the coordinate dimension to use for the outputpublic OraWriter(oracle.jdbc.OracleConnection con)
OraWriter() instead
To simplify connection resource handling, the connection should be
provided in the write(Geometry, OracleConnection) method.
Accordingly, this constructor has been deprecated.
The connection should have sufficient privileges to view the description of the MDSYS.SDO_GEOMETRY type.
The output dimension will be whatever the dimension of the input is.
con - a valid Oracle connectionpublic OraWriter(oracle.jdbc.OracleConnection con,
int outputDimension)
OraWriter(int) instead
To simplify connection resource handling, the connection should be
provided in the write(Geometry, OracleConnection) method.
Accordingly, this constructor has been deprecated.
The connection should have sufficient privileges to view the description of the MDSYS.SDO_GEOMETRY type.
con - a valid Oracle connectionoutputDimension - the coordinate dimension to use for the outputpublic void setDimension(int outputDimension)
outputDimension - the coordinate dimension to use for the outputpublic void setSRID(int srid)
srid - the srid to usepublic void setOptimizeRectangle(boolean isOptimizeRectangle)
false.isOptimizeRectangle - whether to optimize rectangle writingpublic void setOptimizePoint(boolean isOptimizePoint)
false, points are written using the SDO_ORDINATES attribute.
The default setting is true.isOptimizePoint - whether to optimize point writingpublic oracle.sql.STRUCT write(Geometry geom) throws SQLException
Geometry into an Oracle MDSYS.SDO_GEOMETRY STRUCT.
Although invalid geometries may be encoded, and inserted into an Oracle DB, this is not recommended. It is the responsibility of the user to ensure the geometry is valid prior to calling this method.
The SRID of the created SDO_GEOMETRY is the SRID defined explicitly for the writer, if any; otherwise it is the SRID contained in the input geometry. The caller should ensure the the SRID is valid for the intended use, since an incorrect SRID may cause indexing exceptions during an INSERT or UPDATE.
When a null Geometry is passed in, a non-null, empty SDO_GEOMETRY STRUCT is returned. Therefore, inserting the output of the writer into a table will never result in NULL insertions. To pass a NULL Geometry into an Oracle SDO_GEOMETRY-valued parameter using JDBC, use
java.sql.CallableStatement.setNull(index, java.sql.Types.STRUCT, "MDSYS.SDO_GEOMETRY").
geom - the geometry to encodeSQLException - if an encoding error was encounteredpublic oracle.sql.STRUCT write(Geometry geom, oracle.jdbc.OracleConnection connection) throws SQLException
Geometry into an Oracle MDSYS.SDO_GEOMETRY STRUCT.
Although invalid geometries may be encoded, and inserted into an Oracle DB, this is not recommended. It is the responsibility of the user to ensure the geometry is valid prior to calling this method.
The SRID of the created SDO_GEOMETRY is the SRID defined explicitly for the writer, if any; otherwise it is the SRID contained in the input geometry. The caller should ensure the the SRID is valid for the intended use, since an incorrect SRID may cause indexing exceptions during an INSERT or UPDATE.
When a null Geometry is passed in, a non-null, empty SDO_GEOMETRY STRUCT is returned. Therefore, inserting the output of the writer into a table will never result in NULL insertions. To pass a NULL Geometry into an Oracle SDO_GEOMETRY-valued parameter using JDBC, use
java.sql.CallableStatement.setNull(index, java.sql.Types.STRUCT, "MDSYS.SDO_GEOMETRY").
geom - the geometry to encodeSQLException - if an encoding error was encounteredpublic String writeSQL(Geometry geom)
Examples of output are:
SDO_GEOMETRY(2001,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1,1),SDO_ORDINATE_ARRAY(50,50)) SDO_GEOMETRY(3001,NULL,SDO_POINT_TYPE(50,50,100,),NULL,NULL) SDO_GEOMETRY(3006,8307,NULL,SDO_ELEM_INFO_ARRAY(1,2,1, 7,2,1),SDO_ORDINATE_ARRAY(0,0,2, 50,50,100, 10,10,12, 150,150,110))
geom - the Geometry to writeCopyright © 2015. All rights reserved.