ffi-gdal 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +25 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +60 -0
  7. data/Rakefile +57 -0
  8. data/ffi-gdal.gemspec +28 -0
  9. data/lib/ext/cpl_error_symbols.rb +37 -0
  10. data/lib/ext/to_bool.rb +13 -0
  11. data/lib/ffi/gdal/cpl_conv.rb +151 -0
  12. data/lib/ffi/gdal/cpl_error.rb +91 -0
  13. data/lib/ffi/gdal/cpl_string.rb +113 -0
  14. data/lib/ffi/gdal/cpl_vsi.rb +119 -0
  15. data/lib/ffi/gdal/gdal_color_entry.rb +13 -0
  16. data/lib/ffi/gdal/gdal_gcp.rb +18 -0
  17. data/lib/ffi/gdal/ogr_api.rb +28 -0
  18. data/lib/ffi/gdal/ogr_core.rb +199 -0
  19. data/lib/ffi/gdal/ogr_srs_api.rb +48 -0
  20. data/lib/ffi/gdal/version.rb +5 -0
  21. data/lib/ffi/gdal.rb +607 -0
  22. data/lib/ffi-gdal/color_table.rb +59 -0
  23. data/lib/ffi-gdal/dataset.rb +347 -0
  24. data/lib/ffi-gdal/driver.rb +151 -0
  25. data/lib/ffi-gdal/exceptions.rb +17 -0
  26. data/lib/ffi-gdal/geo_transform.rb +137 -0
  27. data/lib/ffi-gdal/major_object.rb +71 -0
  28. data/lib/ffi-gdal/raster_attribute_table.rb +78 -0
  29. data/lib/ffi-gdal/raster_band.rb +571 -0
  30. data/lib/ffi-gdal/version_info.rb +48 -0
  31. data/lib/ffi-gdal.rb +12 -0
  32. data/linkies.rb +35 -0
  33. data/meow.rb +144 -0
  34. data/readie.rb +90 -0
  35. data/rubby.rb +224 -0
  36. data/spec/ext/cpl_error_symbols_spec.rb +79 -0
  37. data/spec/ffi-gdal/integration/color_table_info_spec.rb +60 -0
  38. data/spec/ffi-gdal/integration/dataset_info_spec.rb +95 -0
  39. data/spec/ffi-gdal/integration/driver_info_spec.rb +60 -0
  40. data/spec/ffi-gdal/integration/geo_transform_info_spec.rb +66 -0
  41. data/spec/ffi-gdal/integration/raster_attribute_table_info_spec.rb +23 -0
  42. data/spec/ffi-gdal/integration/raster_band_info_spec.rb +333 -0
  43. data/spec/ffi-gdal/unit/version_info_spec.rb +48 -0
  44. data/spec/ffi-gdal_spec.rb +6 -0
  45. data/spec/spec_helper.rb +13 -0
  46. data/spec/support/integration_help.rb +1 -0
  47. data/spec/support/shared_examples/major_object_examples.rb +68 -0
  48. data/things.rb +84 -0
  49. metadata +216 -0
@@ -0,0 +1,119 @@
1
+ require 'ffi'
2
+
3
+
4
+ module FFI
5
+ module GDAL
6
+ module CPLVSI
7
+ extend ::FFI::Library
8
+ ffi_lib 'gdal'
9
+
10
+ #------------------------------------------------------------------------
11
+ # Defines
12
+ #------------------------------------------------------------------------
13
+ VSI_STAT_EXISTS_FLAG = 0x1
14
+ VSI_STAT_NATURE_FLAG = 0x2
15
+ VSI_STAT_SIZE_FLAG = 0x4
16
+
17
+ #------------------------------------------------------------------------
18
+ # Typedefs
19
+ #------------------------------------------------------------------------
20
+ # Dupes from cpl_conv.rb. Can't figure out how to get these defined
21
+ # from just including the module...
22
+ typedef :long_long, :GIntBig
23
+ typedef :ulong_long, :GUIntBig
24
+
25
+ typedef :GUIntBig, :vsi_l_offset
26
+ callback :VSIWriteFunction, %i[pointer size_t size_t pointer], :pointer
27
+
28
+ #------------------------------------------------------------------------
29
+ # Functions
30
+ #------------------------------------------------------------------------
31
+ attach_function :VSIFOpen, %i[string string], :pointer
32
+ attach_function :VSIFClose, %i[pointer], :int
33
+ attach_function :VSIFSeek, %i[pointer long int], :int
34
+ attach_function :VSIFTell, %i[pointer], :long
35
+ attach_function :VSIRewind, %i[pointer], :void
36
+ attach_function :VSIFFlush, %i[pointer], :void
37
+ attach_function :VSIFRead, %i[pointer size_t size_t pointer], :size_t
38
+ attach_function :VSIFWrite, %i[pointer size_t size_t pointer], :size_t
39
+ attach_function :VSIFGets, %i[pointer int pointer], :string
40
+ attach_function :VSIFPuts, %i[string pointer], :int
41
+ attach_function :VSIFPrintf, %i[pointer string varargs], :int
42
+ attach_function :VSIFGetc, %i[pointer], :int
43
+ attach_function :VSIFPutc, %i[int pointer], :int
44
+
45
+ attach_function :VSIUngetc, %i[int pointer], :int
46
+ attach_function :VSIFEof, %i[pointer], :int
47
+ attach_function :VSIStat, %i[string pointer], :int
48
+
49
+ attach_function :VSIFOpenL, %i[string string], :pointer
50
+ attach_function :VSIFCloseL, %i[pointer], :int
51
+ attach_function :VSIFSeekL, %i[pointer vsi_l_offset int], :int
52
+ attach_function :VSIFTellL, %i[pointer], :vsi_l_offset
53
+ attach_function :VSIRewindL, %i[pointer], :void
54
+ attach_function :VSIFReadL, %i[pointer size_t size_t pointer], :size_t
55
+ attach_function :VSIFReadMultiRangeL,
56
+ %i[int pointer pointer pointer pointer],
57
+ :int
58
+ attach_function :VSIFWriteL, %i[pointer size_t size_t pointer], :size_t
59
+ attach_function :VSIFEofL, %i[pointer], :int
60
+ attach_function :VSIFTruncateL, %i[pointer vsi_l_offset], :int
61
+ attach_function :VSIFFlushL, %i[pointer], :int
62
+ attach_function :VSIFPrintfL, %i[pointer string varargs], :int
63
+ attach_function :VSIFPutcL, %i[int pointer], :int
64
+ attach_function :VSIIngestFile,
65
+ %i[pointer string pointer pointer GIntBig],
66
+ :int
67
+ attach_function :VSIStatL, %i[string pointer], :int
68
+ attach_function :VSIStatExL, %i[string pointer int], :int
69
+
70
+ attach_function :VSIIsCaseSensitiveFS, %i[string], :int
71
+ attach_function :VSIFGetNativeFileDescriptorL, %i[pointer], :pointer
72
+
73
+ attach_function :VSICalloc, %i[size_t size_t], :pointer
74
+ attach_function :VSIMalloc, %i[size_t], :pointer
75
+ attach_function :VSIFree, %i[pointer], :void
76
+ attach_function :VSIRealloc, %i[pointer size_t], :pointer
77
+ attach_function :VSIStrdup, %i[string], :string
78
+ attach_function :VSIMalloc2, %i[size_t size_t], :pointer
79
+ attach_function :VSIMalloc3, %i[size_t size_t size_t], :pointer
80
+
81
+ attach_function :VSIReadDir, %i[string], :pointer
82
+ attach_function :VSIReadDirRecursive, %i[string], :pointer
83
+ attach_function :VSIMkdir, %i[string long], :int
84
+ attach_function :VSIRmdir, %i[string], :int
85
+ attach_function :VSIUnlink, %i[string], :int
86
+ attach_function :VSIRename, %i[string string], :int
87
+
88
+ attach_function :VSIStrerror, %i[int], :string
89
+
90
+ attach_function :VSIInstallMemFileHandler, [], :void
91
+ attach_function :VSIInstallLargeFileHandler, [], :void
92
+ attach_function :VSIInstallSubFileHandler, [], :void
93
+ attach_function :VSIInstallCurlFileHandler, [], :void
94
+ attach_function :VSIInstallCurlStreamingFileHandler, [], :void
95
+ attach_function :VSIInstallGZipFileHandler, [], :void
96
+ attach_function :VSIInstallZipFileHandler, [], :void
97
+ attach_function :VSIInstallStdinHandler, [], :void
98
+ attach_function :VSIInstallStdoutHandler, [], :void
99
+ attach_function :VSIInstallSparseFileHandler, [], :void
100
+ attach_function :VSIInstallTarFileHandler, [], :void
101
+ attach_function :VSICleanupFileManager, [], :void
102
+
103
+ attach_function :VSIFileFromMemBuffer,
104
+ %i[string pointer vsi_l_offset int],
105
+ :pointer
106
+ attach_function :VSIGetMemFileBuffer,
107
+ %i[string pointer int],
108
+ :pointer
109
+ # attach_function :VSIStdoutSetRedirection,
110
+ # %i[VSIWriteFunction pointer],
111
+ # :pointer
112
+
113
+ attach_function :VSITime, %i[pointer], :ulong
114
+ attach_function :VSICTime, %i[ulong], :string
115
+ attach_function :VSIGMTime, %i[pointer pointer], :pointer
116
+ attach_function :VSILocalTime, %i[pointer pointer], :pointer
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,13 @@
1
+ require 'ffi'
2
+
3
+
4
+ module FFI
5
+ module GDAL
6
+ class GDALColorEntry < FFI::Struct
7
+ layout :c1, :short,
8
+ :c2, :short,
9
+ :c3, :short,
10
+ :c4, :short
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ require 'ffi'
2
+
3
+
4
+ module FFI
5
+ module GDAL
6
+
7
+ # Ground Control Point
8
+ class GDALGCP < FFI::Struct
9
+ layout :id, :string,
10
+ :info, :string,
11
+ :pixel, :double,
12
+ :line, :double,
13
+ :x, :double,
14
+ :y, :double,
15
+ :z, :double
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ require 'ffi'
2
+
3
+
4
+ module FFI
5
+ module GDAL
6
+ module OGRAPI
7
+ extend FFI::Library
8
+ ffi_lib 'gdal'
9
+
10
+ #------------------------------------------------------------------------
11
+ # Typedefs
12
+ #------------------------------------------------------------------------
13
+ typedef :pointer, :OGRGeometryH
14
+ typedef :pointer, :OGRSpatialReferenceH
15
+ typedef :pointer, :OGRCoordinateTransformationH
16
+ typedef :pointer, :OGRFieldDefnH
17
+ typedef :pointer, :OGRFeatureDefnH
18
+ typedef :pointer, :OGRFeatureH
19
+ typedef :pointer, :OGRStyleTableH
20
+ typedef :pointer, :OGRGeomFieldDefnH
21
+ typedef :pointer, :OGRLayerH
22
+ typedef :pointer, :OGRDataSourceH
23
+ typedef :pointer, :OGRSFDriverH
24
+ typedef :pointer, :OGRStyleMgrH
25
+ typedef :pointer, :OGRStyleToolH
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,199 @@
1
+ module FFI
2
+ module GDAL
3
+ module OGRCore
4
+ extend FFI::Library
5
+ ffi_lib 'gdal'
6
+
7
+ #------------------------------------------------------------------------
8
+ # Defines
9
+ #------------------------------------------------------------------------
10
+ OGRERR_NONE = 0
11
+ OGRERR_NOT_ENOUGH_DATA = 1
12
+ OGRERR_NOT_ENOUGH_MEMORY = 2
13
+ OGRERR_UNSUPPORTED_GEOMETRY_TYPE = 3
14
+ OGRERR_UNSUPPORTED_OPERATION = 4
15
+ OGRERR_CORRUPT_DATA = 5
16
+ OGRERR_FAILURE = 6
17
+ OGRERR_UNSUPPORTED_SRS = 7
18
+ OGRERR_INVALID_HANDLE = 8
19
+
20
+ WKB_25D_BIT = 0x80000000
21
+ #WKB_FLATTEN
22
+ OGR_Z_MARKER = 0x21125711
23
+
24
+ ALTER_NAME_FLAG = 0x1
25
+ ALTER_TYPE_FLAG = 0x2
26
+ ALTER_WIDTH_PRECISION_FLAG = 0x4
27
+ ALTER_ALL_FLAG =
28
+ ALTER_NAME_FLAG | ALTER_TYPE_FLAG | ALTER_WIDTH_PRECISION_FLAG
29
+
30
+ OGRNullFID = -1
31
+ OGRUnsetMarker = -21121
32
+ OLCRandomRead = 'RandomRead'
33
+ OLCSequentialWrite = 'SequentialWrite'
34
+ OLCRandomeWrite = 'RandomWrite'
35
+ OLCFastSpatialFilter = 'FastSpatialFilter'
36
+ OLCFastFeatureCount = 'FastFeatureCount'
37
+ OLCFastGetExtent = 'FastGetExtent'
38
+ OLCCreateField = 'CreateField'
39
+ OLCDeleteField = 'DeleteField'
40
+ OLCReorderFields = 'ReorderFields'
41
+ OLCAlterFieldDefn = 'AlterFieldDefn'
42
+ OLCTransactions = 'Transactions'
43
+ OLCDeleteFeature = 'DeleteFeature'
44
+ OLCFastSetNextByIndex = 'FastSetNextByIndex'
45
+ OLCStringsAsUTF8 = 'StringsAsUTF8'
46
+ OLCIgnoreFields = 'IgnoreFields'
47
+ OLCCreateGeomField = 'CreateGeomField'
48
+
49
+ ODsCCreateLayer = 'CreateLayer'
50
+ ODsCDeleteLayer = 'DeleteLayer'
51
+ ODsCCreateGeomFieldAfterCreateLayer = 'CreateGeomFieldAfterCreateLayer'
52
+
53
+ ODrCCreateDataSource = 'CreateDataSource'
54
+ ODrCDeleteDataSource = 'DeleteDataSource'
55
+
56
+ #------------------------------------------------------------------------
57
+ # Enums
58
+ #------------------------------------------------------------------------
59
+ OGRwkbGeometryType = enum :wkb_unknown, 0,
60
+ :wkb_point, 1,
61
+ :wkb_line_string, 2,
62
+ :wkb_polygon, 3,
63
+ :wkb_multi_point, 4,
64
+ :wkb_multi_line_string, 5,
65
+ :wkb_mulit_polygon, 6,
66
+ :wkb_geometry_collection, 7,
67
+ :wkb_none, 100,
68
+ :wkb_linear_ring, 101,
69
+ :wkb_point_25d, 0x80000001,
70
+ :wkb_line_string_25d, 0x80000002,
71
+ :wkb_polygon_25d, 0x80000003,
72
+ :wkb_multi_point_25d, 0x80000004,
73
+ :wkb_multi_line_string_25d, 0x80000005,
74
+ :wkb_multi_polygon_25d, 0x80000006,
75
+ :wkb_geometry_collection_25d, 0x80000007
76
+
77
+ OGRwkbVariant = enum :wkb_variant_ogc, :wkb_variant_iso
78
+ OGRwkbByteOrder = enum :wkb_xdr, 0,
79
+ :wkb_ndr, 1
80
+
81
+ OGRFieldType = enum :oft_integer, 0,
82
+ :oft_integer_list, 1,
83
+ :oft_real, 2,
84
+ :oft_real_list, 3,
85
+ :oft_string, 4,
86
+ :oft_string_list, 5,
87
+ :oft_wide_string, 6,
88
+ :oft_wide_string_list, 7,
89
+ :oft_binary, 8,
90
+ :oft_date, 9,
91
+ :oft_time, 10,
92
+ :oft_date_time, 11,
93
+ :oft_max_type, 11
94
+
95
+ OGRJustification = enum :oj_undefined, 0,
96
+ :oj_left, 1,
97
+ :oj_right, 2
98
+
99
+ OGRStyleToolClassID = enum :ogr_stc_none, 0,
100
+ :ogr_stc_pen, 1,
101
+ :ogr_stc_brush, 2,
102
+ :ogr_stc_symbol, 3,
103
+ :ogr_stc_label, 4,
104
+ :ogr_stc_vector, 5
105
+
106
+ OGRStyleToolUnitsID = enum :ogr_stu_ground, 0,
107
+ :ogr_stu_pixel, 1,
108
+ :ogr_stu_points, 2,
109
+ :ogr_stu_mm, 3,
110
+ :ogr_stu_cm, 4,
111
+ :ogr_stu_inches, 5
112
+
113
+ OGRStyleToolParamPenID = enum :ogr_st_pen_color, 0,
114
+ :ogr_st_pen_width, 1,
115
+ :ogr_st_pen_pattern, 2,
116
+ :ogr_st_pen_id, 3,
117
+ :ogr_st_pen_per_offset, 4,
118
+ :ogr_st_pen_per_cap, 5,
119
+ :ogr_st_pen_per_join, 6,
120
+ :ogr_st_pen_per_priority, 7,
121
+ :ogr_st_pen_last, 8
122
+
123
+ OGRStyleToolParamBrushID = enum :ogr_st_brush_f_color, 0,
124
+ :ogr_st_brush_b_color, 1,
125
+ :ogr_st_brush_id, 2,
126
+ :ogr_st_brush_angle, 3,
127
+ :ogr_st_brush_size, 4,
128
+ :ogr_st_brush_dx, 5,
129
+ :ogr_st_brush_dry, 6,
130
+ :ogr_st_brush_priority, 7,
131
+ :ogr_st_brush_last, 8
132
+
133
+ OGRStyleToolParamSymbolID = enum :ogr_st_symbol_id, 0,
134
+ :ogr_st_symbol_angle, 1,
135
+ :ogr_st_symbol_color, 2,
136
+ :ogr_st_symbol_size, 3,
137
+ :ogr_st_symbol_dx, 4,
138
+ :ogr_st_symbol_dy, 5,
139
+ :ogr_st_symbol_step, 6,
140
+ :ogr_st_symbol_perp, 7,
141
+ :ogr_st_symbol_offset, 8,
142
+ :ogr_st_symbol_priority, 9,
143
+ :ogr_st_symbol_font_name, 10,
144
+ :ogr_st_symbol_o_color, 11,
145
+ :ogr_st_symbol_last, 12
146
+
147
+ OGRStyleToolParamLabelID = enum :ogr_st_label_font_name, 0,
148
+ :ogr_st_label_size, 1,
149
+ :ogr_st_label_text_string, 2,
150
+ :ogr_st_label_angle, 3,
151
+ :ogr_st_label_f_color, 4,
152
+ :ogr_st_label_b_color, 5,
153
+ :ogr_st_label_placement, 6,
154
+ :ogr_st_label_anchor, 7,
155
+ :ogr_st_label_dx, 8,
156
+ :ogr_st_label_dy, 9,
157
+ :ogr_st_label_perp, 10,
158
+ :ogr_st_label_bold, 11,
159
+ :ogr_st_label_italic, 12,
160
+ :ogr_st_label_underline, 13,
161
+ :ogr_st_label_priority, 14,
162
+ :ogr_st_label_strikeout, 15,
163
+ :ogr_st_label_stretch, 16,
164
+ :ogr_st_label_adj_hor, 17,
165
+ :ogr_st_label_adj_vert, 18,
166
+ :ogr_st_label_h_color, 19,
167
+ :ogr_st_label_o_color, 20,
168
+ :ogr_st_label_last, 21
169
+
170
+ #------------------------------------------------------------------------
171
+ # Typedefs
172
+ #------------------------------------------------------------------------
173
+ typedef :int, :OGRErr
174
+ typedef :int, :OGRBoolean
175
+ typedef OGRStyleToolClassID, :OGRSTClassId
176
+ typedef OGRStyleToolUnitsID, :OGRSTUnitId
177
+ typedef OGRStyleToolParamPenID, :OGRSTPenParam
178
+ typedef OGRStyleToolParamBrushID, :OGRSTBrushParam
179
+ typedef OGRStyleToolParamSymbolID, :OGRSTSymbolParam
180
+ typedef OGRStyleToolParamLabelID, :OGRSTLabelParam
181
+
182
+ #------------------------------------------------------------------------
183
+ # Functions
184
+ #------------------------------------------------------------------------
185
+ attach_function :OGRMalloc, [:size_t], :pointer
186
+ attach_function :OGRCalloc, [:size_t, :size_t], :pointer
187
+ attach_function :OGRRealloc, [:pointer, :size_t], :pointer
188
+ #attach_function :OGRStrdup, [:string], :string
189
+ attach_function :OGRFree, [:pointer], :void
190
+ attach_function :OGRGeometryTypeToName, [OGRwkbGeometryType], :string
191
+ attach_function :OGRMergeGeometryTypes,
192
+ [OGRwkbGeometryType, OGRwkbGeometryType],
193
+ OGRwkbGeometryType
194
+ attach_function :OGRParseDate, [:string, :pointer, :int], :int
195
+ attach_function :GDALVersionInfo, [:string], :string
196
+ attach_function :GDALCheckVersion, [:int, :int, :string], :int
197
+ end
198
+ end
199
+ end
@@ -0,0 +1,48 @@
1
+ module FFI
2
+ module GDAL
3
+ module OGRSRSAPI
4
+ extend FFI::Library
5
+ ffi_lib 'gdal'
6
+
7
+ #------------------------------------------------------------------------
8
+ # Enums
9
+ #------------------------------------------------------------------------
10
+ OGRAxisOrientation = enum :oao_other, 0,
11
+ :oao_north, 1,
12
+ :oao_south, 2,
13
+ :oao_east, 3,
14
+ :oao_west, 4,
15
+ :oao_up, 5,
16
+ :oao_down, 6
17
+
18
+ OGRDatumType = enum :odt_hd_min, 1000,
19
+ :odt_hd_other, 1000,
20
+ :odt_hd_classic, 1001,
21
+ :odt_hd_geocentric, 1002,
22
+ :odt_hd_max, 1999,
23
+ :odt_vd_min, 2000,
24
+ :odt_vd_other, 2000,
25
+ :odt_vd_orthometric, 2001,
26
+ :odt_vd_ellipsoidal, 2002,
27
+ :odt_vd_altitude_barometric, 2003,
28
+ :odt_vd_normal, 2004,
29
+ :odt_vd_geoid_model_derived, 2005,
30
+ :odt_vd_depth, 2006,
31
+ :odt_vd_max, 2999,
32
+ :odt_ld_min, 10000,
33
+ :odt_ld_max, 32767
34
+
35
+ #------------------------------------------------------------------------
36
+ # Functions
37
+ #------------------------------------------------------------------------
38
+ attach_function :OSRAxisEnumToName, [OGRAxisOrientation], :string
39
+ #attach_function :OSRNewSpacialReference, [:string], :OGRSpatialReferenceH
40
+ #
41
+ attach_function :OPTGetProjectionMethods, [:void], :pointer
42
+ attach_function :OPTGetParameterList, [:string, :pointer], :pointer
43
+ attach_function :OPTGetParameterInfo,
44
+ [:string, :string, :pointer, :pointer, :pointer],
45
+ :int
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,5 @@
1
+ module FFI
2
+ module GDAL
3
+ VERSION = '0.0.1'
4
+ end
5
+ end