org.geotools.data.arcsde
Class GeometryBuilder

java.lang.Object
  extended byorg.geotools.data.arcsde.GeometryBuilder

public abstract class GeometryBuilder
extends java.lang.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

Version:
$Id: GeometryBuilder.java 17700 2006-01-22 23:30:39Z desruisseaux $
Author:
Gabriel Roldan, Axios Engineering

Field Summary
protected  com.vividsolutions.jts.geom.GeometryFactory factory
          JTS geometry factory subclasses use to map SeShapes to JTS ones
 
Method Summary
static GeometryBuilder builderFor(java.lang.Class jtsGeometryClass)
          Factory method that returns an instance of GeometryBuilder specialized in contructing JTS geometries of the JTS Geometry class passed as argument.
 com.vividsolutions.jts.geom.Geometry construct(com.esri.sde.sdk.client.SeShape shape)
          Takes an ArcSDE's SeShape and builds a JTS Geometry.
 com.esri.sde.sdk.client.SeShape constructShape(com.vividsolutions.jts.geom.Geometry geometry, com.esri.sde.sdk.client.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 com.vividsolutions.jts.geom.Geometry defaultValueFor(java.lang.Class geoClass)
          DOCUMENT ME!
protected  com.vividsolutions.jts.geom.Geometry getEmpty()
          returns an empty JTS geometry who's type is given by the GeometryBuilder subclass instance specialization that implements it.
protected abstract  com.vividsolutions.jts.geom.Geometry newGeometry(double[][][] coords)
          Builds a JTS Geometry who't type is given by the GeometryBuilder subclass instance specialization that implements it
protected  com.vividsolutions.jts.geom.Coordinate[] toCoords(double[] coordList)
          Builds an array of JTS Coordinate instances that's geometrically equals to the SeShape single coordinates array passed as argument.
protected  com.esri.sde.sdk.client.SDEPoint[] toPointsArray(com.vividsolutions.jts.geom.Coordinate[] coords)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

protected com.vividsolutions.jts.geom.GeometryFactory factory
JTS geometry factory subclasses use to map SeShapes to JTS ones

Method Detail

construct

public com.vividsolutions.jts.geom.Geometry construct(com.esri.sde.sdk.client.SeShape shape)
                                               throws com.esri.sde.sdk.client.SeException,
                                                      DataSourceException
Takes an ArcSDE's SeShape and builds a JTS Geometry. The geometry type constructed depends on this GeometryBuilder specialized subclass

Parameters:
shape - the ESRI's ArcSDE java api shape upon wich to create the new JTS geometry
Returns:
the type of JTS Geometry this subclass instance is specialized for or an empty geometry of the same class if shape.isNil()
Throws:
com.esri.sde.sdk.client.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 com.esri.sde.sdk.client.SeShape constructShape(com.vividsolutions.jts.geom.Geometry geometry,
                                                      com.esri.sde.sdk.client.SeCoordinateReference seSrs)
                                               throws GeometryBuildingException
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:
GeometryBuildingException - DOCUMENT ME!

newGeometry

protected abstract com.vividsolutions.jts.geom.Geometry newGeometry(double[][][] coords)
                                                             throws DataSourceException
Builds a JTS Geometry who't type is given by the GeometryBuilder subclass instance specialization that implements it

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

getEmpty

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

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

Returns:
an empty JTS geometry
Throws:
java.lang.UnsupportedOperationException - DOCUMENT ME!

toCoords

protected com.vividsolutions.jts.geom.Coordinate[] toCoords(double[] coordList)
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 com.esri.sde.sdk.client.SDEPoint[] toPointsArray(com.vividsolutions.jts.geom.Coordinate[] coords)
DOCUMENT ME!

Parameters:
coords - DOCUMENT ME!
Returns:
DOCUMENT ME!

builderFor

public static GeometryBuilder builderFor(java.lang.Class jtsGeometryClass)
                                  throws java.lang.IllegalArgumentException
Factory method that returns an instance of GeometryBuilder 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 -
Returns:
Throws:
java.lang.IllegalArgumentException - if jtsGeometryClass is not a concrete JTS Geometry class (like com.vividsolutions.jts.geom.MultiPoint.class i.e.)

defaultValueFor

public static com.vividsolutions.jts.geom.Geometry defaultValueFor(java.lang.Class geoClass)
DOCUMENT ME!

Parameters:
geoClass - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.lang.NullPointerException - DOCUMENT ME!


Copyright © GeoTools. All Rights Reserved.