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,68 @@
1
+ RSpec.shared_examples 'a major object' do
2
+ describe '#metadata_domain_list' do
3
+ it 'is an Array of Strings' do
4
+ expect(subject.metadata_domain_list).to be_an Array
5
+
6
+ subject.metadata_domain_list.each do |mdl|
7
+ expect(mdl).to be_a String
8
+ end
9
+ end
10
+ end
11
+
12
+ describe '#metadata_for_domain' do
13
+ context 'default domain' do
14
+ it 'is a Hash' do
15
+ expect(subject.metadata_for_domain).to be_a Hash
16
+ end
17
+ end
18
+ end
19
+
20
+ describe '#metadata_item' do
21
+ context 'default domain' do
22
+ context 'first item in metadata list' do
23
+ it 'is a String' do
24
+ unless subject.metadata_for_domain.empty?
25
+ key = subject.metadata_for_domain.keys.first
26
+
27
+ expect(subject.metadata_item(key)).to be_a String
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ describe '#all_metadata' do
35
+ it 'is a Hash' do
36
+ expect(subject.all_metadata).to be_a Hash
37
+ end
38
+
39
+ it 'has a DEFAULT key' do
40
+ expect(subject.all_metadata[:DEFAULT]).to eq subject.metadata_for_domain
41
+ end
42
+ end
43
+
44
+ describe '#description' do
45
+ it 'is a String' do
46
+ expect(subject.description).to be_a String
47
+ end
48
+ end
49
+
50
+ describe '#description=' do
51
+ context 'new description is a string' do
52
+ around :example do |example|
53
+ original_description = subject.description
54
+ example.run
55
+ subject.description = original_description
56
+ end
57
+
58
+ it 'sets the items description' do
59
+ subject.description = 'a test description'
60
+ expect(subject.description).to eq 'a test description'
61
+ end
62
+ end
63
+ end
64
+
65
+ describe '#null?' do
66
+ it { is_expected.to_not be_null }
67
+ end
68
+ end
data/things.rb ADDED
@@ -0,0 +1,84 @@
1
+ require './lib/ffi-gdal'
2
+
3
+
4
+ #dir = '../../agrian/gis_engine/test/test_files'
5
+ #name = 'empty_red_image.tif'
6
+ #name = 'empty_black_image.tif'
7
+
8
+ #dir = '~/Desktop/geotiffs'
9
+ #name = 'NDVI20000201032.tif'
10
+ #name = 'NDVI20000701183.tif'
11
+ #name = 'NDVI20000701183.zip'
12
+ #name = 'NDVI20000401092.tif'
13
+
14
+ #dir = './spec/support'
15
+ #name = 'google_earth_test.jpg'
16
+ #name = 'compassdata_gcparchive_google_earth.kmz'
17
+
18
+ #dir = './spec/support/aaron/Floyd'
19
+ #name = 'Floyd_1058_20140612_NRGB.tif'
20
+ dir = './spec/support/images/Harper'
21
+ name = 'Harper_1058_20140612_NRGB.tif'
22
+
23
+ #dir = './spec/support/osgeo'
24
+ #name = 'c41078a1.tif'
25
+
26
+
27
+ filename = File.expand_path(name, dir)
28
+ dataset = GDAL::Dataset.open(filename, 'r')
29
+ histogram = FFI::MemoryPointer.new(:int, 256)
30
+
31
+ if dataset.raster_count > 0
32
+ (1..dataset.raster_count).each do |i|
33
+ band = dataset.raster_band(i)
34
+ puts "raster #{i} data type: #{band.data_type}"
35
+
36
+ block_size = band.block_size
37
+ puts "raster #{i} block size: #{block_size}"
38
+
39
+ x_blocks = (band.x_size + block_size[:x] - 1) / block_size[:x]
40
+ puts "raster #{i} X blocks (#{band.x_size} + #{block_size[:x]} - 1): #{x_blocks}"
41
+
42
+ y_blocks = (band.y_size + block_size[:y] - 1) / block_size[:y]
43
+ puts "raster #{i} Y blocks (#{band.y_size} + #{block_size[:y]} - 1): #{y_blocks}"
44
+
45
+ data_pointer = FFI::MemoryPointer.new(:uchar, block_size[:x] * block_size[:y])
46
+
47
+ (0...y_blocks).each do |y_block|
48
+ (0...x_blocks).each do |x_block|
49
+ band.read_block(x_block, y_block, data_pointer)
50
+
51
+ x_valid = if x_block + 1 * block_size[:x] > band.x_size
52
+ band.x_size - x_block * block_size[:x]
53
+ else
54
+ block_size[:x]
55
+ end
56
+
57
+ y_valid = if y_block + 1 * block_size[:y] > band.y_size
58
+ band.y_size - y_block * block_size[:y]
59
+ else
60
+ block_size[:y]
61
+ end
62
+
63
+ $stdout.sync
64
+ (0...y_valid).each do |y|
65
+ (0...x_valid).each do |x|
66
+ offset = x + y * block_size[:x]
67
+
68
+ begin
69
+ value = histogram[offset]
70
+ int = value.read_int
71
+ print "y block: #{y_block}, x block: #{x_block}, offset: #{offset}, value: #{int}, e: #{y_block - int}\r"
72
+ histogram[offset].write_int(value.read_int + 1)
73
+ rescue IndexError
74
+ #puts "MERER"
75
+ end
76
+ end
77
+ end
78
+
79
+ end
80
+ end
81
+
82
+ p histogram.read_array_of_int(0)
83
+ end
84
+ end
metadata ADDED
@@ -0,0 +1,216 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ffi-gdal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Steve Loveless
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: log_switch
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_xml
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: narray
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.6.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: ruby-progressbar
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.0'
125
+ description:
126
+ email:
127
+ - steve.loveless@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - Gemfile
135
+ - LICENSE.txt
136
+ - README.md
137
+ - Rakefile
138
+ - ffi-gdal.gemspec
139
+ - lib/ext/cpl_error_symbols.rb
140
+ - lib/ext/to_bool.rb
141
+ - lib/ffi-gdal.rb
142
+ - lib/ffi-gdal/color_table.rb
143
+ - lib/ffi-gdal/dataset.rb
144
+ - lib/ffi-gdal/driver.rb
145
+ - lib/ffi-gdal/exceptions.rb
146
+ - lib/ffi-gdal/geo_transform.rb
147
+ - lib/ffi-gdal/major_object.rb
148
+ - lib/ffi-gdal/raster_attribute_table.rb
149
+ - lib/ffi-gdal/raster_band.rb
150
+ - lib/ffi-gdal/version_info.rb
151
+ - lib/ffi/gdal.rb
152
+ - lib/ffi/gdal/cpl_conv.rb
153
+ - lib/ffi/gdal/cpl_error.rb
154
+ - lib/ffi/gdal/cpl_string.rb
155
+ - lib/ffi/gdal/cpl_vsi.rb
156
+ - lib/ffi/gdal/gdal_color_entry.rb
157
+ - lib/ffi/gdal/gdal_gcp.rb
158
+ - lib/ffi/gdal/ogr_api.rb
159
+ - lib/ffi/gdal/ogr_core.rb
160
+ - lib/ffi/gdal/ogr_srs_api.rb
161
+ - lib/ffi/gdal/version.rb
162
+ - linkies.rb
163
+ - meow.rb
164
+ - readie.rb
165
+ - rubby.rb
166
+ - spec/ext/cpl_error_symbols_spec.rb
167
+ - spec/ffi-gdal/integration/color_table_info_spec.rb
168
+ - spec/ffi-gdal/integration/dataset_info_spec.rb
169
+ - spec/ffi-gdal/integration/driver_info_spec.rb
170
+ - spec/ffi-gdal/integration/geo_transform_info_spec.rb
171
+ - spec/ffi-gdal/integration/raster_attribute_table_info_spec.rb
172
+ - spec/ffi-gdal/integration/raster_band_info_spec.rb
173
+ - spec/ffi-gdal/unit/version_info_spec.rb
174
+ - spec/ffi-gdal_spec.rb
175
+ - spec/spec_helper.rb
176
+ - spec/support/integration_help.rb
177
+ - spec/support/shared_examples/major_object_examples.rb
178
+ - things.rb
179
+ homepage: https://github.com/turboladen/ffi-gdal
180
+ licenses:
181
+ - MIT
182
+ metadata: {}
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ requirements: []
198
+ rubyforge_project:
199
+ rubygems_version: 2.4.1
200
+ signing_key:
201
+ specification_version: 4
202
+ summary: FFI wrapper for GDAL/OGR.
203
+ test_files:
204
+ - spec/ext/cpl_error_symbols_spec.rb
205
+ - spec/ffi-gdal/integration/color_table_info_spec.rb
206
+ - spec/ffi-gdal/integration/dataset_info_spec.rb
207
+ - spec/ffi-gdal/integration/driver_info_spec.rb
208
+ - spec/ffi-gdal/integration/geo_transform_info_spec.rb
209
+ - spec/ffi-gdal/integration/raster_attribute_table_info_spec.rb
210
+ - spec/ffi-gdal/integration/raster_band_info_spec.rb
211
+ - spec/ffi-gdal/unit/version_info_spec.rb
212
+ - spec/ffi-gdal_spec.rb
213
+ - spec/spec_helper.rb
214
+ - spec/support/integration_help.rb
215
+ - spec/support/shared_examples/major_object_examples.rb
216
+ has_rdoc: