GeoMedia SQL Server Spatial - User Guide
←
→
Page content transcription
If your browser does not render page correctly, please read the page content below
Copyright Copyright © 2012 Intergraph Corporation. All Rights Reserved. Including software, file formats, and audiovisual displays; may be used pursuant to applicable software license agreement; contains confidential and proprietary information of Intergraph and/or third parties which is protected by copyright law, trade secret law, and international treaty, and may not be provided or otherwise made available without proper authorization from Intergraph Corporation. U.S. Government Restricted Rights Legend Use, duplication, or disclosure by the government is subject to restrictions as set forth below. For civilian agencies: This was developed at private expense and is "restricted computer software" submitted with restricted rights in accordance with subparagraphs (a) through (d) of the Commercial Computer Software - Restricted Rights clause at 52.227-19 of the Federal Acquisition Regulations ("FAR") and its successors, and is unpublished and all rights are reserved under the copyright laws of the United States. For units of the Department of Defense ("DoD"): This is "commercial computer software" as defined at DFARS 252.227-7014 and the rights of the Government are as specified at DFARS 227.7202-3. Unpublished - rights reserved under the copyright laws of the United States. Intergraph Corporation P.O. Box 240000 Huntsville, AL 35813 Terms of Use Use of this software product is subject to the End User License Agreement ("EULA") delivered with this software product unless the licensee has a valid signed license for this software product with Intergraph Corporation. If the licensee has a valid signed license for this software product with Intergraph Corporation, the valid signed license shall take precedence and govern the use of this software product. Subject to the terms contained within the applicable license agreement, Intergraph Corporation gives licensee permission to print a reasonable number of copies of the documentation as defined in the applicable license agreement and delivered with the software product for licensee's internal, non-commercial use. The documentation may not be printed for resale or redistribution. Warranties and Liabilities All warranties given by Intergraph Corporation about equipment or software are set forth in the EULA provided with the software or applicable license for the software product signed by Intergraph Corporation, and nothing stated in, or implied by, this document or its contents shall be considered or deemed a modification or amendment of such warranties. Intergraph believes the information in this publication is accurate as of its publication date. The information and the software discussed in this document are subject to change without notice and are subject to applicable technical product descriptions. Intergraph Corporation is not responsible for any error that may appear in this document. The software discussed in this document is furnished under a license and may be used or copied only in accordance with the terms of this license. No responsibility is assumed by Intergraph for the use or reliability of software on equipment that is not supplied by Intergraph or its affiliated companies. THE USER OF THE SOFTWARE IS EXPECTED TO MAKE THE FINAL EVALUATION AS TO THE USEFULNESS OF THE SOFTWARE IN HIS OWN ENVIRONMENT. Intergraph is not responsible for the accuracy of delivered data including, but not limited to, catalog, reference and symbol data. Users should verify for themselves that the data is accurate and suitable for their project work. Trademarks Intergraph, the Intergraph logo, and GeoMedia are registered trademarks of Intergraph Corporation. Microsoft and Windows are registered trademarks of Microsoft Corporation. Bing is a trademark of Microsoft Corporation. Google Maps is a trademark of Google Incorporated. Pictometry Intelligent Images is a registered trademark of Pictometry International Corporation. Other brands and product names are trademarks of their respective owners.
Contents Introduction .................................................................................................................................................. 5 Delivery and Connection ............................................................................................................................ 5 Prerequisites ........................................................................................................................................... 5 Connections ............................................................................................................................................ 5 Password Persistence ............................................................................................................................ 6 Permissions............................................................................................................................................. 6 SQL Server Warehouse Requirements .................................................................................................. 7 Data Storage and Type Matching ............................................................................................................... 9 Geometry Storage ................................................................................................................................... 9 GeoMedia's Binary Geometry to Native Geometry Type Matching ...................................................... 11 SQL Server to GeoMedia Data Type Matching .................................................................................... 14 GeoMedia to SQL Server Data Type Matching .................................................................................... 15 GeoMedia Metadata Requirements .......................................................................................................... 16 Scalar Functions ................................................................................................................................... 17 AttributeProperties Table ...................................................................................................................... 18 FieldLookup Table ................................................................................................................................ 19 GAliasTable........................................................................................................................................... 19 GCoordSystem Table ........................................................................................................................... 20 GeometryProperties Table .................................................................................................................... 21 GFeatures Table ................................................................................................................................... 22 GFieldMapping Table ............................................................................................................................ 23 GIndexColumns Table .......................................................................................................................... 24 GParameters Table ............................................................................................................................... 25 GPickLists Table ................................................................................................................................... 27 GQueue Table....................................................................................................................................... 29 ModifiedTables ...................................................................................................................................... 29 ModificationLog Table ........................................................................................................................... 29 Data Server Required Triggers in SQL Server Spatial ......................................................................... 34 SQL Server Spatial Indexing ................................................................................................................. 35 Working with SQL Server Spatial ............................................................................................................ 37 Using Existing Native Spatial Data ....................................................................................................... 38 Importing Spatial Data .......................................................................................................................... 39 Existing Standard SQL Server Data ..................................................................................................... 40 Feature Class Definition ........................................................................................................................ 40 Undo/Redo ............................................................................................................................................ 41 Default Values ....................................................................................................................................... 41 Spatial Filtering ..................................................................................................................................... 41 Views and Join Views ........................................................................................................................... 42 GeoMedia SQL Server Spatial User Guide 3
Contents Database Utilities ....................................................................................................................................... 43 Exporting to SQL Server ........................................................................................................................... 45 Technical Support and Information ......................................................................................................... 49 Self-Help Support Tools ........................................................................................................................ 49 Phone Numbers .................................................................................................................................... 49 Other Links ............................................................................................................................................ 51 Index ........................................................................................................................................................... 53 4 GeoMedia SQL Server Spatial User Guide
SECTION 1 Introduction The SQL Server Spatial data server is an add-on component for GeoMedia Professional that makes it easier to connect to Microsoft’s Sequel Server (SQL Server 2008 or later) databases that use native spatial geometry storage. This allows GeoMedia applications to use native SQL Server Spatial databases as geospatial warehouses. Once installed, the data server is accessed through GeoMedia Professional's Warehouse > New Connection command. Delivery and Connection 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 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 used by the SQL Server spatial data server is different from the metadata used by the standard SQL Server data server, and 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 GeoMedia SQL Server Spatial User Guide 5
Delivery and Connection 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 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. 6 GeoMedia SQL Server Spatial User Guide
Delivery and Connection 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. SQL Server Warehouse Requirements Connections to SQL Server spatial warehouses have several restrictions and requirements that must be adhered to. Violation of any of these requirements may lead to a connection failure or the inability to load data from the connection. These connection requirements and restrictions are listed below: 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 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. Comparisons on data values will be case-sensitive, so caution is advised when identifier names are stored in the database. 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 allowed but are not recommended for insert operations as the user will need to manually enter the appropriate key value. For the best results and the best performance, use an integer-based auto-increment (identity) primary key column. 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. Even when key preserved, DML operations on join-views will require the use of instead of triggers. GeoMedia SQL Server Spatial User Guide 7
Delivery and Connection 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. 8 GeoMedia SQL Server Spatial User Guide
Data Storage and Type Matching Data Storage and Type Matching Geometry Storage The SQL Server Spatial data server uses two storage columns: one column is used to store the SQL Server's native spatial data types (GEOMETRY or GEOGRAPHY); the second one is a binary column (varbinary(max)) storing the GDO (GeoMedia Data Object - GeoMedia's native binary storage format) geometry blob used for unsupported geometries (for example, arcs, oriented points, text, and raster). 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. 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. 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: GeoMedia SQL Server Spatial User Guide 9
Data Storage and Type Matching Name Data Type Description varbinary(MAX) The binary GDO geometry column.
Data Storage and Type Matching manually inserted for each table using Database Utilities before GeoMedia recognizes these as feature classes. 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 the metadata reflects the association between the GDO geometry and the native geometry column. GeoMedia's Binary Geometry to Native Geometry Type Matching To write geometric data to SQL Server, GeoMedia’s SQL Server Spatial data server converts GeoMedia native GDO geometry format to SQL Server native spatial format using the following: GeoMedia Geometry Type SQL Server GDO column Native column Geometry Type content content PointGeometry POINT (x y z) Exact point OrientedPointGeometry POINT (x y z) Full GDO Exact point, no orientation TextPointGeometry POINT (x y z) Full GDO Point origin LineGeometry LINESTRING( Full GDO Two-point linestring x1 y1 z1, x2 y2 z2) PolylineGeometry LINESTRING( N-point linestring x1 y1 z1, …, xN yN zN) ArcGeometry LINESTRING( Full GDO Stroked N-point x1 y1 z1, linestring …, xN yN zN) GeoMedia SQL Server Spatial User Guide 11
Data Storage and Type Matching GeoMedia Geometry Type SQL Server GDO column Native column Geometry Type content content CompositePolylineGeometry MULTILINESTRING( Full GDO, even Composite ( when no member members need to is approximated, be approximated x11 y11 z11, in order to (like arcs) in a …, recreate multiline string; xN1 yN1 zN1 composite. otherwise, exact ), multiline string. …, (x1M y1M z1M, …, xNM yNM zNM )) PolygonGeometry POLYGON( Exact polygon ( x1 y1 z1, …, xN yN zN )) CompositePolygonGeometry MULTILINESTRING( Full GDO, even Composite ( when no member members need to is approximated, be approximated x11 y11 z11, in order to (like arcs) in a closed …, recreate multiline string; xN1 yN1 zN1 composite. otherwise. exact ), closed multiline …, string. (x1M y1M z1M, …, xNM yNM zNM )) 12 GeoMedia SQL Server Spatial User Guide
Data Storage and Type Matching GeoMedia Geometry Type SQL Server GDO column Native column Geometry Type content content BoundaryGeometry POLYGON( Full GDO if any of Composite ( the members members need to (exterior, interior) be approximated x1_int y1_int z1_int, cannot be (like arcs) in a …, represented fully polygon string; xN_int yN_int zN_int by native type; otherwise, exact ), otherwise, this polygon string. ( 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 x1 y1 z1, raster 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 the members representations or GeoMedia SQL Server Spatial User Guide 13
Data Storage and Type Matching GeoMedia Geometry Type SQL Server GDO column Native column Geometry Type content content geometries, (exterior, interior) approximations, MULTILINESTRING for cannot be according to the line geometries, represented fully rules established by native type; above, for each GDO MULTIPOLYGON for otherwise, this collection member. area geometries, column will be GEOMETRYCOLLECTIO NULL. N when mixed SQL Server to GeoMedia Data Type Matching To use data from SQL Server, GeoMedia’s SQL Server Spatial data server converts SQL Server data types to GeoMedia data types. The following table shows how the SQL Server data types are mapped to the GeoMedia types. Any SQL Server data types missing from this list are considered unsupported and are ignored. SQL Server Data Type GeoMedia Data Type binary LongBinary varbinary bit Boolean char(size) Text if size = 6 and p < 11 p is precision Double for all other cases. s is scale float Double 14 GeoMedia SQL Server Spatial User Guide
Data Storage and Type Matching SQL Server Data Type GeoMedia Data Type binary LongBinary varbinary int Long money Currency real Single smallint Integer tinyint Byte uniqueidentifier GUID GeoMedia to SQL Server Data Type Matching The following table identifies the mapping used when converting from GeoMedia data types to SQL Server data types and whether specific metadata is required for the mapping: GeoMedia Data Type SQL Server Data Type Metadata Required? Boolean bit No Byte tinyint No Integer smallint Yes for autonumber Long int No Single real No Double float No Currency money No Date datetime No Text nvarchar No LongBinary varbinary No Memo ntext No GUID uniqueidentifier No GeoMedia SQL Server Spatial User Guide 15
GeoMedia Metadata Requirements GeoMedia Metadata Requirements GeoMedia applications require specific metadata objects, and these must exist in the SQL Server database before a connection can occur. GeoMedia's metadata tables contain information about both the attribute and geometry tables stored in the database. The metadata functions control the follow of geometry data to and from GeoMedia applications. The following table lists the required metadata and its object type. GeoMedia Metadata Objects Type AttributeProperties Table FieldLookup Table GAliasTable Table GCoordSystem Table GeometryProperties Table GFeatures Table GFieldMapping Table GIndexColumns Table GParameters Table GPickLists Table GQueue Table GTileIndexes Table ModifiedTables View ModificationLog Table Binary2SqlGeography Function Binary2SqlGeometry Function SqlGeography2Binary Function SqlGeometry2Binary Function 16 GeoMedia SQL Server Spatial User Guide
GeoMedia Metadata Requirements 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 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 utilizes binary format for 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 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 native GEOGRAPHY data type to GeoMedia's binary data type when reading WKB data. SqlGeometry2Binary – Converts 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. GeoMedia SQL Server Spatial User Guide 17
GeoMedia Metadata Requirements 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. 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. 18 GeoMedia SQL Server Spatial User Guide
GeoMedia Metadata Requirements 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. 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. GeoMedia SQL Server Spatial User Guide 19
GeoMedia Metadata Requirements 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 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. 20 GeoMedia SQL Server Spatial User Guide
GeoMedia Metadata Requirements 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. GeoMedia SQL Server Spatial User Guide 21
GeoMedia Metadata Requirements FieldDescription – A user-provided description of the column. 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. 22 GeoMedia SQL Server Spatial User Guide
GeoMedia Metadata Requirements 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: TABLE_NAME – The name of the table. COLUMN_NAME – The column in the table that this information apples to. The TABLE_NAME/COLUMN_NAME combination makes up the primary key. 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: GeoMedia SQL Server Spatial User Guide 23
GeoMedia Metadata Requirements 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: The primary key is a combination of the OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME, and COLUMN_NAME fields. OBJECT_SCHEMA – The owner of the view (the default is 'dbo'). OBJECT_NAME – The name of the view. INDEX_NAME – The primary key index name from the base table. COLUMN_NAME – The name of a column in the view that will use the index in INDEX_NAME. 24 GeoMedia SQL Server Spatial User Guide
GeoMedia Metadata Requirements INDEX_TYPE – The type of the index: ‘P’ for primary, ‘U’ for unique. The default value is ‘P’. If this field is missing, the first index will be assumed to be the primary index. If a view does not have a key defined in the GIndexColumns, it will be read-only, and no DML operations will be allowed. COLUMN_POSITION – This field is the order of the column within the index. The default value is 1. BASE_OBJECT_SCHEMA – This field is the owner of the table (view) on which the view is based. If this field contains NULL (empty string), notification will not be supported. Only triggers can support notification in this case. BASE_OBJECT_NAME – This field is the name of the table (view) on which the view is based. If this field is missing or contains NULL (empty string), notification will not be supported. Only triggers can support notification in this case. BASE_COLUMN_NAME – This field is the name of the corresponding field of the base table/view. This field is used for name aliasing. If this field contains NULL (empty string), column name aliasing will not be supported. 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. GeoMedia SQL Server Spatial User Guide 25
GeoMedia Metadata Requirements 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: TypeForNativeGeometryStorage – This controls whether tables will be created using the GEOMETRY or the GEOGRAPHY data type. If you are using projected data, use GEOMETRY. If your data is GPS or longitude/latitude based, use GEOGRAPHY. DefaultNativeStorageSrid – This assigns the default SRID to use. If the TypeForNativeGeometryStorage is set to GEOMETRY, this value must be set to 0. If TypeForNativeGeometryStorage is set to GEOGRAPHY, this value must be set to an SRID that is currently supported by SQL Server. Use the following query for a list of the SRIDs currently supported by SQL Server: SELECT * FROM SYS.spatial_reference_systems DefaultCoordinateSystem – This parameter contains the CSGUID from the GCoordSystem table that corresponds to a GeoMedia coordinate system that is to be used as the default for all feature classes created through the GeoMedia Professional environment. If the TypeForNativeGeometryStorage is set to GEOGRAPHY, this value should correspond to the CSGUID of a coordinate system in the GCoordSystem table that matches the coordinate system for the SRID used for the DefaultNativeStorageSrid. 26 GeoMedia SQL Server Spatial User Guide
GeoMedia Metadata Requirements XUpperBound, YUpperBound, XLowerBound, YLowerBound – These parameters control the MBR or bounding box range used by GeoMedia Professional when creating spatial indexes on geometry data types. Spatial indexes will perform better when the range used here more closely matches the range of the data indexed. Data that falls outside the range will not be indexed but will still be included in the results of the second pass filter, if applicable. Optimizing the spatial indexes for each feature class will improve performance and should be done at the database level. GeoMedia Professional will only create a default spatial index, and it may or may not be optimal. 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. GeoMedia SQL Server Spatial User Guide 27
GeoMedia Metadata Requirements 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 FEATURENAME FIELDNAME PICKLIST VALUE DESCRIPTION FILTERCLAUSE TABLENAME FIELDNAME FIELDNAME BUILDINGS NAME PL_BUILDING CODE_VALUE VAL_DESCRIPTION BLD_TYPE = 'NAME' BUILDINGS STATE PL_STATE STATE_NAME DESC BUILDINGS TYPE PL_BUILDING CODE_VALUE VAL_DESCRIPTION BLD_TYPE = 'TYPE' PL_Building CodeValue ValDescription Bld_Type 0 MOTEL TYPE 1 MARRIOT NAME 2 HOLIDAY INN NAME 3 BED AND BREAKFAST TYPE 4 DAYS INN NAME PL_State StateName Desc Alabama ALABAMA Arkansas ARKANSAS 28 GeoMedia SQL Server Spatial User Guide
GeoMedia Metadata Requirements StateName Desc 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. 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: GeoMedia SQL Server Spatial User Guide 29
GeoMedia Metadata Requirements ModificationNumber – The auto-increment key filed for the table. Type – The type of edit that has occurred: 1 for insert, 2 for update, and 3 for delete. ModifiedTableID – The column identifier from ModifiedTables. KeyValue1 to KeyValue10 – These fields store the primary key column values for the edited row. If there is only one primary key column, only KeyValue1 is used. For multi-column primary keys, the values from each field that makes up the key are stored here. A primary key can be made up of a maximum of 10 columns. SESSIONID – Identifies the SQL Server session making the edit. This field is populated automatically from a function-based default value. ModifiedDate – Identifies the date and time of the edit. This field is populated automatically from a function-based default value. The ModificationLog table is part of the GeoMedia notification system. All edits made to feature classes within the connected SQL Server database are tracked in the ModificationLog table. Over time, this table can grow very large very quickly. Because the size of the ModificationLog table can negatively affect editing performance in GeoMedia applications, the table should be periodically truncated. However, do not clear this table while there are open GeoMedia sessions. The Clear Modification Log command in Database Utilities will truncate this table. You can also use the following SQL to clear this table: Truncate Table dbo.ModificationLog 30 GeoMedia SQL Server Spatial User Guide
GeoMedia Metadata Requirements 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: Type is populated with the following constants: 1 - Insert, 2 – Update, or 3 – Delete. ModifiedTableID is populated with the object ID of the object for which the entry is created. This field comes from the ModifiedTables view. KeyValue1 to KeyValue10 are populated by converting the primary key value to nvarchar(255). For a single column primary key, only KeyValue1 is populated. If the primary key consists of multiple columns, the additional columns can be added to KeyValue2 through KeyValue10. Primary keys consisting of more than 10 columns are not supported. If the primary key is user editable (non-composite or does not contain an identity field), all modifications must create two entries, one for the old key value and one for the new key value. The following are examples of the insert, update, and delete triggers for a feature class (table) called States, whose primary key column is ID: GeoMedia SQL Server Spatial User Guide 31
GeoMedia Metadata Requirements CREATE TRIGGER dbo.StatesGMTI ON dbo.States FOR INSERT AS DECLARE @TableID INT IF object_id('tempdb..#DisableModificationLog') IS null SELECT @TableID=ModifiedTableID FROM ModifiedTables WHERE TableName='States' INSERT INTO ModificationLog(Type,ModifiedTableID,KeyValue1) SELECT 1, CONVERT(nvarchar(20),@TableID),CONVERT(nvarchar(255), inserted.ID) FROM inserted GO -- CREATE TRIGGER dbo.StatesGMTU ON dbo.States FOR UPDATE AS DECLARE @TableID INT IF object_id('tempdb..#DisableModificationLog') IS null SELECT @TableID=ModifiedTableID FROM ModifiedTables WHERE TableName='States' BEGIN IF update(ID) INSERT INTO ModificationLog(Type,ModifiedTableID,KeyValue1) SELECT 2, CONVERT(nvarchar(20),@TableID), CONVERT(nvarchar(255),deleted.ID) FROM deleted INSERT INTO ModificationLog([Type],ModifiedTableID,KeyValue1) SELECT 2, CONVERT(nvarchar(20),@TableID), CONVERT(nvarchar(255),inserted.ID) FROM inserted END GO -- CREATE TRIGGER dbo.StatesGMTD ON dbo.States FOR DELETE AS DECLARE @TableID INT IF object_id('tempdb..#DisableModificationLog') IS null SELECT @TableID=ModifiedTableID FROM ModifiedTables WHERE TableName='States' INSERT INTO ModificationLog(Type,ModifiedTableID,KeyValue1) SELECT 3, CONVERT(nvarchar(20),@TableID), CONVERT(nvarchar(255), deleted.ID) FROM deleted GO 32 GeoMedia SQL Server Spatial User Guide
GeoMedia Metadata Requirements -- To make this 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: CREATE TRIGGER dbo.StatesGMTI ON dbo.States FOR INSERT AS DECLARE @TableID INT DECLARE @ViewID INT if object_id('tempdb..#DisableModificationLog') is null SELECT @TableID=ModifiedTableID FROM ModifiedTables WHERE TableName='States' INSERT INTO ModificationLog(Type,ModifiedTableID,KeyValue1) SELECT 1, convert(nvarchar(20),@TableID), convert(nvarchar(255), inserted.ID) FROM inserted SELECT @TableID=ModifiedTableID FROM ModifiedTables WHERE TableName='States_View' INSERT INTO ModificationLog(Type, ModifiedTableID,KeyValue1) SELECT 1, convert(nvarchar(20),@ViewID), convert(nvarchar(255), inserted.ID) FROM inserted 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 SELECT @TableID=ModifiedTableID FROM ModifiedTables WHERE TableName='States_View' 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. GeoMedia SQL Server Spatial User Guide 33
GeoMedia Metadata Requirements 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. Data Server Required Triggers in SQL Server Spatial To maintain the relationship between the native geometry and GeoMedia's binary GDO geometry, an after-insert and an after-update trigger are required for every table. When a native geometry column is inserted/updated outside of GeoMedia, this trigger sets GeoMedia's binary GDO geometry to NULL. The next time the data is read by the data server, the binary GDO column value will be reconstructed from the native value. These triggers are automatically created for every feature class created by GeoMedia Professional. If you create your tables outside of the GeoMedia Professional environment, you will need to manually add these triggers. The general format for each of these triggers is shown below: CREATE TRIGGER __INS ON AFTER INSERT AS BEGIN SET NOCOUNT ON; IF EXISTS (SELECT NULL FROM INSERTED WHERE INSERTED. IS NULL AND INSERTED. 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 __UPG AFTER UPDATE AS BEGIN SET NOCOUNT ON; 34 GeoMedia SQL Server Spatial User Guide
You can also read