Package org.geotools.data.oracle.sdo
Class GeometryConverter
- Object
-
- GeometryConverter
-
public class GeometryConverter extends Object
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 Modifier and Type Field Description protected OracleConnectionconnectionstatic StringDATATYPE
-
Constructor Summary
Constructors Constructor Description GeometryConverter(OracleConnection connection)GeometryConverter(OracleConnection connection, GeometryFactory geometryFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected doubleasDouble(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 OracleStructasEmptyDataType()Representation ofnullas an EmptySDO_GEOMETRY.GeometryasGeometry(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 intasInteger(Datum datum, int DEFAULT)Presents datum as an intStringgetDataTypeName()Used to handle MDSYS.SDO_GEOMETRY.booleanisCapable(Geometry geom)Ensure that obj is a JTS Geometry (2D or 3D) with no LRS measures.protected OracleArraytoARRAY(double[] doubles, String dataType)Convenience method for OracleArray construction.protected OracleArraytoARRAY(int[] ints, String dataType)Convenience method for OracleArray construction.protected OracleArraytoATTRIBUTE(double[] ords, String desc)protected CHARtoCHAR(String s)Convenience method for CHAR constructionprotected NUMBERtoNUMBER(double number)Convenience method for NUMBER construction.protected NUMBERtoNUMBER(int number)Convenience method for NUMBER constructionprotected OracleArraytoORDINATE(double[] ords)protected OracleArraytoORDINATE(CoordinateList list, double[][] measures, int D)Convenience method for OracleArray construction.OracleStructtoSDO(Geometry geom)Used to convert double[] to SDO_ODINATE_ARRAY.OracleStructtoSDO(Geometry geom, int srid)Used to convert double[] to SDO_ODINATE_ARRAY.protected OracleStructtoSTRUCT(Datum[] attributes, String dataType)Convenience method for OracleStruct construction.
-
-
-
Field Detail
-
connection
protected OracleConnection connection
-
DATATYPE
public static final String DATATYPE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GeometryConverter
public GeometryConverter(OracleConnection connection)
-
GeometryConverter
public GeometryConverter(OracleConnection connection, GeometryFactory geometryFactory)
-
-
Method Detail
-
getDataTypeName
public String getDataTypeName()
Used to handle MDSYS.SDO_GEOMETRY.- Returns:
MDSYS.SDO_GEOMETRY- See Also:
DATATYPE
-
isCapable
public boolean isCapable(Geometry geom)
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:
trueifobjis a JTS Geometry
-
asGeometry
public Geometry asGeometry(OracleStruct sdoGeometry) throws SQLException
Convert provided SDO_GEOMETRY to JTS Geometry.Will return
nullasnull.- Parameters:
sdoGeometry- datum STRUCT to be converted to a geometry- Returns:
- JTS
Geometryrepresenting the provideddatum - Throws:
SQLException
-
toSDO
public OracleStruct toSDO(Geometry geom) throws SQLException
Used to convert double[] to SDO_ODINATE_ARRAY.Will return
nullas an emptySDO_GEOMETRY- Parameters:
geom- Map to be represented as a STRUCT- Returns:
- Struct representing provided Map
- Throws:
SQLException
-
toSDO
public OracleStruct toSDO(Geometry geom, int srid) throws SQLException
Used to convert double[] to SDO_ODINATE_ARRAY.Will return
nullas an emptySDO_GEOMETRY- Parameters:
geom- Map to be represented as a STRUCT- Returns:
- STRUCT representing provided Map
- Throws:
SQLException
-
asEmptyDataType
protected OracleStruct asEmptyDataType() throws SQLExceptionRepresentation ofnullas an EmptySDO_GEOMETRY.- Returns:
nullas a SDO_GEOMETRY- Throws:
SQLException
-
toSTRUCT
protected final OracleStruct toSTRUCT(Datum[] attributes, String dataType) throws SQLExceptionConvenience method for OracleStruct construction.- Throws:
SQLException
-
toARRAY
protected final OracleArray toARRAY(double[] doubles, String dataType) throws SQLExceptionConvenience method for OracleArray construction.Compare and contrast with toORDINATE - which treats
Double.NaNasNULL- 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
NULLnumbers 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
NULLNUMBERs.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) }- Parameters:
list- CoordinateList to be representedmeasures- Per Coordinate Measures,nullif not requiredD- Dimension of Coordinates (limited to 2d, 3d)- Throws:
SQLException
- JTS: records lack of data as
-
toORDINATE
protected final OracleArray toORDINATE(double[] ords) throws SQLException- Throws:
SQLException
-
toATTRIBUTE
protected final OracleArray toATTRIBUTE(double[] ords, String desc) throws SQLException- Throws:
SQLException
-
toNUMBER
protected final NUMBER toNUMBER(double number) throws SQLExceptionConvenience method for NUMBER construction.Double.NaN is represented as
NULLto agree with JTS use.- Throws:
SQLException
-
toARRAY
protected final OracleArray toARRAY(int[] ints, String dataType) throws SQLExceptionConvenience method for OracleArray construction.- Throws:
SQLException
-
toNUMBER
protected final NUMBER toNUMBER(int number)
Convenience method for NUMBER construction
-
toCHAR
protected final CHAR toCHAR(String s)
Convenience method for CHAR construction
-
asInteger
protected int asInteger(Datum datum, int DEFAULT) throws SQLExceptionPresents datum as an int- Throws:
SQLException
-
asDouble
protected double asDouble(Datum datum, double DEFAULT) throws SQLExceptionPresents datum as a double- Throws:
SQLException
-
asDoubleArray
protected double[] asDoubleArray(OracleStruct struct, double DEFAULT) throws SQLExceptionPresents struct as a double[]- Throws:
SQLException
-
asDoubleArray
protected double[] asDoubleArray(OracleArray array, double DEFAULT) throws SQLExceptionPresents array as a double[]- Throws:
SQLException
-
asDoubleArray
protected double[] asDoubleArray(Datum[] data, double DEFAULT) throws SQLExceptionPresents Datum[] as a double[]- Throws:
SQLException
-
asIntArray
protected int[] asIntArray(OracleArray array, int DEFAULT) throws SQLException- Throws:
SQLException
-
asIntArray
protected int[] asIntArray(Datum[] data, int DEFAULT) throws SQLExceptionPresents Datum[] as a int[]- Throws:
SQLException
-
-