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,60 +1,76 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'support/integration_help'
|
3
2
|
require 'ffi-gdal'
|
4
|
-
require 'gdal
|
3
|
+
require 'gdal'
|
5
4
|
|
6
|
-
|
7
|
-
dataset
|
5
|
+
RSpec.describe 'GDAL Color Table access', type: :integration do
|
6
|
+
let(:dataset) { GDAL::Dataset.open(tmp_tiff, 'r') }
|
7
|
+
let(:tmp_tiff) { make_temp_test_file(original_tiff) }
|
8
|
+
after(:each) { dataset.close }
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
subject(:color_table) do
|
11
|
+
band = dataset.raster_band(1)
|
12
|
+
band.color_table
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
context 'file with color table' do
|
16
|
+
let(:original_tiff) do
|
17
|
+
path = '../../../spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif'
|
18
|
+
File.expand_path(path, __dir__)
|
18
19
|
end
|
19
20
|
|
20
21
|
describe '#palette_interpretation' do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
expect(subject.palette_interpretation).to eq :GPI_RGB
|
25
|
-
end
|
22
|
+
subject { color_table.palette_interpretation }
|
23
|
+
it { is_expected.to eq :GPI_RGB }
|
26
24
|
end
|
27
25
|
|
28
26
|
describe '#color_entry_count' do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
expect(subject.color_entry_count).to eq 256
|
33
|
-
end
|
27
|
+
subject { color_table.color_entry_count }
|
28
|
+
it { is_expected.to eq 256 }
|
34
29
|
end
|
35
30
|
|
36
31
|
describe '#color_entry' do
|
37
32
|
it 'returns a GDAL::ColorEntry' do
|
38
|
-
next if subject.nil?
|
39
|
-
|
40
33
|
expect(subject.color_entry(0)).to be_a GDAL::ColorEntry
|
41
34
|
end
|
42
35
|
|
43
36
|
it 'has 4 Fixnum values, >= 0' do
|
44
|
-
|
37
|
+
expect(subject.color_entry(0).color1).to eq 0
|
38
|
+
expect(subject.color_entry(0).color2).to eq 0
|
39
|
+
expect(subject.color_entry(0).color3).to eq 0
|
40
|
+
expect(subject.color_entry(0).color4).to eq 255
|
45
41
|
|
46
|
-
expect(subject.color_entry(
|
47
|
-
expect(subject.color_entry(
|
42
|
+
expect(subject.color_entry(1).color1).to eq 192
|
43
|
+
expect(subject.color_entry(1).color2).to eq 0
|
44
|
+
expect(subject.color_entry(1).color3).to eq 0
|
45
|
+
expect(subject.color_entry(1).color4).to eq 255
|
46
|
+
end
|
47
|
+
end
|
48
48
|
|
49
|
-
|
50
|
-
|
49
|
+
describe '#color_entry_as_rgb' do
|
50
|
+
it 'returns a GDAL::ColorEntry' do
|
51
|
+
expect(subject.color_entry_as_rgb(0)).to be_a GDAL::ColorEntry
|
52
|
+
end
|
51
53
|
|
52
|
-
|
53
|
-
expect(subject.color_entry(0).
|
54
|
+
it 'has 4 Fixnum values, >= 0' do
|
55
|
+
expect(subject.color_entry(0).color1).to eq 0
|
56
|
+
expect(subject.color_entry(0).color2).to eq 0
|
57
|
+
expect(subject.color_entry(0).color3).to eq 0
|
58
|
+
expect(subject.color_entry(0).color4).to eq 255
|
54
59
|
|
55
|
-
expect(subject.color_entry(
|
56
|
-
expect(subject.color_entry(
|
60
|
+
expect(subject.color_entry(1).color1).to eq 192
|
61
|
+
expect(subject.color_entry(1).color2).to eq 0
|
62
|
+
expect(subject.color_entry(1).color3).to eq 0
|
63
|
+
expect(subject.color_entry(1).color4).to eq 255
|
57
64
|
end
|
58
65
|
end
|
59
66
|
end
|
67
|
+
|
68
|
+
context 'file without color table' do
|
69
|
+
let(:original_tiff) do
|
70
|
+
path = '../../../spec/support/images/osgeo/geotiff/gdal_eg/cea.tif'
|
71
|
+
File.expand_path(path, __dir__)
|
72
|
+
end
|
73
|
+
|
74
|
+
it { is_expected.to be_nil }
|
75
|
+
end
|
60
76
|
end
|
@@ -1,90 +1,339 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'support/integration_help'
|
3
2
|
require 'ffi-gdal'
|
3
|
+
require 'gdal'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
RSpec.describe 'Dataset Info', type: :integration do
|
6
|
+
let(:tmp_tiff) { make_temp_test_file(original_tiff) }
|
7
|
+
|
8
|
+
let(:original_tiff) do
|
9
|
+
path = '../../../spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif'
|
10
|
+
File.expand_path(path, __dir__)
|
11
|
+
end
|
12
|
+
|
13
|
+
subject { GDAL::Dataset.open(tmp_tiff, 'r') }
|
14
|
+
|
15
|
+
after { subject.close if File.exist?(tmp_tiff) }
|
16
|
+
|
17
|
+
describe '#driver' do
|
18
|
+
it 'is a GDAL::Driver' do
|
19
|
+
expect(subject.driver).to be_a GDAL::Driver
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#file_list' do
|
24
|
+
it 'is a non-empty Array' do
|
25
|
+
expect(subject.file_list).to be_an Array
|
9
26
|
end
|
10
27
|
|
11
|
-
|
28
|
+
it 'contains the file name' do
|
29
|
+
expect(subject.file_list).to include(File.expand_path(tmp_tiff))
|
30
|
+
end
|
31
|
+
end
|
12
32
|
|
13
|
-
|
14
|
-
|
15
|
-
|
33
|
+
describe '#flush_cache' do
|
34
|
+
it 'is a GDAL::Driver' do
|
35
|
+
expect { subject.flush_cache }.to_not raise_exception
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#raster_x_size' do
|
40
|
+
it 'is a Fixnum' do
|
41
|
+
expect(subject.raster_x_size).to eq 101
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#raster_y_size' do
|
46
|
+
it 'is a Fixnum' do
|
47
|
+
expect(subject.raster_y_size).to eq 101
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#raster_count' do
|
52
|
+
it 'is a Fixnum' do
|
53
|
+
expect(subject.raster_count).to eq 1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#raster_band' do
|
58
|
+
it 'each band is a GDAL::RasterBand' do
|
59
|
+
1.upto(subject.raster_count) do |i|
|
60
|
+
expect(subject.raster_band(i)).to be_a GDAL::RasterBand
|
16
61
|
end
|
17
62
|
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#projection' do
|
66
|
+
it 'is a String' do
|
67
|
+
expect(subject.projection).to be_a String
|
68
|
+
end
|
69
|
+
end
|
18
70
|
|
19
|
-
|
20
|
-
|
21
|
-
|
71
|
+
describe '#projection=' do
|
72
|
+
context 'param is an invalid projection string' do
|
73
|
+
it 'raises a GDAL::Error' do
|
74
|
+
expect { subject.projection = 'meow' }.to raise_exception(GDAL::Error)
|
22
75
|
end
|
76
|
+
end
|
23
77
|
|
24
|
-
|
25
|
-
|
78
|
+
context 'param is an valid projection string' do
|
79
|
+
let(:wkt) do
|
80
|
+
<<-WKT
|
81
|
+
GEOGCS["WGS 84",
|
82
|
+
DATUM["WGS_1984",
|
83
|
+
SPHEROID["WGS 84",6378137,298.257223563,
|
84
|
+
AUTHORITY["EPSG",7030]],
|
85
|
+
TOWGS84[0,0,0,0,0,0,0],
|
86
|
+
AUTHORITY["EPSG",6326]],
|
87
|
+
PRIMEM["Greenwich",0,AUTHORITY["EPSG",8901]],
|
88
|
+
UNIT["DMSH",0.0174532925199433,AUTHORITY["EPSG",9108]],
|
89
|
+
AXIS["Lat",NORTH],
|
90
|
+
AXIS["Long",EAST],
|
91
|
+
AUTHORITY["EPSG",4326]]
|
92
|
+
WKT
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'sets the projection' do
|
96
|
+
subject.projection = wkt
|
97
|
+
expect(subject.projection).to eq wkt
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'param is not a string' do
|
102
|
+
it 'raises a GDAL::Error' do
|
103
|
+
expect { subject.projection = { one: 1 } }.to raise_exception(GDAL::Error)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe '#access_flag' do
|
109
|
+
it 'is GA_ReadOnly' do
|
110
|
+
expect(subject.access_flag).to be :GA_ReadOnly
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '#add_band' do
|
115
|
+
it 'raises a GDAL::UnsupportedOperation' do
|
116
|
+
expect { subject.add_band(:GDT_Byte) }.to raise_exception(GDAL::UnsupportedOperation)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#create_mask_band' do
|
121
|
+
context ':GMF_ALL_VALID' do
|
122
|
+
it 'returns true' do
|
123
|
+
expect(subject.create_mask_band(:GMF_ALL_VALID)).to eq true
|
26
124
|
end
|
27
125
|
end
|
28
126
|
|
29
|
-
|
30
|
-
it '
|
31
|
-
expect(subject.
|
127
|
+
context ':GMF_PER_DATASET' do
|
128
|
+
it 'returns true' do
|
129
|
+
expect(subject.create_mask_band(:GMF_PER_DATASET)).to eq true
|
32
130
|
end
|
33
131
|
end
|
34
132
|
|
35
|
-
|
36
|
-
it '
|
37
|
-
expect(subject.
|
133
|
+
context ':GMF_PER_ALPHA' do
|
134
|
+
it 'returns true' do
|
135
|
+
expect(subject.create_mask_band(:GMF_PER_ALPHA)).to eq true
|
38
136
|
end
|
39
137
|
end
|
40
138
|
|
41
|
-
|
42
|
-
it '
|
43
|
-
expect(subject.
|
139
|
+
context ':GMF_NODATA' do
|
140
|
+
it 'returns true' do
|
141
|
+
expect(subject.create_mask_band(:GMF_NODATA)).to eq true
|
44
142
|
end
|
45
143
|
end
|
46
144
|
|
47
|
-
|
48
|
-
it '
|
49
|
-
|
50
|
-
expect(subject.raster_band(i)).to be_a GDAL::RasterBand
|
51
|
-
end
|
145
|
+
context 'all flags' do
|
146
|
+
it 'returns true' do
|
147
|
+
expect(subject.create_mask_band(:GMF_ALL_VALID, :GMF_PER_DATASET, :GMF_PER_ALPHA, :GMF_NODATA)).to eq true
|
52
148
|
end
|
53
149
|
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe '#geo_transform' do
|
153
|
+
it 'is a GDAL::GeoTransform' do
|
154
|
+
expect(subject.geo_transform).to be_a GDAL::GeoTransform
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe '#geo_transform=' do
|
159
|
+
let(:geo_transform) { GDAL::GeoTransform.new }
|
54
160
|
|
55
|
-
|
56
|
-
it '
|
57
|
-
expect
|
161
|
+
context 'read-only dataset' do
|
162
|
+
it 'raises a GDAL::UnsupportedOperation' do
|
163
|
+
expect { subject.geo_transform = geo_transform }.to raise_exception GDAL::UnsupportedOperation
|
58
164
|
end
|
59
165
|
end
|
60
166
|
|
61
|
-
|
62
|
-
|
63
|
-
|
167
|
+
context 'writable dataset, param is a valid GeoTransform' do
|
168
|
+
subject { GDAL::Dataset.open(tmp_tiff, 'w') }
|
169
|
+
|
170
|
+
it 'returns the same GDAL::GeoTransform' do
|
171
|
+
subject.geo_transform = geo_transform
|
172
|
+
expect(subject.geo_transform).to eq geo_transform
|
64
173
|
end
|
65
174
|
end
|
66
175
|
|
67
|
-
|
68
|
-
|
176
|
+
context 'writable dataset, param is a pointer to a valid GeoTransform' do
|
177
|
+
subject { GDAL::Dataset.open(tmp_tiff, 'w') }
|
178
|
+
|
179
|
+
it 'returns the same GDAL::GeoTransform' do
|
180
|
+
subject.geo_transform = geo_transform.c_pointer
|
69
181
|
expect(subject.geo_transform).to be_a GDAL::GeoTransform
|
70
182
|
end
|
71
183
|
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe '#gcp_count' do
|
187
|
+
it 'is a Fixnum' do
|
188
|
+
expect(subject.gcp_count).to be_a Fixnum
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe '#gcp_projection' do
|
193
|
+
it 'is a String' do
|
194
|
+
expect(subject.gcp_projection).to be_a String
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
describe '#gcps' do
|
199
|
+
it 'is a GDALGCP' do
|
200
|
+
expect(subject.gcps).to be_a FFI::GDAL::GCP
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe '#build_overviews' do
|
205
|
+
let(:ovr_file) { "#{tmp_tiff}.ovr" }
|
206
|
+
after { File.unlink(ovr_file) if File.exist?(ovr_file) }
|
207
|
+
|
208
|
+
context 'nearest neighbor resampling' do
|
209
|
+
it 'creates an .ovr file with the same base name as the dataset file' do
|
210
|
+
subject.build_overviews(:nearest, [2, 4, 8])
|
211
|
+
expect(File.exist?(ovr_file)).to eq true
|
212
|
+
end
|
213
|
+
end
|
72
214
|
|
73
|
-
|
74
|
-
it '
|
75
|
-
|
215
|
+
context 'Gauss resampling' do
|
216
|
+
it 'creates an .ovr file with the same base name as the dataset file' do
|
217
|
+
subject.build_overviews(:gauss, [2, 4, 8])
|
218
|
+
expect(File.exist?(ovr_file)).to eq true
|
76
219
|
end
|
77
220
|
end
|
78
221
|
|
79
|
-
|
80
|
-
it '
|
81
|
-
|
222
|
+
context 'Cubic resampling' do
|
223
|
+
it 'creates an .ovr file with the same base name as the dataset file' do
|
224
|
+
subject.build_overviews(:cubic, [2, 4, 8])
|
225
|
+
expect(File.exist?(ovr_file)).to eq true
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
context 'Average resampling' do
|
230
|
+
it 'creates an .ovr file with the same base name as the dataset file' do
|
231
|
+
subject.build_overviews(:average, [2, 4, 8])
|
232
|
+
expect(File.exist?(ovr_file)).to eq true
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
context 'Mode resampling' do
|
237
|
+
it 'creates an .ovr file with the same base name as the dataset file' do
|
238
|
+
subject.build_overviews(:mode, [2, 4, 8])
|
239
|
+
expect(File.exist?(ovr_file)).to eq true
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
context 'Average mag phase resampling' do
|
244
|
+
it 'creates an .ovr file with the same base name as the dataset file' do
|
245
|
+
subject.build_overviews(:average_magphase, [2, 4, 8])
|
246
|
+
expect(File.exist?(ovr_file)).to eq true
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
context 'no resampling' do
|
251
|
+
it 'creates an .ovr file with the same base name as the dataset file' do
|
252
|
+
subject.build_overviews(:none, [2, 4, 8])
|
253
|
+
expect(File.exist?(ovr_file)).to eq true
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
context 'unknown resampling algorithm' do
|
258
|
+
it 'creates an .ovr file with the same base name as the dataset file' do
|
259
|
+
expect { subject.build_overviews(:stuff, [2, 4, 8]) }.
|
260
|
+
to raise_exception(GDAL::Error)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
describe '#raster_io' do
|
266
|
+
let(:write_buffer) do
|
267
|
+
buffer = GDAL._buffer_from_data_type(:GDT_Byte, 2)
|
268
|
+
buffer.write_array_of_uchar([1, 2])
|
269
|
+
end
|
270
|
+
|
271
|
+
let(:read_buffer) { GDAL._buffer_from_data_type(:GDT_Byte, 2) }
|
272
|
+
|
273
|
+
context 'write to read-only dataset' do
|
274
|
+
it 'raises a GDAL::Error when flushing the cache' do
|
275
|
+
expect do
|
276
|
+
subject.raster_io('w', write_buffer, x_size: 2, y_size: 1)
|
277
|
+
subject.flush_cache
|
278
|
+
end.to raise_exception(GDAL::Error)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
context 'write using buffer that is too small for defaults' do
|
283
|
+
subject { GDAL::Dataset.open(tmp_tiff, 'w') }
|
284
|
+
|
285
|
+
it 'raises a GDAL::Error when flushing the cache' do
|
286
|
+
expect do
|
287
|
+
subject.raster_io('w', write_buffer)
|
288
|
+
subject.flush_cache
|
289
|
+
end.to raise_exception(GDAL::BufferTooSmall)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
context 'write to writable dataset' do
|
294
|
+
subject { GDAL::Dataset.open(tmp_tiff, 'w') }
|
295
|
+
|
296
|
+
it 'writes the data' do
|
297
|
+
expect do
|
298
|
+
subject.raster_io('w', write_buffer, x_size: 2, y_size: 1)
|
299
|
+
subject.flush_cache
|
300
|
+
end.to_not raise_exception
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
context 'read, buffer size too small' do
|
305
|
+
it 'raises a GDAL::BufferTooSmall' do
|
306
|
+
expect { subject.raster_io('r', read_buffer) }.
|
307
|
+
to raise_exception GDAL::BufferTooSmall
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
context 'read, giving params that fulfil buffer size requirements' do
|
312
|
+
it 'reads the data' do
|
313
|
+
subject.raster_io('r', read_buffer, x_size: 2, y_size: 1)
|
314
|
+
expect(read_buffer.read_array_of_uchar(2)).to eq [2, 2]
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
describe '#valid_min_buffer_size' do
|
320
|
+
it 'returns the number of bytes for the GDT type * x buffer size * y buffer size' do
|
321
|
+
expect(subject.send(:valid_min_buffer_size, :GDT_Float32, 3, 4)).to eq 48
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
describe '#band_numbers_args' do
|
326
|
+
context 'param is nil' do
|
327
|
+
it 'returns no pointer and 0 band count' do
|
328
|
+
expect(subject.send(:band_numbers_args, nil)).to eq [nil, 0]
|
82
329
|
end
|
83
330
|
end
|
84
331
|
|
85
|
-
|
86
|
-
it '
|
87
|
-
|
332
|
+
context 'param is an array of numbers' do
|
333
|
+
it 'returns a pointer and the number of bands' do
|
334
|
+
result_ptr, band_count = subject.send(:band_numbers_args, [3, 4, 5])
|
335
|
+
expect(result_ptr).to be_a FFI::MemoryPointer
|
336
|
+
expect(band_count).to eq 3
|
88
337
|
end
|
89
338
|
end
|
90
339
|
end
|