org.geotools.data.oracle.attributeio
Class AdapterJTS

java.lang.Object
  extended byorg.geotools.data.oracle.attributeio.AdapterJTS
All Implemented Interfaces:
oracle.sdoapi.adapter.GeometryAdapter

public class AdapterJTS
extends java.lang.Object
implements oracle.sdoapi.adapter.GeometryAdapter

Adapter class that handles the conversion between SDO and JTS geometry classes.

Version:
$Id: AdapterJTS.java,v 1.6 2003/10/24 02:47:50 seangeo Exp $
Author:
Sean Geoghegan, Defence Science and Technology Organisation, $Author: seangeo $

Constructor Summary
AdapterJTS()
          Creates a new AdapterJTS that uses the default SDO and JTS geometry factories.
AdapterJTS(com.vividsolutions.jts.geom.GeometryFactory jtsFactory)
          Creates a new AdapterJTS that uses the supplied JTS geometry factory and the default SDO geometry factory.
AdapterJTS(oracle.sdoapi.geom.GeometryFactory sdoFactory)
          Creates a new AdapterJTS that uses the supplied SDO geometry Factory and the default JTS geometry factory.
AdapterJTS(com.vividsolutions.jts.geom.GeometryFactory jtsFactory, oracle.sdoapi.geom.GeometryFactory sdoFactory)
          Creates a new AdapterJTS that uses the supplied geometry factories.
 
Method Summary
 java.lang.Object exportGeometry(java.lang.Class outputType, oracle.sdoapi.geom.Geometry geom)
          Converts an Oracle SDO Geometry into a JTS Geometry.
 void exportGeometry(java.lang.Object outputObject, oracle.sdoapi.geom.Geometry geom)
          Not supported by this implementation.
 oracle.sdoapi.sref.SpatialReference getDefaultSRS()
          Gets the default SpatialReference.
 java.lang.String getFormatName()
          Gets the format name that this adapter supports.
 java.lang.String getFormatVersion()
          Gets the format version.
 java.lang.Class[] getSupportedInputTypes()
          Returns the supported input types.
 java.lang.Class[] getSupportedOutputTypes()
          Returns the supported output types.
 java.lang.Class[] getSupportedPassthroughOutputTypes()
          Gets the supported pass through output types.
 oracle.sdoapi.geom.Geometry importGeometry(java.lang.Object inputSource)
          Converts a JTS geometry to an SDO geometry.
 oracle.sdoapi.geom.Geometry importGeometry(java.lang.Object inputSource, int nDim)
          This method redirects to importGeometry(Object) since dimemsionality is ignored.
 boolean inputTypeSupported(java.lang.Class type)
          Determines whether this adapter supports conversion to SDO Geometry from the given class.
 boolean outputTypeSupported(java.lang.Class type)
          Determines whether this adapter can convert SDO geometries to the given type.
 boolean passthroughOutputTypeSupported(java.lang.Class type)
          Always returns false since this adpater does not support any passthrough conversion.
 void setDefaultSRS(oracle.sdoapi.sref.SpatialReference sr)
          Sets the default SRS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdapterJTS

public AdapterJTS()
Creates a new AdapterJTS that uses the default SDO and JTS geometry factories.


AdapterJTS

public AdapterJTS(com.vividsolutions.jts.geom.GeometryFactory jtsFactory)
Creates a new AdapterJTS that uses the supplied JTS geometry factory and the default SDO geometry factory.

Parameters:
jtsFactory - The JTS geometry factory.

AdapterJTS

public AdapterJTS(com.vividsolutions.jts.geom.GeometryFactory jtsFactory,
                  oracle.sdoapi.geom.GeometryFactory sdoFactory)
Creates a new AdapterJTS that uses the supplied geometry factories.

Parameters:
jtsFactory - The JTS geometry factory.
sdoFactory - The SDO geometry factory.

AdapterJTS

public AdapterJTS(oracle.sdoapi.geom.GeometryFactory sdoFactory)
Creates a new AdapterJTS that uses the supplied SDO geometry Factory and the default JTS geometry factory.

Parameters:
sdoFactory - The SDO geometry factory.
Method Detail

exportGeometry

public java.lang.Object exportGeometry(java.lang.Class outputType,
                                       oracle.sdoapi.geom.Geometry geom)
                                throws oracle.sdoapi.geom.InvalidGeometryException,
                                       oracle.sdoapi.adapter.GeometryOutputTypeNotSupportedException
Converts an Oracle SDO Geometry into a JTS Geometry.

Specified by:
exportGeometry in interface oracle.sdoapi.adapter.GeometryAdapter
Parameters:
outputType - The output type. This must be one of the supported output types.
geom - The SDO Geometry to convert.
Returns:
The JTS geometry.
Throws:
oracle.sdoapi.geom.InvalidGeometryException - Throw in the input geometry cannot be converted.
oracle.sdoapi.adapter.GeometryOutputTypeNotSupportedException - Throw if the outputType is not supported.
See Also:
GeometryAdapter.exportGeometry(java.lang.Class, oracle.sdoapi.geom.Geometry)

exportGeometry

public void exportGeometry(java.lang.Object outputObject,
                           oracle.sdoapi.geom.Geometry geom)
                    throws oracle.sdoapi.geom.InvalidGeometryException,
                           oracle.sdoapi.adapter.GeometryOutputTypeNotSupportedException
Not supported by this implementation. This adapter does not support converting SDO geometries into existing objects. Calling this method will throw a GeometryOutputTypeNotSupportedException.

This method is not implemented because it is not needed by the OracleDataSource. Since the OracleDataSource is the only Geotools, entry point into Oracle Spatial Database leaving this as an unsupported operation is safe.

Specified by:
exportGeometry in interface oracle.sdoapi.adapter.GeometryAdapter
Parameters:
outputObject - The object to output to.
geom - The SDO Geometry to convert.
Throws:
oracle.sdoapi.geom.InvalidGeometryException - Throw in the input geometry cannot be converted.
oracle.sdoapi.adapter.GeometryOutputTypeNotSupportedException - Throw if the outputType is not supported.
See Also:
GeometryAdapter.exportGeometry(java.lang.Object, oracle.sdoapi.geom.Geometry)

importGeometry

public oracle.sdoapi.geom.Geometry importGeometry(java.lang.Object inputSource)
                                           throws oracle.sdoapi.geom.InvalidGeometryException,
                                                  oracle.sdoapi.adapter.GeometryInputTypeNotSupportedException
Converts a JTS geometry to an SDO geometry.

Specified by:
importGeometry in interface oracle.sdoapi.adapter.GeometryAdapter
Parameters:
inputSource - The JTS geometry
Returns:
An SDO geometry.
Throws:
oracle.sdoapi.geom.InvalidGeometryException - Throw in the input geometry cannot be converted.
oracle.sdoapi.adapter.GeometryInputTypeNotSupportedException - Thrown if the inputType is not supported.
See Also:
GeometryAdapter.importGeometry(java.lang.Object)

importGeometry

public oracle.sdoapi.geom.Geometry importGeometry(java.lang.Object inputSource,
                                                  int nDim)
                                           throws oracle.sdoapi.geom.InvalidGeometryException,
                                                  oracle.sdoapi.adapter.GeometryInputTypeNotSupportedException
This method redirects to importGeometry(Object) since dimemsionality is ignored. We can ignore dimensionality since both JTS and the SDO API only support 3D coordinates, therefore if we try to put a 2D JTS geometry within a 3D SDO Geometry, the z coordinate will be left as 0.

Specified by:
importGeometry in interface oracle.sdoapi.adapter.GeometryAdapter
Parameters:
inputSource - The input JTS geometry.
nDim - IGNORED
Returns:
The SDO geometry.
Throws:
oracle.sdoapi.geom.InvalidGeometryException - Throw in the input geometry cannot be converted.
oracle.sdoapi.adapter.GeometryInputTypeNotSupportedException - Throw if the input Type is not supported.
See Also:
GeometryAdapter.importGeometry(java.lang.Object, int)

inputTypeSupported

public boolean inputTypeSupported(java.lang.Class type)
Determines whether this adapter supports conversion to SDO Geometry from the given class.

Specified by:
inputTypeSupported in interface oracle.sdoapi.adapter.GeometryAdapter
Parameters:
type - The class to test for conversion support.
Returns:
True if the adapter can convert type to an SDO geometry.
See Also:
GeometryAdapter.inputTypeSupported(java.lang.Class), getSupportedInputTypes()

outputTypeSupported

public boolean outputTypeSupported(java.lang.Class type)
Determines whether this adapter can convert SDO geometries to the given type.

Specified by:
outputTypeSupported in interface oracle.sdoapi.adapter.GeometryAdapter
Parameters:
type - The class to test for conversion support
Returns:
True if the adapter can convert SDO geometries to type.
See Also:
GeometryAdapter.outputTypeSupported(java.lang.Class), getSupportedOutputTypes()

passthroughOutputTypeSupported

public boolean passthroughOutputTypeSupported(java.lang.Class type)
Always returns false since this adpater does not support any passthrough conversion.

Specified by:
passthroughOutputTypeSupported in interface oracle.sdoapi.adapter.GeometryAdapter
Parameters:
type - The type to check
Returns:
Always false.
See Also:
GeometryAdapter.passthroughOutputTypeSupported(java.lang.Class)

getSupportedInputTypes

public java.lang.Class[] getSupportedInputTypes()
Returns the supported input types.

Specified by:
getSupportedInputTypes in interface oracle.sdoapi.adapter.GeometryAdapter
Returns:
The types that this adapter can convert to SDO Geometry objects. In this case we support importing from com.vividsolutions.jts.geom.Geometry objects.
See Also:
GeometryAdapter.getSupportedInputTypes()

getSupportedOutputTypes

public java.lang.Class[] getSupportedOutputTypes()
Returns the supported output types.

Specified by:
getSupportedOutputTypes in interface oracle.sdoapi.adapter.GeometryAdapter
Returns:
The types that this adapter can convert SDO Geometry object to. In this case we support exporting to com.vividsolutiions.jts.geom.Geometry objects.
See Also:
GeometryAdapter.getSupportedOutputTypes()

getSupportedPassthroughOutputTypes

public java.lang.Class[] getSupportedPassthroughOutputTypes()
Gets the supported pass through output types. This adapter does not support pass through types.

Specified by:
getSupportedPassthroughOutputTypes in interface oracle.sdoapi.adapter.GeometryAdapter
Returns:
An empty Class[].
See Also:
GeometryAdapter.getSupportedPassthroughOutputTypes()

getFormatName

public java.lang.String getFormatName()
Gets the format name that this adapter supports.

Specified by:
getFormatName in interface oracle.sdoapi.adapter.GeometryAdapter
Returns:
The format name. In this case "JTS".
See Also:
GeometryAdapter.getFormatName()

getFormatVersion

public java.lang.String getFormatVersion()
Gets the format version.

Specified by:
getFormatVersion in interface oracle.sdoapi.adapter.GeometryAdapter
Returns:
The format version. In this case "1.3"
See Also:
GeometryAdapter.getFormatVersion()

setDefaultSRS

public void setDefaultSRS(oracle.sdoapi.sref.SpatialReference sr)
Sets the default SRS.

Specified by:
setDefaultSRS in interface oracle.sdoapi.adapter.GeometryAdapter
Parameters:
sr - The new default spatial reference system id.
See Also:
GeometryAdapter.setDefaultSRS(oracle.sdoapi.sref.SpatialReference)

getDefaultSRS

public oracle.sdoapi.sref.SpatialReference getDefaultSRS()
Gets the default SpatialReference.

Specified by:
getDefaultSRS in interface oracle.sdoapi.adapter.GeometryAdapter
Returns:
The SpatialReference of the SDO geometry Factory.


Copyright © GeoTools. All Rights Reserved.