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.
- checksums.yaml +4 -4
- data/.gitignore +7 -3
- data/.rubocop.yml +7 -0
- data/.ruby-version +1 -0
- data/Gemfile +1 -1
- data/History.md +143 -1
- data/README.md +5 -11
- data/Rakefile +2 -60
- data/TODO.md +10 -0
- data/examples/geometries.rb +4 -6
- data/examples/gridding.rb +99 -98
- data/examples/ogr_layer_to_layer.rb +0 -2
- data/examples/raster_erasing.rb +47 -0
- data/examples/remove_small_polygons.rb +62 -0
- data/examples/testing_gdal.rb +0 -3
- data/examples/warping.rb +140 -0
- data/ffi-gdal.gemspec +5 -2
- data/lib/ext/error_symbols.rb +1 -1
- data/lib/ext/ffi_library_function_checks.rb +3 -2
- data/lib/ext/float_ext.rb +2 -2
- data/lib/ext/narray_ext.rb +1 -1
- data/lib/ext/numeric_as_data_type.rb +1 -1
- data/lib/ext/to_bool.rb +2 -2
- data/lib/ffi/cpl/conv.rb +1 -3
- data/lib/ffi/cpl/error.rb +0 -3
- data/lib/ffi/cpl/minixml.rb +17 -21
- data/lib/ffi/cpl/progress.rb +27 -0
- data/lib/ffi/cpl/string.rb +0 -8
- data/lib/ffi/cpl/vsi.rb +0 -1
- data/lib/ffi/cpl/xml_node.rb +0 -1
- data/lib/ffi/cpl.rb +15 -0
- data/lib/ffi/gdal/alg.rb +72 -54
- data/lib/ffi/gdal/gdal.rb +669 -672
- data/lib/ffi/gdal/grid.rb +141 -24
- data/lib/ffi/gdal/grid_data_metrics_options.rb +1 -1
- data/lib/ffi/gdal/grid_moving_average_options.rb +1 -1
- data/lib/ffi/gdal/matching.rb +0 -2
- data/lib/ffi/gdal/transformer_info.rb +1 -1
- data/lib/ffi/gdal/version.rb +1 -1
- data/lib/ffi/gdal/vrt.rb +0 -2
- data/lib/ffi/gdal/warp_options.rb +12 -14
- data/lib/ffi/gdal/warper.rb +61 -6
- data/lib/ffi/gdal.rb +18 -3
- data/lib/ffi/ogr/api.rb +10 -21
- data/lib/ffi/ogr/core.rb +9 -12
- data/lib/ffi/ogr/featurestyle.rb +0 -5
- data/lib/ffi/ogr/geocoding.rb +0 -1
- data/lib/ffi/ogr/srs_api.rb +0 -4
- data/lib/ffi/ogr/style_value.rb +1 -2
- data/lib/ffi/ogr.rb +15 -12
- data/lib/ffi-gdal.rb +5 -3
- data/lib/gdal/color_entry.rb +1 -0
- data/lib/gdal/color_interpretation.rb +2 -2
- data/lib/gdal/color_table.rb +14 -14
- data/lib/gdal/color_table_mixins/extensions.rb +4 -4
- data/lib/gdal/cpl_error_handler.rb +12 -14
- data/lib/gdal/data_type.rb +13 -12
- data/lib/gdal/dataset.rb +170 -94
- data/lib/gdal/dataset_mixins/algorithm_methods.rb +47 -21
- data/lib/gdal/dataset_mixins/extensions.rb +32 -61
- data/lib/gdal/dataset_mixins/matching.rb +0 -2
- data/lib/gdal/dataset_mixins/warp_methods.rb +42 -0
- data/lib/gdal/driver.rb +62 -47
- data/lib/gdal/driver_mixins/extensions.rb +2 -7
- data/lib/gdal/environment_methods.rb +13 -10
- data/lib/gdal/exceptions.rb +24 -2
- data/lib/gdal/geo_transform.rb +10 -16
- data/lib/gdal/geo_transform_mixins/extensions.rb +58 -3
- data/lib/gdal/grid.rb +62 -109
- data/lib/gdal/{grid_types → grid_algorithms}/data_metrics_base.rb +1 -3
- data/lib/gdal/{grid_types → grid_algorithms}/inverse_distance_to_a_power.rb +2 -4
- data/lib/gdal/{grid_types → grid_algorithms}/metric_average_distance.rb +2 -2
- data/lib/gdal/{grid_types → grid_algorithms}/metric_average_distance_pts.rb +2 -2
- data/lib/gdal/{grid_types → grid_algorithms}/metric_count.rb +2 -2
- data/lib/gdal/{grid_types → grid_algorithms}/metric_maximum.rb +2 -2
- data/lib/gdal/{grid_types → grid_algorithms}/metric_minimum.rb +2 -2
- data/lib/gdal/{grid_types → grid_algorithms}/metric_range.rb +2 -2
- data/lib/gdal/{grid_types → grid_algorithms}/moving_average.rb +2 -4
- data/lib/gdal/{grid_types → grid_algorithms}/nearest_neighbor.rb +2 -4
- data/lib/gdal/grid_algorithms.rb +22 -0
- data/lib/gdal/gridder/point_extracting.rb +89 -0
- data/lib/gdal/gridder.rb +294 -0
- data/lib/gdal/gridder_options.rb +273 -0
- data/lib/gdal/internal_helpers.rb +132 -23
- data/lib/gdal/major_object.rb +13 -10
- data/lib/gdal/merger.rb +130 -0
- data/lib/gdal/options.rb +3 -2
- data/lib/gdal/raster_attribute_table.rb +74 -51
- data/lib/gdal/raster_attribute_table_mixins/extensions.rb +21 -3
- data/lib/gdal/raster_band.rb +139 -167
- data/lib/gdal/raster_band_classifier.rb +19 -18
- data/lib/gdal/raster_band_mixins/algorithm_extensions.rb +107 -0
- data/lib/gdal/raster_band_mixins/algorithm_methods.rb +79 -40
- data/lib/gdal/raster_band_mixins/coloring_extensions.rb +84 -0
- data/lib/gdal/raster_band_mixins/extensions.rb +34 -169
- data/lib/gdal/raster_band_mixins/io_extensions.rb +180 -0
- data/lib/gdal/rpc_info.rb +1 -2
- data/lib/gdal/transformer.rb +1 -6
- data/lib/gdal/transformers/approximate_transformer.rb +0 -4
- data/lib/gdal/transformers/base_general_image_projection_transformer.rb +0 -6
- data/lib/gdal/transformers/gcp_transformer.rb +2 -6
- data/lib/gdal/transformers/general_image_projection_transformer.rb +8 -7
- data/lib/gdal/transformers/general_image_projection_transformer2.rb +1 -1
- data/lib/gdal/transformers/geolocation_transformer.rb +0 -4
- data/lib/gdal/transformers/reprojection_transformer.rb +0 -8
- data/lib/gdal/transformers/rpc_transformer.rb +0 -4
- data/lib/gdal/transformers/tps_transformer.rb +1 -3
- data/lib/gdal/version_info.rb +7 -8
- data/lib/gdal/virtual_dataset.rb +2 -4
- data/lib/gdal/warp_operation.rb +17 -14
- data/lib/gdal/warp_options.rb +132 -0
- data/lib/gdal.rb +41 -2
- data/lib/ogr/coordinate_transformation.rb +79 -32
- data/lib/ogr/data_source.rb +17 -14
- data/lib/ogr/data_source_extensions.rb +1 -5
- data/lib/ogr/driver.rb +11 -14
- data/lib/ogr/envelope.rb +1 -1
- data/lib/ogr/envelope_extensions.rb +23 -6
- data/lib/ogr/error_handling.rb +3 -3
- data/lib/ogr/exceptions.rb +6 -0
- data/lib/ogr/feature.rb +25 -38
- data/lib/ogr/feature_definition.rb +6 -8
- data/lib/ogr/feature_definition_extensions.rb +2 -6
- data/lib/ogr/feature_extensions.rb +71 -41
- data/lib/ogr/field.rb +16 -15
- data/lib/ogr/field_definition.rb +4 -4
- data/lib/ogr/geocoder.rb +5 -5
- data/lib/ogr/geometries/geometry_collection.rb +4 -1
- data/lib/ogr/geometries/geometry_collection_25d.rb +12 -0
- data/lib/ogr/geometries/line_string.rb +30 -8
- data/lib/ogr/geometries/line_string_25d.rb +21 -0
- data/lib/ogr/geometries/linear_ring.rb +10 -1
- data/lib/ogr/geometries/multi_line_string.rb +2 -1
- data/lib/ogr/geometries/multi_line_string_25d.rb +13 -0
- data/lib/ogr/geometries/multi_point.rb +2 -1
- data/lib/ogr/geometries/multi_point_25d.rb +14 -0
- data/lib/ogr/geometries/multi_polygon.rb +3 -2
- data/lib/ogr/geometries/multi_polygon_25d.rb +13 -0
- data/lib/ogr/geometries/point.rb +20 -23
- data/lib/ogr/geometries/point_25d.rb +48 -0
- data/lib/ogr/geometries/polygon.rb +4 -1
- data/lib/ogr/geometries/polygon_25d.rb +14 -0
- data/lib/ogr/geometry.rb +125 -93
- data/lib/ogr/geometry_field_definition.rb +7 -5
- data/lib/ogr/geometry_mixins/container_mixins.rb +23 -0
- data/lib/ogr/geometry_mixins/extensions.rb +111 -0
- data/lib/ogr/geometry_types/container.rb +10 -3
- data/lib/ogr/geometry_types/curve.rb +68 -23
- data/lib/ogr/geometry_types/surface.rb +0 -9
- data/lib/ogr/internal_helpers.rb +3 -3
- data/lib/ogr/layer.rb +4 -5
- data/lib/ogr/layer_mixins/extensions.rb +242 -17
- data/lib/ogr/layer_mixins/ogr_feature_methods.rb +11 -11
- data/lib/ogr/layer_mixins/ogr_field_methods.rb +6 -11
- data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +18 -18
- data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +0 -2
- data/lib/ogr/layer_mixins/ogr_sql_methods.rb +1 -1
- data/lib/ogr/spatial_reference.rb +12 -37
- data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +53 -55
- data/lib/ogr/spatial_reference_mixins/exporters.rb +18 -49
- data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +10 -29
- data/lib/ogr/style_table.rb +2 -2
- data/lib/ogr/style_table_extensions.rb +3 -1
- data/lib/ogr/style_tool.rb +8 -14
- data/lib/ogr.rb +39 -1
- data/spec/ffi-gdal_spec.rb +18 -1
- data/spec/integration/gdal/color_table_info_spec.rb +49 -33
- data/spec/integration/gdal/dataset_info_spec.rb +294 -45
- data/spec/integration/gdal/driver_info_spec.rb +139 -31
- data/spec/integration/gdal/geo_transform_info_spec.rb +197 -26
- data/spec/integration/gdal/gridder_spec.rb +329 -0
- data/spec/integration/gdal/raster_attribute_table_info_spec.rb +216 -11
- data/spec/integration/gdal/raster_band_algorithms_spec.rb +33 -0
- data/spec/integration/gdal/raster_band_info_spec.rb +240 -271
- data/spec/integration/ogr/layer_spec.rb +3 -1
- data/spec/spec_helper.rb +15 -6
- data/spec/support/images/osgeo/gdal/data/hfa/float-rle.img +0 -0
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.lgo +31 -0
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif +0 -0
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif.msk +0 -0
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.txt +10 -0
- data/spec/support/images/osgeo/geotiff/gdal_eg/cea.tif +0 -0
- data/spec/support/images/osgeo/geotiff/gdal_eg/cea.txt +84 -0
- data/spec/support/images/osgeo/geotiff/zi_imaging/image0.lgo +45 -0
- data/spec/support/images/osgeo/geotiff/zi_imaging/image0.tif +0 -0
- data/spec/support/integration_help.rb +32 -2
- data/spec/support/shared_examples/gdal/major_object_examples.rb +0 -6
- data/spec/support/shared_examples/ogr/a_geometry.rb +1 -1
- data/spec/unit/ffi/gdal_spec.rb +1 -1
- data/spec/unit/gdal/color_entry_spec.rb +1 -0
- data/spec/unit/gdal/color_interpretation_spec.rb +1 -0
- data/spec/unit/gdal/dataset_spec.rb +53 -2
- data/spec/unit/gdal/geo_transform_mixins/extensions_spec.rb +67 -0
- data/spec/unit/gdal/geo_transform_spec.rb +1 -1
- data/spec/unit/gdal/grid_spec.rb +83 -0
- data/spec/unit/gdal/gridder/point_extracting_spec.rb +99 -0
- data/spec/unit/gdal/gridder_options_spec.rb +183 -0
- data/spec/unit/gdal/gridder_spec.rb +140 -0
- data/spec/unit/gdal/internal_helpers_spec.rb +166 -2
- data/spec/unit/gdal/major_object_spec.rb +2 -0
- data/spec/unit/gdal/options_spec.rb +1 -0
- data/spec/unit/gdal/raster_band_classifier_spec.rb +70 -12
- data/spec/unit/gdal/raster_band_mixins/extensions_spec.rb +71 -0
- data/spec/unit/gdal/raster_band_mixins/io_extensions_spec.rb +133 -0
- data/spec/unit/gdal/raster_band_spec.rb +1 -0
- data/spec/unit/gdal/rpc_info_spec.rb +1 -0
- data/spec/unit/gdal/version_info_spec.rb +2 -0
- data/spec/unit/gdal/warp_operation_spec.rb +1 -0
- data/spec/unit/ogr/coordinate_transformation_spec.rb +102 -0
- data/spec/unit/ogr/data_source_spec.rb +12 -0
- data/spec/unit/ogr/feature_extensions_spec.rb +88 -0
- data/spec/unit/ogr/feature_spec.rb +30 -46
- data/spec/unit/ogr/geometries/geometry_collection_25d_spec.rb +23 -0
- data/spec/unit/ogr/geometries/geometry_collection_spec.rb +3 -3
- data/spec/unit/ogr/geometries/line_string_25d_spec.rb +23 -0
- data/spec/unit/ogr/geometries/line_string_spec.rb +2 -2
- data/spec/unit/ogr/geometries/linear_ring_spec.rb +2 -2
- data/spec/unit/ogr/geometries/multi_line_string_25d_spec.rb +23 -0
- data/spec/unit/ogr/geometries/multi_point_25d_spec.rb +23 -0
- data/spec/unit/ogr/geometries/multi_polygon_25d_spec.rb +23 -0
- data/spec/unit/ogr/geometries/point_25d_spec.rb +23 -0
- data/spec/unit/ogr/geometries/point_spec.rb +14 -24
- data/spec/unit/ogr/geometries/polygon_25d_spec.rb +23 -0
- data/spec/unit/ogr/geometries/polygon_spec.rb +1 -1
- data/spec/unit/ogr/geometry_field_definition_spec.rb +1 -1
- data/spec/unit/ogr/geometry_spec.rb +196 -30
- data/spec/unit/ogr/internal_helpers_spec.rb +20 -9
- data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +14 -6
- data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +9 -1
- data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +2 -1
- data/spec/unit/ogr/style_table_spec.rb +1 -1
- data/tmp/.keep +0 -0
- metadata +121 -19
- data/examples/points.txt +0 -127
- data/lib/gdal/grid_types.rb +0 -22
- data/lib/ogr/geometries/point_extensions.rb +0 -32
- data/lib/ogr/geometry_extensions.rb +0 -59
data/lib/gdal/color_entry.rb
CHANGED
@@ -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
|
data/lib/gdal/color_table.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative '../
|
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
|
-
|
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
|
-
|
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
|
-
|
8
|
+
raise "Invalid ColorEntry number 'color#{color_number}'"
|
9
9
|
end
|
10
10
|
|
11
|
-
color_entry_count
|
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
|
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
|
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,
|
14
|
-
{ cple: :CPLE_AppDefined,
|
15
|
-
{ cple: :CPLE_OutOfMemory,
|
16
|
-
{ cple: :CPLE_FileIO,
|
17
|
-
{ cple: :CPLE_OpenFailed,
|
18
|
-
{ cple: :CPLE_IllegalArg,
|
19
|
-
{ cple: :CPLE_NotSupported,
|
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,
|
22
|
-
{ cple: :CPLE_UserInterrupt,
|
23
|
-
{ cple: :CPLE_ObjectNull,
|
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
|
-
|
28
|
+
raise(ex)
|
31
29
|
end
|
32
30
|
|
33
31
|
SUCCESS_PROC = proc { true }
|
data/lib/gdal/data_type.rb
CHANGED
@@ -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
|