-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathGDAL.bas
187 lines (164 loc) · 6.93 KB
/
GDAL.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
Attribute VB_Name = "GDAL"
'*****************************************************************************
' $Id$
'
' Project: GDAL VB6 Bindings
' Purpose: Main GDAL Public Module - public non-class GDAL declarations.
' Author: Frank Warmerdam, warmerdam@pobox.com
'
'*****************************************************************************
' Copyright (c) 2005, Frank Warmerdam <warmerdam@pobox.com>
'
' Permission is hereby granted, free of charge, to any person obtaining a
' copy of this software and associated documentation files (the "Software"),
' to deal in the Software without restriction, including without limitation
' the rights to use, copy, modify, merge, publish, distribute, sublicense,
' and/or sell copies of the Software, and to permit persons to whom the
' Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included
' in all copies or substantial portions of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
' OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
' FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'*****************************************************************************
'
' $Log$
' Revision 1.6 2005/08/04 20:53:51 fwarmerdam
' convert to DOS text mode
'
' Revision 1.5 2005/04/11 19:58:47 fwarmerdam
' added CPLSet/GetConfigOption
'
' Revision 1.4 2005/04/08 14:36:25 fwarmerdam
' applied owned flag, and auto-destroy
'
' Revision 1.3 2005/04/06 22:29:50 fwarmerdam
' added CreateCoordinateTransformation() function
'
' Revision 1.2 2005/03/16 23:34:07 fwarmerdam
' fixed up open to always return a GDALDataset
'
' Revision 1.1 2005/03/16 19:40:49 fwarmerdam
' new
'
'
' GDALAccess (for open)
Public Const GA_ReadOnly As Long = 0
Public Const GA_Update As Long = 1
' GDALDataTypes
Public Const GDT_Unknown As Long = 0
Public Const GDT_Byte As Long = 1
Public Const GDT_UInt16 As Long = 2
Public Const GDT_Int16 As Long = 3
Public Const GDT_UInt32 As Long = 4
Public Const GDT_Int32 As Long = 5
Public Const GDT_Float32 As Long = 6
Public Const GDT_Float64 As Long = 7
Public Const GDT_CInt16 As Long = 8
Public Const GDT_CInt32 As Long = 9
Public Const GDT_CFloat32 As Long = 10
Public Const GDT_CFloat64 As Long = 11
Public Const GDT_TypeCount As Long = 12
' read/write flags for RasterIO
Public Const GF_Read As Long = 0
Public Const GF_Write As Long = 1
' Palette Interpretation
Public Const GPI_Gray As Long = 0
Public Const GPI_RGB As Long = 1
Public Const GPI_CMYK As Long = 2
Public Const GPI_HLS As Long = 3
' Driver metadata items.
Public Const DMD_SHORTNAME As String = "DMD_SHORTNAME"
Public Const DMD_LONGNAME As String = "DMD_LONGNAME"
Public Const DMD_HELPTOPIC As String = "DMD_HELPTOPIC"
Public Const DMD_MIMETYPE As String = "DMD_MIMETYPE"
Public Const DMD_EXTENSION As String = "DMD_EXTENSION"
Public Const DMD_CREATIONOPTIONLIST As String = "DMD_CREATIONOPTIONLIST"
Public Const DMD_CREATIONDATATYPES As String = "DMD_CREATIONDATATYPES"
Public Const DCAP_CREATE As String = "DCAP_CREATE"
Public Const DCAP_CREATECOPY As String = "DCAP_CREATECOPY"
' ----------------------------------------------------------------------------
Public Function GetLastErrorMsg() As String
GetLastErrorMsg = CStr2VB(GDALCore.CPLGetLastErrorMsg())
End Function
' ----------------------------------------------------------------------------
Public Function GetConfigOption(Key As String, Default As String)
GetConfigOption = CStr2VB(GDALCore.CPLGetConfigOption(Key, Default))
End Function
' ----------------------------------------------------------------------------
Public Sub SetConfigOption(Key As String, Value As String)
Call GDALCore.CPLSetConfigOption(Key, Value)
End Sub
' ----------------------------------------------------------------------------
Public Sub AllRegister()
Call GDALCore.GDALAllRegister
End Sub
' ----------------------------------------------------------------------------
Public Function GetDriverByName(DriverName As String) As GDALDriver
Dim drv_c As Long
drv_c = GDALCore.GDALGetDriverByName(DriverName)
If drv_c <> 0 Then
Set GetDriverByName = New GDALDriver
GetDriverByName.CInit (drv_c)
End If
End Function
' ----------------------------------------------------------------------------
Public Function GetDriver(ByVal DriverIndex As Long) As GDALDriver
Dim drv_c As Long
drv_c = GDALCore.GDALGetDriver(DriverIndex)
If drv_c <> 0 Then
Set GetDriver = New GDALDriver
GetDriver.CInit (drv_c)
End If
End Function
' ----------------------------------------------------------------------------
Public Function GetDriverCount() As Long
GetDriverCount = GDALCore.GDALGetDriverCount()
End Function
' ----------------------------------------------------------------------------
Public Function GetDataTypeName(ByVal DataType As Long) As String
GetDataTypeName = GDALCore.CStr2VB(GDALCore.GDALGetDataTypeName(DataType))
End Function
' ----------------------------------------------------------------------------
Public Function GetDataTypeSize(ByVal DataType As Long) As Long
GetDataTypeSize = GDALCore.GDALGetDataTypeSize(DataType)
End Function
' ----------------------------------------------------------------------------
Public Function OpenDS(Filename As String, ByVal Access As Long) As GDALDataset
Set OpenDS = New GDALDataset
Call OpenDS.CInit(GDALCore.GDALOpen(Filename, Access), 1)
End Function
' ----------------------------------------------------------------------------
Public Function OpenSharedDS(Filename As String, ByVal Access As Long) As GDALDataset
Set OpenSharedDS = New GDALDataset
Call OpenSharedDS.CInit(GDALCore.GDALOpenShared(Filename, Access), 1)
End Function
' ----------------------------------------------------------------------------
Public Function CreateColorTable(ByVal PaletteInterp As Long) _
As GDALColorTable
Dim obj As Long
obj = GDALCore.GDALCreateColorTable(PaletteInterp)
If obj <> 0 Then
Set CreateColorTable = New GDALColorTable
Call CreateColorTable.CInit(obj, 1)
End If
End Function
' ----------------------------------------------------------------------------
Public Function CreateCoordinateTransformation( _
SrcSRS As OGRSpatialReference, TrgSRS As OGRSpatialReference) _
As OGRCoordinateTransformation
Dim obj As Long
Set ct = New OGRCoordinateTransformation
obj = GDALCore.OCTNewCoordinateTransformation(SrcSRS.GetObjPtr(), _
TrgSRS.GetObjPtr())
If obj <> 0 Then
Call ct.CInit(obj, 1)
End If
Set CreateCoordinateTransformation = ct
End Function