SQL Server Spatial Data Server - User Guide
SQL Server Spatial Data Server - User Guide
January 2015
SQL Server Spatial Data Server
User Guide
CONTENTS
Contents ..................................................................................................................................... 4
Prerequisites ......................................................................................................................... 6
Connections .......................................................................................................................... 6
Password Persistence ............................................................................................................ 6
Permissions ........................................................................................................................... 7
SQL Server Warehouse Requirements ................................................................................... 7
Page 5
SQL Server Spatial Data Server
User Guide
Prerequisites
SQL Server connections do not require client software. The SQL Server Spatial data server will be
installed whether SQL Server is present or not. Connections can be made to SQL Server installations
that are configured as case-sensitive or case-insensitive. Both Windows authentication and SQL Server
authentication are supported for all user accounts. A SQL Server database must already exist and must
have the required metadata tables before a SQL Server connection can be made. The data server has
full read-write capability, but the ability to access and edit database objects is controlled by the
privileges on the login account used for the database connection.
Connections
GeoMedia applications require specific metadata tables to exist in the SQL Server database before a
connection can be made. This metadata is created using GeoMedia Professional's Database Utilities or
during the bulk import of data from GeoMedia Professional’s Export to SQL Server command. The
metadata and geometry storage formats used by the SQL Server spatial data server is different from
the metadata used by the standard SQL Server data server, they cannot be used interchangeably.
See the GeoMedia Metadata Requirements section of this document for a list of the required tables.
To make a connection to SQL Server, provide a valid server name, and then a valid username and
password. Any databases the specified user has privilege to see will appear in the drop-down
database list.
SQL Server has two modes for validating users: Windows domain authentication and SQL Server
authentication. If the SQL Server connection is set to use Windows authentication (the default), your
domain login account will need to be added to SQL Server by a database administrator and
appropriate privileges will need to be granted on the databases you want to access. On connection,
you will only need to supply the server name and the database name.
If you are using SQL Server authentication, you will need to have a valid SQL Server user account and
password as well as the appropriate privileges on the database you want to connect to.
Password Persistence
When using SQL Server authentication, GeoMedia stores the SQL Server connection password in the
GeoWorkspace. This is meant as a convenience and allows users to open existing GeoWorkspaces
containing SQL Server connections without having to re-enter connection passwords. However, this is
a drawback to those users wanting higher levels of security. If you do not want the passwords to be
Page 6
SQL Server Spatial Data Server
User Guide
persisted in the GeoWorkspace, you must use domain authentication. Domain authenticated
connections do not store any user or password information in the GeoWorkspace and have the added
benefit of not prompting you to re-enter passwords.
Permissions
In SQL Server warehouses, access to database objects is controlled by the object’s owner through the
use of permissions. GeoMedia requires all objects in your SQL Server database to be in the DBO
schema. Objects that are not owned by DBO will not be accessible or visible in GeoMedia except by
the user who created them.
When creating database objects using GeoMedia Professional’s Feature Class Definition command,
the user account must be assigned the DB_OWNER role. For database objects created outside of
GeoMedia Professional, only a user account with the role DB_OWNER will ensure that the resulting
objects are in the DBO schema.
SQL server users who need to be restricted to read-only access should be assigned the
DB_DATAREADER role, and users who need read-write access should be assigned the
DB_DATAWRITER role. All other specific SQL Server privileges are honored as long as the DBO
ownership criterion is met when creating database objects.
There are also four scalar functions that are required for any access to native spatial data through
GeoMedia. Execute privileges are required on these four functions for any user who does not have the
DB_OWNER role. See the Scalar Functions section for more information.
All geometries are stored in 3 dimensions; 2 dimensional geometries are not supported.
All non-system SQL Server database objects must be owned by dbo. Users who create objects
(tables, views, etc.) in the database must have the DB_OWNER role.
Names of tables, views, indexes, and fields are always expressed in their defined cases. The server
will preserve the case of identifiers but will be case-insensitive on comparisons.
A local SQL Server client is not required; however, client-side administrative tools are required when
importing data generated by the Export to SQL Server command. The server drop-down list on the
New Connection dialog box is only populated when SQL Server agents are active.
Do not use SQL Server’s TIMESTAMP data type. This data type is not related to date/time functions
and is not supported. A list of supported data types is presented in the SQL Server to GeoMedia
Data Type Matching section. Data types that do not appear in this list are not supported and are
generally ignored by the data server.
All DML operations (inserts, updates, and deletes) will require a clustered primary key. Both multi-
column and character-based primary keys are supported but are not recommended for insert
Page 7
SQL Server Spatial Data Server
User Guide
operations as the user will need to manually enter the appropriate key value(s). For the best results
and the best performance, use an integer-based auto-increment (identity) primary key column or a
uniqueidentifier based primary key column with the NewID() function assigned as the default value
(uniqueidentifiers are mapped to GDBText in GeoMedia).
Views are editable as long as they are key preserved and have the appropriate metadata entries in
the GINDEXCOLUMNS table. Any column in the view that is both unique and not null can act as the
pseudo primary key, which can be assigned via GeoMedia Professional's Database Utilities. Even
when key preserved, DML operations on join-views will require the use of INSTEAD OF triggers.
GeoMedia metadata must be present before making a connection to the database. The required
metadata can be created using GeoMedia Professional's Database Utilities or using the metadata
script created by the Export to SQL Server command.
Metadata entries must exist for all tables and views for them to be visible in the GeoMedia
environment. Database Utilities can be used to make the metadata assignments.
Page 8
SQL Server Spatial Data Server
User Guide
Geometry Storage
The default native storage data type is GEOMETRY because most data is assumed to be projected. The
GEOGRAPHY data type is fully supported as well but will require the use of an EPSG spatial reference
system identifier (SRID). For geographic data, each feature must fit inside a single hemisphere.
Objects larger than a single hemisphere are not supported and may throw an argument exception.
Geographic spatial filter areas must also fit inside a single hemisphere.
The default geometry type used by GeoMedia Professional's Feature Class Definition command (or any
other GeoMedia command that creates a table) is determined by the TypeForNativeGeometryStorage
parameter in the GParameters metadata table.
The default spatial reference system identifier (SRID) is 0 because that is what SQL Server expects for
GEOMETRY data types. SQL Server does not store the EPSG SRID's for projected data, and a NULL SRID
is not allowed. You can enter a custom SRID for a geometry but it will not be utilized for any
coordinate system operations. For GEOGRAPHY data types, a valid SRID is required, and it must be one
of the EPSG SRIDs currently stored in SQL Server's sys.spatial_reference_systems table. The default
SRID used by GeoMedia Professional's Feature Class Definition command (or any other GeoMedia
command that creates a table) is determined by the DefaultNativeGeometrySrid parameter in the
GParameters metadata table.
Every native spatial geometry column must have a corresponding GeoMedia binary column. If the
table is created using Feature Class Definition, the following columns are present in the base table for
the feature:
The native geometry column in SQL Server (<GDO geometry name>_SPA) stores the exact
representation for geometries that are currently supported by SQL Server. For unsupported GeoMedia
geometry types, an approximation of the GeoMedia geometry type is stored in the native geometry
column while the actual geometry is stored in the VARBINARY column. The approximation is, as
follows:
A line geometry for GeoMedia's POLYLINEGEOMETRY. In this case the geometry is represented
exactly in its native format, but because the polylines are converted back from native line format,
they are also stored in the GDO column to have the information about its type – a two-point
POLYLINEGEOMETRY is the same as LINEGEOMETRY in native format.
A two-point polyline for GeoMedia's LINEGEOMETRY. In this case the geometry is represented
exactly in native format, but because the line geometries are converted back from the native
polyline format, they are also stored in the GDO column to provide the information about its type.
Any and all items required for GeoMedia's COMPOSITEPOLYLINEGEOMETRY, even if all the items
are fully supported by the underlying data source, since there is no way to convert it back to
GeoMedia's COMPOSITEPOLYLINEGEOMETRY from native format.
Any and all items required for GeoMedia's COMPOSITEPOLYGONGEOMETRY, even if all the items
are fully supported by the underlying data source, because there is no way to convert it back to
GeoMedia's COMPOSITEPOLYGONGEOMETRY from native format.
Any and all items required for GeoMedia's GEOMETRYCOLLECTION. The VARBINARY column is
used only if any of the items are not fully supported by SQL Server's geometry.
The raster footprint for GeoMedia's RASTERGEOMETRY.
For tables created outside Feature Class Definition, the VARBINARY(MAX) column used by GeoMedia
must be added manually, and GeoMedia's metadata must contain the association between the native
geometry column and the varbinary column. Use GeoMedia Professional's Database Utilities to insert
the metadata required to view native geometry tables in the GeoMedia environment.
The use of _SPA is just a naming convention used by GeoMedia applications; you do not need
to use this naming convention if you are creating or modifying tables outside of GeoMedia applications
as long as GeoMedia's metadata reflects the association between the GDO geometry and the native
geometry column.
GeoMedia Geometry Type SQL Server GDO column Native column content
Geometry Type content
Page 10
SQL Server Spatial Data Server
User Guide
GeoMedia Geometry Type SQL Server GDO column Native column content
Geometry Type content
x1 y1 z1,
…,
xN yN zN)
ArcGeometry LINESTRING( Full GDO Stroked N-point linestring
x1 y1 z1,
…,
xN yN zN)
CompositePolylineGeometry MULTILINESTRING( Full GDO, even Composite members need to
( when no member be approximated (like arcs) in
is approximated, a multiline string; otherwise,
x11 y11 z11,
in order to exact multiline string.
…,
recreate
xN1 yN1 zN1 composite.
),
…,
(x1M y1M z1M,
…,
xNM yNM zNM
))
PolygonGeometry POLYGON( Exact polygon
(
x1 y1 z1,
…,
xN yN zN
))
CompositePolygonGeometry MULTILINESTRING( Full GDO, even Composite members need to
( when no member be approximated (like arcs) in
is approximated, a closed multiline string;
x11 y11 z11,
in order to otherwise, exact closed
…, multiline string.
recreate
xN1 yN1 zN1 composite.
),
…,
(x1M y1M z1M,
…,
Page 11
SQL Server Spatial Data Server
User Guide
GeoMedia Geometry Type SQL Server GDO column Native column content
Geometry Type content
xNM yNM zNM
))
BoundaryGeometry POLYGON( Full GDO if any of Composite members need to
( the members be approximated (like arcs) in
(exterior, interior) a polygon string; otherwise,
x1_int y1_int z1_int,
cannot be exact polygon string.
…,
represented fully
xN_int yN_int zN_int by native type;
), otherwise, this
( column will be
null.
x11_ext y11_ext
z11_ext,
…,
xN1_ext yN1_ext
zN1_ext)
),
…,
(
x11M_ext y11M_ext
z11M_ext,
…,
xN1M_ext yN1M_ext
zN1M_ext)
))
RasterGeometry POLYGON ( Full GDO Exact polygon of the raster
x1 y1 z1, footprint.
x2 y2 z2,
x3 y3 z3,
x4 y4 z4,
x1 y1 z1)
GeometryCollection MULTPOINT for point Full GDO if any of A collection of exact
geometries, the members representations or
MULTILINESTRING for (exterior, interior) approximations, according to
line geometries, cannot be the rules established above,
represented fully for each GDO collection
MULTIPOLYGON for
by native type; member.
Page 12
SQL Server Spatial Data Server
User Guide
GeoMedia Geometry Type SQL Server GDO column Native column content
Geometry Type content
area geometries, otherwise, this
GEOMETRYCOLLECTIO column will be
N when mixed NULL.
Page 13
SQL Server Spatial Data Server
User Guide
*Uniqueidentifiers are a special case when used with the SQL Server spatial data server. If the primary
key column is defined as a uniqueidentifier, the SQL Server function NewID() must be assigned as the
default value. This will allow GeoMedia to automatically generate a new key value during inserts. If this
is not done, insert operations will fail. Internally, GeoMedia will treat the uniqueidentifier as a text field.
Page 14
SQL Server Spatial Data Server
User Guide
To create GeoMedia's required metadata objects, you must use one of the following methods:
Database Utilities – Use Database Utilities from the GeoMedia Professional program group. Enter
the server name and login as the database owner (or administrator). When connected, select the
Create Metadata Tables command. This is the preferred method and is also the method to use
when updating the metadata objects as new releases become available.
Export to SQL Server – You can also create the required metadata tables during bulk loading when
using the IMPORT.BAT command file created by the Export to SQL Server command in GeoMedia
Page 15
SQL Server Spatial Data Server
User Guide
Professional by setting the sixth parameter to Y. The METADATA.SQL file generated by Export to
SQL Server can also be run directly in SQL Server's Management Console.
Scalar Functions
Internally, GeoMedia uses a binary data type when reading WKB data so it converts SQL Server's
GEOMETRY/GEOGRAPHY data type to/from binary when reading/writing native geometry records. It
uses the following four scalar functions to do the data type conversion:
Binary2SqlGeography – Converts GeoMedia's binary data type to the native GEOGRAPHY data
type when writing WKB geographic data.
Binary2SqlGeometry – Converts GeoMedia's binary data type to the native GEOMETRY data type
when writing WKB geometry data.
SqlGeography2Binary – Converts a native GEOGRAPHY data type to GeoMedia's binary data type
when reading WKB data.
SqlGeometry2Binary – Converts a native GEOMETRY data type to GeoMedia's binary data type
when reading WKB data.
Execute privileges are required on these four functions for any login to a SQL Server database that does
not have the DB_OWNER role. These functions only convert the data type used to store the data; they
do not convert data between WKB and GDO formats.
AttributeProperties Table
The ATTRIBUTEPROPERTIES metadata table describes the attribute types for the columns listed in the
FIELDLOOKUP table. The common link between this table and FIELDLOOKUP is the INDEXID column.
The ATTRIBUTEPROPERTIES table is defined, as follows:
INDEXID – Uniquely identifies the column being described. The INDEXID value comes from the
FIELDLOOKUP table.
ISKEYFIELD – Determines whether a column is a primary key field. The default value is 0 for FALSE.
Use -1 (TRUE) if the column is a primary key.
ISFIELDDISPLAYABLE – Determines whether a column is displayed in GeoMedia Professional. The
default value is -1 for TRUE. Use 0 (FALSE) to hide the column.
Page 16
SQL Server Spatial Data Server
User Guide
FIELDTYPE – Determines how GeoMedia interprets the data type used in the column definition.
These are based on the conversion from SQL Server to GeoMedia data types. The field type values
correspond to the following:
1 – Boolean 8 – Date
2 – Byte 10 – Text
3 – Integer 11 – Binary
4 – Long 12 – Memo
5 – Currency 15 – GUID
6 – Single 32 – Spatial geometry
7 – Double 33 – Graphic geometry
FIELDPRECISION – Represents the number of decimal places displayed in GeoMedia Professional.
For numeric data types, the default is 6. Usually, this is the same as the scale defined for the
number field.
FIELDFORMAT – Determines the general format of the data being displayed. Format types include
General Number, Date/Time, and Currency.
FIELDDESCRIPTION – A user-provided description of the column.
FieldLookup Table
The FIELDLOOKUP metadata table provides a unique identifier (INDEXID) for every column in every
table/view in the database. The table definition is, as follows:
INDEXID – This key column contains a unique identifier for every column in every table in the
database. It is populated using an identity increment.
FEATURENAME – The table name.
FIELDNAME – Stores each column name for the associated feature name.
The INDEXID is used as a reference by other metadata tables like ATTRIBUTEPROPERTIES and
GEOMETRYPROPERTIES, which are used to describe the columns and their contents.
Page 17
SQL Server Spatial Data Server
User Guide
GAliasTable
The GALIASTABLE metadata table determines the names of the other metadata tables used by
GeoMedia Professional. The GALIASTABLE is the only metadata table whose name is hard coded. This
table must exist and cannot be modified or altered in any way. The table definition is, as follows:
TABLETYPE – This key column contains an internal reference name used by GeoMedia applications.
TABLENAME – This is the table name used by the associated table type. A table or view is required
for each table type.
GCoordSystem Table
The GCOORDSYSTEM metadata table stores GeoMedia's coordinate system definitions. If this table is
not present, no coordinate system transformation will occur, and the GeoWorkspace coordinate
system will be used. This table is not user editable and is not listed due to the large number of
columns and types of parameters required to define a coordinate system. This table should never be
populated manually. There are three columns worth noting:
NAME – The name the user has assigned to this coordinate system. This is an optional parameter,
but it should be used because it makes the coordinate system easier to identify, particularly if
multiple coordinate systems are used in the database.
DESCRIPTION – A user-provided description of the coordinate system. This is optional, but like the
name, it can also be useful.
CSGUID – The CSGUID is a special value used to uniquely identify the coordinate system
parameters. The CSGUID IS used to associate a geometry object to a GeoMedia coordinate system.
The CSGUID is also referenced in GEOMETRYPROPERTIES and in GFIELDMAPPING.
Coordinate systems should be created using GeoMedia Professional's Define Coordinate System
command. When a defined coordinate system is assigned to a feature class, the parameters that make
up the coordinate system are inserted into the database table. Any feature class that uses the
coordinate system is assigned the CSGUID for that coordinate system.
Coordinate systems are defined on a per-feature-class basis. Each feature class can have its own
coordinate system. If the database has a default coordinate system defined using the
DEFAULTCOORDINATESYSTEM parameter in the GParameters table, feature classes created using the
Feature Class Definition, Output to Feature Classes, or Export to SQL Server commands will
automatically use the default. Outside of GeoMedia Professional, you will need to use the Database
Utilities command, which is available in the GeoMedia Professional program group. If you have
incorrectly assigned a coordinate system to a feature class, you can also use the Database Utilities to
correct the assigned coordinate system.
If you plan to use multiple coordinate systems in your SQL Server database, you need to assign one
coordinate system to use as a default. Default coordinate systems can be assigned using Database
Page 18
SQL Server Spatial Data Server
User Guide
Utilities or Feature Class Definition. Only one default coordinate system is allowed per database. The
CSGUID of the default coordinate system is stored in the DEFAULTCOORDINATESYSTEM parameter in
the GPARAMETERS metadata table.
When digitizing in GeoMedia Professional, you should ensure that the GeoWorkspace coordinate
system matches the coordinate system of the feature class into which you are digitizing. This is not
always required, but depending on the coordinate transformation used, conversion errors can occur
when the coordinates are written to the database. GeoMedia Professional will compare the
GeoWorkspace coordinate system to the coordinate system of the feature you select for editing and
will warn you if there is a mismatch. It will be up to the user to rectify or ignore the mismatch. One
example where a difference is required is when editing geographic data in the Polar Regions; in this
case, your workspace should be set to either north or south polar stereographic.
GeometryProperties Table
The GEOMETRYPROPERTIES metadata table stores the geometry type, primary geometry flag, and the
coordinate system ID for geometry columns contained by feature classes. The common link between
this table and FIELDLOOKUP is the INDEXID column. The table definition is, as follows:
INDEXID – This key field links the information to the actual column defined in the FIELDLOOKUP
table.
PRIMARYGEOMETRYFLAG – A feature class can contain multiple geometry fields, but only one field
is allowed to be primary. The primary geometry field is the field that allows for editing. A value of -1
means the geometry column is the primary geometry. All other geometry columns in the feature
class should be assigned 0. Only one primary geometry field is allowed.
GEOMETRYTYPE – This field determines how the data server maps the geometry:
1 – Line 2 – Area
3 – AnySpatial 4 – Coverage
5 – GraphicsText 10 – Point
GCOORDSYSTEMGUID – This field contains the CSGUID from the GCOORDSYSTEM table. It tells the
data server what coordinate system is assigned to the geometry.
FIELDDESCRIPTION – A user-provided description of the column.
Page 19
SQL Server Spatial Data Server
User Guide
GFeatures Table
The GFEATURES metadata table stores the table names of all user tables (feature classes). By
manipulating the tables listed here, you can make feature classes visible or invisible in GeoMedia. The
table definition is, as follows:
FEATURENAME – This key column contains the name of the table that will be exposed as a feature
class in GeoMedia applications. This table is used by every command in GeoMedia Professional that
lists the available feature classes, for example, Add Legend Entries.
GEOMETRYTYPE – This field determines how the data server maps the geometry.
1 – Line 2 – Area
3 – AnySpatial 4 – Coverage
33 – GraphicsText 10 – Point
-1 – Attribute only (no geometry field)
PRIMARYGEOMETRYFIELDNAME – The name of the primary geometry column.
FEATUREDESCRIPTION – A user-provided description of the column.
GFieldMapping Table
The GFIELDMAPPING metadata table is used to override various aspects of column definitions.
Information stored here typically consists of the primary key column and the primary geometry with
their associated GeoMedia data types, the coordinate system ID, and any assigned autonumber types.
This table also defines the relationship between the native geometry storage column and the
GeoMedia binary geometry column. The table definition is, as follows:
DATA_TYPE – Determines how GeoMedia interprets the data type used in the column definition.
Field type values include the following types (these are derived from the SQL Server to GeoMedia
data type matching table):
1 – Boolean 8 – Date
2 – Byte 10 – Text
3 – Integer 11 – Binary
4 – Long 12 – Memo
5 – Currency 15 – GUID
6 – Single 32 – Spatial geometry
7 – Double 33 – Graphic geometry
DATA_SUBTYPE – Used when the DATA_TYPE is 32 or 33; the subtype determines the graphic type:
1 – Line 2 – Area
3 – AnySpatial 4 – Coverage
5 – GraphicsText 10 – Point
CSGUID – The coordinate system assigned to the primary geometry field.
AUTOINCREMENT – A Boolean field indicating that the field is set to auto-increment. Use -1 for
True; otherwise, the value is NULL.
NATIVE_GEOMETRY – This column is used to match the native geometry column with its associated
GeoMedia binary geometry column.
NATIVE_SRID – This column contains the SRID of the native geometry field. Typically it will be 0 for
GEOMETRY type fields. For GEOGRAPHY types, it should reflect an SRID value that is defined in SQL
Server's SYS.SPATIAL_REFERENCE_SYSTEMS table.
GIndexColumns Table
The GINDEXCOLUMNS metadata table is used to specify the column or columns in a view that can act
as primary or unique key fields. This table is populated using Database Utilities. The table definition
is, as follows:
Page 21
SQL Server Spatial Data Server
User Guide
GParameters Table
The GPARAMETERS metadata table contains the default values for the parameters needed to create
new tables using GeoMedia Professional as well as other miscellaneous information, such as the
default warehouse coordinate system.
Page 22
SQL Server Spatial Data Server
User Guide
This table contains two fields, GPARAMETER and GVALUE. Currently, the following values are used by
default:
NEVER modify the values in the GPARAMETER column. The values used in the GVALUE column are
user editable and these control how GeoMedia Professional creates tables in the database. These
values mainly affect Feature Class Definition, but any GeoMedia Professional command that creates a
table in the database will use these as defaults. Typically, you would edit the following:
If you need to modify any of the other GPARAMETER/GVALUE pairs, you should first consult
GeoMedia customer support.
GPickLists Table
The GPICKLISTS metadata table contains the Picklist assignments used by both the Properties dialog
box and the data window in GeoMedia Professional. Also known as domain lists, Picklists allow for a
predefined list of values to be used when updating attribute fields. GPICKLISTS is defined, as follows:
The primary key is a combination of the FEATURENAME and FIELDNAME columns. These columns
refer to the feature class and the specific attribute field for which the Picklist is to be used.
PICKLISTTABLENAME – Specifies a table in the schema containing the PickList values.
VALUEFIELDNAME and DESCRIPTIONFIELDNAME – Refers to the name of the columns in the table
containing the Picklist values.
VALUEFIELDNAME – Specifies the field in the Picklist table that contains the values to be stored in
the database. The data type of the field in the Picklist table specified here must match the data type
of the attribute assigned in the FIELDNAME.
DESCRIPTIONFIELDNAME – Specifies the field that contains Picklist descriptions to be displayed in
the pop-up menu on the Properties dialog box.
The values stored in VALUEFIELDNAME and DESCRIPTIONFIELDNAME could be the same when the
displayed values are the same as the stored values.
FILTERCLAUSE – Is optional and may contain a SQL WHERE clause that will be used to filter the
records in the Picklist. The filter allows a single Picklist table to be used when creating multiple
Picklists.
Picklist tables can be any tables that contain the required information, including existing feature
classes. You can implement a Picklist as a code list (using separate value and description entries) or as
a domain list (when value and description entries are the same). Ranges are not supported.
The Picklist metadata table can either be populated manually or by using the Picklist Manager utility.
This utility is available from Intergraph Customer Support. For more information, visit the SG&I
Support page (http://support.intergraph.com/).
The following is an example of tables, columns, and values that could be defined for Picklists:
GPickLists
Page 24
SQL Server Spatial Data Server
User Guide
PL_Building
StateName Desc
Alabama ALABAMA
Arkansas ARKANSAS
Colorado COLORADO
Texas TEXAS
Florida FLORIDA
Queue Table
The GQUEUE metadata table is used to store the static queues for the Queued Edit command. The
columns in GQUEUE are populated through commands in GeoMedia Professional and are used solely
by the Queued Edit command. This table is not user editable and should not be modified in any way.
ModifiedTables
MODIFIEDTABLES is a join view that provides the object ID for each table/view. The view uses an
inner join between the SYSOBJECTS table and the SYSINDEXES table in conjunction with a union on
GINDEXCOLUMNS. The MODIFIEDTABLEID in this view provides the values for the
MODIFIEDTABLEID used in the MODIFICATIONLOG table. This value is used to identify the edited
table in the MODIFICATIONLOG table. This view is not user editable and should not be modified in
any way.
Page 25
SQL Server Spatial Data Server
User Guide
ModificationLog Table
The MODIFICATIONLOG metadata table tracks modifications made from the GeoMedia environment
for all feature classes in the connected schema. Specifically, it is used to track all inserts, updates, and
changes made to tables/views listed in MODIFIEDTABLES. The MODIFIEDTABLEID is the common link
between MODIFICATIONLOG and MODIFIEDTABLES. The definition of the MODIFICATIONLOG table
is, as follows:
You could also set up a SQL Server job to do this automatically; just make sure it runs when there are
no active GeoMedia sessions.
The MODIFICATIONLOG table is currently only configured to track modifications made through the
GeoMedia environment. Modifications to the data made outside of GeoMedia do not update the
MODIFICATIONLOG table; thus, GeoMedia sessions are not notified of those changes.
To solve this issue, you can create triggers that will automatically provide modification logging. To
prevent insert events from happening twice, the triggers must have names that are recognized by the
SQL Server data server:
The trigger for insert must have a name that corresponds to the feature class name appended by
GMTI.
The trigger for update must have a name that corresponds to the feature class name appended by
GMTU.
The trigger for delete must have a name that corresponds to the feature class name appended by
GMTD.
For example, if the feature class is STATES, the triggers must have the name STATESGMTI,
STATESGMTU, and STATESGMTD. This rule holds true regardless of whether the feature class is a
table or a view. When the triggers are detected, GeoMedia will offload all the modification logging for
the specific feature class to the trigger.
Each trigger fires on the specific editing event and writes an entry into the MODIFICATIONLOG table:
The following are examples of the insert, update, and delete triggers for a feature class (table) called
STATES, whose primary key column is ID:
Page 27
SQL Server Spatial Data Server
User Guide
END;
GO
--
To make notification work with views, you need to add an entry to the base table trigger that handles
the modification to the view. For example, if you have a simple view on STATES called STATES_VIEW,
you could use the following trigger to handle notification for inserts:
Page 28
SQL Server Spatial Data Server
User Guide
END;
GO
The trigger in the above example will handle edit notification for both the table and the view, but
GeoMedia will still attempt to write another notification for the view itself. To stop this second
notification event, another trigger needs to be created on the view using the view name:
CREATE TRIGGER dbo.States_View_GMTI ON dbo.States FOR INSERT AS
DECLARE @TableID INT
if object_id('tempdb..#DisableModificationLog') is null
BEGIN
SELECT @TableID=1
END
GO
The trigger itself is still on the base table STATES; it is only the name of the trigger that refers to
the view. This is essentially a dummy trigger; it does not do anything other than telling GeoMedia not
to write directly to the MODIFICATIONLOG table.
When you edit through a view, it is the underlying base table that is actually edited, and in that case, a
modification log trigger is required. This becomes more complicated as more views are added on the
same base table. Every update to the base table should also update the MODIFICATIONLOG table for
every view that is dependent on the base table. For join views, you will need to take into account all
the base tables and associated views. In the case of join views, most editing would be handled
through INSTEAD OF triggers. In this case, you could embed the insert into the MODIFICATIONLOG
table directly using the INSTEAD OF trigger as long as the trigger name adheres to the rules listed
above.
END;
END;
GO
The use of these triggers can mean data loss is possible for some types of geometries. For example, if
an OrientedPointGeometry is stored in SQL Server, GeoMedia's binary GDO geometry field contains
the actual oriented point geometry, while the native geometry field stores only the point location.
When a non-GeoMedia client updates the native POINT (x y z) geometry, the orientation vector is lost.
A more complicated scenario occurs when arcs are stored in the binary GDOgeometry and
corresponding stroked polylines are stored in the native geometry. In this case, information
referencing the geometry as an arc will be lost, and its stroked PolylineGeometry will remain.
For native geometries using the GEOGRAPHY data type, the spatial index is created using the following
syntax:
CREATE SPATIAL INDEX <TABLE_NAME>_<NATIVE_COLUMN_NAME>_sindx
ON <TABLE_NAME> (<NATIVE_COLUMN_NAME>);
For native geometries using the GEOMETRY data type, the spatial index is created using the following
syntax:
CREATE SPATIAL INDEX <TABLE_NAME>_<NATIVE_COLUMN_NAME>_sindx
ON <TABLE_NAME> (<NATIVE_COLUMN_NAME>)
Page 30
SQL Server Spatial Data Server
User Guide
For existing tables that contain native geometries, the database administrator should ensure that the
spatial indexes exist and are up to date. Spatial indexes can only be created on tables that have a
clustered primary key. The maximum number of key columns allowed on any given table is 15, and the
maximum size of the index key records is 895 bytes. The primary key definition cannot be changed
while the spatial index exists. For best performance, use a single integer-based primary key populated
by an identity increment.
The parameters used to create a spatial index, particularly for projected data, can have a large effect
on overall query performance. Refer to SQL Server Books Online for more information on creating and
optimizing spatial indexes.
A default spatial index is automatically created whenever a table is created via GeoMedia, but
there is no guarantee that this index will be optimal. For best performance, you should optimize every
spatial index for the specific geometry stored and periodically rebuild the index as new data is entered.
Page 31
SQL Server Spatial Data Server
User Guide
For existing native spatial data, the GDO column will have to be added and the association made via
Database Utilities. Initially, the GDO column will only contain NULL rows. During GeoMedia INSERT
and UPDATE operations, the data server will automatically populate records in both columns using
GDO format for the varbinary column and WKB for the native geometry. This ensures that geometry
types that are currently not supported by SQL Server can still be retrieved from the GDO column while
a close approximation is stored in the native geometry column (see the section GeoMedia's Binary
Geometry to Native Geometry Type Matching for more information).
During an INSERT operation, a trigger fires to verify that if a new geometry record is inserted into the
GDO column, the same (or a close approximation) geometry is also inserted into the corresponding
row of the native geometry column. Every geometry record in the GDO column must always have a
corresponding geometry record in the native geometry column (the native geometry record cannot be
NULL if there is a GDO record). However, a new geometry record can be inserted into the native
geometry column without a corresponding record being inserted into the GDO column (the GDO
record can be NULL).
During an UPDATE operation, a trigger fires to verify that both columns are being updated, if only the
row in the native geometry column is being updated, the corresponding row in the GDO column is set
to NULL. This situation would only happen if the native geometry record was edited outside of the
GeoMedia environment. If GeoMedia detects a NULL row in the GDO column, it will read the
corresponding row from the native geometry column. The next time an update on this same row
occurs in GeoMedia, the corresponding row in the GDO column will again be populated. While this
ensures that the geometry records remain in sync, it can lead to loss of data in some cases. For
example, if you have a rotated point that is used for symbology and the native geometry for that point
is edited outside of GeoMedia, the rotation value will revert to zero because the corresponding row in
the GDO column will be set to NULL and GeoMedia will only read the native geometry the next time
the point is displayed. You would have to reset the point's rotation using GeoMedia which would
replace the NULL record in the GDO column with the current native geometry and the updated point
rotation.
Page 32
SQL Server Spatial Data Server
User Guide
make associating the two columns a lot easier when metadata is assigned using Database Utilities. For
example, if the table ROADS contains a native geometry column called CENTERLINE and an identity-
based primary key called ID, you need to add a new column called CENTERLINE_GDO:
ALTER TABLE ROADS ADD COLUMN CENTERLINE_GDO VARBINARY(MAX)
GO
Each table also requires two maintenance triggers for the additional GDO column: an after insert and
an after update trigger. See the Data Server Required Triggers in SQL Server Spatial section for more
information. For the example ROADS table listed above, the triggers would look like the following:
CREATE TRIGGER [dbo].[ROADS_GEOMETRY_INS] ON [dbo].[ROADS]
AFTER INSERT AS
BEGIN
SET NOCOUNT ON;
IF EXISTS (SELECT NULL FROM INSERTED WHERE INSERTED.[CENTERLINE] IS NULL
AND INSERTED.[CENTERLINE_GDO] IS NOT NULL)
BEGIN
RAISERROR(N'Unsupported. Cannot specify value for GDO column only,
native column value must also be provided.', 0, 1)
ROLLBACK TRANSACTION
END
END;
GO
CREATE TRIGGER [ROADS_GEOMETRY_UPG] ON [dbo].[ROADS]
AFTER UPDATE AS
BEGIN
SET NOCOUNT ON;
IF UPDATE([CENTERLINE])
BEGIN
IF NOT UPDATE([CENTERLINE_GDO])
BEGIN
UPDATE [ROADS] SET [CENTERLINE_GDO] = NULL
WHERE EXISTS (SELECT NULL FROM INSERTED
WHERE INSERTED.[ID] = [ROADS].[ID])
END
END
ELSE IF UPDATE([CENTERLINE_GDO])
BEGIN
RAISERROR('Unsupported. Cannot specify value for GDO column only,
native column value must also be provided.', 0, 1)
ROLLBACK TRANSACTION
END
END;
GO
Once the binary column and the triggers have been added, you will need to add the metadata tables
required by GeoMedia applications and then add the metadata entries for each table you want to use
as a feature class. You can use Database Utilities for both of these operations.
Page 33
SQL Server Spatial Data Server
User Guide
Export to SQL Server creates a set of files and an IMPORT.BAT script that will load a SQL Server
database from any data source that GeoMedia Professional is connected to. The process will use the
coordinate system of the GeoWorkspace for the output. The resulting export files use SQL Server’s
CMDSQL and BCP to load the data. For this reason, imports can only be run on a SQL Server
Administrative Client or on the system where SQL Server is installed. This method is very fast and is
ideal for bulk loading large amounts of data (>1000000 rows per table). This method also allows you
to optionally create the required metadata tables.
Output to Feature Classes requires that metadata tables already exist in the target SQL Server
database. To manually create the metadata, use GeoMedia Professional’s Database Utilities, connect
to the new database using an account with the DB_OWNER role, and then click Create Metadata
Tables. Once the metadata is created, you will be able to connect to the warehouse through
GeoMedia Professional and then use Output to Feature Classes to create feature classes. This
command is very flexible and allows you to make modifications to the table/column definitions, key
definitions, and coordinate system assignments. The drawback is in performance; this command is
considerably slower than Export to SQL Server and is best used for smaller datasets (<1000000 rows
per table).
When editing tables using Feature Class Definition, the following caveats apply:
Never change the primary key column of a table after the table has been created. This could make
the table inaccessible by GeoMedia Professional. If you need to do this, use Database Utilities to
drop the metadata before altering the table using SQL Server’s own tools. You can re-add the
metadata after making the table change. If the table has a spatial index, you will need to drop it
before modifying the primary key.
Page 34
SQL Server Spatial Data Server
User Guide
Do not change data types on existing columns using Feature Class Definition. If you need to do this,
drop the metadata first, make the data type change using SQL Server's Management Studio, and
then re-insert the metadata using Database Utilities.
Renaming a table can take a long time if the table contains data, and by default, SQL Server will
disallow this operation. The rename process creates a copy of the existing table, deletes the
original, re-creates the table with a new name, and then populates the data back to the newly
named table. If you need this capability, you may need to activate the capability using SQL Server's
Management Studio.
Copying an existing table will not work due to the way the metadata for the GDO to native geometry
relationship is handled. If you need to copy a table, use SQL Server's Management Console.
Undo/Redo
If you use the Undo/Redo commands while editing the geometry or attributes associated with tables
that contain an identity column, be aware that the numeric sequence is not preserved. Auto-
increment identity columns are usually assigned as primary key columns, and they should not be used
as part of a foreign key. Failure to heed this warning could invalidate view-join definitions.
For example, a row of your data consists of an identity field called ID that contains the value 10, and
there are 300 total records in this table such that MAX(ID)=300. If you accidentally delete the row
ID=10 and use the Undo command to get it back, ID will now be assigned the next available number in
the auto-increment sequence, in this case 301. The original ID=10 is not recoverable. In all cases, the
next available autonumber value will be obtained on an undo/redo operation; the previous
autonumber value will not be preserved. This is actually by design; it is how Microsoft intends the
auto-increment field to be used.
Default Values
Default values can simplify data entry and supply values for columns that are either required or just
need to have a specific entry. Default values are honored by GeoMedia but not directly. When
inserting a new record with the option to display the Attribute Properties dialog box turned on, the
default values are not shown in the dialog box even though they are available at the database level.
They will only be used when the insert occurs. If the fields are required, you will not see an error;
instead, the insert will pick up the default values. However, if the option Copy attribute values from
previous feature is enabled (from the Placement and Editing tab on the Options dialog box), you will
no longer be able to use the default value. Instead, the value used in the previous insert will be used.
If you delete the previous value used in a required field, the default value will still not be used, and you
will get an error message.
For best results with defaults, either disable Copy attribute values from previous feature option, or do
not make the fields required. Function based defaults also will work, but again, you must disable the
Copy attribute values from previous feature option. This same problem will occur if you are using
triggers to populate required fields.
Page 35
SQL Server Spatial Data Server
User Guide
Spatial Filtering
Spatial filtering will use the spatial index created on the tables' native geometry columns. The
performance of spatial indexes can vary widely, so if performance is an issue, consider re-creating the
spatial indexes using different parameters. GeoMedia applications have four different spatial filter
options (listed in order of performance):
Coarse Overlap – This method uses SQL Server's FILTER method to return the results. This is
generally the fastest performing filter because it only uses the spatial index; however, it will always
pick up extraneous values.
Overlap – This method uses SQL Server's STINTERSECTS method.
Inside - This method uses SQL Server's STWITHIN method.
Entirely Inside - This method uses SQL Server's STWITHIN method and then processes the final
results on the client. It will generally be the slowest filter method.
Simple rectangular polygons will return the quickest results; the more complicated the filter area, the
slower the process. For geographic data, SQL Server only supports FILTER and STINTERSECTS. For
these cases, GeoMedia will perform the final filtering on the client.
For a view to be treated as a spatial feature class, the view definition must include both the native
geometry column and GeoMedia's binary GDO column. Metadata is also required to see the view in
GeoMedia applications, and Database Utilities can be used to insert the required metadata. For views
to be updatable in GeoMedia Professional, there must also be an entry for the key column in the
GINDEXCOLUMNS metadata table. This is required for both spatial and non-spatial feature classes
that are view based.
Page 36
SQL Server Spatial Data Server
User Guide
DATABASE UTILITIES
Database Utilities consist of several utilities for managing and updating Access, Oracle, and SQL Server
databases for use with GeoMedia products. These utilities are delivered with GeoMedia Professional
and are accessible from the Start menu.
Database Utilities includes seven separate database tools, but only six of these are available for SQL
Server. Here are the six basic tools:
You can connect to a SQL Server spatial databases using either Windows domain authentication or
SQL Server authentication. For best results, all Database Utilities operations should be performed
by a database administrator login or by any user who has been assigned the DB_OWNER role.
For new databases, select the Create Metadata Tables command before attempting any other
GeoMedia operation. Subsequent use of this command will update existing metadata with the
changes for the given release (if any).
For tables or views created in SQL Server, use the Insert Feature Class Metadata command to add
the metadata required to see these as feature classes in GeoMedia. The primary difference between
the SQL Server spatial data server and the standard SQL Server data server is the assignment of the
native geometry field and the native SRID value:
Note: For the Geographic data type, you must select or enter a SRID (EPSG code) that matches the
coordinate system being used and the code must exist in SQL Server. For the Geometry data type,
the default SRID is 0 because SQL Server does not use or store SRID’s for projected data. You can
enter any SRID here and it will be stored in metadata but neither SQL Server not GeoMedia will
utilize it for coordinate system operations.
To alter metadata already entered for existing feature classes, use the Edit Feature Class Metadata
command.
To delete the metadata for an existing feature class, use the Delete Feature Class Metadata
command. If significant DDL modifications are going to be made to a table or view, the metadata
should first be deleted and then re-inserted after the modifications have been made.
Page 37
SQL Server Spatial Data Server
User Guide
To assign a default coordinate system to a new database or to re-assign coordinate systems for
existing feature classes, use the Assign Coordinate System command. For existing feature classes,
this command changes the coordinate system assignment without changing the data. Use discretion
here; assigning an incorrect coordinate system can cause problems when editing. Make sure the
correct coordinate system is assigned.
Page 38
SQL Server Spatial Data Server
User Guide
To use this command, you first select the data to be exported from a treeview of all feature
classes/queries, including categories and reference features. You can select any mixture of feature
classes, queries, categories, and reference features, across any number of connections.
SQL Server non-Spatial – for SQL Server 2005 or later. Geometry storage uses VARBINARY(MAX).
SQL Server Spatial – SQL Server 2008 or later. Geometry storage uses native spatial
GEOMETRY/GEOGRAPHY combined with VARBINARY(MAX) for unsupported geometry types.
SQL Server 2000 was de-supported starting from GeoMedia 6.1.11. Only SQL Server 2005 and
later version are supported starting from GeoMedia 6.1.11. Native spatial storage is only available in
SQL Server 2008 or later.
You can write the command output in SQL Server native spatial format for either a projected or non-
projected target coordinate system. For a non-projected target coordinate system, you select the
appropriate spatial reference system from all the supported spatial reference systems.
The export process takes the source data as is with no modification. Source data that is not
from another database may have problems once it is imported into the SQL Server spatial
environment. Column names may be illegal, primary key columns may not exist, and there may be
data issues. After import, verify that the data model conforms to the requirements of SQL Server
spatial, and make any necessary corrections before using the data in the GeoMedia environment. You
should also make sure that spatial indexes are created on the spatial geometry columns after any
import operation.
In the Exporting options on the Export to SQL Server dialog box, the Export native spatial format
check box is enabled whether the active target coordinate system is projected or non-projected.
When this check box is checked and a non-projected target coordinate system is active, the Spatial
reference system identifier drop-down list is enabled and populated with all supported spatial
reference systems, from which you choose the appropriate one. Export to SQL Server creates the
following files based on the coordinate system of the GeoWorkspace:
Page 39
SQL Server Spatial Data Server
User Guide
FEATURECLASSNAME_POST.SQL (one for each feature class or query exported)—Populates the SQL
Server metadata table and all GeoMedia metadata tables.
FEATURECLASSNAME.DAT—Contains the attribute and geometry data for use with the bulk load
processor.
IMPORT.BAT—Script file with all of the above files, which uses common defaults and can be edited
for handling specific options.
EXPORT.LOG—Log file that contains either the cause of failure if error conditions arise or the
number of features successfully exported per selected feature class during the export process.
By default, the data is exported to the \WAREHOUSES folder. You can change this location on the
dialog box, and this location is then remembered as a session preference.
Error conditions are not reported to you while the Export to SQL Server command is being run.
This is to improve performance and to ensure uninterrupted exports of large sets of data. You should
review the EXPORT.LOG file at the completion of the export to determine if any errors occurred during
the export process.
To export data to SQL Server:
1. Connect to the existing warehouse from which you want to export data.
2. Verify that the GeoWorkspace coordinate system is the appropriate target coordinate system for
the data that is to be exported.
3. Select Warehouse > Export to > SQL Server to open the Export to SQL Server dialog box.
4. Select the appropriate items from the Features to export tree view.
Holding the cursor over an entry displays a tooltip with the geometry type of the entry.
5. OPTIONAL: Check the Export to native spatial format check box.
Page 40
SQL Server Spatial Data Server
User Guide
6. With the check box in the previous step checked, and using an active non-projected target
coordinate system, select the appropriate reference system from the Spatial reference system
identifier drop-down list,
When you select a spatial reference system identifier for the first time with an active non-
projected coordinate system, the following warning message is displayed:
Verify that the GeoWorkspace coordinate system is identical to the selected spatial system
before proceeding.
This warning is also displayed when the default selection is restored from session preferences and
you have not changed it.
7. Select the appropriate Export folder.
8. Click Apply to export the data.
The following error message is displayed when there is no selected spatial reference system
identifier for a non-projected active coordinate system, and you click Apply:
Select a spatial reference system identifier that matches the GeoWorkspace coordinate
system before proceeding.
9. Examine the output ASCII files, and modify them if necessary.
10. Run the output script file.
11. Use Bulk Loader to create SQL Server tables and to load the geometry and attributes to the SQL
Server database.
Page 41
SQL Server Spatial Data Server
User Guide
The information contained in this document (the “Work”) is the exclusive property of Intergraph Corporation (“Intergraph”). The Work is protected under
United States copyright law and other international copyright treaties and conventions, to include the Berne and Geneva Phonograms Conventions, the
WIPO Copyright Treaty, and the World Trade Organization.
No part of the Work may be reproduced, stored, or transmitted in any form or by any means, electronic or mechanical, including photocopying and
recording, or by any information storage or retrieval system, except as expressly permitted in writing by Intergraph. All such requests should be sent to
the attention of Manager of Customer Education of the Hexagon Geospatial Division of Intergraph (“Hexagon Geospatial”) at the following address:
Hexagon Geospatial
5051 Peachtree Corners Circle
Norcross, Georgia 30092-2500 USA
Page 42