Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
xml
xml
titleBasic SQL Server connection
<spatial:spatialengine id="sqlserver">
  <dbtype>sqlserver</dbtype>
  <host>sqlhost</host>
  <port>1434</port>
  <user>gis</user>
  <passwd>hak0rz</passwd>
  <schema>GIS</schema>
  <minconnection>2</minconnections>
  <validateconnections>true</validateconnections>
</spatial:spatialengine>
Code Block
sql
languagesql
titleSQL create statement for gt_pk_metadata table
CREATE TABLE gtGT_pkPK_metadataMETADATA (
  tableTABLE_schemaSCHEMA varchar(255) NOT NULL,
  tableTABLE_nameNAME varchar(255) NOT NULL,
  pkPK_columnCOLUMN varchar(255) NOT NULL,
  pkPK_columnCOLUMN_idxIDX int NOT NULL,
  pkPK_policyPOLICY varchar(255) NOT NULL,
  pkPK_sequenceSEQUENCE varchar(255),
   UNIQUE(TABLE_SCHEMA, TABLE_NAME, PK_COLUMN),
   CHECK(PK_POLICY IN ('ASSIGNED','SEQUENCE', 'AUTOGENERATED') )
)

pk_policy can be 'assigned', 'sequence' or 'autogenerated' depending upon how the key column value is generated. The pk_sequence value only need to be set if the policy is 'sequence'.
'sequence' means that the value for the column is generated using a database sequence, and the 'pk_sequence' value must be set.
'autogenerated' means that the value for the column is generated by the database using another method.
'assigned' means that the value for the column is determined by the current maximum value +1, if the column is an integral type, or as a random string if the column is textual.

...

The SQL server data store can determine the geometry type and native SRID of a particular column only by data inspection, by looking at the first row in the table. Of course this is error prone, and works only if there is data in the table. The administrator can address the above issue by manually creating a geometry metadata table describing each geometry column. Its presence is indicated via the SQL Server datastore connection parameter named geometrymetadatatable (which may be a simple table name or a schema-qualified one). The table has the following structure (the table name is flexible, just specify the one chosen in the data store connection parameter):

Code Block
languagesql
titleCreating geometry metadata table
CREATE TABLE GT_GEOMETRY_COLUMNSMETADATA (
   F_TABLE_SCHEMA VARCHAR(30) NOT NULL,
   F_TABLE_NAME VARCHAR(30) NOT NULL,
   F_GEOMETRY_COLUMN VARCHAR(30) NOT NULL,
   COORD_DIMENSION INTEGER,
   SRID INTEGER NOT NULL,
   TYPE VARCHAR(30) NOT NULL,
   UNIQUE(F_TABLE_SCHEMA, F_TABLE_NAME, F_GEOMETRY_COLUMN),
   CHECK(TYPE IN ('POINT','LINE', 'POLYGON', 'COLLECTION', 'MULTIPOINT', 'MULTILINE', 'MULTIPOLYGON', 'GEOMETRY') )
);

When the table is present the store first searches it for information about each geometry column to be classified, and falls back on data inspection only if the table does not contain any information.