Class TLcdDB2SpatialModelEncoder

java.lang.Object
com.luciad.format.database.TLcdDatabaseModelEncoder
com.luciad.format.db2.spatial.TLcdDB2SpatialModelEncoder
All Implemented Interfaces:
ILcdModelEncoder, Serializable

@LcdService(service=ILcdModelEncoder.class, priority=20000) public class TLcdDB2SpatialModelEncoder extends TLcdDatabaseModelEncoder
This ILcdModelEncoder encodes models into DB2 Spatial databases.

A spatial database is accessed based on a set of properties. The properties can be passed in a Properties object, or using a properties file with extension "db2".

The common properties needed to establish a connection and to specify tables, columns, rows, etc. are the same as those for the TLcdDB2SpatialModelDecoder. In addition, the following property is required:

  • featureDataTypes.0, ...: the SQL data types of the feature columns. Each featureNames.i must have a corresponding featureDataTypes.i.
The following properties are optional:
  • SRID: the database system reference identifier corresponding to the model reference. If not specified, the encoder will attempt to find a suitable the SRID by itself. If this fails, the model is encoded with the SRID=0 ("unspecified") and a warning is issued to the log.
  • EPSG: the EPSG code corresponding to the model reference. If this property is present, the encoder will try to find and use the associated SRID from the database. If the SRID cannot be found, the model is encoded with the SRID=0 ("unspecified") and a warning is issued to the log. When both the SRID and the EPSG properties are specified by the user the SRID takes precendence.
  • useSHP (default=false): the elements will be stored in the database in the ESRI Shapefile format. This allows specifying 3D coordinates and/or measurement values (see ILcdSHPMeasure and ILcdSHPMeasureList).
  • dropBeforeCreatingTable (optional, default=false): if set to true, the encoder will attempt to drop the spatial table before re-creating it.
  • voronoiIndex (optional, default=1): when the encoded spatial table contains geodetic data, this property specifies the cell structure ID of the geodetic Voronoi index (see the IBM DB2 User Guide).
  • spatialIndex (optional, default=1.0, 5.0, 50.0): when the encoded spatial table contains spatial data, this property specifies the spatial grid index (see the IBM DB2 User Guide).

Example properties file:

 # The basic database connection properties.
 driver    = com.ibm.db2.jcc.DB2Driver
 url       = jdbc:db2://host_name:50002/db_name
 user      = db2inst1
 password  = db2inst1

 # The data of interest.
 table         = STATES
 spatialColumn = GEOM

 # The feature columns to be decoded.
 featureNames.0 = ID
 featureNames.1 = STATE

 # The index of the feature that can be used as primary key.
 primaryFeatureIndex = 0

 # Optional additional constraints to retrieve a subset of the table.
 #selectionTables =
 #selectionFilter = STATE = 'New York'

 # Optional maximum cache size (expressed as number of objects, default is 100).
 maxCacheSize = 60

 # Optionally close the database connection after each query.
 # Only advisable when using a connection pooling database driver.
 #alwaysCloseConnection = false

 # Additional properties required for creating a new DB2 Spatial table.
 # SRID = 1003
 # Alternatively, an EPSG code can be specified (SRID takes precedence)
 # EPSG = 4326

 # The regular SQL data types of the feature columns.
 featureDataTypes.0 = NUMERIC(11,3)
 featureDataTypes.1 = CHAR(20)
 

The encoder supports ILcdShape objects. They are converted to DB2 Spatial objects as follows:

FROM
ILcdShape
TO
ESRI SHAPE Geometry
ILcdPoint POINT
ILcdPolyline LINE_STRING
ILcdPolygon POLYGON
ILcdComplexPolygon POLYGON or MULTI_POLYGON
ILcdPolypoint MULTI_POINT
ILcdShapeList containing one ILcdPoint element POINT
ILcdShapeList containing one ILcdPolyline element LINE_STRING
ILcdShapeList containing one ILcdPolygon element POLYGON
ILcdShapeList containing one ILcdComplexPolygon elementPOLYGON or MULTI_POLYGON
ILcdShapeList containing one ILcdPolypoint element MULTI_POINT
ILcdShapeList containing several ILcdPoint elements MULTI_POINT
ILcdShapeList containing several ILcdPolyline elementsMULTI_LINE_STRING
ILcdShapeList containing several ILcdPolygon elements MULTI_POLYGON
ILcdShapeList containing several ILcdComplexPolygon elements MULTI_POLYGON

The ILcdShape can also be a homogeneous ILcdShapeList containing any of the above ILcdShape instances.

If a LuciadLightspeed complex polygon consists of a single exterior ring and possibly one or more interior rings (holes) the encoder will map it to a POLYGON element. If the complex polygon contains more than one exterior ring, it will be split into several complex polygons, each containing exactly one exterior ring and all the associated interior rings. In this case the result is encoded as a MULTI_POLYGON.

When using geodetic data, DB2 expects the orientation of the exterior ring of a complex polygon to be counter-clockwise and the orientation of the interior rings to be clockwise (cf. Chapter 16 - "DB2 Geodetic Data Management Feature" from the IBM DB2 user guide). The encoder automatically changes the orientation of the exterior/interior rings to meet this requirement.

Features are retrieved by means of the ILcdFeatured interface, which the objects must implement.

Known limitations

  • Shapes can be encoded in 3D only when the useSHP property is true
  • When the useSHP property is true, shape list objects containing more than one complex polygon are stored as an unfolded list of all the composing simple polygons, regardless whether they are inner or outer polygons.

Requirements

  • When using short-form database connection URLs (jdbc:db2:DATABASE), the db2jcct2 native library must be in the Java's library path. The library can usually be found in the DB2 installation directory - for example "/opt/ibm/db2/V9.5/lib". To use it, add the "-Djava.library.path=[path]" argument to the command line when launching the Java virtual machine
Since:
8.3.03
See Also:
  • "DB2 Spatial Extender and Geodetic Data Management Feature, Version 9, User's Guide and Reference"
  • Serialized Form