org.deegree_impl.io.sdeapi
Class SpatialQuery

java.lang.Object
  extended byorg.deegree_impl.io.sdeapi.SpatialQuery

public class SpatialQuery
extends java.lang.Object

This class handles a complete ArcSDE request: If instanciated, the class can open a connection/instance of the specified ArcSDE server, set a bounding box as a spatial filter to query the defined layer. The resultset of the query contains the geometries as well as the tabular data associated with them. The table is stored as a deegree Table object whereas the geometries are stored as an array of deegree GM_Objects. Depending on the datatype of the geometries, the array of GM_Objects might be GM_Point, GM_Curve etc.

Some bits of sample code to create a query:

SpatialQuery sq = new SpatialQuery();
try {
 sq.openConnection(server, instance, database, user, password);
 sq.setLayer(layer);
 sq.setSpatialFilter(minX, minY, maxX, maxY);
 sp.runSpatialQuery();
 GM_Object[] deegree_gm_obj = sq.getGeometries();
 Table deegree_table = sq.getTable();
 sq.closeConnection();
} catch ( SeException sexp ) {
 System.out.println("SeException : " + sexp.getSeError().getErrDesc());
}

Version:
$Revision: 1.19 $ $Date: 2004/03/08 07:26:27 $
Author:
Markus Bedel, Andreas Poth

Field Summary
private  SeConnection conn
           
private  GM_Object[] deegreeGM_Objects
           
private  SeLayer layer
           
private  SeShape spatialFilter
           
private  SeTable table
           
 
Constructor Summary
SpatialQuery(java.lang.String server, int port, java.lang.String database, java.lang.String user, java.lang.String password)
          Creates a new SpatialQuery object.
 
Method Summary
 void closeConnection()
          Close the current connection to the ArcSDE server
throws SeException
private  void createGeometry(SeShape shape, java.util.ArrayList list)
          CreateGeometry - used with every row of the SpatialQuery Depending on the layers' geometries datatype different operations are made to create the appropriate object.
 GM_Object[] getGeometries()
          Get GM_Object[] containing the queried Geometries
returns null if no query has been done yet.
 SeLayer getLayer()
          Get the current SDE layer
returns null if it not yet set.
 SeShape getSpatialFilter()
          Get the current Spatial Filter
returns null if it not yet set.
private  Table initTable(SeRow row)
          Initialize Table object - used with first row of the SpatialQuery This method sets the TableName, TableColumnNames and their DataTypes
throws SeException
 void openConnection(java.lang.String server, int port, java.lang.String database, java.lang.String user, java.lang.String password)
          Connect to the ArcSDE server
throws SeException
 Table runSpatialQuery(java.lang.String[] cols)
          Runs a spatial query against the opened layer using the specified spatial filter.
 void setLayer(java.lang.String layername)
          Set a SDE layer to work on and appropriate table
throws SeException
 void setSpatialFilter(double minx, double miny, double maxx, double maxy)
          Set a SpatialFilter to Query (BoundingBox)
throws SeException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conn

private SeConnection conn

layer

private SeLayer layer

spatialFilter

private SeShape spatialFilter

table

private SeTable table

deegreeGM_Objects

private GM_Object[] deegreeGM_Objects
Constructor Detail

SpatialQuery

public SpatialQuery(java.lang.String server,
                    int port,
                    java.lang.String database,
                    java.lang.String user,
                    java.lang.String password)
             throws SeException
Creates a new SpatialQuery object.

Parameters:
server -
port -
database -
user -
password -
Throws:
SeException
Method Detail

openConnection

public void openConnection(java.lang.String server,
                           int port,
                           java.lang.String database,
                           java.lang.String user,
                           java.lang.String password)
                    throws SeException
Connect to the ArcSDE server
throws SeException

Throws:
SeException

closeConnection

public void closeConnection()
                     throws SeException
Close the current connection to the ArcSDE server
throws SeException

Throws:
SeException

setLayer

public void setLayer(java.lang.String layername)
              throws SeException
Set a SDE layer to work on and appropriate table
throws SeException

Throws:
SeException

getLayer

public SeLayer getLayer()
Get the current SDE layer
returns null if it not yet set.


setSpatialFilter

public void setSpatialFilter(double minx,
                             double miny,
                             double maxx,
                             double maxy)
                      throws SeException
Set a SpatialFilter to Query (BoundingBox)
throws SeException

Throws:
SeException

getSpatialFilter

public SeShape getSpatialFilter()
Get the current Spatial Filter
returns null if it not yet set.


getGeometries

public GM_Object[] getGeometries()
Get GM_Object[] containing the queried Geometries
returns null if no query has been done yet.


runSpatialQuery

public Table runSpatialQuery(java.lang.String[] cols)
                      throws SeException
Runs a spatial query against the opened layer using the specified spatial filter.
throws SeException

Throws:
SeException

initTable

private Table initTable(SeRow row)
                 throws SeException
Initialize Table object - used with first row of the SpatialQuery This method sets the TableName, TableColumnNames and their DataTypes
throws SeException

Throws:
SeException

createGeometry

private void createGeometry(SeShape shape,
                            java.util.ArrayList list)
                     throws SeException
CreateGeometry - used with every row of the SpatialQuery Depending on the layers' geometries datatype different operations are made to create the appropriate object.
Available ArcSDE ShapeTypes:
TYPE_POINT (impl)
TYPE_MULTI_POINT (impl)
TYPE_SIMPLE_LINE (impl)
TYPE_MULTI_SIMPLE_LINE (impl)
TYPE_LINE (impl)
TYPE_MULTI_LINE (impl)
TYPE_POLYGON (impl)
TYPE_MULTI_POLYGON (impl)
TYPE_NIL (impl)
throws SeException

Throws:
SeException