net.sourceforge.hatbox.jts
Class Proc

java.lang.Object
  extended by net.sourceforge.hatbox.jts.Proc

public class Proc
extends java.lang.Object

Implementation of server side procedures

Author:
Peter Yuill

Method Summary
static void buildIndex(java.sql.Connection con, java.lang.String schema, java.lang.String table, int commitInterval, ProgressMonitor progressMonitor)
          Build the index for a spatial table.
static void buildIndexProc(java.lang.String schema, java.lang.String table, int commitInterval, ProgressMonitor progressMonitor)
           
static void delSpatial(java.lang.String schema, java.lang.String table, long id)
          Delete an entry from the index for a deleted row in the spatial table.
static void deSpatialize(java.sql.Connection con, java.lang.String schema, java.lang.String table)
          Despatialize a currently spatialized table.
static void deSpatializeProc(java.lang.String schema, java.lang.String table)
           
static java.lang.String getDefaultSchema(java.sql.Connection con)
           
static void insSpatial(java.lang.String schema, java.lang.String table, long id)
          Insert an entry into the index for an existing row in the spatial table.
static java.sql.ResultSet mbrIntersectsEnv(java.sql.Connection con, java.lang.String schema, java.lang.String table, double minx, double maxx, double miny, double maxy)
          A Table Function designed to provide the fastest possible intersection search at the cost of spatial inaccuracy ie an id is returned for each feature whose minimum bounding rectangle (MBR) intersects a rectangular search envelope.
static java.sql.ResultSet mbrIntersectsEnvFunc(java.lang.String schema, java.lang.String table, double minx, double maxx, double miny, double maxy)
           
static java.sql.ResultSet queryIntersectsWkb(java.sql.Connection con, java.lang.String schema, java.lang.String table, byte[] wkb)
           
static java.sql.ResultSet queryIntersectsWkbFunc(java.lang.String schema, java.lang.String table, byte[] wkb)
           
static java.sql.ResultSet queryIntersectsWkt(java.sql.Connection con, java.lang.String schema, java.lang.String table, java.lang.String wkt)
           
static java.sql.ResultSet queryIntersectsWktFunc(java.lang.String schema, java.lang.String table, java.lang.String wkt)
           
static java.sql.ResultSet queryWithPredicateWkb(java.sql.Connection con, java.lang.String schema, java.lang.String table, java.lang.String predicate, byte[] wkb)
           
static java.sql.ResultSet queryWithPredicateWkbFunc(java.lang.String schema, java.lang.String table, java.lang.String predicate, byte[] wkb)
           
static java.sql.ResultSet queryWithPredicateWkt(java.sql.Connection con, java.lang.String schema, java.lang.String table, java.lang.String predicate, java.lang.String wkt)
           
static java.sql.ResultSet queryWithPredicateWktFunc(java.lang.String schema, java.lang.String table, java.lang.String predicate, java.lang.String wkt)
           
static void saveEntry(java.lang.String schema, java.lang.String table, long id)
          This procedure is invoked from 'before delete' and 'before update' triggers.
static void spatialize(java.sql.Connection con, java.lang.String schema, java.lang.String table, java.lang.String geomColumn, java.lang.String geomType, java.lang.String srid, java.lang.String exposePK, java.lang.String entriesMax)
          Spatialize a currently non-spatialized table.
static void spatializeProc(java.lang.String schema, java.lang.String table, java.lang.String geomColumn, java.lang.String geomType, java.lang.String srid, java.lang.String exposePK, java.lang.String entriesMax)
           
static MetaNode spatialMetaData(java.sql.Connection con, java.lang.String schema, java.lang.String table)
           
static void updSpatial(java.lang.String schema, java.lang.String table, long id)
          Update an entry in the index for an existing row in the spatial table.
static java.lang.String wkbToWkt(byte[] wkb)
          Convert Well Known Binary byte array to Well Known Text string.
static byte[] wktToWkb(java.lang.String wkt)
          Convert Well Known Text string to Well Known Binary byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDefaultSchema

public static java.lang.String getDefaultSchema(java.sql.Connection con)
                                         throws java.sql.SQLException
Throws:
java.sql.SQLException

spatialMetaData

public static MetaNode spatialMetaData(java.sql.Connection con,
                                       java.lang.String schema,
                                       java.lang.String table)
                                throws java.sql.SQLException
Throws:
java.sql.SQLException

spatializeProc

public static void spatializeProc(java.lang.String schema,
                                  java.lang.String table,
                                  java.lang.String geomColumn,
                                  java.lang.String geomType,
                                  java.lang.String srid,
                                  java.lang.String exposePK,
                                  java.lang.String entriesMax)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

spatialize

public static void spatialize(java.sql.Connection con,
                              java.lang.String schema,
                              java.lang.String table,
                              java.lang.String geomColumn,
                              java.lang.String geomType,
                              java.lang.String srid,
                              java.lang.String exposePK,
                              java.lang.String entriesMax)
                       throws java.sql.SQLException
Spatialize a currently non-spatialized table. This creates the Hatbox table in 'NO_INDEX' mode. The index must be created separately if required.

There are no triggers created at this time, so bulk data loading can proceed efficiently.

The case of database object names must be specified exactly as recorded in database meta data. Both derby and H2 will convert un-escaped object names to upper case when it records them in the database meta data.

Parameters:
spatialSchema -
spatialTable -
entriesMax - The maximum number of entries per node (defaults to 98)
fidColumn - The feature Id column in the spatial table
geomColumn - The geometry column in the spatial table
geomType - The geometry type (refer WKT types)
Throws:
java.sql.SQLException

buildIndexProc

public static void buildIndexProc(java.lang.String schema,
                                  java.lang.String table,
                                  int commitInterval,
                                  ProgressMonitor progressMonitor)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

buildIndex

public static void buildIndex(java.sql.Connection con,
                              java.lang.String schema,
                              java.lang.String table,
                              int commitInterval,
                              ProgressMonitor progressMonitor)
                       throws java.sql.SQLException
Build the index for a spatial table. The Hatbox table must already be created (ie the target table is spatialized). This procedure will create the index maintenance triggers, change the status to 'BUILDING', build the index, then change the status to 'INDEXED'.

This procedure uses a non-nested connection that is committed independently of the connection that started the procedure.

Parameters:
spatialSchema -
spatialTable -
progressMonitor -
Throws:
java.sql.SQLException

deSpatializeProc

public static void deSpatializeProc(java.lang.String schema,
                                    java.lang.String table)
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

deSpatialize

public static void deSpatialize(java.sql.Connection con,
                                java.lang.String schema,
                                java.lang.String table)
                         throws java.sql.SQLException
Despatialize a currently spatialized table. This amounts to removing the triggers on the spatial table and dropping the index table.

Parameters:
spatialSchema -
spatialTable -
Throws:
java.sql.SQLException

insSpatial

public static void insSpatial(java.lang.String schema,
                              java.lang.String table,
                              long id)
                       throws java.sql.SQLException
Insert an entry into the index for an existing row in the spatial table. This method is used by the post-insert trigger on the spatial table.

Parameters:
schema - The spatial schema
table - The spatial table
id - The id of the row in the spatial table
Throws:
java.sql.SQLException

updSpatial

public static void updSpatial(java.lang.String schema,
                              java.lang.String table,
                              long id)
                       throws java.sql.SQLException
Update an entry in the index for an existing row in the spatial table. This method is used by the post-update trigger on the spatial table.

Parameters:
schema - The spatial schema
table - The spatial table
id - The id of the row in the spatial table
Throws:
java.sql.SQLException

delSpatial

public static void delSpatial(java.lang.String schema,
                              java.lang.String table,
                              long id)
                       throws java.sql.SQLException
Delete an entry from the index for a deleted row in the spatial table. This method is used by the post-delete trigger on the spatial table.

Parameters:
schema - The spatial schema
table - The spatial table
id - The id of the row in the spatial table
Throws:
java.sql.SQLException

saveEntry

public static void saveEntry(java.lang.String schema,
                             java.lang.String table,
                             long id)
                      throws java.sql.SQLException
This procedure is invoked from 'before delete' and 'before update' triggers. Its purpose is to store the entry of the 'old' state of a feature in the ThreadLocal savedEntry to be used by the corresponding 'after delete' and 'after update' triggers. This is necessary because Derby does not allow large objects (eg BLOB) to be passed into procedures as parameters. Derby also does not allow before triggers to do any database updates.

Parameters:
schema - The spatial schema
table - The spatial table
id - The id of the row in the spatial table
Throws:
java.sql.SQLException

wktToWkb

public static byte[] wktToWkb(java.lang.String wkt)
                       throws com.vividsolutions.jts.io.ParseException
Convert Well Known Text string to Well Known Binary byte array.

Note the Derby limitation on function arguments and return values that limits the size of WKT strings to 32,672 char and WKB arrays to 32,672 bytes.

Parameters:
WKT -
Returns:
WKB
Throws:
com.vividsolutions.jts.io.ParseException

wkbToWkt

public static java.lang.String wkbToWkt(byte[] wkb)
                                 throws com.vividsolutions.jts.io.ParseException
Convert Well Known Binary byte array to Well Known Text string.

Note the Derby limitation on function arguments and return values that limits the size of WKT strings to 32,672 char and WKB arrays to 32,672 bytes.

Parameters:
WKB -
Returns:
WKT
Throws:
com.vividsolutions.jts.io.ParseException

mbrIntersectsEnvFunc

public static java.sql.ResultSet mbrIntersectsEnvFunc(java.lang.String schema,
                                                      java.lang.String table,
                                                      double minx,
                                                      double maxx,
                                                      double miny,
                                                      double maxy)
                                               throws java.sql.SQLException
Throws:
java.sql.SQLException

mbrIntersectsEnv

public static java.sql.ResultSet mbrIntersectsEnv(java.sql.Connection con,
                                                  java.lang.String schema,
                                                  java.lang.String table,
                                                  double minx,
                                                  double maxx,
                                                  double miny,
                                                  double maxy)
                                           throws java.sql.SQLException
A Table Function designed to provide the fastest possible intersection search at the cost of spatial inaccuracy ie an id is returned for each feature whose minimum bounding rectangle (MBR) intersects a rectangular search envelope. This search employs only the spatial index, never retrieving the feature itself and never applying a secondary spatial filter.

Parameters:
con -
schema -
table -
minx -
maxx -
miny -
maxy -
Returns:
Throws:
java.sql.SQLException

queryIntersectsWkbFunc

public static java.sql.ResultSet queryIntersectsWkbFunc(java.lang.String schema,
                                                        java.lang.String table,
                                                        byte[] wkb)
                                                 throws java.sql.SQLException,
                                                        com.vividsolutions.jts.io.ParseException
Throws:
java.sql.SQLException
com.vividsolutions.jts.io.ParseException

queryIntersectsWkb

public static java.sql.ResultSet queryIntersectsWkb(java.sql.Connection con,
                                                    java.lang.String schema,
                                                    java.lang.String table,
                                                    byte[] wkb)
                                             throws java.sql.SQLException,
                                                    com.vividsolutions.jts.io.ParseException
Throws:
java.sql.SQLException
com.vividsolutions.jts.io.ParseException

queryIntersectsWktFunc

public static java.sql.ResultSet queryIntersectsWktFunc(java.lang.String schema,
                                                        java.lang.String table,
                                                        java.lang.String wkt)
                                                 throws java.sql.SQLException,
                                                        com.vividsolutions.jts.io.ParseException
Throws:
java.sql.SQLException
com.vividsolutions.jts.io.ParseException

queryIntersectsWkt

public static java.sql.ResultSet queryIntersectsWkt(java.sql.Connection con,
                                                    java.lang.String schema,
                                                    java.lang.String table,
                                                    java.lang.String wkt)
                                             throws java.sql.SQLException,
                                                    com.vividsolutions.jts.io.ParseException
Throws:
java.sql.SQLException
com.vividsolutions.jts.io.ParseException

queryWithPredicateWkbFunc

public static java.sql.ResultSet queryWithPredicateWkbFunc(java.lang.String schema,
                                                           java.lang.String table,
                                                           java.lang.String predicate,
                                                           byte[] wkb)
                                                    throws java.sql.SQLException,
                                                           com.vividsolutions.jts.io.ParseException
Throws:
java.sql.SQLException
com.vividsolutions.jts.io.ParseException

queryWithPredicateWkb

public static java.sql.ResultSet queryWithPredicateWkb(java.sql.Connection con,
                                                       java.lang.String schema,
                                                       java.lang.String table,
                                                       java.lang.String predicate,
                                                       byte[] wkb)
                                                throws java.sql.SQLException,
                                                       com.vividsolutions.jts.io.ParseException
Throws:
java.sql.SQLException
com.vividsolutions.jts.io.ParseException

queryWithPredicateWktFunc

public static java.sql.ResultSet queryWithPredicateWktFunc(java.lang.String schema,
                                                           java.lang.String table,
                                                           java.lang.String predicate,
                                                           java.lang.String wkt)
                                                    throws java.sql.SQLException,
                                                           com.vividsolutions.jts.io.ParseException
Throws:
java.sql.SQLException
com.vividsolutions.jts.io.ParseException

queryWithPredicateWkt

public static java.sql.ResultSet queryWithPredicateWkt(java.sql.Connection con,
                                                       java.lang.String schema,
                                                       java.lang.String table,
                                                       java.lang.String predicate,
                                                       java.lang.String wkt)
                                                throws java.sql.SQLException,
                                                       com.vividsolutions.jts.io.ParseException
Throws:
java.sql.SQLException
com.vividsolutions.jts.io.ParseException


Copyright © 2010. All Rights Reserved.