Package org.geotools.data.oracle.sdo
Class GeometryConverter
Object
GeometryConverter
Sample use of SDO class for simple JTS Geometry.
If needed I can make a LRSGeometryConverter that allows JTS Geometries with additional ordinates beyond xyz.
- Author:
- jgarnett, Mark Prins, B3Partners
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGeometryConverter
(OracleConnection connection) GeometryConverter
(OracleConnection connection, GeometryFactory geometryFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected double
asDouble
(Datum datum, double DEFAULT) Presents datum as a doubleprotected double[]
asDoubleArray
(OracleArray array, double DEFAULT) Presents array as a double[]protected double[]
asDoubleArray
(OracleStruct struct, double DEFAULT) Presents struct as a double[]protected double[]
asDoubleArray
(Datum[] data, double DEFAULT) Presents Datum[] as a double[]protected OracleStruct
Representation ofnull
as an EmptySDO_GEOMETRY
.asGeometry
(OracleStruct sdoGeometry) Convert provided SDO_GEOMETRY to JTS Geometry.protected int[]
asIntArray
(OracleArray array, int DEFAULT) protected int[]
asIntArray
(Datum[] data, int DEFAULT) Presents Datum[] as a int[]protected int
asInteger
(Datum datum, int DEFAULT) Presents datum as an intUsed to handle MDSYS.SDO_GEOMETRY.boolean
Ensure that obj is a JTS Geometry (2D or 3D) with no LRS measures.protected final OracleArray
Convenience method for OracleArray construction.protected final OracleArray
Convenience method for OracleArray construction.protected final OracleArray
toATTRIBUTE
(double[] ords, String desc) protected final CHAR
Convenience method for CHAR constructionprotected final NUMBER
toNUMBER
(double number) Convenience method for NUMBER construction.protected final NUMBER
toNUMBER
(int number) Convenience method for NUMBER constructionprotected final OracleArray
toORDINATE
(double[] ords) protected final OracleArray
toORDINATE
(CoordinateList list, double[][] measures, int D) Convenience method for OracleArray construction.OracleStruct
Used to convert double[] to SDO_ODINATE_ARRAY.OracleStruct
Used to convert double[] to SDO_ODINATE_ARRAY.protected final OracleStruct
Convenience method for OracleStruct construction.
-
Field Details
-
connection
protected OracleConnection connection -
DATATYPE
- See Also:
-
-
Constructor Details
-
GeometryConverter
public GeometryConverter(OracleConnection connection) -
GeometryConverter
-
-
Method Details
-
getDataTypeName
Used to handle MDSYS.SDO_GEOMETRY.- Returns:
MDSYS.SDO_GEOMETRY
- See Also:
-
isCapable
Ensure that obj is a JTS Geometry (2D or 3D) with no LRS measures.This Converter does not support SpatialCoordinates
- Parameters:
geom
- the Geometry to be converted- Returns:
true
ifobj
is a JTS Geometry
-
asGeometry
Convert provided SDO_GEOMETRY to JTS Geometry.Will return
null
asnull
.- Parameters:
sdoGeometry
- datum STRUCT to be converted to a geometry- Returns:
- JTS
Geometry
representing the provideddatum
- Throws:
SQLException
-
toSDO
Used to convert double[] to SDO_ODINATE_ARRAY.Will return
null
as an emptySDO_GEOMETRY
- Parameters:
geom
- Map to be represented as a STRUCT- Returns:
- Struct representing provided Map
- Throws:
SQLException
-
toSDO
Used to convert double[] to SDO_ODINATE_ARRAY.Will return
null
as an emptySDO_GEOMETRY
- Parameters:
geom
- Map to be represented as a STRUCT- Returns:
- STRUCT representing provided Map
- Throws:
SQLException
-
asEmptyDataType
Representation ofnull
as an EmptySDO_GEOMETRY
.- Returns:
null
as a SDO_GEOMETRY- Throws:
SQLException
-
toSTRUCT
Convenience method for OracleStruct construction.- Throws:
SQLException
-
toARRAY
Convenience method for OracleArray construction.Compare and contrast with toORDINATE - which treats
Double.NaN
asNULL
- Throws:
SQLException
-
toORDINATE
protected final OracleArray toORDINATE(CoordinateList list, double[][] measures, int D) throws SQLException Convenience method for OracleArray construction.Forced to burn memory here - only way to actually place
NULL
numbers in the ordinate stream.- JTS: records lack of data as
Double.NaN
- SDO: records lack of data as
NULL
The alternative is to construct the array from a array of doubles, which does not record
NULL
NUMBERs.The results is an "MDSYS.SDO_ORDINATE_ARRAY"
{@code list = c1(1,2,0), c2(3,4,Double.NaN) measures = {{5,6},{7,8} toORDINATE( list, measures, 2 ) = (1,2,5,7, 3,4,6,8) toORDINATE( list, measures, 3 ) = (1,2,0,5,7, 3,4,NULL,6,8) toORDINATE( list, null, 2 ) = (1,2, 3,4) } </pre> @param list CoordinateList to be represented @param measures Per Coordinate Measures, {@code null} if not required @param D Dimension of Coordinates (limited to 2d, 3d)
- Throws:
SQLException
- JTS: records lack of data as
-
toORDINATE
- Throws:
SQLException
-
toATTRIBUTE
- Throws:
SQLException
-
toNUMBER
Convenience method for NUMBER construction.Double.NaN is represented as
NULL
to agree with JTS use.- Throws:
SQLException
-
toARRAY
Convenience method for OracleArray construction.- Throws:
SQLException
-
toNUMBER
protected final NUMBER toNUMBER(int number) Convenience method for NUMBER construction -
toCHAR
Convenience method for CHAR construction -
asInteger
Presents datum as an int- Throws:
SQLException
-
asDouble
Presents datum as a double- Throws:
SQLException
-
asDoubleArray
Presents struct as a double[]- Throws:
SQLException
-
asDoubleArray
Presents array as a double[]- Throws:
SQLException
-
asDoubleArray
Presents Datum[] as a double[]- Throws:
SQLException
-
asIntArray
- Throws:
SQLException
-
asIntArray
Presents Datum[] as a int[]- Throws:
SQLException
-