ffi-gdal 1.0.0.beta5 → 1.0.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -3
  3. data/.rubocop.yml +7 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +1 -1
  6. data/History.md +143 -1
  7. data/README.md +5 -11
  8. data/Rakefile +2 -60
  9. data/TODO.md +10 -0
  10. data/examples/geometries.rb +4 -6
  11. data/examples/gridding.rb +99 -98
  12. data/examples/ogr_layer_to_layer.rb +0 -2
  13. data/examples/raster_erasing.rb +47 -0
  14. data/examples/remove_small_polygons.rb +62 -0
  15. data/examples/testing_gdal.rb +0 -3
  16. data/examples/warping.rb +140 -0
  17. data/ffi-gdal.gemspec +5 -2
  18. data/lib/ext/error_symbols.rb +1 -1
  19. data/lib/ext/ffi_library_function_checks.rb +3 -2
  20. data/lib/ext/float_ext.rb +2 -2
  21. data/lib/ext/narray_ext.rb +1 -1
  22. data/lib/ext/numeric_as_data_type.rb +1 -1
  23. data/lib/ext/to_bool.rb +2 -2
  24. data/lib/ffi/cpl/conv.rb +1 -3
  25. data/lib/ffi/cpl/error.rb +0 -3
  26. data/lib/ffi/cpl/minixml.rb +17 -21
  27. data/lib/ffi/cpl/progress.rb +27 -0
  28. data/lib/ffi/cpl/string.rb +0 -8
  29. data/lib/ffi/cpl/vsi.rb +0 -1
  30. data/lib/ffi/cpl/xml_node.rb +0 -1
  31. data/lib/ffi/cpl.rb +15 -0
  32. data/lib/ffi/gdal/alg.rb +72 -54
  33. data/lib/ffi/gdal/gdal.rb +669 -672
  34. data/lib/ffi/gdal/grid.rb +141 -24
  35. data/lib/ffi/gdal/grid_data_metrics_options.rb +1 -1
  36. data/lib/ffi/gdal/grid_moving_average_options.rb +1 -1
  37. data/lib/ffi/gdal/matching.rb +0 -2
  38. data/lib/ffi/gdal/transformer_info.rb +1 -1
  39. data/lib/ffi/gdal/version.rb +1 -1
  40. data/lib/ffi/gdal/vrt.rb +0 -2
  41. data/lib/ffi/gdal/warp_options.rb +12 -14
  42. data/lib/ffi/gdal/warper.rb +61 -6
  43. data/lib/ffi/gdal.rb +18 -3
  44. data/lib/ffi/ogr/api.rb +10 -21
  45. data/lib/ffi/ogr/core.rb +9 -12
  46. data/lib/ffi/ogr/featurestyle.rb +0 -5
  47. data/lib/ffi/ogr/geocoding.rb +0 -1
  48. data/lib/ffi/ogr/srs_api.rb +0 -4
  49. data/lib/ffi/ogr/style_value.rb +1 -2
  50. data/lib/ffi/ogr.rb +15 -12
  51. data/lib/ffi-gdal.rb +5 -3
  52. data/lib/gdal/color_entry.rb +1 -0
  53. data/lib/gdal/color_interpretation.rb +2 -2
  54. data/lib/gdal/color_table.rb +14 -14
  55. data/lib/gdal/color_table_mixins/extensions.rb +4 -4
  56. data/lib/gdal/cpl_error_handler.rb +12 -14
  57. data/lib/gdal/data_type.rb +13 -12
  58. data/lib/gdal/dataset.rb +170 -94
  59. data/lib/gdal/dataset_mixins/algorithm_methods.rb +47 -21
  60. data/lib/gdal/dataset_mixins/extensions.rb +32 -61
  61. data/lib/gdal/dataset_mixins/matching.rb +0 -2
  62. data/lib/gdal/dataset_mixins/warp_methods.rb +42 -0
  63. data/lib/gdal/driver.rb +62 -47
  64. data/lib/gdal/driver_mixins/extensions.rb +2 -7
  65. data/lib/gdal/environment_methods.rb +13 -10
  66. data/lib/gdal/exceptions.rb +24 -2
  67. data/lib/gdal/geo_transform.rb +10 -16
  68. data/lib/gdal/geo_transform_mixins/extensions.rb +58 -3
  69. data/lib/gdal/grid.rb +62 -109
  70. data/lib/gdal/{grid_types → grid_algorithms}/data_metrics_base.rb +1 -3
  71. data/lib/gdal/{grid_types → grid_algorithms}/inverse_distance_to_a_power.rb +2 -4
  72. data/lib/gdal/{grid_types → grid_algorithms}/metric_average_distance.rb +2 -2
  73. data/lib/gdal/{grid_types → grid_algorithms}/metric_average_distance_pts.rb +2 -2
  74. data/lib/gdal/{grid_types → grid_algorithms}/metric_count.rb +2 -2
  75. data/lib/gdal/{grid_types → grid_algorithms}/metric_maximum.rb +2 -2
  76. data/lib/gdal/{grid_types → grid_algorithms}/metric_minimum.rb +2 -2
  77. data/lib/gdal/{grid_types → grid_algorithms}/metric_range.rb +2 -2
  78. data/lib/gdal/{grid_types → grid_algorithms}/moving_average.rb +2 -4
  79. data/lib/gdal/{grid_types → grid_algorithms}/nearest_neighbor.rb +2 -4
  80. data/lib/gdal/grid_algorithms.rb +22 -0
  81. data/lib/gdal/gridder/point_extracting.rb +89 -0
  82. data/lib/gdal/gridder.rb +294 -0
  83. data/lib/gdal/gridder_options.rb +273 -0
  84. data/lib/gdal/internal_helpers.rb +132 -23
  85. data/lib/gdal/major_object.rb +13 -10
  86. data/lib/gdal/merger.rb +130 -0
  87. data/lib/gdal/options.rb +3 -2
  88. data/lib/gdal/raster_attribute_table.rb +74 -51
  89. data/lib/gdal/raster_attribute_table_mixins/extensions.rb +21 -3
  90. data/lib/gdal/raster_band.rb +139 -167
  91. data/lib/gdal/raster_band_classifier.rb +19 -18
  92. data/lib/gdal/raster_band_mixins/algorithm_extensions.rb +107 -0
  93. data/lib/gdal/raster_band_mixins/algorithm_methods.rb +79 -40
  94. data/lib/gdal/raster_band_mixins/coloring_extensions.rb +84 -0
  95. data/lib/gdal/raster_band_mixins/extensions.rb +34 -169
  96. data/lib/gdal/raster_band_mixins/io_extensions.rb +180 -0
  97. data/lib/gdal/rpc_info.rb +1 -2
  98. data/lib/gdal/transformer.rb +1 -6
  99. data/lib/gdal/transformers/approximate_transformer.rb +0 -4
  100. data/lib/gdal/transformers/base_general_image_projection_transformer.rb +0 -6
  101. data/lib/gdal/transformers/gcp_transformer.rb +2 -6
  102. data/lib/gdal/transformers/general_image_projection_transformer.rb +8 -7
  103. data/lib/gdal/transformers/general_image_projection_transformer2.rb +1 -1
  104. data/lib/gdal/transformers/geolocation_transformer.rb +0 -4
  105. data/lib/gdal/transformers/reprojection_transformer.rb +0 -8
  106. data/lib/gdal/transformers/rpc_transformer.rb +0 -4
  107. data/lib/gdal/transformers/tps_transformer.rb +1 -3
  108. data/lib/gdal/version_info.rb +7 -8
  109. data/lib/gdal/virtual_dataset.rb +2 -4
  110. data/lib/gdal/warp_operation.rb +17 -14
  111. data/lib/gdal/warp_options.rb +132 -0
  112. data/lib/gdal.rb +41 -2
  113. data/lib/ogr/coordinate_transformation.rb +79 -32
  114. data/lib/ogr/data_source.rb +17 -14
  115. data/lib/ogr/data_source_extensions.rb +1 -5
  116. data/lib/ogr/driver.rb +11 -14
  117. data/lib/ogr/envelope.rb +1 -1
  118. data/lib/ogr/envelope_extensions.rb +23 -6
  119. data/lib/ogr/error_handling.rb +3 -3
  120. data/lib/ogr/exceptions.rb +6 -0
  121. data/lib/ogr/feature.rb +25 -38
  122. data/lib/ogr/feature_definition.rb +6 -8
  123. data/lib/ogr/feature_definition_extensions.rb +2 -6
  124. data/lib/ogr/feature_extensions.rb +71 -41
  125. data/lib/ogr/field.rb +16 -15
  126. data/lib/ogr/field_definition.rb +4 -4
  127. data/lib/ogr/geocoder.rb +5 -5
  128. data/lib/ogr/geometries/geometry_collection.rb +4 -1
  129. data/lib/ogr/geometries/geometry_collection_25d.rb +12 -0
  130. data/lib/ogr/geometries/line_string.rb +30 -8
  131. data/lib/ogr/geometries/line_string_25d.rb +21 -0
  132. data/lib/ogr/geometries/linear_ring.rb +10 -1
  133. data/lib/ogr/geometries/multi_line_string.rb +2 -1
  134. data/lib/ogr/geometries/multi_line_string_25d.rb +13 -0
  135. data/lib/ogr/geometries/multi_point.rb +2 -1
  136. data/lib/ogr/geometries/multi_point_25d.rb +14 -0
  137. data/lib/ogr/geometries/multi_polygon.rb +3 -2
  138. data/lib/ogr/geometries/multi_polygon_25d.rb +13 -0
  139. data/lib/ogr/geometries/point.rb +20 -23
  140. data/lib/ogr/geometries/point_25d.rb +48 -0
  141. data/lib/ogr/geometries/polygon.rb +4 -1
  142. data/lib/ogr/geometries/polygon_25d.rb +14 -0
  143. data/lib/ogr/geometry.rb +125 -93
  144. data/lib/ogr/geometry_field_definition.rb +7 -5
  145. data/lib/ogr/geometry_mixins/container_mixins.rb +23 -0
  146. data/lib/ogr/geometry_mixins/extensions.rb +111 -0
  147. data/lib/ogr/geometry_types/container.rb +10 -3
  148. data/lib/ogr/geometry_types/curve.rb +68 -23
  149. data/lib/ogr/geometry_types/surface.rb +0 -9
  150. data/lib/ogr/internal_helpers.rb +3 -3
  151. data/lib/ogr/layer.rb +4 -5
  152. data/lib/ogr/layer_mixins/extensions.rb +242 -17
  153. data/lib/ogr/layer_mixins/ogr_feature_methods.rb +11 -11
  154. data/lib/ogr/layer_mixins/ogr_field_methods.rb +6 -11
  155. data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +18 -18
  156. data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +0 -2
  157. data/lib/ogr/layer_mixins/ogr_sql_methods.rb +1 -1
  158. data/lib/ogr/spatial_reference.rb +12 -37
  159. data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +53 -55
  160. data/lib/ogr/spatial_reference_mixins/exporters.rb +18 -49
  161. data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +10 -29
  162. data/lib/ogr/style_table.rb +2 -2
  163. data/lib/ogr/style_table_extensions.rb +3 -1
  164. data/lib/ogr/style_tool.rb +8 -14
  165. data/lib/ogr.rb +39 -1
  166. data/spec/ffi-gdal_spec.rb +18 -1
  167. data/spec/integration/gdal/color_table_info_spec.rb +49 -33
  168. data/spec/integration/gdal/dataset_info_spec.rb +294 -45
  169. data/spec/integration/gdal/driver_info_spec.rb +139 -31
  170. data/spec/integration/gdal/geo_transform_info_spec.rb +197 -26
  171. data/spec/integration/gdal/gridder_spec.rb +329 -0
  172. data/spec/integration/gdal/raster_attribute_table_info_spec.rb +216 -11
  173. data/spec/integration/gdal/raster_band_algorithms_spec.rb +33 -0
  174. data/spec/integration/gdal/raster_band_info_spec.rb +240 -271
  175. data/spec/integration/ogr/layer_spec.rb +3 -1
  176. data/spec/spec_helper.rb +15 -6
  177. data/spec/support/images/osgeo/gdal/data/hfa/float-rle.img +0 -0
  178. data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.lgo +31 -0
  179. data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif +0 -0
  180. data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif.msk +0 -0
  181. data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.txt +10 -0
  182. data/spec/support/images/osgeo/geotiff/gdal_eg/cea.tif +0 -0
  183. data/spec/support/images/osgeo/geotiff/gdal_eg/cea.txt +84 -0
  184. data/spec/support/images/osgeo/geotiff/zi_imaging/image0.lgo +45 -0
  185. data/spec/support/images/osgeo/geotiff/zi_imaging/image0.tif +0 -0
  186. data/spec/support/integration_help.rb +32 -2
  187. data/spec/support/shared_examples/gdal/major_object_examples.rb +0 -6
  188. data/spec/support/shared_examples/ogr/a_geometry.rb +1 -1
  189. data/spec/unit/ffi/gdal_spec.rb +1 -1
  190. data/spec/unit/gdal/color_entry_spec.rb +1 -0
  191. data/spec/unit/gdal/color_interpretation_spec.rb +1 -0
  192. data/spec/unit/gdal/dataset_spec.rb +53 -2
  193. data/spec/unit/gdal/geo_transform_mixins/extensions_spec.rb +67 -0
  194. data/spec/unit/gdal/geo_transform_spec.rb +1 -1
  195. data/spec/unit/gdal/grid_spec.rb +83 -0
  196. data/spec/unit/gdal/gridder/point_extracting_spec.rb +99 -0
  197. data/spec/unit/gdal/gridder_options_spec.rb +183 -0
  198. data/spec/unit/gdal/gridder_spec.rb +140 -0
  199. data/spec/unit/gdal/internal_helpers_spec.rb +166 -2
  200. data/spec/unit/gdal/major_object_spec.rb +2 -0
  201. data/spec/unit/gdal/options_spec.rb +1 -0
  202. data/spec/unit/gdal/raster_band_classifier_spec.rb +70 -12
  203. data/spec/unit/gdal/raster_band_mixins/extensions_spec.rb +71 -0
  204. data/spec/unit/gdal/raster_band_mixins/io_extensions_spec.rb +133 -0
  205. data/spec/unit/gdal/raster_band_spec.rb +1 -0
  206. data/spec/unit/gdal/rpc_info_spec.rb +1 -0
  207. data/spec/unit/gdal/version_info_spec.rb +2 -0
  208. data/spec/unit/gdal/warp_operation_spec.rb +1 -0
  209. data/spec/unit/ogr/coordinate_transformation_spec.rb +102 -0
  210. data/spec/unit/ogr/data_source_spec.rb +12 -0
  211. data/spec/unit/ogr/feature_extensions_spec.rb +88 -0
  212. data/spec/unit/ogr/feature_spec.rb +30 -46
  213. data/spec/unit/ogr/geometries/geometry_collection_25d_spec.rb +23 -0
  214. data/spec/unit/ogr/geometries/geometry_collection_spec.rb +3 -3
  215. data/spec/unit/ogr/geometries/line_string_25d_spec.rb +23 -0
  216. data/spec/unit/ogr/geometries/line_string_spec.rb +2 -2
  217. data/spec/unit/ogr/geometries/linear_ring_spec.rb +2 -2
  218. data/spec/unit/ogr/geometries/multi_line_string_25d_spec.rb +23 -0
  219. data/spec/unit/ogr/geometries/multi_point_25d_spec.rb +23 -0
  220. data/spec/unit/ogr/geometries/multi_polygon_25d_spec.rb +23 -0
  221. data/spec/unit/ogr/geometries/point_25d_spec.rb +23 -0
  222. data/spec/unit/ogr/geometries/point_spec.rb +14 -24
  223. data/spec/unit/ogr/geometries/polygon_25d_spec.rb +23 -0
  224. data/spec/unit/ogr/geometries/polygon_spec.rb +1 -1
  225. data/spec/unit/ogr/geometry_field_definition_spec.rb +1 -1
  226. data/spec/unit/ogr/geometry_spec.rb +196 -30
  227. data/spec/unit/ogr/internal_helpers_spec.rb +20 -9
  228. data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +14 -6
  229. data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +9 -1
  230. data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +2 -1
  231. data/spec/unit/ogr/style_table_spec.rb +1 -1
  232. data/tmp/.keep +0 -0
  233. metadata +121 -19
  234. data/examples/points.txt +0 -127
  235. data/lib/gdal/grid_types.rb +0 -22
  236. data/lib/ogr/geometries/point_extensions.rb +0 -32
  237. data/lib/ogr/geometry_extensions.rb +0 -59
@@ -7,6 +7,7 @@ module GDAL
7
7
  # @return [FFI::GDAL::ColorEntry]
8
8
  attr_reader :c_struct
9
9
 
10
+ # @param color_entry [FFI::GDAL::ColorEntry]
10
11
  def initialize(color_entry = nil)
11
12
  @c_struct = color_entry || FFI::GDAL::ColorEntry.new
12
13
  end
@@ -3,13 +3,13 @@ module GDAL
3
3
  # @param gdal_color_interp [FFI::GDAL::ColorInterp]
4
4
  # @return [String]
5
5
  def self.name(gdal_color_interp)
6
- FFI::GDAL.GDALGetColorInterpretationName(gdal_color_interp)
6
+ FFI::GDAL::GDAL.GDALGetColorInterpretationName(gdal_color_interp)
7
7
  end
8
8
 
9
9
  # @param name [String]
10
10
  # @return [FFI::GDAL::ColorInterp]
11
11
  def self.by_name(name)
12
- FFI::GDAL.GDALGetColorInterpretationByName(name)
12
+ FFI::GDAL::GDAL.GDALGetColorInterpretationByName(name)
13
13
  end
14
14
  end
15
15
  end
@@ -1,4 +1,4 @@
1
- require_relative '../ffi/gdal'
1
+ require_relative '../gdal'
2
2
  require_relative 'color_table_mixins/extensions'
3
3
  require_relative 'color_entry'
4
4
 
@@ -25,14 +25,14 @@ module GDAL
25
25
  # @raise [GDAL::InvalidColorTable] If unable to create the color table.
26
26
  def initialize(palette_interp_or_pointer)
27
27
  @c_pointer =
28
- if FFI::GDAL::PaletteInterp[palette_interp_or_pointer]
29
- FFI::GDAL.GDALCreateColorTable(palette_interp_or_pointer)
28
+ if FFI::GDAL::GDAL::PaletteInterp[palette_interp_or_pointer]
29
+ FFI::GDAL::GDAL.GDALCreateColorTable(palette_interp_or_pointer)
30
30
  else
31
31
  palette_interp_or_pointer
32
32
  end
33
33
 
34
34
  if !@c_pointer.is_a?(FFI::Pointer) || @c_pointer.null?
35
- fail GDAL::InvalidColorTable,
35
+ raise GDAL::InvalidColorTable,
36
36
  "Unable to create #{self.class.name} from #{palette_interp_or_pointer}"
37
37
  end
38
38
 
@@ -44,14 +44,14 @@ module GDAL
44
44
  when :GPI_CMYK then extend GDAL::ColorTableTypes::CMYK
45
45
  when :GPI_HLS then extend GDAL::ColorTableTypes::HLS
46
46
  else
47
- fail "Unknown PaletteInterpretation: #{palette_interpretation}"
47
+ raise "Unknown PaletteInterpretation: #{palette_interpretation}"
48
48
  end
49
49
  end
50
50
 
51
51
  def destroy!
52
52
  return unless @c_pointer
53
53
 
54
- FFI::GDAL.GDALDestroyColorTable(@c_pointer)
54
+ FFI::GDAL::GDAL.GDALDestroyColorTable(@c_pointer)
55
55
  @c_pointer = nil
56
56
  end
57
57
 
@@ -59,7 +59,7 @@ module GDAL
59
59
  #
60
60
  # @return [GDAL::ColorTable]
61
61
  def clone
62
- ct_ptr = FFI::GDAL.GDALCloneColorTable(@c_pointer)
62
+ ct_ptr = FFI::GDAL::GDAL.GDALCloneColorTable(@c_pointer)
63
63
  return nil if ct_ptr.null?
64
64
 
65
65
  GDAL::ColorTable.new(ct_ptr)
@@ -67,21 +67,21 @@ module GDAL
67
67
 
68
68
  # Usually :GPI_RGB.
69
69
  #
70
- # @return [Symbol] One of FFI::GDAL::PaletteInterp.
70
+ # @return [Symbol] One of FFI::GDAL::GDAL::PaletteInterp.
71
71
  def palette_interpretation
72
- FFI::GDAL.GDALGetPaletteInterpretation(@c_pointer)
72
+ FFI::GDAL::GDAL.GDALGetPaletteInterpretation(@c_pointer)
73
73
  end
74
74
 
75
75
  # @return [Fixnum]
76
76
  def color_entry_count
77
- FFI::GDAL.GDALGetColorEntryCount(@c_pointer)
77
+ FFI::GDAL::GDAL.GDALGetColorEntryCount(@c_pointer)
78
78
  end
79
79
 
80
80
  # @param index [Fixnum]
81
81
  # @return [GDAL::ColorEntry]
82
82
  def color_entry(index)
83
83
  @color_entries.fetch(index) do
84
- color_entry = FFI::GDAL.GDALGetColorEntry(@c_pointer, index)
84
+ color_entry = FFI::GDAL::GDAL.GDALGetColorEntry(@c_pointer, index)
85
85
  return nil if color_entry.null?
86
86
 
87
87
  GDAL::ColorEntry.new(color_entry)
@@ -94,7 +94,7 @@ module GDAL
94
94
  entry = color_entry(index)
95
95
  return unless entry
96
96
 
97
- FFI::GDAL.GDALGetColorEntryAsRGB(@c_pointer, index, entry.c_pointer)
97
+ FFI::GDAL::GDAL.GDALGetColorEntryAsRGB(@c_pointer, index, entry.c_pointer)
98
98
  return nil if entry.c_pointer.null?
99
99
 
100
100
  entry
@@ -123,7 +123,7 @@ module GDAL
123
123
  entry.color3 = three if three
124
124
  entry.color4 = four if four
125
125
 
126
- FFI::GDAL.GDALSetColorEntry(@c_pointer, index, entry.c_struct)
126
+ FFI::GDAL::GDAL.GDALSetColorEntry(@c_pointer, index, entry.c_struct)
127
127
  @color_entries.insert(index, entry)
128
128
 
129
129
  entry
@@ -142,7 +142,7 @@ module GDAL
142
142
  start_color_ptr = start_color.c_struct
143
143
  end_color_ptr = end_color.c_struct
144
144
 
145
- FFI::GDAL.GDALCreateColorRamp(@c_pointer, start_index,
145
+ FFI::GDAL::GDAL.GDALCreateColorRamp(@c_pointer, start_index,
146
146
  start_color_ptr,
147
147
  end_index,
148
148
  end_color_ptr)
@@ -5,17 +5,17 @@ module GDAL
5
5
  module Extensions
6
6
  def color_entries_for(color_number)
7
7
  unless (1..4).to_a.include? color_number
8
- fail "Invalid ColorEntry number 'color#{color_number}'"
8
+ raise "Invalid ColorEntry number 'color#{color_number}'"
9
9
  end
10
10
 
11
- color_entry_count.times.map do |i|
11
+ Array.new(color_entry_count) do |i|
12
12
  color_entry(i).send("color#{color_number}".to_sym)
13
13
  end
14
14
  end
15
15
 
16
16
  # @return [Array<GDAL::ColorEntry>]
17
17
  def color_entries
18
- color_entry_count.times.map do |i|
18
+ Array.new(color_entry_count) do |i|
19
19
  color_entry(i)
20
20
  end
21
21
  end
@@ -25,7 +25,7 @@ module GDAL
25
25
  #
26
26
  # @return [Array<GDAL::ColorEntry>]
27
27
  def color_entries_as_rgb
28
- color_entry_count.times.map do |i|
28
+ Array.new(color_entry_count) do |i|
29
29
  color_entry_as_rgb(i)
30
30
  end
31
31
  end
@@ -1,5 +1,3 @@
1
- require_relative 'exceptions'
2
-
3
1
  module GDAL
4
2
  # This is used to override GDAL's built-in error handling. By default, GDAL
5
3
  # only logs errors to STDOUT, which doesn't allow a whole lot of flexibility.
@@ -10,24 +8,24 @@ module GDAL
10
8
  include GDAL::Logger
11
9
 
12
10
  CPLE_MAP = [
13
- { cple: :CPLE_None, exception: nil },
14
- { cple: :CPLE_AppDefined, exception: nil },
15
- { cple: :CPLE_OutOfMemory, exception: ::NoMemoryError },
16
- { cple: :CPLE_FileIO, exception: ::IOError },
17
- { cple: :CPLE_OpenFailed, exception: GDAL::OpenFailure },
18
- { cple: :CPLE_IllegalArg, exception: ::ArgumentError },
19
- { cple: :CPLE_NotSupported, exception: GDAL::UnsupportedOperation },
11
+ { cple: :CPLE_None, exception: nil },
12
+ { cple: :CPLE_AppDefined, exception: nil },
13
+ { cple: :CPLE_OutOfMemory, exception: ::NoMemoryError },
14
+ { cple: :CPLE_FileIO, exception: ::IOError },
15
+ { cple: :CPLE_OpenFailed, exception: GDAL::OpenFailure },
16
+ { cple: :CPLE_IllegalArg, exception: ::ArgumentError },
17
+ { cple: :CPLE_NotSupported, exception: GDAL::UnsupportedOperation },
20
18
  { cple: :CPLE_AssertionFailed, exception: ::RuntimeError },
21
- { cple: :CPLE_NoWriteAccess, exception: GDAL::NoWriteAccess },
22
- { cple: :CPLE_UserInterrupt, exception: ::Interrupt },
23
- { cple: :CPLE_ObjectNull, exception: GDAL::NullObject }
24
- ]
19
+ { cple: :CPLE_NoWriteAccess, exception: GDAL::NoWriteAccess },
20
+ { cple: :CPLE_UserInterrupt, exception: ::Interrupt },
21
+ { cple: :CPLE_ObjectNull, exception: GDAL::NullObject }
22
+ ].freeze
25
23
 
26
24
  FAIL_PROC = lambda do |exception, message|
27
25
  ex = exception ? exception.new(message) : GDAL::Error.new(message)
28
26
  ex.set_backtrace(caller(4))
29
27
 
30
- fail(ex)
28
+ raise(ex)
31
29
  end
32
30
 
33
31
  SUCCESS_PROC = proc { true }
@@ -1,38 +1,39 @@
1
1
  module GDAL
2
+ # Info about GDAL data types (GDT symbols).
2
3
  class DataType
3
4
  # The size in bits.
4
5
  #
5
- # @param gdal_data_type [FFI::GDAL::DataType]
6
+ # @param gdal_data_type [FFI::GDAL::GDAL::DataType]
6
7
  # @return [Fixnum]
7
8
  def self.size(gdal_data_type)
8
- FFI::GDAL.GDALGetDataTypeSize(gdal_data_type)
9
+ FFI::GDAL::GDAL.GDALGetDataTypeSize(gdal_data_type)
9
10
  end
10
11
 
11
- # @param gdal_data_type [FFI::GDAL::DataType]
12
+ # @param gdal_data_type [FFI::GDAL::GDAL::DataType]
12
13
  # @return [Fixnum]
13
14
  def self.complex?(gdal_data_type)
14
- FFI::GDAL.GDALDataTypeIsComplex(gdal_data_type)
15
+ FFI::GDAL::GDAL.GDALDataTypeIsComplex(gdal_data_type)
15
16
  end
16
17
 
17
- # @param gdal_data_type [FFI::GDAL::DataType]
18
+ # @param gdal_data_type [FFI::GDAL::GDAL::DataType]
18
19
  # @return [String]
19
20
  def self.name(gdal_data_type)
20
- FFI::GDAL.GDALGetDataTypeName(gdal_data_type)
21
+ FFI::GDAL::GDAL.GDALGetDataTypeName(gdal_data_type)
21
22
  end
22
23
 
23
24
  # The data type's symbolic name.
24
25
  #
25
26
  # @param name [String]
26
- # @return [FFI::GDAL::DataType]
27
+ # @return [FFI::GDAL::GDAL::DataType]
27
28
  def self.by_name(name)
28
- FFI::GDAL.GDALGetDataTypeByName(name)
29
+ FFI::GDAL::GDAL.GDALGetDataTypeByName(name.to_s)
29
30
  end
30
31
 
31
- # @param gdal_data_type1 [FFI::GDAL::DataType]
32
- # @param gdal_data_type2 [FFI::GDAL::DataType]
33
- # @return [FFI::GDAL::DataType]
32
+ # @param gdal_data_type1 [FFI::GDAL::GDAL::DataType]
33
+ # @param gdal_data_type2 [FFI::GDAL::GDAL::DataType]
34
+ # @return [FFI::GDAL::GDAL::DataType]
34
35
  def self.union(gdal_data_type1, gdal_data_type2)
35
- FFI::GDAL.GDALDataTypeUnion(gdal_data_type1, gdal_data_type2)
36
+ FFI::GDAL::GDAL.GDALDataTypeUnion(gdal_data_type1, gdal_data_type2)
36
37
  end
37
38
  end
38
39
  end