EnumGeoKeys Example for Visual Basic
' This is an efficient way of reading all the GeoKeys in a file
Public WithEvents RasterIO As LEADRasterIO
Private Sub TestEnumFileGeoKeys()
Dim nRet As Integer
nRet = RasterIO.EnumFileGeoKeys ("GeoTif.tif", 0, 0)
If nRet = 0 Then
MsgBox "Enumeration SUCCEEDED!"
Else
MsgBox "Error enumerating GeoKeys"
End If
End Sub
Private Sub RasterIO_EnumGeoKeys(ByVal uTag As Long, ByVal uType As Long, ByVal uCount As Long)
Dim str As String
If uType = TAG_ASCII Then
str = "ASCII"
Else
If uType = TAG_SHORT Then
str = "SHORT"
Else
str = "DOUBLE"
End If
End If
str = "Key = " + CStr(uTag) + Chr(13) + "Type = " + str + Chr(13) + "Count = " + CStr(uCount)
MsgBox str, vbOKOnly, "Key Info"
If uType = TAG_SHORT Then
If uCount = 1 Then
str = "Key Value = " + CStr(RasterIO.GeoKeyData.ShortValue)
Else
str = "Key Value = " + CStr(RasterIO.GeoKeyData.ShortItemValue (0))
End If
Else
If uType = TAG_DOUBLE Then
If uCount = 1 Then
str = "Key Value = " + CStr(RasterIO.GeoKeyData.DoubleValue)
Else
str = "Key Value = " + CStr(RasterIO.GeoKeyData.DoubleItemValue (0))
End If
End If
End If
MsgBox str, vbOKOnly, "Key Value"
RasterIO.StopFireEnumGeoKeys = FALSE
End Sub