Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Occasional Contributor
Posts: 5
Registered: ‎08-07-2017
Accepted Solution

Use GeoMedia automation to export features to a (new) table

Hi There

 

I'm trying to automate exporting (Geometry based line and area) data to a new table. But, I'm getting errors relating to setting the coordinate system. Specifically, in this case I'm trying to export a buffer zone (area geometry).

 

In the Object Reference help file there is a an example that shows how to use the Output To Table Service [code excerpt below]. The example doesn't show how to specify a coordinate system, but there is an additional property to set a coordinate system (OutputCoordSystem) if the destination table doesn't have one i.e. the table is NEW and needs to be created first. But I get an error when I try to set the coordinate system to the one in use my active/open Document:

 

Unable to get the coordinate system of the input recordset primary geometry.

If I don't set the OutputCoordSystem property, I get this error:

 

Input recordset's coordinate system is missing.

Code:

Imports GMOUTPUTTOTABLESERVICE = Intergraph.GeoMedia.GMOUTPUTTOTABLESERVICE
Dim objOutputToTableService As GMOUTPUTTOTABLESERVICE.OutputToTableService
objOutputToTableService = CreateObject("GeoMedia.OutputToTableService")
         With objOutputToTableService
             .DisableModificationLogging = True
             .InputRecordset = objSchemaProjectionPipe.OutputRecordset
             .OutputTableName = "MyCities"
             .OutputMode = GMOUTPUTTOTABLESERVICE.gmopmConstants.gmopmNewOrAppend
             .NewTableKeyMode = GMOUTPUTTOTABLESERVICE.gmntkmConstants.gmntkmNewKey
             .NewTableAutonumberMode = GMOUTPUTTOTABLESERVICE.gmntamConstants.gmntamPreserveValues
             .OutputConnection = objConn
             .OutputLogFileName = "C:\temp\GMOTTS.log"
             .Execute()
         End With
objConn.BroadcastDatabaseChanges()

Is OutputToTableService the right service for the task? How do I correctly export an area geometry with a coordinate system?

Technical Evangelist
Posts: 531
Registered: ‎09-11-2015

Re: Use GeoMedia automation to export features to a (new) table

Hi Top-Dog,

 

the error message complains about the INPUT recordset, so I suggest you to focus on how the SchemaProjectionPipe and all parent pipes have been created.

 

Pavel

Occasional Contributor
Posts: 5
Registered: ‎08-07-2017

Re: Use GeoMedia automation to export features to a (new) table

[ Edited ]

The input recordset seems to be fine (in my case I'm generating the recordset with the BufferPipe and then merging buffer zones with the functional attributes pipe). I've managed to save the output of the BufferPipe+FunctionalAttributesPipe as a query and display it on the map/legend without issues, and I use that same recordet (referenced in the saved query) as the input to the OutputToTableService. There don't appear to be any coordinate systems properties to set/get for the GRecordset object. Using the GetExtension and  ExtendedPropertySet I can get the geometry type (I get 2 or gdbAreal, which is what I expect for an area object).

Technical Evangelist
Posts: 531
Registered: ‎09-11-2015

Re: Use GeoMedia automation to export features to a (new) table

Can you simulate the whole procedure (including OTFC) from GeoMedia GUI to see what will happen? Also if you run your code as a command, try to run it directly from GeoMedia, if you tested it from a debugger.

 

Pavel

Occasional Contributor
Posts: 5
Registered: ‎08-07-2017

Re: Use GeoMedia automation to export features to a (new) table

[ Edited ]

Sorry, what's OTFC?

 

Anyway, when I try the Output to Feature class via the GUI I get the same error (from GMOTTS.log):

Start: 09-Aug-2017 08:26:49

Component Name: Output to Table Service

Input Name: Queries.2016 Road Buffer

Information: Output Connection: InfoDisc2014

Information: Output Table Name: F2016_Road_Buffer

Information: Output Mode: New

Information: Key Mode: New Key

Information: AutoNumber Mode: Preserve Values

Error: Input recordset's coordinate system is missing.

End: 09-Aug-2017 08:26:49

 

This is after a prompt that indicates NEW mode will be used since there isn't an existing table with the same name/coordinate system in the warehouse pointed to via the connection. The warehouse/DB I'm trying to output to already exists i.e. I did not create it via Geomedia and it contains normal tabular data in several different tables (all non-geometric data).

 

If I use the Geomedia GUI to create a new warehouse (Access DB) and select that as the output then it seems to work (less an error on one of the features):

Start: 09-Aug-2017 09:39:04

Component Name: Output to Table Service

Input Name: Queries.2016 Road Buffer

Information: Output Connection: testDB

Information: Output Table Name: F2016_Road_Buffer

Information: Output Mode: New

Information: Key Mode: New Key

Information: AutoNumber Mode: Preserve Values

Information: Input  Attributes:  BufferGeometry

Information: Valid Attributes:  BufferGeometry

Error: Unable to update the record. (Error: Error computing spatial key value for FieldError getting Field value ) where

Information: Number of features output:  15

Information: Number of features skipped:  1

End: 09-Aug-2017 09:39:08

 

So there must be some setup work that needs to be done on the database to prepare it for geometric data. The OutputToCoordSystem property mentions the "target warehouse's GCoordSystem table", but I can't find any more information on it. Creating the warehouse via GeoMedia seems to create a whole bunch of auxiliary tables (in addition to the F2016_Road_Buffer):

GeoMedia Road Buffer.PNG

 

So the answer is - to output to a table you need to have a GeoMedia warehouse/connection object as opposed to a an ordinary DB. For some reason I thought that GeoMedia would create the necessary support tables if I tried to output to an ordinary DB table.

 

As a follow on question, do you know what might be causing the "Error: Error computing spatial key value for FieldError getting Field value"?

Technical Evangelist
Posts: 531
Registered: ‎09-11-2015

Re: Use GeoMedia automation to export features to a (new) table

OTFC means Output To Feature Classes. And indeed, if you want to write anything from GeoMedia into any database, the database must contain GeoMedia metadata, There is a utility delivered with GeoMedia called "Database Utilities", which should be used to create the metedata tables prior you want to gain write access to that database for GeoMedia. And the error most likely means that GeoMedia can understand the geometries from all the records except one, which is probably broken somehow.

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.