08-07-2017 11:47 PM
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?
Solved! Go to Solution.
08-07-2017 11:58 PM
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
08-08-2017 04:38 AM - edited 08-08-2017 04:40 AM
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).
08-08-2017 04:50 AM
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
08-08-2017 03:36 PM - edited 08-08-2017 04:15 PM
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):
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"?
08-09-2017 02:05 AM
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.