org.geotools.data.mysql
Class MysqlGeomColumn

java.lang.Object
  extended byorg.geotools.data.mysql.MysqlGeomColumn

public class MysqlGeomColumn
extends java.lang.Object

MysqlGeoColumn is used by MysqlDataSource to query its specific geometric information. There should be one created for each geometry column of each feature table. It encapsulates information about the column, such as the name of the corresponding geometric table, the storage type used by that table, the type of geometry contained, and various other useful information culled from the GEOMETRY_COLUMNS table. It also generates the geometries of the column when queried with the ID from the feature table.

Version:
$Id: MysqlGeomColumn.java 17700 2006-01-22 23:30:39Z desruisseaux $
Author:
Chris Holmes, Vision for New York

Field Summary
static java.lang.String GEOMETRY_META_NAME
          From the SFS for SQL spec, always has the meta data
static int NORMALIZED_STORAGE_TYPE
          For get and set Storage type, see SFS for SQL spec
static int WKB_STORAGE_TYPE
          For get and set Storage type, see SFS for SQL spec, the Well Known Binary
 
Constructor Summary
MysqlGeomColumn()
          Default constructor
MysqlGeomColumn(java.sql.Connection dbConnection, java.lang.String feaTableName)
          A convenience constructor, when you there is an open connection, and only using flat features.
MysqlGeomColumn(java.lang.String feaTabName, java.lang.String feaGeomColumn, java.lang.String geomTabName)
          Convenience constructor with the minimum meta information needed to do anything useful.
 
Method Summary
 java.lang.String getFeaTableCat()
          Getter method for Feature Catalog.
 java.lang.String getFeaTableName()
          Getter method for feature table name.
 java.lang.String getFeaTableSchema()
          Getter method for feature schema.
 java.lang.String getGeomColName()
          Getter method for geometry column.
 com.vividsolutions.jts.geom.Geometry getGeometry(int geomID)
          Returns a jts Geometry when queried with a geometry ID.
 java.lang.String getGeomTableCat()
          Getter method for Geometry Catalog.
 java.lang.String getGeomTableName()
          Getter method for geometry table name.
 java.lang.String getGeomTableSchema()
          Getter method for geometry schema
 int getGeomType()
          Gets the Geometry type of the geometry column.
 FeatureType getSchema()
          Gets the schema for this geometry column.
 int getStorageType()
          Gets the type used for storage in the geometry column.
static FeatureType makeSchema(java.sql.ResultSetMetaData metaData, java.lang.String geoColumn)
          Creates the schema, a FeatureType of the attributes.
 void populateData(int geomID, java.lang.String wellKnownText)
          Stores the geometry information by geometry ID, so that it can be queried later.
 void removeData(int geomID)
          Takes out a geometry according to its ID.
 void setFeaTableCat(java.lang.String catalog)
          Setter method for feature catalog.
 void setFeaTableName(java.lang.String name)
          Setter method for feature table name.
 void setFeaTableSchema(java.lang.String schema)
          Setter method for feature schema.
 void setGeomColName(java.lang.String name)
          Setter method for geometry column.
 void setGeomTableCat(java.lang.String catalog)
          Setter method for geometry catalog.
 void setGeomTableName(java.lang.String name)
          Setter method for geometry table name.
 void setGeomTableSchema(java.lang.String schema)
          Setter method for geometry schema.
 void setGeomType(int gType)
          Sets the Geometry type of the geometry column.
 void setSchema(FeatureType schema)
          sets the schema for this geometry column.
 void setStorageType(int sType)
          Sets the type used for storage in the geometry column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORMALIZED_STORAGE_TYPE

public static final int NORMALIZED_STORAGE_TYPE
For get and set Storage type, see SFS for SQL spec

See Also:
Constant Field Values

WKB_STORAGE_TYPE

public static final int WKB_STORAGE_TYPE
For get and set Storage type, see SFS for SQL spec, the Well Known Binary

See Also:
Constant Field Values

GEOMETRY_META_NAME

public static final java.lang.String GEOMETRY_META_NAME
From the SFS for SQL spec, always has the meta data

See Also:
Constant Field Values
Constructor Detail

MysqlGeomColumn

public MysqlGeomColumn()
Default constructor


MysqlGeomColumn

public MysqlGeomColumn(java.lang.String feaTabName,
                       java.lang.String feaGeomColumn,
                       java.lang.String geomTabName)
Convenience constructor with the minimum meta information needed to do anything useful.

Parameters:
feaTabName - The name of the feature table for this geometry.
feaGeomColumn - The name of the column in the feature table that refers to the MysqlGeomColumn.
geomTabName - The name of the table holding the geometry data.

MysqlGeomColumn

public MysqlGeomColumn(java.sql.Connection dbConnection,
                       java.lang.String feaTableName)
                throws java.sql.SQLException,
                       SchemaException
A convenience constructor, when you there is an open connection, and only using flat features. This constructor will not work with feature tables that contain multiple geometries as the query on the feature table will return multiple rows, which will be discarded. For multiple geometries an array of MysqlGeomColumns must be created, each initialized with the default constructor, filling in the values through the accesssor functions.

Parameters:
dbConnection - An open connection to the database.
feaTableName - The feature table that references this Geometry Col.
Throws:
java.sql.SQLException - if there were problems accessing the database.
SchemaException - if there were problems creating the schema.
Task:
TODO: Get rid of this constructor, move the functionality outside.
Method Detail

populateData

public void populateData(int geomID,
                         java.lang.String wellKnownText)
Stores the geometry information by geometry ID, so that it can be queried later. Currently only takes Well Known Text. This should eventually change to Well Known Binary, possible stored as a bit stream? And in time an overloaded populateData that allows for normalized SQL 92 storage.

Parameters:
geomID - the primary key for a row in the Geometry Table;
wellKnownText - the WKT representation of the geometry; tasks: TODO: Well Known Binary, and normalized SQL 92 (see SFS for for SQL spec 2.2.5)

removeData

public void removeData(int geomID)
Takes out a geometry according to its ID.

Parameters:
geomID - the primary key for a rwo in the Geometry Table

getGeometry

public com.vividsolutions.jts.geom.Geometry getGeometry(int geomID)
                                                 throws DataSourceException
Returns a jts Geometry when queried with a geometry ID.

Parameters:
geomID - the ID of the feature geometry.
Returns:
a jts geometry represention of the stored data, returns null is it is not found.
Throws:
DataSourceException - if there is trouble with the Database.

setFeaTableCat

public void setFeaTableCat(java.lang.String catalog)
Setter method for feature catalog.

Parameters:
catalog - the name of the catalog.

getFeaTableCat

public java.lang.String getFeaTableCat()
Getter method for Feature Catalog.

Returns:
the name of the catalog.

setFeaTableSchema

public void setFeaTableSchema(java.lang.String schema)
Setter method for feature schema.

Parameters:
schema - the name of the schema.

getFeaTableSchema

public java.lang.String getFeaTableSchema()
Getter method for feature schema.

Returns:
the name of the schema.

setFeaTableName

public void setFeaTableName(java.lang.String name)
Setter method for feature table name.

Parameters:
name - the name of the feature table.

getFeaTableName

public java.lang.String getFeaTableName()
Getter method for feature table name.

Returns:
the name of the feature table.

setGeomColName

public void setGeomColName(java.lang.String name)
Setter method for geometry column.

Parameters:
name - the name of the column.

getGeomColName

public java.lang.String getGeomColName()
Getter method for geometry column.

Returns:
the name of the column.

setGeomTableCat

public void setGeomTableCat(java.lang.String catalog)
Setter method for geometry catalog.

Parameters:
catalog - the name of the catalog.

getGeomTableCat

public java.lang.String getGeomTableCat()
Getter method for Geometry Catalog.

Returns:
the name of the catalog.

setGeomTableSchema

public void setGeomTableSchema(java.lang.String schema)
Setter method for geometry schema.

Parameters:
schema - the name of the catalog.

getGeomTableSchema

public java.lang.String getGeomTableSchema()
Getter method for geometry schema

Returns:
the name of the schema.

setGeomTableName

public void setGeomTableName(java.lang.String name)
Setter method for geometry table name.

Parameters:
name - the name of the geometry table.

getGeomTableName

public java.lang.String getGeomTableName()
Getter method for geometry table name.

Returns:
the name of the catalog.

setStorageType

public void setStorageType(int sType)
Sets the type used for storage in the geometry column.

Parameters:
sType - 0 for NORMALIZED_STORAGE_TYPE 1, for WKB_STORAGE_TYPE

getStorageType

public int getStorageType()
Gets the type used for storage in the geometry column.

Returns:
0 for NORMALIZED_STORAGE_TYPE, 1 for WKB_STORAGE_TYPE

setGeomType

public void setGeomType(int gType)
Sets the Geometry type of the geometry column.

Parameters:
gType - the geometery type

getGeomType

public int getGeomType()
Gets the Geometry type of the geometry column.

Returns:
the int representation of the GeometryType
Task:
TODO: implement a hashmap so we return jts Geometry Class Types instead of ints.

getSchema

public FeatureType getSchema()
Gets the schema for this geometry column.

Returns:
the schema corresponding to this geometry column.

setSchema

public void setSchema(FeatureType schema)
sets the schema for this geometry column.

Parameters:
schema - for this geometry column.

makeSchema

public static FeatureType makeSchema(java.sql.ResultSetMetaData metaData,
                                     java.lang.String geoColumn)
                              throws java.sql.SQLException,
                                     SchemaException
Creates the schema, a FeatureType of the attributes.

Parameters:
metaData - from the query of the feature table.
geoColumn - the name of the geometry column in the feature table.
Returns:
a FeatureType of the attributes.
Throws:
java.sql.SQLException - if there was database connectivity issues.
SchemaException - if there was problems creating the FeatureType.
To Do:
Fix FeatureType name - IanS tasks TODO: put this method MysqlGeomColumn or a SchemaFactory.


Copyright © GeoTools. All Rights Reserved.