ffi-gdal 1.0.0.beta1 → 1.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +32 -0
- data/LICENSE.txt +1 -1
- data/TODO.md +0 -2
- data/examples/extract_and_colorize.rb +81 -0
- data/{testing_ogr.rb → examples/geometries.rb} +4 -16
- data/{testing_layer_to_layer.rb → examples/ogr_layer_to_layer.rb} +1 -1
- data/examples/testing_gdal.rb +46 -0
- data/lib/ext/error_symbols.rb +1 -0
- data/lib/ffi/cpl/conv_h.rb +15 -15
- data/lib/ffi/cpl/error_h.rb +13 -13
- data/lib/ffi/cpl/string_h.rb +10 -10
- data/lib/ffi/cpl/vsi_h.rb +23 -23
- data/lib/ffi/gdal.rb +1 -1
- data/lib/ffi/gdal/grid_h.rb +3 -3
- data/lib/ffi/gdal/version.rb +1 -1
- data/lib/ffi/ogr/api_h.rb +3 -3
- data/lib/gdal/dataset.rb +5 -4
- data/lib/gdal/dataset_extensions.rb +2 -2
- data/lib/gdal/raster_band.rb +1 -0
- data/lib/gdal/raster_band_extensions.rb +5 -5
- data/lib/ogr/geometry.rb +1 -0
- data/spec/unit/gdal/color_table_extensions_spec.rb +60 -0
- data/spec/unit/gdal/data_type_spec.rb +79 -0
- data/spec/unit/gdal/dataset_spec.rb +98 -0
- metadata +12 -11
- data/linkies.rb +0 -35
- data/readie.rb +0 -90
- data/testing_gdal.rb +0 -168
- data/testing_gdalwarp.rb +0 -91
- data/testing_ndvi.rb +0 -76
- data/testing_nir.rb +0 -77
- data/things.rb +0 -84
data/things.rb
DELETED
@@ -1,84 +0,0 @@
|
|
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
|