org.geotools.arcsde.data
Class ArcSDEGeometryBuilder

Object
  extended by ArcSDEGeometryBuilder

public abstract class ArcSDEGeometryBuilder
extends Object

Creates propper JTS Geometry objects from SeShape objects and viceversa.

SeShape's are gathered from an SeRow ArcSDE API's result object and holds it's geometry attributes as a three dimensional array of double primitives as explained bellow.

By this way, we avoid the creation of ArcSDE's java implementation of OGC geometries for later translation to JTS, avoiding too the dependency on the ArcSDE native library wich the geometry package of the ArcSDE Java API depends on.

Given double [][][]coords the meaning of this array is as follow:

This abstract class will use specialized subclass for constructing the propper geometry type

Author:
Gabriel Roldan, Axios Engineering
Module:

Method Summary
static ArcSDEGeometryBuilder builderFor(Class<? extends Geometry> jtsGeometryClass)
          Factory method that returns an instance of ArcSDEGeometryBuilder specialized in contructing JTS geometries of the JTS Geometry class passed as argument.
 Geometry construct(SeShape shape, GeometryFactory geometryFactory)
          Takes an ArcSDE's SeShape and builds a JTS Geometry.
 SeShape constructShape(Geometry geometry, SeCoordinateReference seSrs)
          Creates the ArcSDE Java API representation of a Geometry object in its shape format, suitable to filter expressions as the SDE API expects
static Geometry defaultValueFor(Class<?> geoClass)
          Create an empty geometry for the indicated class
protected  Geometry getEmpty()
          returns an empty JTS geometry who's type is given by the ArcSDEGeometryBuilder subclass instance specialization that implements it.
protected abstract  Geometry newGeometry(double[][][] coords, GeometryFactory geometryFactory)
          Builds a JTS Geometry who't type is given by the ArcSDEGeometryBuilder subclass instance specialization that implements it
protected  CoordinateSequence toCoords(double[] coordList, CoordinateSequenceFactory csFact)
          Builds an array of JTS Coordinate instances that's geometrically equals to the SeShape single coordinates array passed as argument.
protected  SDEPoint[] toPointsArray(Coordinate[] coords)
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

construct

public Geometry construct(SeShape shape,
                          GeometryFactory geometryFactory)
                   throws SeException,
                          DataSourceException
Takes an ArcSDE's SeShape and builds a JTS Geometry. The geometry type constructed depends on this ArcSDEGeometryBuilder specialized subclass

Parameters:
shape - the ESRI's ArcSDE java api shape upon wich to create the new JTS geometry
geometryFactory -
Returns:
the type of JTS Geometry this subclass instance is specialized for or an empty geometry of the same class if shape.isNil()
Throws:
SeException - if it occurs fetching the coordinates array from shape
DataSourceException - if the com.vividsolutions.jts.geom.GeometryFactory this builder is backed by can't create the com.vividsolutions.jts.geom.Geometry with the com.vividsolutions.jts.geom.Coordinate[] provided by newGeometry

constructShape

public final SeShape constructShape(Geometry geometry,
                                    SeCoordinateReference seSrs)
                             throws ArcSdeException
Creates the ArcSDE Java API representation of a Geometry object in its shape format, suitable to filter expressions as the SDE API expects

Parameters:
geometry - the JTS Geometry object to get the SDE representation from
seSrs - Coordinate Reference System of the underlying SeLayer object for wich the SeShape is constructed.
Returns:
the SeShape representation of passed Geometry
Throws:
ArcSDEGeometryBuildingException
ArcSdeException

newGeometry

protected abstract Geometry newGeometry(double[][][] coords,
                                        GeometryFactory geometryFactory)
                                 throws DataSourceException
Builds a JTS Geometry who't type is given by the ArcSDEGeometryBuilder subclass instance specialization that implements it

Parameters:
coords - SeShape's coordinate array to build the geometry from
geometryFactory -
Returns:
the JST form of the passed geometry coordinates
Throws:
DataSourceException - if an error occurs while creating the JTS Geometry

getEmpty

protected Geometry getEmpty()
returns an empty JTS geometry who's type is given by the ArcSDEGeometryBuilder subclass instance specialization that implements it.

this method is called in case that SeShape.isNil() == true

Returns:
an empty JTS geometry
Throws:
UnsupportedOperationException

toCoords

protected final CoordinateSequence toCoords(double[] coordList,
                                            CoordinateSequenceFactory csFact)
Builds an array of JTS Coordinate instances that's geometrically equals to the SeShape single coordinates array passed as argument.

Parameters:
coordList - array of coordinates of a single shape part to build a Coordinate from
Returns:
a geometrically equal to coordList array of Coordinate instances

toPointsArray

protected SDEPoint[] toPointsArray(Coordinate[] coords)

builderFor

public static ArcSDEGeometryBuilder builderFor(Class<? extends Geometry> jtsGeometryClass)
                                        throws IllegalArgumentException
Factory method that returns an instance of ArcSDEGeometryBuilder specialized in contructing JTS geometries of the JTS Geometry class passed as argument. Note that jtsGeometryClass must be one of the supported concrete JTS Geometry classes.

Parameters:
jtsGeometryClass -
Throws:
IllegalArgumentException - if jtsGeometryClass is not a concrete JTS Geometry class (like com.vividsolutions.jts.geom.MultiPoint.class i.e.)

defaultValueFor

public static Geometry defaultValueFor(Class<?> geoClass)
Create an empty geometry for the indicated class



Copyright © 1996-2009 Geotools. All Rights Reserved.