com.mizar.persistence.jdbc.convert
Class JdbcShapeFileWriter

java.lang.Object
  extended by com.mizar.persistence.jdbc.convert.JdbcShapeFileWriter

public class JdbcShapeFileWriter
extends java.lang.Object


Constructor Summary
JdbcShapeFileWriter()
           
JdbcShapeFileWriter(java.sql.ResultSet resultSet, java.lang.String baseFileName)
           
 
Method Summary
 void close()
           
 com.vividsolutions.jts.geom.LineString createLineString(oracle.spatial.geometry.JGeometry geometry)
           
 com.vividsolutions.jts.geom.MultiPolygon createMultiPolygon(oracle.spatial.geometry.JGeometry geometry)
           
 com.vividsolutions.jts.geom.Point createPoint(oracle.spatial.geometry.JGeometry geometry)
           
 com.vividsolutions.jts.geom.Polygon createPolygon(oracle.spatial.geometry.JGeometry geometry)
           
static java.sql.ResultSet createRewindableResultSet(java.sql.Connection conn, java.lang.String query)
           
static java.sql.ResultSet createRewindableResultSet(java.sql.Connection conn, java.lang.String queryRoot, int srid, double xlo, double ylo, double xhi, double yhi)
           
static java.sql.ResultSet createRewindableResultSet(java.sql.Connection conn, java.lang.String table, java.lang.String columns, int srid, double[] range)
           
static java.sql.ResultSet createRewindableResultSet(java.sql.Connection conn, java.lang.String table, java.lang.String columns, int srid, double xlo, double ylo, double xhi, double yhi)
           
static java.sql.ResultSet createRewindableResultSetByGeometryType(java.sql.Connection conn, java.lang.String table, java.lang.String columns, int dim, int geometryType)
           
 int createShapeFile()
           
 java.lang.String getBaseFileName()
           
 int getCommonGeometryType()
           
 java.sql.Connection getConn()
           
 JdbcDbaseWriter getDbaseCreator()
           
 int getGeometryColumnIndex()
           
 java.lang.String getGeometryColumnName()
           
 int getGeometryTypeFilter()
           
 java.sql.ResultSet getResultSet()
           
 org.geotools.data.shapefile.shp.ShapeType getShapeType()
           
 int getSrid()
           
 java.lang.String getStatus()
           
 int getValidRows()
           
 boolean isHeterogeneousGeometryTypes()
           
static void main(java.lang.String[] args)
           
 void setBaseFileName(java.lang.String fileName)
           
 void setConn(java.sql.Connection conn)
           
 void setDbaseCreator(JdbcDbaseWriter dbaseWriter)
           
 void setGeometryColumnName(java.lang.String geometryColumnName)
          By default the class will use the first SDO_GEOMETRY column in the table if there are multiple SDO_GEOMETRY columns and the desired column is not the first one then the geometry column name can be set using this setter.
 void setGeometryTypeFilter(int geometryTypeFilter)
           
 void setResultSet(java.sql.ResultSet resultSet)
           
 void setShapeType(org.geotools.data.shapefile.shp.ShapeType shapeType)
           
 void setSrid(int srid)
           
 int validRows(java.sql.ResultSet rs)
           
 int writeHeader()
           
 boolean writeRow()
           
 int writeRows()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcShapeFileWriter

public JdbcShapeFileWriter()

JdbcShapeFileWriter

public JdbcShapeFileWriter(java.sql.ResultSet resultSet,
                           java.lang.String baseFileName)
                    throws java.sql.SQLException
Parameters:
resultSet - a rewindable ResultSet
baseFileName - the filename root including the path, but excluding the extention which will be added by this class
Throws:
java.sql.SQLException
Method Detail

createRewindableResultSet

public static java.sql.ResultSet createRewindableResultSet(java.sql.Connection conn,
                                                           java.lang.String query)
                                                    throws java.sql.SQLException
Parameters:
conn - an open Connection
query - a valid SQL select statement that contains an SDO_GEOMETRY column.
Returns:
Throws:
java.sql.SQLException

createRewindableResultSet

public static java.sql.ResultSet createRewindableResultSet(java.sql.Connection conn,
                                                           java.lang.String table,
                                                           java.lang.String columns,
                                                           int srid,
                                                           double[] range)
                                                    throws java.sql.SQLException
Parameters:
conn - an open connection
table - the name of the table to select rows from
columns - one or more comma separated column names
srid - the spatial reference identifier to return the results in
range - the range of the query {xlo,ylo,xhi,yhi}
Returns:
Throws:
java.sql.SQLException

createRewindableResultSet

public static java.sql.ResultSet createRewindableResultSet(java.sql.Connection conn,
                                                           java.lang.String table,
                                                           java.lang.String columns,
                                                           int srid,
                                                           double xlo,
                                                           double ylo,
                                                           double xhi,
                                                           double yhi)
                                                    throws java.sql.SQLException
Parameters:
conn - an open connection
table - the name of the table to select rows from
columns - one or more comma separated column names
srid - the spaial reference identifier to return the results in
xlo - the low x ordinate for the query
ylo - the low y ordinate for the query
xhi - the high x ordinate for the query
yhi - the high y ordinate for the query
Returns:
Throws:
java.sql.SQLException

createRewindableResultSet

public static java.sql.ResultSet createRewindableResultSet(java.sql.Connection conn,
                                                           java.lang.String queryRoot,
                                                           int srid,
                                                           double xlo,
                                                           double ylo,
                                                           double xhi,
                                                           double yhi)
                                                    throws java.sql.SQLException
Parameters:
conn - an open connection
queryRoot - a select SQL statement in the form "select col1,col2 from tablename ms where (condition) ". This method will append " and {Range condition}" NOTE: the spatial tablename must have an alias of "ms"
srid - the spaial reference identifier to return the results in
xlo - the low x ordinate for the query
ylo - the low y ordinate for the query
xhi - the high x ordinate for the query
yhi - the high y ordinate for the query
Returns:
Throws:
java.sql.SQLException

createRewindableResultSetByGeometryType

public static java.sql.ResultSet createRewindableResultSetByGeometryType(java.sql.Connection conn,
                                                                         java.lang.String table,
                                                                         java.lang.String columns,
                                                                         int dim,
                                                                         int geometryType)
                                                                  throws java.sql.SQLException
Throws:
java.sql.SQLException

createShapeFile

public int createShapeFile()
                    throws java.sql.SQLException,
                           java.io.IOException,
                           org.geotools.data.shapefile.dbf.DbaseFileException
Throws:
java.sql.SQLException
java.io.IOException
org.geotools.data.shapefile.dbf.DbaseFileException

writeHeader

public int writeHeader()
                throws java.sql.SQLException,
                       java.io.IOException,
                       org.geotools.data.shapefile.dbf.DbaseFileException
Throws:
java.sql.SQLException
java.io.IOException
org.geotools.data.shapefile.dbf.DbaseFileException

writeRows

public int writeRows()
              throws java.sql.SQLException,
                     java.io.IOException,
                     org.geotools.data.shapefile.dbf.DbaseFileException
Throws:
java.sql.SQLException
java.io.IOException
org.geotools.data.shapefile.dbf.DbaseFileException

writeRow

public boolean writeRow()
                 throws java.sql.SQLException,
                        java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

createPoint

public com.vividsolutions.jts.geom.Point createPoint(oracle.spatial.geometry.JGeometry geometry)

createLineString

public com.vividsolutions.jts.geom.LineString createLineString(oracle.spatial.geometry.JGeometry geometry)

createPolygon

public com.vividsolutions.jts.geom.Polygon createPolygon(oracle.spatial.geometry.JGeometry geometry)

createMultiPolygon

public com.vividsolutions.jts.geom.MultiPolygon createMultiPolygon(oracle.spatial.geometry.JGeometry geometry)

close

public void close()
           throws java.sql.SQLException,
                  java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

validRows

public int validRows(java.sql.ResultSet rs)
              throws java.sql.SQLException
Parameters:
rs - a rewindable ResultSet
Returns:
the number of rows with valid SDO_GEOMETRY columns
Throws:
java.sql.SQLException

setConn

public void setConn(java.sql.Connection conn)

getConn

public java.sql.Connection getConn()

setResultSet

public void setResultSet(java.sql.ResultSet resultSet)

getResultSet

public java.sql.ResultSet getResultSet()

setBaseFileName

public void setBaseFileName(java.lang.String fileName)

getBaseFileName

public java.lang.String getBaseFileName()

setGeometryColumnName

public void setGeometryColumnName(java.lang.String geometryColumnName)
By default the class will use the first SDO_GEOMETRY column in the table if there are multiple SDO_GEOMETRY columns and the desired column is not the first one then the geometry column name can be set using this setter.

Parameters:
geometryColumnName -

getGeometryColumnName

public java.lang.String getGeometryColumnName()

setDbaseCreator

public void setDbaseCreator(JdbcDbaseWriter dbaseWriter)

getDbaseCreator

public JdbcDbaseWriter getDbaseCreator()

getGeometryColumnIndex

public int getGeometryColumnIndex()
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

getValidRows

public int getValidRows()

isHeterogeneousGeometryTypes

public boolean isHeterogeneousGeometryTypes()

getCommonGeometryType

public int getCommonGeometryType()

getStatus

public java.lang.String getStatus()

setSrid

public void setSrid(int srid)

getSrid

public int getSrid()

main

public static void main(java.lang.String[] args)

setGeometryTypeFilter

public void setGeometryTypeFilter(int geometryTypeFilter)

getGeometryTypeFilter

public int getGeometryTypeFilter()

setShapeType

public void setShapeType(org.geotools.data.shapefile.shp.ShapeType shapeType)

getShapeType

public org.geotools.data.shapefile.shp.ShapeType getShapeType()