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
@@ -1,329 +1,298 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'support/integration_help'
|
3
2
|
require 'ffi-gdal'
|
3
|
+
require 'gdal'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
RSpec.describe 'Raster Band Info', type: :integration do
|
6
|
+
let(:original_tiff) do
|
7
|
+
path = '../../../spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif'
|
8
|
+
File.expand_path(path, __dir__)
|
9
|
+
end
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
11
|
+
let(:tmp_tiff) { make_temp_test_file(original_tiff) }
|
12
|
+
let(:dataset) { GDAL::Dataset.open(tmp_tiff, 'w') }
|
13
|
+
after { dataset.close }
|
14
|
+
subject { dataset.raster_band(1) }
|
13
15
|
|
14
|
-
|
15
|
-
subject do
|
16
|
-
GDAL::RasterBand.new(band_under_test.c_pointer)
|
17
|
-
end
|
16
|
+
it_behaves_like 'a major object'
|
18
17
|
|
19
|
-
|
18
|
+
describe '#x_size' do
|
19
|
+
it 'is a non-zero Integer' do
|
20
|
+
expect(subject.x_size).to be_a Fixnum
|
21
|
+
expect(subject.x_size).to be > 0
|
22
|
+
end
|
23
|
+
end
|
20
24
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
describe '#y_size' do
|
26
|
+
it 'is a non-zero Integer' do
|
27
|
+
expect(subject.y_size).to be_a Fixnum
|
28
|
+
expect(subject.y_size).to be > 0
|
29
|
+
end
|
30
|
+
end
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
expect(subject.y_size).to be > 0
|
32
|
-
end
|
33
|
-
end
|
32
|
+
describe '#access_flag' do
|
33
|
+
specify { expect(subject.access_flag).to eq :GA_Update }
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
describe '#number' do
|
37
|
+
it 'is a non-zero Integer' do
|
38
|
+
expect(subject.number).to be_a Fixnum
|
39
|
+
expect(subject.number).to be > 0
|
40
|
+
end
|
41
|
+
end
|
38
42
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
describe '#color_interpretation' do
|
44
|
+
it 'is a Symbol; one of FFI::GDAL::GDAL::ColorInterp' do
|
45
|
+
expect(subject.color_interpretation).to be_a Symbol
|
46
|
+
expect(FFI::GDAL::GDAL::ColorInterp.symbols).to include subject.color_interpretation
|
47
|
+
end
|
48
|
+
end
|
45
49
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
50
|
+
describe '#color_table' do
|
51
|
+
it 'is a GDAL::ColorTable' do
|
52
|
+
if subject.color_table
|
53
|
+
expect(subject.color_table).to be_a GDAL::ColorTable
|
51
54
|
end
|
55
|
+
end
|
56
|
+
end
|
52
57
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
58
|
+
describe '#data_type' do
|
59
|
+
it 'is a Symbol; one of FFI::GDAL::GDAL::DataType' do
|
60
|
+
expect(subject.data_type).to be_a Symbol
|
61
|
+
expect(FFI::GDAL::GDAL::DataType.symbols).to include subject.data_type
|
62
|
+
end
|
63
|
+
end
|
60
64
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
describe '#block_size' do
|
66
|
+
it 'is a Hash with x and y keys that are >= 1' do
|
67
|
+
expect(subject.block_size).to be_a Hash
|
68
|
+
expect(subject.block_size[:x]).to be >= 1
|
69
|
+
expect(subject.block_size[:y]).to be >= 1
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#category_names' do
|
74
|
+
it 'is an Array of Strings' do
|
75
|
+
expect(subject.category_names).to be_an Array
|
67
76
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
expect(subject.block_size[:x]).to be >= 1
|
72
|
-
expect(subject.block_size[:y]).to be >= 1
|
73
|
-
end
|
77
|
+
subject.category_names.each do |category_name|
|
78
|
+
expect(category_name).to be_a String
|
79
|
+
expect(category_name).to_not be_empty
|
74
80
|
end
|
81
|
+
end
|
82
|
+
end
|
75
83
|
|
76
|
-
|
77
|
-
|
78
|
-
|
84
|
+
describe '#category_names=' do
|
85
|
+
it 'sets the category names' do
|
86
|
+
subject.category_names = %w[one two three]
|
79
87
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
88
|
+
expect(subject.category_names).to eq %w[one two three]
|
89
|
+
end
|
90
|
+
end
|
86
91
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
example.run
|
91
|
-
subject.category_names = category_names
|
92
|
-
end
|
92
|
+
describe '#no_data_value' do
|
93
|
+
it 'is a Hash with :value and :is_associated keys' do
|
94
|
+
expect(subject.no_data_value).to be_an Hash
|
93
95
|
|
94
|
-
|
95
|
-
|
96
|
+
expect(subject.no_data_value[:value]).to be_a Float
|
97
|
+
expect(subject.no_data_value[:is_associated]).to_not be_nil
|
98
|
+
end
|
99
|
+
end
|
96
100
|
|
97
|
-
|
101
|
+
describe '#overview_count' do
|
102
|
+
it 'is a Fixnum' do
|
103
|
+
expect(subject.overview_count).to be_a Fixnum
|
104
|
+
end
|
105
|
+
end
|
98
106
|
|
99
|
-
|
100
|
-
|
101
|
-
|
107
|
+
describe '#arbitrary_overviews?' do
|
108
|
+
it 'is true or false' do
|
109
|
+
expect([true, false]).to include subject.arbitrary_overviews?
|
110
|
+
end
|
111
|
+
end
|
102
112
|
|
103
|
-
|
104
|
-
|
105
|
-
|
113
|
+
describe '#overview' do
|
114
|
+
it 'returns a GDAL::RasterBand if the overview exists' do
|
115
|
+
overview = subject.overview(0)
|
116
|
+
expect(overview).to be_a GDAL::RasterBand if overview
|
117
|
+
end
|
118
|
+
end
|
106
119
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
120
|
+
describe '#raster_sample_overview' do
|
121
|
+
it 'returns a GDAL::RasterBand if the overview exists' do
|
122
|
+
overview = subject.raster_sample_overview
|
123
|
+
expect(overview).to be_a GDAL::RasterBand
|
124
|
+
end
|
125
|
+
end
|
111
126
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
127
|
+
describe '#mask_band' do
|
128
|
+
it 'returns a GDAL::RasterBand if the mask_band exists' do
|
129
|
+
overview = subject.mask_band
|
130
|
+
expect(overview).to be_a GDAL::RasterBand
|
131
|
+
end
|
132
|
+
end
|
117
133
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
134
|
+
describe '#mask_flags' do
|
135
|
+
it 'returns an Array of Symbols' do
|
136
|
+
expect(subject.mask_flags).to eq([:GMF_ALL_VALID]).or eq([:GMF_PER_DATASET])
|
137
|
+
end
|
138
|
+
end
|
123
139
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
140
|
+
describe '#statistics' do
|
141
|
+
it 'returns a Hash with populated values' do
|
142
|
+
expect(subject.statistics).to be_a Hash
|
143
|
+
expect(%i[minimum maximum mean standard_deviation]).
|
144
|
+
to eq subject.statistics.keys
|
145
|
+
end
|
130
146
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
147
|
+
it 'has a :minimum that ranges between 0.0/-32768.0 and 255.0' do
|
148
|
+
min = subject.statistics[:minimum]
|
149
|
+
unless min == -32_768.0
|
150
|
+
expect(subject.statistics[:minimum]).to satisfy { |v| v >= 0 || v == -32_768 }
|
151
|
+
expect(subject.statistics[:minimum]).to be <= 255.0
|
136
152
|
end
|
153
|
+
end
|
154
|
+
end
|
137
155
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
end
|
156
|
+
describe '#scale' do
|
157
|
+
it 'returns a Hash with populated values' do
|
158
|
+
expect(subject.scale).to be_a Hash
|
159
|
+
expect(%i[value is_meaningful]).to eq subject.scale.keys
|
160
|
+
end
|
144
161
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
end
|
149
|
-
end
|
162
|
+
it 'has a :value that is a Float' do
|
163
|
+
expect(subject.scale[:value]).to be_a Float
|
164
|
+
end
|
150
165
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
to eq subject.statistics.keys
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'has a :minimum that ranges between 0.0/-32768.0 and 255.0' do
|
159
|
-
min = subject.statistics[:minimum]
|
160
|
-
unless min == -32_768.0
|
161
|
-
expect(subject.statistics[:minimum]).to (be >= 0.0).or eq(-32_768.0)
|
162
|
-
expect(subject.statistics[:minimum]).to be <= 255.0
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
+
it 'has a :is_meaningful that is false (since the examples are geotiffs)' do
|
167
|
+
expect(subject.scale[:is_meaningful]).to eq false
|
168
|
+
end
|
169
|
+
end
|
166
170
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
171
|
+
describe '#scale=' do
|
172
|
+
it 'does nothing (because the file formats dont support it)' do
|
173
|
+
subject.scale = 0.1
|
174
|
+
expect(subject.scale[:value]).to eq 0.1
|
175
|
+
end
|
176
|
+
end
|
172
177
|
|
173
|
-
|
174
|
-
|
175
|
-
|
178
|
+
describe '#offset' do
|
179
|
+
it 'returns a Hash with populated values' do
|
180
|
+
expect(subject.offset).to be_a Hash
|
181
|
+
expect(%i[value is_meaningful]).to eq subject.offset.keys
|
182
|
+
end
|
176
183
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
end
|
184
|
+
it 'has a :value that is a Float' do
|
185
|
+
expect(subject.offset[:value]).to be_a Float
|
186
|
+
end
|
181
187
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
subject.scale = scale
|
187
|
-
end
|
188
|
-
|
189
|
-
it 'does nothing (because the file formats dont support it)' do
|
190
|
-
subject.scale = 0.1
|
191
|
-
expect(subject.scale[:value]).to eq 0.1
|
192
|
-
end
|
193
|
-
end
|
188
|
+
it 'has a :is_meaningful that is false (since the examples are geotiffs)' do
|
189
|
+
expect(subject.offset[:is_meaningful]).to eq false
|
190
|
+
end
|
191
|
+
end
|
194
192
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
193
|
+
describe '#offset=' do
|
194
|
+
it 'does nothing (because the file formats dont support it)' do
|
195
|
+
subject.offset = 0.1
|
196
|
+
expect(subject.offset[:value]).to eq 0.1
|
197
|
+
end
|
198
|
+
end
|
200
199
|
|
201
|
-
|
202
|
-
|
203
|
-
|
200
|
+
describe '#unit_type' do
|
201
|
+
it 'returns a String' do
|
202
|
+
expect(subject.unit_type).to be_a String
|
203
|
+
end
|
204
|
+
end
|
204
205
|
|
205
|
-
|
206
|
-
|
207
|
-
|
206
|
+
describe '#unit_type=' do
|
207
|
+
it 'does nothing (because the file formats dont support it)' do
|
208
|
+
if defined? FFI::GDAL::GDAL::GDALSetRasterUnitType
|
209
|
+
subject.unit_type = 'ft'
|
210
|
+
expect(subject.unit_type).to eq 'ft'
|
211
|
+
else
|
212
|
+
skip 'GDALSetRasterUnitType not supported'
|
208
213
|
end
|
214
|
+
end
|
215
|
+
end
|
209
216
|
|
210
|
-
|
211
|
-
|
212
|
-
offset = subject.offset[:value]
|
213
|
-
example.run
|
214
|
-
subject.offset = offset
|
215
|
-
end
|
216
|
-
|
217
|
-
it 'does nothing (because the file formats dont support it)' do
|
218
|
-
subject.offset = 0.1
|
219
|
-
expect(subject.offset[:value]).to eq 0.1
|
220
|
-
end
|
221
|
-
end
|
217
|
+
describe '#default_histogram' do
|
218
|
+
let!(:histogram) { subject.default_histogram }
|
222
219
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
220
|
+
it 'returns a Hash with :minimum, :maximum, :buckets, and :totals' do
|
221
|
+
if histogram
|
222
|
+
expect(histogram).to be_a Hash
|
223
|
+
expect(histogram.keys).to eq %i[minimum maximum buckets totals]
|
227
224
|
end
|
225
|
+
end
|
228
226
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
example.run
|
233
|
-
subject.unit_type = unit_type
|
234
|
-
end
|
235
|
-
|
236
|
-
it 'does nothing (because the file formats dont support it)' do
|
237
|
-
if defined? FFI::GDAL::GDALSetRasterUnitType
|
238
|
-
subject.unit_type = 'ft'
|
239
|
-
expect(subject.unit_type).to eq 'ft'
|
240
|
-
else
|
241
|
-
skip 'GDALSetRasterUnitType not supported'
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
227
|
+
it 'has :minimum as a Float' do
|
228
|
+
expect(histogram[:minimum]).to be_a Float if histogram
|
229
|
+
end
|
245
230
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
it 'returns a Hash with :minimum, :maximum, :buckets, and :totals' do
|
250
|
-
if histogram
|
251
|
-
expect(histogram).to be_a Hash
|
252
|
-
expect(histogram.keys).to eq %i[minimum maximum buckets totals]
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
it 'has :minimum as a Float' do
|
257
|
-
expect(histogram[:minimum]).to be_a Float if histogram
|
258
|
-
end
|
259
|
-
|
260
|
-
it 'has :maximum as a Float' do
|
261
|
-
expect(histogram[:maximum]).to be_a Float if histogram
|
262
|
-
end
|
263
|
-
|
264
|
-
it 'has :buckets as a Fixnum' do
|
265
|
-
expect(histogram[:buckets]).to be_a Fixnum if histogram
|
266
|
-
end
|
267
|
-
|
268
|
-
it 'has :totals as an Array of 0 or 256 Fixnums' do
|
269
|
-
if histogram
|
270
|
-
expect(histogram[:totals]).to be_an Array
|
271
|
-
expect(histogram[:totals].size).to eq(256).or eq(0)
|
272
|
-
expect(histogram[:totals].all? { |t| t.class == Fixnum }).to eq true
|
273
|
-
end
|
274
|
-
end
|
275
|
-
end
|
231
|
+
it 'has :maximum as a Float' do
|
232
|
+
expect(histogram[:maximum]).to be_a Float if histogram
|
233
|
+
end
|
276
234
|
|
277
|
-
|
278
|
-
|
279
|
-
|
235
|
+
it 'has :buckets as a Fixnum' do
|
236
|
+
expect(histogram[:buckets]).to be_a Fixnum if histogram
|
237
|
+
end
|
280
238
|
|
281
|
-
|
282
|
-
|
239
|
+
it 'has :totals as an Array of 0 or 256 Fixnums' do
|
240
|
+
if histogram
|
241
|
+
expect(histogram[:totals]).to be_an Array
|
242
|
+
expect(histogram[:totals].size).to eq(256).or eq(0)
|
243
|
+
expect(histogram[:totals].all? { |t| t.class == Fixnum }).to eq true
|
283
244
|
end
|
245
|
+
end
|
246
|
+
end
|
284
247
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
expect(subject.min_max.size).to eq 2
|
289
|
-
expect(subject.min_max[:min]).to be_a Float
|
290
|
-
expect(subject.min_max[:max]).to be_a Float
|
291
|
-
end
|
292
|
-
|
293
|
-
it 'has a min that is < its max' do
|
294
|
-
expect(subject.min_max[:min]).to be < subject.min_max[:max]
|
295
|
-
end
|
296
|
-
end
|
248
|
+
describe '#default_raster_attribute_table' do
|
249
|
+
it 'returns a GDAL::RasterAttributeTable' do
|
250
|
+
rat = subject.default_raster_attribute_table
|
297
251
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
expect(%i[value is_tight]).to eq subject.minimum_value.keys
|
302
|
-
end
|
252
|
+
expect(rat).to be_a GDAL::RasterAttributeTable if rat
|
253
|
+
end
|
254
|
+
end
|
303
255
|
|
304
|
-
|
305
|
-
|
306
|
-
|
256
|
+
describe '#min_max' do
|
257
|
+
it 'returns a Hash with :min and :max keys' do
|
258
|
+
expect(subject.min_max).to be_a Hash
|
259
|
+
expect(subject.min_max.size).to eq 2
|
260
|
+
expect(subject.min_max[:min]).to be_a Float
|
261
|
+
expect(subject.min_max[:max]).to be_a Float
|
262
|
+
end
|
307
263
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
264
|
+
it 'has a min that is < its max' do
|
265
|
+
expect(subject.min_max[:min]).to be < subject.min_max[:max]
|
266
|
+
end
|
267
|
+
end
|
312
268
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
269
|
+
describe '#minimum_value' do
|
270
|
+
it 'returns a Hash with populated values' do
|
271
|
+
expect(subject.minimum_value).to be_a Hash
|
272
|
+
expect(%i[value is_tight]).to eq subject.minimum_value.keys
|
273
|
+
end
|
318
274
|
|
319
|
-
|
320
|
-
|
321
|
-
|
275
|
+
it 'has a :value that is a Float' do
|
276
|
+
expect(subject.minimum_value[:value]).to be_a Float
|
277
|
+
end
|
322
278
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
279
|
+
it 'has a :is_tight that is nil (since the examples are geotiffs)' do
|
280
|
+
# expect(subject.minimum_value[:is_tight]).to eq nil
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
describe '#maximum_value' do
|
285
|
+
it 'returns a Hash with populated values' do
|
286
|
+
expect(subject.maximum_value).to be_a Hash
|
287
|
+
expect(%i[value is_tight]).to eq subject.maximum_value.keys
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'has a :value that is a Float' do
|
291
|
+
expect(subject.maximum_value[:value]).to be_a Float
|
292
|
+
end
|
293
|
+
|
294
|
+
it 'has a :is_tight that is nil (since the examples are geotiffs)' do
|
295
|
+
# expect(subject.maximum_value[:is_tight]).to eq nil
|
327
296
|
end
|
328
297
|
end
|
329
298
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'ogr'
|
2
3
|
|
3
|
-
RSpec.describe OGR::Layer do
|
4
|
+
RSpec.describe 'OGR::Layer' do
|
4
5
|
let(:data_source) do
|
5
6
|
OGR::DataSource.open('spec/support/shapefiles/states_21basic/states.shp', 'r')
|
6
7
|
end
|
@@ -35,6 +36,7 @@ RSpec.describe OGR::Layer do
|
|
35
36
|
|
36
37
|
describe '#next_feature' do
|
37
38
|
subject { layer0.next_feature }
|
39
|
+
after { subject.destroy! }
|
38
40
|
it { is_expected.to be_a OGR::Feature }
|
39
41
|
end
|
40
42
|
|
data/spec/spec_helper.rb
CHANGED
@@ -9,9 +9,9 @@ end
|
|
9
9
|
|
10
10
|
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
11
11
|
require 'ffi-gdal'
|
12
|
+
require 'byebug'
|
12
13
|
|
13
|
-
|
14
|
-
Dir['./spec/support/shared_examples/**/*.rb'].sort.each { |f| require f }
|
14
|
+
Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
|
15
15
|
|
16
16
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
17
17
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
@@ -81,13 +81,13 @@ RSpec.configure do |config|
|
|
81
81
|
# Use the documentation formatter for detailed output,
|
82
82
|
# unless a formatter has already been configured
|
83
83
|
# (e.g. via a command-line flag).
|
84
|
-
|
84
|
+
config.default_formatter = 'doc'
|
85
85
|
end
|
86
86
|
|
87
87
|
# Print the 10 slowest examples and example groups at the
|
88
88
|
# end of the spec run, to help surface which specs are running
|
89
89
|
# particularly slow.
|
90
|
-
config.profile_examples =
|
90
|
+
config.profile_examples = 10
|
91
91
|
|
92
92
|
# Run specs in random order to surface order dependencies. If you find an
|
93
93
|
# order dependency and want to debug it, you can fix the order by providing
|
@@ -100,6 +100,15 @@ RSpec.configure do |config|
|
|
100
100
|
# test failures related to randomization by passing the same `--seed` value
|
101
101
|
# as the one that triggered the failure.
|
102
102
|
Kernel.srand config.seed
|
103
|
-
end
|
104
103
|
|
105
|
-
|
104
|
+
config.include IntegrationHelp, type: :integration
|
105
|
+
|
106
|
+
config.before do
|
107
|
+
::FFI::GDAL::GDAL.GDALAllRegister
|
108
|
+
Dir[File.join('tmp', '*')].each { |f| File.unlink(f) if File.exist?(f) }
|
109
|
+
end
|
110
|
+
|
111
|
+
config.after(:example, type: :integration) do
|
112
|
+
cleanup_test_files
|
113
|
+
end
|
114
|
+
end
|
Binary file
|