ffi-gdal 0.0.4 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -1
  3. data/Rakefile +12 -1
  4. data/TODO.md +11 -0
  5. data/ffi-gdal.gemspec +2 -2
  6. data/lib/ext/error_symbols.rb +59 -0
  7. data/lib/ext/float_ext.rb +15 -0
  8. data/lib/ext/narray_ext.rb +16 -0
  9. data/lib/ext/to_bool.rb +2 -0
  10. data/lib/ffi-gdal.rb +139 -4
  11. data/lib/ffi/{gdal/cpl_conv.rb → cpl/conv_h.rb} +2 -3
  12. data/lib/ffi/{gdal/cpl_error.rb → cpl/error_h.rb} +1 -25
  13. data/lib/ffi/cpl/minixml_h.rb +14 -0
  14. data/lib/ffi/{gdal/cpl_string.rb → cpl/string_h.rb} +0 -25
  15. data/lib/ffi/{gdal/cpl_vsi.rb → cpl/vsi_h.rb} +0 -0
  16. data/lib/ffi/cpl/xml_node.rb +13 -0
  17. data/lib/ffi/gdal.rb +57 -593
  18. data/lib/ffi/gdal/alg_h.rb +127 -0
  19. data/lib/ffi/gdal/gdal_grid_data_metrics_options.rb +14 -0
  20. data/lib/ffi/gdal/gdal_grid_inverse_distance_to_a_power_options.rb +19 -0
  21. data/lib/ffi/gdal/gdal_grid_moving_average_options.rb +14 -0
  22. data/lib/ffi/gdal/gdal_grid_nearest_neighbor_options.rb +13 -0
  23. data/lib/ffi/gdal/gdal_h.rb +683 -0
  24. data/lib/ffi/gdal/gdal_rpc_info.rb +27 -0
  25. data/lib/ffi/gdal/gdal_transformer_info.rb +14 -0
  26. data/lib/ffi/gdal/gdal_warp_options.rb +43 -0
  27. data/lib/ffi/gdal/grid_h.rb +51 -0
  28. data/lib/ffi/gdal/version.rb +1 -1
  29. data/lib/ffi/gdal/warper_h.rb +48 -0
  30. data/lib/ffi/ogr.rb +12 -0
  31. data/lib/ffi/ogr/api_h.rb +553 -0
  32. data/lib/ffi/ogr/core_h.rb +148 -0
  33. data/lib/ffi/ogr/featurestyle_h.rb +22 -0
  34. data/lib/ffi/ogr/geocoding_h.rb +21 -0
  35. data/lib/ffi/ogr/ogr_contour_writer_info.rb +14 -0
  36. data/lib/ffi/ogr/ogr_envelope.rb +12 -0
  37. data/lib/ffi/ogr/ogr_envelope_3d.rb +14 -0
  38. data/lib/ffi/ogr/ogr_field.rb +50 -0
  39. data/lib/ffi/ogr/ogr_style_param.rb +12 -0
  40. data/lib/ffi/ogr/ogr_style_value.rb +13 -0
  41. data/lib/ffi/ogr/srs_api_h.rb +325 -0
  42. data/lib/gdal/color_entry.rb +47 -0
  43. data/lib/gdal/color_entry_extensions.rb +30 -0
  44. data/lib/gdal/color_interpretation.rb +15 -0
  45. data/lib/gdal/color_table.rb +146 -0
  46. data/lib/gdal/color_table_extensions.rb +47 -0
  47. data/lib/gdal/color_table_types/cmyk.rb +25 -0
  48. data/lib/gdal/color_table_types/gray.rb +9 -0
  49. data/lib/gdal/color_table_types/hls.rb +21 -0
  50. data/lib/gdal/color_table_types/rgb.rb +25 -0
  51. data/lib/gdal/data_type.rb +38 -0
  52. data/lib/gdal/dataset.rb +437 -0
  53. data/lib/gdal/dataset_extensions.rb +496 -0
  54. data/lib/gdal/driver.rb +244 -0
  55. data/lib/gdal/driver_extensions.rb +56 -0
  56. data/lib/gdal/environment_methods.rb +43 -0
  57. data/lib/{ffi-gdal → gdal}/exceptions.rb +4 -1
  58. data/lib/gdal/geo_transform.rb +188 -0
  59. data/lib/gdal/geo_transform_extensions.rb +90 -0
  60. data/lib/gdal/logger.rb +7 -0
  61. data/lib/{ffi-gdal → gdal}/major_object.rb +15 -14
  62. data/lib/gdal/options.rb +49 -0
  63. data/lib/gdal/raster_attribute_table.rb +185 -0
  64. data/lib/gdal/raster_attribute_table_extensions.rb +40 -0
  65. data/lib/{ffi-gdal → gdal}/raster_band.rb +227 -99
  66. data/lib/gdal/raster_band_extensions.rb +198 -0
  67. data/lib/{ffi-gdal → gdal}/version_info.rb +8 -0
  68. data/lib/gdal/warp_operation.rb +96 -0
  69. data/lib/ogr/coordinate_transformation.rb +108 -0
  70. data/lib/ogr/data_source.rb +172 -0
  71. data/lib/ogr/data_source_extensions.rb +32 -0
  72. data/lib/ogr/driver.rb +119 -0
  73. data/lib/ogr/envelope.rb +80 -0
  74. data/lib/ogr/envelope_extensions.rb +92 -0
  75. data/lib/ogr/exceptions.rb +35 -0
  76. data/lib/ogr/feature.rb +212 -0
  77. data/lib/ogr/feature_definition.rb +120 -0
  78. data/lib/ogr/feature_definition_extensions.rb +36 -0
  79. data/lib/ogr/feature_extensions.rb +31 -0
  80. data/lib/ogr/field.rb +91 -0
  81. data/lib/ogr/field_extensions.rb +23 -0
  82. data/lib/ogr/geocoding_session.rb +84 -0
  83. data/lib/ogr/geometry.rb +617 -0
  84. data/lib/ogr/geometry_extensions.rb +60 -0
  85. data/lib/ogr/geometry_types/collection.rb +45 -0
  86. data/lib/ogr/geometry_types/curve.rb +120 -0
  87. data/lib/ogr/geometry_types/surface.rb +20 -0
  88. data/lib/ogr/layer.rb +226 -0
  89. data/lib/ogr/layer_extensions.rb +55 -0
  90. data/lib/ogr/line_string.rb +7 -0
  91. data/lib/ogr/linear_ring.rb +6 -0
  92. data/lib/ogr/multi_line_string.rb +9 -0
  93. data/lib/ogr/multi_point.rb +7 -0
  94. data/lib/ogr/multi_polygon.rb +14 -0
  95. data/lib/ogr/point.rb +89 -0
  96. data/lib/ogr/polygon.rb +9 -0
  97. data/lib/ogr/spatial_reference.rb +723 -0
  98. data/lib/ogr/spatial_reference_extensions.rb +32 -0
  99. data/lib/ogr/style_table.rb +17 -0
  100. data/lib/ogr/style_table_extensions.rb +16 -0
  101. data/spec/{ffi-gdal/integration → integration}/color_table_info_spec.rb +1 -1
  102. data/spec/{ffi-gdal/integration → integration}/dataset_info_spec.rb +0 -0
  103. data/spec/{ffi-gdal/integration → integration}/driver_info_spec.rb +1 -1
  104. data/spec/{ffi-gdal/integration → integration}/geo_transform_info_spec.rb +0 -0
  105. data/spec/{ffi-gdal/integration → integration}/raster_attribute_table_info_spec.rb +1 -1
  106. data/spec/{ffi-gdal/integration → integration}/raster_band_info_spec.rb +5 -5
  107. data/spec/spec_helper.rb +4 -1
  108. data/spec/support/shapefiles/states_21basic/states.prj +1 -0
  109. data/spec/support/shapefiles/states_21basic/states.sbn +0 -0
  110. data/spec/support/shapefiles/states_21basic/states.sbx +0 -0
  111. data/spec/support/shapefiles/states_21basic/states.shp +0 -0
  112. data/spec/support/worldfiles/SR_50M/SR_50M.VERSION.txt +1 -0
  113. data/spec/support/worldfiles/SR_50M/SR_50M.prj +1 -0
  114. data/spec/support/worldfiles/SR_50M/SR_50M.tfw +6 -0
  115. data/spec/{ext/cpl_error_symbols_spec.rb → unit/ext/error_symbols_spec.rb} +1 -1
  116. data/spec/unit/gdal/color_table_spec.rb +146 -0
  117. data/spec/unit/ogr/layer_spec.rb +97 -0
  118. data/spec/unit/ogr/linear_ring_spec.rb +111 -0
  119. data/spec/unit/ogr/point_spec.rb +321 -0
  120. data/spec/{ffi-gdal/unit → unit}/version_info_spec.rb +1 -1
  121. data/testing_gdal.rb +168 -0
  122. data/testing_gdalwarp.rb +91 -0
  123. data/testing_layer_to_layer.rb +35 -0
  124. data/testing_ndvi.rb +76 -0
  125. data/testing_nir.rb +77 -0
  126. data/testing_ogr.rb +63 -0
  127. metadata +167 -59
  128. data/lib/ext/cpl_error_symbols.rb +0 -37
  129. data/lib/ffi-gdal/color_table.rb +0 -59
  130. data/lib/ffi-gdal/dataset.rb +0 -359
  131. data/lib/ffi-gdal/driver.rb +0 -151
  132. data/lib/ffi-gdal/geo_transform.rb +0 -137
  133. data/lib/ffi-gdal/raster_attribute_table.rb +0 -78
  134. data/lib/ffi/gdal/ogr_api.rb +0 -21
  135. data/lib/ffi/gdal/ogr_core.rb +0 -195
  136. data/lib/ffi/gdal/ogr_srs_api.rb +0 -44
  137. data/meow.rb +0 -144
  138. data/rubby.rb +0 -224
@@ -1,44 +0,0 @@
1
- module FFI
2
- module GDAL
3
-
4
- #------------------------------------------------------------------------
5
- # Enums
6
- #------------------------------------------------------------------------
7
- OGRAxisOrientation = enum :oao_other, 0,
8
- :oao_north, 1,
9
- :oao_south, 2,
10
- :oao_east, 3,
11
- :oao_west, 4,
12
- :oao_up, 5,
13
- :oao_down, 6
14
-
15
- OGRDatumType = enum :odt_hd_min, 1000,
16
- :odt_hd_other, 1000,
17
- :odt_hd_classic, 1001,
18
- :odt_hd_geocentric, 1002,
19
- :odt_hd_max, 1999,
20
- :odt_vd_min, 2000,
21
- :odt_vd_other, 2000,
22
- :odt_vd_orthometric, 2001,
23
- :odt_vd_ellipsoidal, 2002,
24
- :odt_vd_altitude_barometric, 2003,
25
- :odt_vd_normal, 2004,
26
- :odt_vd_geoid_model_derived, 2005,
27
- :odt_vd_depth, 2006,
28
- :odt_vd_max, 2999,
29
- :odt_ld_min, 10000,
30
- :odt_ld_max, 32767
31
-
32
- #------------------------------------------------------------------------
33
- # Functions
34
- #------------------------------------------------------------------------
35
- attach_function :OSRAxisEnumToName, [OGRAxisOrientation], :string
36
- #attach_function :OSRNewSpacialReference, [:string], :OGRSpatialReferenceH
37
- #
38
- attach_function :OPTGetProjectionMethods, [:void], :pointer
39
- attach_function :OPTGetParameterList, [:string, :pointer], :pointer
40
- attach_function :OPTGetParameterInfo,
41
- [:string, :string, :pointer, :pointer, :pointer],
42
- :int
43
- end
44
- end
data/meow.rb DELETED
@@ -1,144 +0,0 @@
1
- # http://www.gdal.org/gdal_tutorial.html
2
-
3
-
4
- require './lib/ffi/gdal'
5
- require 'ruby-progressbar'
6
- include FFI::GDAL
7
-
8
- progressbar = ProgressBar.create
9
- #name = 'empty_red_image.tif'
10
- #name = 'empty_black_image.tif'
11
- name = 'NDVI20000201032.tif'
12
-
13
- #dir = '../../agrian/gis_engine/test/test_files'
14
- dir = '~/Desktop/geotiffs'
15
-
16
- psz_src_filename = File.expand_path(name, dir)
17
- progressbar.log "file name: #{psz_src_filename}"
18
-
19
- FFI::GDAL.GDALAllRegister
20
- dataset = GDALOpen(psz_src_filename, :GA_ReadOnly)
21
-
22
- abort 'file was not compatible' if dataset.null?
23
- progressbar.log "dataset: #{dataset}"
24
-
25
- #-------------------
26
- # Getting dataset information
27
- #-------------------
28
-
29
- dataset_driver = GDALGetDatasetDriver(dataset)
30
- progressbar.log "driver: #{dataset_driver}"
31
- progressbar.log "driver short name: #{GDALGetDriverShortName(dataset_driver)}"
32
- progressbar.log "driver long name: #{GDALGetDriverLongName(dataset_driver)}"
33
-
34
- progressbar.log "size, x: #{GDALGetRasterXSize(dataset)}"
35
- progressbar.log "size, y: #{GDALGetRasterYSize(dataset)}"
36
- progressbar.log "size, count: #{GDALGetRasterCount(dataset)}"
37
-
38
- progressbar.log "Projection is #{GDALGetProjectionRef(dataset)}"
39
-
40
- geo_transform = FFI::MemoryPointer.new(:double, 6)
41
-
42
- GDALGetGeoTransform(dataset, geo_transform)
43
- progressbar.log "origin: #{geo_transform[0].read_double}, #{geo_transform[3].read_double}"
44
- progressbar.log "pixel size: #{geo_transform[1].read_double}, #{geo_transform[5].read_double}"
45
-
46
-
47
- #-------------------
48
- # Fetching a raster band
49
- #-------------------
50
- block_x_size = FFI::MemoryPointer.new(:int)
51
- block_y_size = FFI::MemoryPointer.new(:int)
52
- raster_band = GDALGetRasterBand(dataset, 1)
53
- GDALGetBlockSize(raster_band, block_x_size, block_y_size)
54
-
55
- progressbar.log "Block: #{block_x_size.read_int}x#{block_y_size.read_int}"
56
- progressbar.log "Type: #{GDALGetDataTypeName(GDALGetRasterDataType(raster_band))}"
57
- progressbar.log "ColorInterp: #{GDALGetColorInterpretationName(GDALGetRasterColorInterpretation(raster_band))}"
58
-
59
- b_got_min = FFI::MemoryPointer.new(:double)
60
- b_got_max = FFI::MemoryPointer.new(:double)
61
-
62
- adf_min_max = FFI::MemoryPointer.new(:double, 2)
63
- adf_min_max.put_array_of_double(0, [
64
- GDALGetRasterMinimum(raster_band, b_got_min),
65
- GDALGetRasterMaximum(raster_band, b_got_max)
66
- ])
67
-
68
- unless b_got_max && b_got_min
69
- GDALComputeRasterMinMax(raster_band, true, adf_min_max)
70
- end
71
-
72
- progressbar.log "Min: #{adf_min_max[0].read_double}"
73
- progressbar.log "Max: #{adf_min_max[1].read_double}"
74
-
75
- overview_count = GDALGetOverviewCount(raster_band)
76
- progressbar.log "Band has #{overview_count} overviews."
77
-
78
- raster_color_table = GDALGetRasterColorTable(raster_band)
79
- unless raster_color_table.null?
80
- progressbar.log "Band has a color table with #{raster_color_table} entries."
81
- end
82
-
83
-
84
- #-------------------
85
- # Reading Raster Data
86
- #-------------------
87
- x_size = GDALGetRasterBandXSize(raster_band)
88
- paf_scanline = FFI::MemoryPointer.new(:float, x_size)
89
- GDALRasterIO(raster_band,
90
- :GF_Read,
91
- 0,
92
- 0,
93
- x_size,
94
- 1,
95
- paf_scanline,
96
- x_size,
97
- 1,
98
- :GDT_Float32,
99
- 0,
100
- 0)
101
-
102
- progressbar.log "scanline: #{paf_scanline.read_float}"
103
-
104
- #-------------------
105
- # Techniques for creating files
106
- #-------------------
107
- psz_format = 'GTiff'
108
- geotiff_driver = GDALGetDriverByName(psz_format)
109
- abort "No such driver #{psz_format}" if geotiff_driver.null?
110
- papsz_metadata = GDALGetMetadata(geotiff_driver, nil)
111
-
112
- if CSLFetchBoolean(papsz_metadata, GDAL_DCAP_CREATE, 0)
113
- progressbar.log "Driver #{psz_format} supports Create() method."
114
- end
115
-
116
- if CSLFetchBoolean(papsz_metadata, GDAL_DCAP_CREATECOPY, 0)
117
- progressbar.log "Driver #{psz_format} supports CreateCopy() method."
118
- end
119
-
120
- psz_dst_filename = File.expand_path('gdal_createcopy_test.tif', dir)
121
- src_dataset = GDALOpen(psz_src_filename, :GA_ReadOnly)
122
- dest_dataset = GDALCreateCopy(geotiff_driver, psz_dst_filename, src_dataset, 0, nil, nil, nil)
123
- GDALClose(dest_dataset) unless dest_dataset.null?
124
-
125
- # Don't close this yet--we use it later.
126
- # GDALClose(src_dataset)
127
-
128
-
129
- papsz_options = CSLSetNameValue(FFI::MemoryPointer.new(:pointer, 2), 'TILED', 'YES')
130
- papsz_options = CSLSetNameValue(papsz_options, 'COMPRESS', 'PACKBITS')
131
- progressbar.log "First option key/value pair: #{papsz_options.read_array_of_pointer(2).first.read_string}"
132
- progressbar.log "Second option key/value pair: #{papsz_options.read_array_of_pointer(2).last.read_string}"
133
-
134
-
135
- callback = Proc.new do |double, _, _|
136
- progress = double * 100
137
- progressbar.progress = progress unless progressbar.progress == 100
138
- end
139
- dest_dataset2 = GDALCreateCopy(geotiff_driver, psz_dst_filename, src_dataset, 0, papsz_options, callback, nil)
140
-
141
- GDALClose(dest_dataset2) unless dest_dataset2.null?
142
- CSLDestroy(papsz_options)
143
- GDALClose(src_dataset)
144
-
data/rubby.rb DELETED
@@ -1,224 +0,0 @@
1
- require './lib/ffi-gdal'
2
- require 'pp'
3
- require 'pathname'
4
-
5
- #dir = '../../agrian/gis_engine/test/test_files'
6
- #name = 'empty_red_image.tif'
7
- #name = 'empty_black_image.tif'
8
-
9
- #dir = '~/Desktop/geotiffs'
10
- #name = 'NDVI20000201032.tif'
11
- #name = 'NDVI20000701183.tif'
12
- #name = 'NDVI20000701183.zip'
13
- #name = 'NDVI20000401092.tif'
14
-
15
- #dir = './spec/support'
16
- #name = 'google_earth_test.jpg'
17
- #name = 'compassdata_gcparchive_google_earth.kmz'
18
-
19
- #dir = './spec/support/aaron/Floyd'
20
- #name = 'Floyd_1058_20140612_NRGB.tif'
21
-
22
- dir = './spec/support/images/Harper'
23
- name = 'Harper_1058_20140612_NRGB.tif'
24
-
25
- #dir = './spec/support/osgeo'
26
- #name = 'c41078a1.tif'
27
-
28
- #dir = './spec/support/ShapeDailyCurrent'
29
- #name = '851449507.dbf'
30
- #name = '851449507.prj'
31
-
32
- filename = File.expand_path(name, dir)
33
- dataset = GDAL::Dataset.open(filename, 'r')
34
-
35
- current_directory = Pathname.new(Dir.pwd)
36
-
37
- puts '#------------------------------------------------------------------------'
38
- puts '#'
39
- puts "# #{GDAL.long_version}"
40
- puts '#'
41
- puts '# Build info:'
42
- GDAL.build_info.each do |k, v|
43
- puts "# - #{k} -> #{v}"
44
- end
45
- puts '#'
46
- puts '#------------------------------------------------------------------------'
47
- puts '#------------------------------------------------------------------------'
48
- puts '# Dataset Info'
49
- puts '#------------------------------------------------------------------------'
50
- puts "* Description:\t\t\t#{dataset.description}"
51
- puts "* Raster size (x, y):\t\t#{dataset.raster_x_size}, #{dataset.raster_y_size}"
52
- puts "* Raster count:\t\t\t#{dataset.raster_count}"
53
- puts "* Access flag:\t\t\t#{dataset.access_flag}"
54
- puts "* Projection:\t#{dataset.projection}"
55
- puts '* File list:'
56
- dataset.file_list.each do |path|
57
- p = Pathname.new(path)
58
- puts "\t\t\t\t- #{p.relative_path_from(current_directory)}"
59
- end
60
-
61
- puts '* Metadata'
62
- dataset.all_metadata.each do |domain, data|
63
- puts "\t\t\t\t+ Domain: #{domain}"
64
- if data.empty?
65
- puts "\t\t\t\t\t- No values"
66
- else
67
- data.each do |k, v|
68
- print "\t\t\t\t\t- #{k} => "
69
- pp v
70
- end
71
- end
72
- end
73
-
74
-
75
-
76
- puts '#------------------------------------------------------------------------'
77
- puts '# Driver Info'
78
- puts '#------------------------------------------------------------------------'
79
- puts "* Description:\t\t#{dataset.driver.description}"
80
- puts "* Short name:\t\t#{dataset.driver.short_name}"
81
- puts "* Long name:\t\t#{dataset.driver.long_name}"
82
- puts "* Help topic:\t\t#{dataset.driver.help_topic}"
83
- puts '* Metadata:'
84
- dataset.driver.all_metadata.each do |domain, data|
85
- puts "\t\t\t+ Domain: #{domain}"
86
- if data.empty?
87
- puts "\t\t\t\t- No values"
88
- else
89
- data.each do |k, v|
90
- print "\t\t\t\t- #{k} => "
91
- pp v
92
- end
93
- end
94
- end
95
-
96
- puts '* Creation option list:'
97
- dataset.driver.creation_option_list.each do |option|
98
- puts "\t\t\t- #{option}" unless option.empty?
99
- end
100
- puts
101
-
102
-
103
- if dataset.raster_count > 0
104
- puts '#------------------------------------------------------------------------'
105
- puts '# Raster Band Info'
106
- puts '#------------------------------------------------------------------------'
107
- (1..dataset.raster_count).each do |i|
108
- band = dataset.raster_band(i)
109
- puts "* Band #{i}/#{dataset.raster_count}"
110
- puts " - description:\t\t\t#{band.description}"
111
- puts " - size (x,y):\t\t\t#{band.x_size},#{band.y_size}"
112
- puts " - no-data value:\t\t#{band.no_data_value}"
113
- puts " - access flag:\t\t#{band.access_flag}"
114
- puts " - number:\t\t\t#{band.number}"
115
- puts " - color interp:\t\t#{band.color_interpretation}"
116
- puts " - type:\t\t\t#{band.data_type}"
117
- puts " - block size:\t\t\t#{band.block_size}"
118
- puts " - category names:\t\t#{band.category_names}"
119
- band.category_names = 'meow'
120
- puts " - category names:\t\t#{band.category_names}"
121
- puts " - value range:\t\t#{band.minimum_value}..#{band.maximum_value}"
122
- #puts " + read:\t\t\t#{band.read}"
123
- puts " - unit type:\t\t\t#{band.unit_type}"
124
- puts " - statistics:\t\t\t#{band.statistics}"
125
- puts " - scale:\t\t\t#{band.scale}"
126
- puts " - offset:\t\t\t#{band.offset}"
127
- puts " - mask flags:\t\t\t#{band.mask_flags}"
128
- #puts " + default histogram:\t\t\t#{band.default_histogram}"
129
- #puts " + histogram:\t\t\t#{band.histogram(-0.5, 255.5, 256)}"
130
-
131
- if band.mask_band
132
- puts ' + Mask band:'
133
- puts " - number:\t\t\t\t#{band.mask_band.number}"
134
- puts " - size (x,y):\t\t\t#{band.mask_band.x_size},#{band.mask_band.y_size}"
135
- puts " - color interp:\t\t\t#{band.mask_band.color_interpretation}"
136
- puts " - type:\t\t\t\t#{band.mask_band.data_type}"
137
- puts " - block size:\t\t\t#{band.mask_band.block_size}"
138
- puts " - value range:\t\t\t#{band.mask_band.minimum_value}..#{band.mask_band.maximum_value}"
139
- end
140
- puts " - has arbitrary overviews?\t#{band.arbitrary_overviews?}"
141
- puts " - raster sample overview:\t#{band.raster_sample_overview}"
142
- puts " - overview count:\t\t#{band.overview_count}"
143
- if band.overview_count > 0
144
- (0...band.overview_count).each do |j|
145
- overview = band.overview(j)
146
- puts " # Overview #{j} Info:"
147
- puts " - size (x, y):\t\t#{overview.x_size}, #{overview.y_size}"
148
- puts " - color interp:\t\t#{overview.color_interpretation}"
149
- puts " - type:\t\t\t#{overview.data_type}"
150
- puts " - block size:\t\t#{overview.block_size}"
151
- puts " - value range:\t\t#{overview.minimum_value}..#{overview.maximum_value}"
152
- puts " - overview count:\t\t#{overview.overview_count}"
153
- end
154
- end
155
- puts ' + Metadata:'
156
- band.all_metadata.each do |domain, data|
157
- puts "\t\t\t\t+ Domain: #{domain}"
158
- if data.empty?
159
- puts "\t\t\t\t\t- No values"
160
- else
161
- data.each do |k, v|
162
- print "\t\t\t\t\t- #{k} => "
163
- pp v
164
- end
165
- end
166
- end
167
- if band.color_table
168
- puts ' + Color Table Info'
169
- puts " - palette interp:\t\t#{band.color_table.palette_interpretation}"
170
- puts " - color entry count:\t#{band.color_table.color_entry_count}"
171
- if band.color_table.color_entry_count > 0
172
- puts " - #{band.color_table.color_entry_count} color entries:"
173
-
174
- (0...band.color_table.color_entry_count).each do |j|
175
- ce = band.color_table.color_entry(j)
176
- ce_string = "(#{ce[:c1]},#{ce[:c2]},#{ce[:c3]},#{ce[:c4]})"
177
-
178
- rgb = band.color_table.color_entry_as_rgb(j)
179
- rgb_string = "(#{rgb[:c1]},#{rgb[:c2]},#{rgb[:c3]},#{rgb[:c4]})"
180
-
181
- if band.color_table.palette_interpretation == :GPI_RGB
182
- puts "\t\t\t\t~ #{j}:\t#{ce_string}"
183
- else
184
- puts "\t\t\t\t~ #{j}:\t#{ce_string}, RGB: #{rgb_string}"
185
- end
186
- end
187
- else
188
- puts ' - No Color Entry Info.'
189
- end
190
- end
191
- end
192
- end
193
-
194
- puts
195
-
196
- puts '#------------------------------------------------------------------------'
197
- puts '# Ground Control Point (GCP) Info'
198
- puts '#------------------------------------------------------------------------'
199
- puts "* GCP count:\t\t\t#{dataset.gcp_count}"
200
- if dataset.gcp_count > 0
201
- puts "* GCP projection:\t\t'#{dataset.gcp_projection}'"
202
- puts '* GCPs:'
203
- puts "\t\t\t- ID:\t\t\t\t'#{dataset.gcps[:id]}'"
204
- puts "\t\t\t- Info:\t\t\t'#{dataset.gcps[:info]}'"
205
- puts "\t\t\t- Pixel:\t\t\t#{dataset.gcps[:pixel]}"
206
- puts "\t\t\t- Line:\t\t\t#{dataset.gcps[:line]}"
207
- puts "\t\t\t- X:\t\t\t\t#{dataset.gcps[:x]}"
208
- puts "\t\t\t- Y:\t\t\t\t#{dataset.gcps[:y]}"
209
- puts "\t\t\t- Z:\t\t\t\t#{dataset.gcps[:z]}"
210
- end
211
-
212
- puts
213
- puts '#------------------------------------------------------------------------'
214
- puts '# Geo-transform Info'
215
- puts '#------------------------------------------------------------------------'
216
- puts "* x origin (C):\t\t\t#{dataset.geo_transform.x_origin}"
217
- puts "* y origin (F):\t\t\t#{dataset.geo_transform.y_origin}"
218
- puts "* pixel width (A):\t\t#{dataset.geo_transform.pixel_width}"
219
- puts "* pixel height (E):\t\t#{dataset.geo_transform.pixel_height}"
220
- puts "* x rotation (B):\t\t#{dataset.geo_transform.x_rotation}"
221
- puts "* y rotation (D):\t\t#{dataset.geo_transform.y_rotation}"
222
- puts "* x projection (0.1, 0.2):\t#{dataset.geo_transform.x_projection(0.1, 0.2)}"
223
- puts "* y projection (0.2, 0.1):\t#{dataset.geo_transform.y_projection(0.2, 0.1)}"
224
- puts '#----------------------------------------------------'