@LcdService(service=ILcdModelEncoder.class, priority=20000) public class TLcdMSSQLModelEncoder extends Object implements ILcdModelEncoder
ILcdModelEncoder
encodes models into Microsoft SQL
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 "mss
".
The common properties needed to establish a connection and to specify tables,
columns, rows, etc. are the same as those for the
TLcdMSSQLModelDecoder
. In addition, the following
properties are required:
SRID
the 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 type
GEOGRAPHY
that is available in Microsoft SQL Server 2008 and higher.
featureDataTypes.0
, ...: the SQL data types of the feature
columns. Each featureNames.i
must have a
corresponding featureDataTypes.i
.
dropBeforeCreatingTable
(optional, default =
false
): if set to true
, the encoder will
attempt to drop the spatial table before re-creating it.
# The basic database connection properties. driver = com.microsoft.sqlserver.jdbc.SQLServerDriver url = jdbc:sqlserver://server:1433 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 Microsoft SQL server table. SRID = 4326 # WGS 84 lon lat # Optional geometry type of the geometry column. (GEOMETRY or GEOGRAPHY) #geometryType = GEOGRAPHY #geometryType = GEOMETRY # 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 Microsoft SQL objects as follows:
FROMILcdShape
| TOWKB GEOMETRY |
---|---|
ILcd2DEditablePoint
| POINT |
ILcd3DEditablePoint
| POINT |
ILcd2DEditablePolypoint
| MULTIPOINT |
ILcd3DEditablePolypoint
| MULTIPOINT |
ILcd2DEditablePolyline
| POLYLINE |
ILcd3DEditablePolyline
| POLYLINE |
ILcd2DEditablePolygon
| POLYGON |
ILcdComplexPolygon
| POLYGON |
ILcdShapeList containing multiple ILcd2DEditablePoint
instances | MULTIPOINT |
ILcdShapeList containing multiple ILcd3DEditablePoint
instances | MULTIPOINT |
ILcdShapeList containing multiple ILcd2DEditablePolyline
instances | MULTIPOLYLINE |
ILcdShapeList containing multiple ILcd3DEditablePolyline
instances | MULTIPOLYLINE |
ILcdShapeList containing multiple ILcd2DEditablePolygon
instances | MULTIPOLYGON |
ILcdShapeList containing multiple ILcd3DEditablePolygon
instances | MULTIPOLYGON |
ILcdShapeList containing multiple ILcdComplexPolygon
instances | MULTIPOLYGON |
ILcdShapeList containing one of the above (recursive)
instances | GEOMETRYCOLLECTION |
ILcdDataObject
interface,
which the objects must implement.Constructor and Description |
---|
TLcdMSSQLModelEncoder()
Creates a new Microsoft SQL model encoder.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canExport(ILcdModel aModel,
String aDestinationName)
Returns whether the given model can be saved into the database described by the given
properties file.
|
boolean |
canSave(ILcdModel aModel)
Returns whether the given model can be saved back into the database.
|
void |
export(ILcdModel aModel,
Properties aProperties)
Exports the given model in a new table, based on the given properties.
|
void |
export(ILcdModel aModel,
String aDestinationName)
Exports the given model in a new table, based on the properties in the given file.
|
int |
getAutoCommitCount()
Returns the number of inserted elements after which an export operation
is committed.
|
String |
getDisplayName()
Returns a short, displayable name for the format this
ILcdModelEncoder encodes to. |
void |
save(ILcdModel aModel)
Saves the given model in its original location, by committing all changes.
|
void |
setAutoCommitCount(int aAutoCommitCount)
Sets the number of inserted elements after which an export operation
should be committed, periodically.
|
public TLcdMSSQLModelEncoder()
public void setAutoCommitCount(int aAutoCommitCount)
aAutoCommitCount
- The number of inserted elements after which an export operation
should be committedpublic int getAutoCommitCount()
public String getDisplayName()
ILcdModelEncoder
ILcdModelEncoder
encodes to.getDisplayName
in interface ILcdModelEncoder
ILcdModelEncoder
.public boolean canExport(ILcdModel aModel, String aDestinationName)
canExport
in interface ILcdModelEncoder
aModel
- the model to be verified.aDestinationName
- the location where the model should be exported to.true
if this encoder can export the specified model to the
specified location, false
otherwise.ILcdModelEncoder.export(com.luciad.model.ILcdModel, java.lang.String)
public void export(ILcdModel aModel, String aDestinationName) throws IOException, IllegalArgumentException
export
in interface ILcdModelEncoder
aModel
- the model to be exported.aDestinationName
- the properties file describing the database table to be created.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)
).public void export(ILcdModel aModel, Properties aProperties) throws IOException, IllegalArgumentException
aModel
- the model to be exported.aProperties
- the properties describing the database table to be created.IOException
- for any database access errors. This includes the case where the
table already exists.IllegalArgumentException
public boolean canSave(ILcdModel aModel)
canSave
in interface ILcdModelEncoder
aModel
- the model to be verified.true
if this encoder can save the model in the location where it originally came from,
false
otherwise.ILcdModelEncoder.save(com.luciad.model.ILcdModel)
public void save(ILcdModel aModel) throws IOException, IllegalArgumentException
save
in interface ILcdModelEncoder
aModel
- the database model to be committed.IOException
- for any database access errors.IllegalArgumentException
- if the model cannot be saved by this encoder (!canSave(aModel)
).