|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeoMedia SecretsBy Lars Tungen (lars.tungen@abaris.no)
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 objectsTo 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. InMemoryRecordsetThe 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:
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
UnionPipeThe 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:
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:
The AddFieldsPipe object has the following members:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
© 2001 MyGeoMedia.com - Webmaster: webmaster@mygeomedia.com |