Package com.luciad.format.postgresql
Class TLcdPostGISModelEncoder
java.lang.Object
com.luciad.format.postgresql.TLcdPostGISModelEncoder
- All Implemented Interfaces:
ILcdModelEncoder,Serializable
@LcdService(service=ILcdModelEncoder.class,
priority=20000)
public class TLcdPostGISModelEncoder
extends Object
implements ILcdModelEncoder
This
If the shape list contains only a single element, the element will be
considered on its own, without the enclosing shape list.
Features are retrieved by means of the
ILcdModelEncoder encodes models into PostgreSQL PostGIS
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 "pgs".
The common properties needed to establish a connection and to specify tables,
columns, rows, etc. are the same as those for the
TLcdPostGISModelDecoder. In addition, the following
properties are required:
SRIDthe spatial reference ID for the spatial data.geometryType(default = "GEOMETRY"): the SQL data type of the geometry column, as listed the OpenGIS Well Known Binary specification. The encoder also supports the special geodetic typeGEOGRAPHYthat is available in PostGIS 1.5 and higher.featureDataTypes.0, ...: the SQL data types of the feature columns. EachfeatureNames.imust have a correspondingfeatureDataTypes.i.dropBeforeCreatingTable(optional, default =false): if set totrue, the encoder will attempt to drop the spatial table before re-creating it.bounds: the spatial bounds of the model, specified as a comma-separated list of values: "min_x, min_y, width, height".
# The basic database connection properties. driver = org.postgresql.Driver url = jdbc:postgresql://server:5432/database user = user password = password # 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 PostgreSQL PostGIS table. SRID = 4326 # WGS 84 lon lat # Optional geometry type of the geometry column. #geometryType = MULTIPOLYGON # The regular SQL data types of the feature columns. featureDataTypes.0 = NUMERIC(11,3) featureDataTypes.1 = CHAR(20)# Optional the dimension size of the geometry. # 2 for 2D geometry (default), 3 for 3D geometry. #dimensions = 3 The encoder supports
ILcdShape objects. They are converted
to PostgreSQL PostGIS objects as follows:
FROMILcdShape | TOWKB GEOMETRY |
|---|---|
ILcdPoint | POINT |
ILcdPolypoint | MULTIPOINT |
ILcdPolyline | POLYLINE |
ILcdPolygon | POLYGON |
ILcdComplexPolygon | POLYGON |
ILcdCircularArcBy3Points or TLcdCompositeCurve containing
multiple ILcdCircularArcBy3Points instances | CIRCULARSTRING |
ILcdShapeList containing
multiple ILcdPoint instances | MULTIPOINT |
ILcdShapeList containing
multiple ILcdPolyline instances | MULTIPOLYLINE |
TLcdCompositeCurve containing
multiple ILcdPolyline and ILcd2DEditableCircularArcBy3Points instances | COMPOUNDCURVE |
TLcdSurface where exterior ring and interior rings are
ILcdPolyline and ILcd2DEditableCircularArcBy3Points instances | CURVEPOLYGON |
ILcdShapeList containing
multiple ILcdPolygon instances | MULTIPOLYGON |
ILcdShapeList containing
multiple ILcdComplexPolygon instances | MULTIPOLYGON |
ILcdShapeList containing the following objects:
| MULTICURVE |
ILcdShapeList containing the following objects:
| MULTISURFACE |
ILcdShapeList containing one of the above (recursive) instances | GEOMETRYCOLLECTION |
ILcdDataObject interface using the getValue method.
Objects must therefore implement the ILcdDataObject interface.- Since:
- 6.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the given model can be saved into the database described by the given properties file.booleanReturns whether the given model can be saved back into the database.voidExports the given model in a new table, based on the properties in the given file.voidexport(ILcdModel aModel, Properties aProperties) Exports the given model in a new table, based on the given properties.intReturns the number of inserted elements after which an export operation is committed.Returns a short, displayable name for the format thisILcdModelEncoderencodes to.voidSaves the given model in its original location, by committing all changes.voidsetAutoCommitCount(int aAutoCommitCount) Sets the number of inserted elements after which an export operation should be committed, periodically.
-
Constructor Details
-
TLcdPostGISModelEncoder
public TLcdPostGISModelEncoder()Creates a new PostGIS PostgreSQL model encoder.
-
-
Method Details
-
setAutoCommitCount
public void setAutoCommitCount(int aAutoCommitCount) Sets the number of inserted elements after which an export operation should be committed, periodically. The default is 0, meaning that the export operation is only committed when all elements have been inserted. A different value can be useful to avoid overflow of database transaction logs. -
getAutoCommitCount
public int getAutoCommitCount()Returns the number of inserted elements after which an export operation is committed. -
getDisplayName
Description copied from interface:ILcdModelEncoderReturns a short, displayable name for the format thisILcdModelEncoderencodes to.- Specified by:
getDisplayNamein interfaceILcdModelEncoder- Returns:
- the displayable name of this
ILcdModelEncoder.
-
canExport
Returns whether the given model can be saved into the database described by the given properties file.- Specified by:
canExportin interfaceILcdModelEncoder- Parameters:
aModel- the model to be verified.aDestinationName- the location where the model should be exported to.- Returns:
trueif this encoder can export the specified model to the specified location,falseotherwise.- See Also:
-
export
public void export(ILcdModel aModel, String aDestinationName) throws IOException, IllegalArgumentException Exports the given model in a new table, based on the properties in the given file.- Specified by:
exportin interfaceILcdModelEncoder- Parameters:
aModel- the model to be exported.aDestinationName- the properties file describing the database table to be created.- Throws:
IOException- for any database access errors. This includes the case where the table already exists.IllegalArgumentException- if the model cannot be saved by this encoder (!canExport(aModel, aDestinationName)).
-
export
public void export(ILcdModel aModel, Properties aProperties) throws IOException, IllegalArgumentException Exports the given model in a new table, based on the given properties.- Parameters:
aModel- the model to be exported.aProperties- the properties describing the database table to be created.- Throws:
IOException- for any database access errors. This includes the case where the table already exists.IllegalArgumentException
-
canSave
Returns whether the given model can be saved back into the database.- Specified by:
canSavein interfaceILcdModelEncoder- Parameters:
aModel- the model to be verified.- Returns:
trueif this encoder can save the model in the location where it originally came from,falseotherwise.- See Also:
-
save
Saves the given model in its original location, by committing all changes.- Specified by:
savein interfaceILcdModelEncoder- Parameters:
aModel- the database model to be committed.- Throws:
IOException- for any database access errors.IllegalArgumentException- if the model cannot be saved by this encoder (!canSave(aModel)).
-