GeoMedia Secrets

By

Lars Tungen (lars.tungen@abaris.no)
Abaris Consulting

Abstract:

The GeoMedia object API offers some undocumented components which in many cases are extremely useful when implementing custom commands and applications. This paper tries to document some of these objects.


How to get access to hidden COM objects

To utilize hidden objects available in ActiveX/COM libraries in Visual Basic, you must turn on these hidden objects in the object browser. This is done by selecting the "Show Hidden Members" menu available from the context menu in the Visual Basic object browser. Hidden objects and mehods will then become visible.

 

After enabling hidden members, the InMemoryRecordset object (and an associated interface), becomes available in the object browser.

 InMemoryRecordset

The InMemoryRecordset object is useful when a recordset is needed and it's not possible to create the recordset through an OriginatingPipe or other GeoMedia pipes. The InMemoryRecordset is a recordset created and maintained in memory. For those of you familiar with ADO, an InMemoryRecordset can be compared to a disconnected ADO recordset. InMemoryRecordset is a hidden member of the GeoMedia PDBPipe library.

The InMemoryRecordset object has the following members:

MemberTypeDescription
AddReadOnlyFieldMethodAdd a read only GField object to the recordset.
AddReadWriteFieldMethodAdd an updatable GField object to the recordset.
OutputRecordsetPropertyReturns the recordset object (GRecordset).
ReadOnlyDisabledPropertyTurn on/off read only mode. Used when filling the recordset with data.

Example on how to use the InMemoryRecordset object:

   Dim objMemRS As InMemoryRecordset
   Dim objRS As GRecordset
   
   ' Create a new InMemoryRecordset object
   Set objMemRS = gobjGeoApp.CreateService("GeoMedia.InMemoryRecordset")
   
   With objMemRS
      ' Add fields
      With .AddReadOnlyField 
         .Name = "ID"
         .Type = gdbLong
      End With
      
      With .AddReadOnlyField
         .Name = "Geometry"
         .Type = gdbSpatial
         .SubType = gdbLinear
      End With
      
      ' Get GRecordset object
      Set objRS = .OutputRecordset
      
      ' Turn off read only mode to populate the recordset
      .ReadOnlyDisabled = True
      
      ' Add records
      With objRS
         .AddNew
         With .GFields
            .Item("ID").Value = 1
            .Item(Geometry").Value = Null 
         End With
         .Update
      End With
      
      ' Turn on read only mode
      .ReadOnlyDisabled = False 
   End With
   
   ' Use the recordset object
   ...
   
   ' Close
   objRS.Close
   
   ' Cleanup
   Set objRS = Nothing 
   Set objMemRS = Nothing  
      

UnionPipe

The UnionPipe object makes it possible to combine records from several recordsets into one recordset. It's similar to the SQL UNION operator, but more powerful.

The UnionPipe object has the following members:

MemberTypeDescription
AppendMethodAppend a record from another recordset to the union recordset.
RemoveMethodRemove a record from the recordset.
OutputRecordsetPropertyReturns the union recordset (GRecordset).

Example on how to use the UnionPipe object:

      
      Dim objUnionPipe As UnionPipe
      Dim objRS1 As GRecordset
      Dim objRS2 As GRecordset
      Dim objUnionRS As GRecordset
      
      ' Initialize recordset 1 and 2 
      Set objRS1 = ...
      Set objRS2 = ...

      ' Create a new UnionPipe object
      Set objUnionPipe = gobjGeoApp.CreateService("GeoMedia.UnionPipe")
      With objUnionPipe
         ' Add first record of recordset 1
         objRS1.MoveFirst
         .Append objRS1, objRS1.Bookmark
         
         ' Add last record of recordset 2
         objRS2.MoveLast
         .Append objRS2, objRS2.Bookmark
         
         ' Get union recordset
         Set objUnionRS = .OutputRecordset
      End With

      ' The union recordset will now consist
      ' of two records, the first record of objRS1
      ' and the last record of objRS2. The union
      ' recordset has all fields from objRS1 and
      ' objRS2.
      With objUnionRS
	     If Not (.EOF And .BOF) Then
            .MoveFirst
            Do Until .EOF
                ...
                .MoveNext
            Loop
      End With
            
      ' Cleanup
      objUnionRS.Close
      objRS1.Close
      objRS2.Close
      Set objUnionPipe = Nothing      
      Set objUnionRS = Nothing
      Set objRS1 = Nothing
      Set objRS2 = Nothing
      

AddFieldsPipe (incomplete and preliminary)

The AddFieldsPipe object is used to create custom pipes. Custom pipes implemented with the AddFieldsPipe will be saved with the workspace as other standard GeoMedia pipes. It works by adding extra fields to an existing recordset and enabling the client to provide the value for these extra fields through  the special interfaces IFieldProviderCallback and IFieldDelegateCallback.

To create a custom pipe the following steps are required:

  1. Create a public COM object. This will be the custom pipe object.
  2. Add an AddFieldsPipe object as a member to the new COM object.
  3. Implement the IFieldProviderCallback and/or IFieldDelegateCallback interface(s) in the new COM object.

The AddFieldsPipe object has the following members:

MemberTypeDescription
AddDelegateFieldMethod Add delegate field to the pipe.
AddReadOnlyFieldMethod Add read only field to the pipe.
AddReadWriteFieldMethod Add read/write field to the pipe.
CriteriaChangedMethod ?
SetFieldExtensionMethod ?
CreationStringProperty The prog id for the custom pipe object that "owns" this AddFieldsPipe. This is the string that the AddFieldsPipe object will pass to CreateObect when it needs to  recreate the pipe when a geoworkspace is being loaded.
ExtendedPropertySetProperty Used to store extra properties necessary for the custom pipe to work properly. All persistant properties must be stored in this ExtendedPropertySet object and not as member variables in the custom pipe. This is because the extended property set will be stored in the geoworkspace, while the member properties of the custom pipe will not.
FieldDelegateCallbackProperty Points to the custom pipe object which must implement the IFieldDelegateCallback interface.
FieldProviderCallbackProperty Points to the custom pipe object which must implement the IFieldProviderCallback interface.
InputRecordsetProperty Standard InputRecordset property.
OutputRecordsetProperty Standard OutputRecordset property.
PipelineOutputRecordsetProperty ?
PipeNameProperty The name of the custom pipe.
ReadOnlyDisabledProperty Turn on/off read only mode.
SchemaUpdatableProperty True if schema can be updated.

Print friendly version Print friendly version

 

© 2001 MyGeoMedia.com - Webmaster: webmaster@mygeomedia.com