ffi-gdal 1.0.0.beta16 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +17 -0
- data/.github/workflows/codacy.yml +61 -0
- data/.github/workflows/codeql.yml +74 -0
- data/.github/workflows/continuous-integration.yml +36 -0
- data/.github/workflows/dependency-review.yml +20 -0
- data/.github/workflows/specs-in-docker.yml +27 -0
- data/.gitignore +3 -0
- data/.rspec +1 -0
- data/.rubocop.yml +10 -80
- data/.rubocop_todo.yml +23 -40
- data/.ruby-version +1 -1
- data/Changelog-0.x.md +512 -0
- data/Changelog.md +12 -0
- data/Dockerfile.gdal2 +110 -0
- data/Dockerfile.gdal3 +73 -0
- data/README.md +25 -14
- data/Rakefile +0 -8
- data/Tiltfile +91 -0
- data/bin/bundle +123 -0
- data/bin/docker-clean +8 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/rubocop +29 -0
- data/docker-compose.yml +25 -0
- data/examples/extract_and_colorize.rb +0 -13
- data/examples/geometries.rb +14 -14
- data/examples/ogr_layer_to_layer.rb +1 -3
- data/examples/raster_erasing.rb +1 -0
- data/examples/remove_small_polygons.rb +1 -1
- data/examples/testing_gdal.rb +20 -17
- data/examples/warping.rb +9 -7
- data/ffi-gdal.gemspec +12 -6
- data/lib/ext/ffi_library_function_checks.rb +2 -2
- data/lib/ext/to_bool.rb +5 -3
- data/lib/ffi/cpl/conv.rb +27 -25
- data/lib/ffi/cpl/error.rb +19 -20
- data/lib/ffi/cpl/hash_set.rb +4 -4
- data/lib/ffi/cpl/http.rb +3 -3
- data/lib/ffi/cpl/http_result.rb +8 -8
- data/lib/ffi/cpl/list.rb +1 -1
- data/lib/ffi/cpl/mime_part.rb +2 -2
- data/lib/ffi/cpl/minixml.rb +7 -7
- data/lib/ffi/cpl/progress.rb +8 -8
- data/lib/ffi/cpl/quad_tree.rb +14 -14
- data/lib/ffi/cpl/rect_obj.rb +3 -3
- data/lib/ffi/cpl/string.rb +17 -20
- data/lib/ffi/cpl/vsi.rb +13 -13
- data/lib/ffi/cpl/xml_node.rb +3 -3
- data/lib/ffi/extensions/gdal/extensions/all.rb +4 -0
- data/lib/ffi/extensions/gdal/extensions/version.rb +9 -0
- data/lib/ffi/extensions/gdal/extensions.rb +12 -0
- data/lib/ffi/extensions/rttopo/gbox.rb +19 -0
- data/lib/ffi/extensions/rttopo/geom.rb +16 -0
- data/lib/ffi/extensions/rttopo.rb +41 -0
- data/lib/ffi/gdal/alg.rb +277 -277
- data/lib/ffi/gdal/color_entry.rb +3 -3
- data/lib/ffi/gdal/gcp.rb +6 -6
- data/lib/ffi/gdal/gdal.rb +349 -349
- data/lib/ffi/gdal/grid.rb +134 -134
- data/lib/ffi/gdal/grid_data_metrics_options.rb +4 -4
- data/lib/ffi/gdal/grid_inverse_distance_to_a_power_options.rb +9 -9
- data/lib/ffi/gdal/grid_moving_average_options.rb +4 -4
- data/lib/ffi/gdal/grid_nearest_neighbor_options.rb +3 -3
- data/lib/ffi/gdal/matching.rb +3 -3
- data/lib/ffi/gdal/rpc_info.rb +17 -17
- data/lib/ffi/gdal/transformer_info.rb +4 -4
- data/lib/ffi/gdal/version.rb +1 -1
- data/lib/ffi/gdal/vrt.rb +39 -39
- data/lib/ffi/gdal/warp_options.rb +34 -34
- data/lib/ffi/gdal/warper.rb +90 -90
- data/lib/ffi/gdal.rb +2 -31
- data/lib/ffi/ogr/api.rb +175 -167
- data/lib/ffi/ogr/contour_writer_info.rb +4 -4
- data/lib/ffi/ogr/core.rb +107 -107
- data/lib/ffi/ogr/envelope.rb +3 -3
- data/lib/ffi/ogr/envelope_3d.rb +5 -5
- data/lib/ffi/ogr/featurestyle.rb +3 -3
- data/lib/ffi/ogr/field.rb +22 -22
- data/lib/ffi/ogr/geocoding.rb +4 -4
- data/lib/ffi/ogr/srs_api.rb +154 -155
- data/lib/ffi/ogr/style_param.rb +3 -3
- data/lib/ffi/ogr/style_value.rb +4 -4
- data/lib/gdal/color_entry.rb +1 -5
- data/lib/gdal/color_interpretation.rb +7 -3
- data/lib/gdal/color_table.rb +46 -27
- data/lib/gdal/cpl_error_handler.rb +26 -6
- data/lib/gdal/data_type.rb +10 -3
- data/lib/gdal/dataset.rb +171 -85
- data/lib/gdal/dataset_mixins/algorithm_methods.rb +44 -44
- data/lib/gdal/dataset_mixins/matching.rb +1 -1
- data/lib/gdal/dataset_mixins/warp_methods.rb +4 -2
- data/lib/gdal/driver.rb +38 -21
- data/lib/gdal/environment_methods.rb +6 -6
- data/lib/gdal/extensions/all.rb +3 -0
- data/lib/gdal/{color_entry_mixins → extensions/color_entry}/extensions.rb +4 -1
- data/lib/gdal/{color_table_mixins → extensions/color_table}/extensions.rb +3 -0
- data/lib/gdal/extensions/dataset/extensions.rb +205 -0
- data/lib/gdal/{driver_mixins → extensions/driver}/extensions.rb +6 -2
- data/lib/gdal/{geo_transform_mixins → extensions/geo_transform}/extensions.rb +10 -8
- data/lib/gdal/{gridder → extensions/gridder}/point_extracting.rb +7 -5
- data/lib/gdal/{gridder.rb → extensions/gridder.rb} +33 -33
- data/lib/gdal/{gridder_options.rb → extensions/gridder_options.rb} +13 -14
- data/lib/gdal/{raster_attribute_table_mixins → extensions/raster_attribute_table}/extensions.rb +8 -6
- data/lib/gdal/{raster_band_mixins → extensions/raster_band}/algorithm_extensions.rb +8 -6
- data/lib/gdal/{raster_band_mixins → extensions/raster_band}/coloring_extensions.rb +6 -4
- data/lib/gdal/{raster_band_mixins → extensions/raster_band}/extensions.rb +9 -5
- data/lib/gdal/{raster_band_mixins → extensions/raster_band}/io_extensions.rb +18 -14
- data/lib/gdal/{raster_band_classifier.rb → extensions/raster_band_classifier.rb} +3 -5
- data/lib/gdal/geo_transform.rb +1 -6
- data/lib/gdal/grid.rb +3 -2
- data/lib/gdal/grid_algorithms.rb +9 -9
- data/lib/gdal/internal_helpers.rb +46 -9
- data/lib/gdal/major_object.rb +11 -3
- data/lib/gdal/options.rb +26 -32
- data/lib/gdal/raster_attribute_table.rb +63 -37
- data/lib/gdal/raster_band.rb +164 -116
- data/lib/gdal/raster_band_mixins/algorithm_methods.rb +26 -25
- data/lib/gdal/rpc_info.rb +3 -2
- data/lib/gdal/transformers/approximate_transformer.rb +12 -3
- data/lib/gdal/transformers/base_general_image_projection_transformer.rb +15 -2
- data/lib/gdal/transformers/gcp_transformer.rb +27 -19
- data/lib/gdal/transformers/general_image_projection_transformer.rb +8 -6
- data/lib/gdal/transformers/general_image_projection_transformer2.rb +9 -6
- data/lib/gdal/transformers/general_image_projection_transformer3.rb +6 -2
- data/lib/gdal/transformers/geolocation_transformer.rb +12 -4
- data/lib/gdal/transformers/reprojection_transformer.rb +11 -3
- data/lib/gdal/transformers/rpc_transformer.rb +11 -2
- data/lib/gdal/transformers/tps_transformer.rb +12 -4
- data/lib/gdal/version_info.rb +2 -2
- data/lib/gdal/virtual_dataset.rb +2 -0
- data/lib/gdal/warp_operation.rb +65 -54
- data/lib/gdal/warp_options.rb +9 -11
- data/lib/ogr/coordinate_transformation.rb +23 -9
- data/lib/ogr/data_source.rb +68 -37
- data/lib/ogr/driver.rb +18 -17
- data/lib/ogr/envelope.rb +0 -3
- data/lib/ogr/error_handling.rb +22 -24
- data/lib/ogr/extensions/all.rb +3 -0
- data/lib/ogr/{data_source_mixins → extensions/data_source}/capability_methods.rb +2 -0
- data/lib/ogr/extensions/data_source/data_source_extensions.rb +16 -0
- data/lib/ogr/{driver_mixins → extensions/driver}/capability_methods.rb +5 -1
- data/lib/ogr/extensions/envelope/extensions.rb +114 -0
- data/lib/ogr/extensions/feature/extensions.rb +87 -0
- data/lib/ogr/extensions/feature_definition/extensions.rb +43 -0
- data/lib/ogr/extensions/geometries/point/extensions.rb +19 -0
- data/lib/ogr/extensions/geometry/container_mixins.rb +56 -0
- data/lib/ogr/extensions/geometry/ewkb_io_extensions.rb +44 -0
- data/lib/ogr/extensions/geometry/ewkb_record.rb +94 -0
- data/lib/ogr/{geometry_mixins → extensions/geometry}/extensions.rb +16 -9
- data/lib/ogr/extensions/geometry/rttopo_extensions.rb +48 -0
- data/lib/ogr/extensions/geometry/wkb_record.rb +63 -0
- data/lib/ogr/extensions/geometry_types/curve/extensions.rb +68 -0
- data/lib/ogr/{layer_mixins → extensions/layer}/capability_methods.rb +4 -0
- data/lib/ogr/{layer_mixins → extensions/layer}/extensions.rb +11 -6
- data/lib/ogr/extensions/spatial_reference/extensions.rb +38 -0
- data/lib/ogr/extensions/spatial_reference/initializers.rb +138 -0
- data/lib/ogr/extensions/style_table/extensions.rb +31 -0
- data/lib/ogr/feature.rb +173 -88
- data/lib/ogr/feature_definition.rb +53 -45
- data/lib/ogr/field.rb +17 -19
- data/lib/ogr/field_definition.rb +30 -18
- data/lib/ogr/geocoder.rb +11 -4
- data/lib/ogr/geometries/line_string.rb +1 -0
- data/lib/ogr/geometries/line_string_25d.rb +0 -9
- data/lib/ogr/geometries/linear_ring.rb +2 -2
- data/lib/ogr/geometries/point.rb +0 -9
- data/lib/ogr/geometry.rb +116 -49
- data/lib/ogr/geometry_field_definition.rb +31 -15
- data/lib/ogr/geometry_types/container.rb +26 -28
- data/lib/ogr/geometry_types/curve.rb +5 -61
- data/lib/ogr/geometry_types/surface.rb +1 -1
- data/lib/ogr/internal_helpers.rb +2 -2
- data/lib/ogr/layer.rb +12 -10
- data/lib/ogr/layer_mixins/ogr_feature_methods.rb +39 -27
- data/lib/ogr/layer_mixins/ogr_field_methods.rb +66 -50
- data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +17 -8
- data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +7 -6
- data/lib/ogr/layer_mixins/ogr_sql_methods.rb +15 -7
- data/lib/ogr/spatial_reference.rb +79 -42
- data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +149 -118
- data/lib/ogr/spatial_reference_mixins/exporters.rb +87 -51
- data/lib/ogr/spatial_reference_mixins/importers.rb +88 -43
- data/lib/ogr/spatial_reference_mixins/morphers.rb +12 -8
- data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +27 -13
- data/lib/ogr/style_table.rb +15 -5
- data/lib/ogr/style_tool.rb +29 -15
- data/lib/ogr.rb +1 -0
- data/rakelib/docker.rake +10 -0
- data/sorbet/rbi/hidden-definitions/errors.txt +21790 -0
- data/tilt/gdal2.yml +22 -0
- data/tilt/gdal3.yml +22 -0
- metadata +116 -280
- data/History.md +0 -360
- data/lib/ext/error_symbols.rb +0 -7
- data/lib/gdal/dataset_mixins/extensions.rb +0 -380
- data/lib/gdal/merger.rb +0 -132
- data/lib/ogr/data_source_extensions.rb +0 -10
- data/lib/ogr/envelope_extensions.rb +0 -110
- data/lib/ogr/feature_definition_extensions.rb +0 -39
- data/lib/ogr/feature_extensions.rb +0 -87
- data/lib/ogr/geometry_mixins/container_mixins.rb +0 -25
- data/lib/ogr/spatial_reference_extensions.rb +0 -34
- data/lib/ogr/style_table_extensions.rb +0 -26
- data/spec/ffi-gdal_spec.rb +0 -24
- data/spec/integration/gdal/color_table_info_spec.rb +0 -78
- data/spec/integration/gdal/dataset_info_spec.rb +0 -342
- data/spec/integration/gdal/driver_info_spec.rb +0 -170
- data/spec/integration/gdal/geo_transform_info_spec.rb +0 -226
- data/spec/integration/gdal/gridder_spec.rb +0 -331
- data/spec/integration/gdal/raster_attribute_table_info_spec.rb +0 -229
- data/spec/integration/gdal/raster_band_algorithms_spec.rb +0 -35
- data/spec/integration/gdal/raster_band_info_spec.rb +0 -320
- data/spec/integration/ogr/layer_spec.rb +0 -95
- data/spec/spec_helper.rb +0 -116
- data/spec/support/images/123.tiff +0 -0
- data/spec/support/images/osgeo/gdal/data/hfa/float-rle.img +0 -0
- data/spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.lgo +0 -31
- 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 +0 -10
- data/spec/support/images/osgeo/geotiff/gdal_eg/cea.tif +0 -0
- data/spec/support/images/osgeo/geotiff/gdal_eg/cea.txt +0 -84
- data/spec/support/images/osgeo/geotiff/zi_imaging/image0.lgo +0 -45
- data/spec/support/images/osgeo/geotiff/zi_imaging/image0.tif +0 -0
- data/spec/support/integration_help.rb +0 -34
- data/spec/support/shapefiles/states_21basic/states.dbf +0 -0
- data/spec/support/shapefiles/states_21basic/states.prj +0 -1
- data/spec/support/shapefiles/states_21basic/states.sbn +0 -0
- data/spec/support/shapefiles/states_21basic/states.sbx +0 -0
- data/spec/support/shapefiles/states_21basic/states.shp +0 -0
- data/spec/support/shapefiles/states_21basic/states.shp.xml +0 -3
- data/spec/support/shapefiles/states_21basic/states.shx +0 -0
- data/spec/support/shared_contexts.rb +0 -28
- data/spec/support/shared_examples/gdal/major_object_examples.rb +0 -55
- data/spec/support/shared_examples/ogr/a_25d_geometry.rb +0 -9
- data/spec/support/shared_examples/ogr/a_container_geometry.rb +0 -49
- data/spec/support/shared_examples/ogr/a_geometry.rb +0 -406
- data/spec/support/shared_examples/ogr/a_line_string.rb +0 -18
- data/spec/support/test_style_table.txt +0 -3
- data/spec/support/worldfiles/SR_50M/SR_50M.VERSION.txt +0 -1
- data/spec/support/worldfiles/SR_50M/SR_50M.prj +0 -1
- data/spec/support/worldfiles/SR_50M/SR_50M.tfw +0 -6
- data/spec/support/worldfiles/SR_50M/SR_50M.tif +0 -0
- data/spec/unit/ext/error_symbols_spec.rb +0 -69
- data/spec/unit/ext/numeric_as_data_type_spec.rb +0 -115
- data/spec/unit/ffi/gdal_spec.rb +0 -73
- data/spec/unit/gdal/color_entry_spec.rb +0 -8
- data/spec/unit/gdal/color_interpretation_spec.rb +0 -8
- data/spec/unit/gdal/color_table_mixins/extensions_spec.rb +0 -62
- data/spec/unit/gdal/color_table_spec.rb +0 -146
- data/spec/unit/gdal/data_type_spec.rb +0 -74
- data/spec/unit/gdal/dataset_mixins/warp_methods_spec.rb +0 -55
- data/spec/unit/gdal/dataset_spec.rb +0 -148
- data/spec/unit/gdal/driver_mixins/extensions_spec.rb +0 -24
- data/spec/unit/gdal/driver_spec.rb +0 -51
- data/spec/unit/gdal/environment_methods_spec.rb +0 -8
- data/spec/unit/gdal/geo_transform_mixins/extensions_spec.rb +0 -69
- data/spec/unit/gdal/geo_transform_spec.rb +0 -265
- data/spec/unit/gdal/grid_spec.rb +0 -98
- data/spec/unit/gdal/gridder/point_extracting_spec.rb +0 -101
- data/spec/unit/gdal/gridder_options_spec.rb +0 -185
- data/spec/unit/gdal/gridder_spec.rb +0 -182
- data/spec/unit/gdal/internal_helpers_spec.rb +0 -278
- data/spec/unit/gdal/major_object_spec.rb +0 -10
- data/spec/unit/gdal/options_spec.rb +0 -33
- data/spec/unit/gdal/raster_attribute_table_spec.rb +0 -7
- data/spec/unit/gdal/raster_band_classifier_spec.rb +0 -260
- data/spec/unit/gdal/raster_band_mixins/extensions_spec.rb +0 -73
- data/spec/unit/gdal/raster_band_mixins/io_extensions_spec.rb +0 -135
- data/spec/unit/gdal/raster_band_spec.rb +0 -8
- data/spec/unit/gdal/rpc_info_spec.rb +0 -8
- data/spec/unit/gdal/version_info_spec.rb +0 -10
- data/spec/unit/gdal/virtual_dataset_spec.rb +0 -34
- data/spec/unit/gdal/warp_operation_spec.rb +0 -8
- data/spec/unit/gdal/warp_options_spec.rb +0 -338
- data/spec/unit/ogr/coordinate_transformation_spec.rb +0 -104
- data/spec/unit/ogr/data_source_mixins/capability_methods_spec.rb +0 -32
- data/spec/unit/ogr/data_source_spec.rb +0 -223
- data/spec/unit/ogr/driver_mixins/capability_methods_spec.rb +0 -20
- data/spec/unit/ogr/driver_spec.rb +0 -152
- data/spec/unit/ogr/envelope_spec.rb +0 -324
- data/spec/unit/ogr/feature_definition_spec.rb +0 -296
- data/spec/unit/ogr/feature_extensions_spec.rb +0 -90
- data/spec/unit/ogr/feature_spec.rb +0 -363
- data/spec/unit/ogr/field_definition_spec.rb +0 -118
- data/spec/unit/ogr/field_spec.rb +0 -195
- data/spec/unit/ogr/geometries/geometry_collection_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/geometry_collection_spec.rb +0 -188
- data/spec/unit/ogr/geometries/line_string_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/line_string_spec.rb +0 -107
- data/spec/unit/ogr/geometries/linear_ring_spec.rb +0 -92
- data/spec/unit/ogr/geometries/multi_line_string_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/multi_line_string_spec.rb +0 -16
- data/spec/unit/ogr/geometries/multi_point_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/multi_point_spec.rb +0 -16
- data/spec/unit/ogr/geometries/multi_polygon_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/multi_polygon_spec.rb +0 -43
- data/spec/unit/ogr/geometries/none_geometry_spec.rb +0 -14
- data/spec/unit/ogr/geometries/point_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/point_spec.rb +0 -307
- data/spec/unit/ogr/geometries/polygon_25d_spec.rb +0 -25
- data/spec/unit/ogr/geometries/polygon_spec.rb +0 -19
- data/spec/unit/ogr/geometries/unknown_geometry_spec.rb +0 -12
- data/spec/unit/ogr/geometry_field_definition_spec.rb +0 -73
- data/spec/unit/ogr/geometry_spec.rb +0 -711
- data/spec/unit/ogr/internal_helpers_spec.rb +0 -70
- data/spec/unit/ogr/layer_mixins/capability_methods_spec.rb +0 -90
- data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +0 -155
- data/spec/unit/ogr/layer_mixins/ogr_field_methods_spec.rb +0 -434
- data/spec/unit/ogr/layer_mixins/ogr_layer_method_methods_spec.rb +0 -22
- data/spec/unit/ogr/layer_mixins/ogr_query_filter_methods_spec.rb +0 -44
- data/spec/unit/ogr/layer_mixins/ogr_sql_methods_spec.rb +0 -14
- data/spec/unit/ogr/layer_spec.rb +0 -98
- data/spec/unit/ogr/spatial_reference_mixins/coordinate_system_getter_setters_spec.rb +0 -48
- data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +0 -151
- data/spec/unit/ogr/spatial_reference_mixins/importers_spec.rb +0 -40
- data/spec/unit/ogr/spatial_reference_mixins/morphers_spec.rb +0 -38
- data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +0 -105
- data/spec/unit/ogr/spatial_reference_mixins/type_checks_spec.rb +0 -159
- data/spec/unit/ogr/spatial_reference_spec.rb +0 -44
- data/spec/unit/ogr/style_table_spec.rb +0 -108
- data/spec/unit/ogr/style_tool_spec.rb +0 -159
- data/spec/unit/version_info_spec.rb +0 -50
@@ -1,278 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'gdal/internal_helpers'
|
5
|
-
require 'ogr/spatial_reference'
|
6
|
-
require 'gdal/dataset'
|
7
|
-
|
8
|
-
RSpec.describe GDAL::InternalHelpers do
|
9
|
-
subject(:tester) do
|
10
|
-
module Tester
|
11
|
-
include GDAL::InternalHelpers
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '._pointer' do
|
16
|
-
context 'variable is a kind of the klass that was passed in' do
|
17
|
-
let(:variable) { OGR::SpatialReference.new }
|
18
|
-
|
19
|
-
it "returns the variable's pointer with autorelease = true" do
|
20
|
-
expect(variable.c_pointer).to receive(:autorelease=).with(true)
|
21
|
-
expect(subject._pointer(OGR::SpatialReference, variable)).to eq variable.c_pointer
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'variable is an FFI::Pointer' do
|
26
|
-
let(:variable) { FFI::MemoryPointer.new(:pointer) }
|
27
|
-
|
28
|
-
it 'returns the pointer with autorelease = true' do
|
29
|
-
expect(variable).to receive(:autorelease=).with(true)
|
30
|
-
expect(subject._pointer(GDAL::Dataset, variable)).to eq variable
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context 'variable is nil' do
|
35
|
-
it 'returns nil' do
|
36
|
-
expect(subject._pointer(GDAL::Dataset, nil, false)).to be_nil
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '._string_array_to_pointer' do
|
42
|
-
context 'an array' do
|
43
|
-
let(:array) { ['one', 2, 3.0, :four] }
|
44
|
-
|
45
|
-
it 'returns a pointer that contains the array values as strings' do
|
46
|
-
pointer = subject._string_array_to_pointer(array)
|
47
|
-
expect(pointer).to be_an FFI::MemoryPointer
|
48
|
-
expect(pointer.get_array_of_string(0)).to eq %w[one 2 3.0 four]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'not an array' do
|
53
|
-
it 'raises an error about no responding to #map' do
|
54
|
-
expect do
|
55
|
-
subject._string_array_to_pointer('blarg')
|
56
|
-
end.to raise_exception NoMethodError
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe '._gdal_data_type_to_ffi' do
|
62
|
-
context 'data type is :GDT_Byte' do
|
63
|
-
subject { tester._gdal_data_type_to_ffi(:GDT_Byte) }
|
64
|
-
it { is_expected.to eq :uchar }
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'data type is :GDT_UInt16' do
|
68
|
-
subject { tester._gdal_data_type_to_ffi(:GDT_UInt16) }
|
69
|
-
it { is_expected.to eq :uint16 }
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'data type is :GDT_Int16' do
|
73
|
-
subject { tester._gdal_data_type_to_ffi(:GDT_Int16) }
|
74
|
-
it { is_expected.to eq :int16 }
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'data type is :GDT_UInt32' do
|
78
|
-
subject { tester._gdal_data_type_to_ffi(:GDT_UInt32) }
|
79
|
-
it { is_expected.to eq :uint32 }
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'data type is :GDT_Int32' do
|
83
|
-
subject { tester._gdal_data_type_to_ffi(:GDT_Int32) }
|
84
|
-
it { is_expected.to eq :int32 }
|
85
|
-
end
|
86
|
-
|
87
|
-
context 'data type is :GDT_Float32' do
|
88
|
-
subject { tester._gdal_data_type_to_ffi(:GDT_Float32) }
|
89
|
-
it { is_expected.to eq :float }
|
90
|
-
end
|
91
|
-
|
92
|
-
context 'data type is :GDT_Float64' do
|
93
|
-
subject { tester._gdal_data_type_to_ffi(:GDT_Float64) }
|
94
|
-
it { is_expected.to eq :double }
|
95
|
-
end
|
96
|
-
|
97
|
-
context 'data type is not one listed' do
|
98
|
-
it 'raises a GDAL::InvalidDataType' do
|
99
|
-
expect { tester._gdal_data_type_to_ffi(:blargh) }.
|
100
|
-
to raise_exception(GDAL::InvalidDataType)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
describe '._read_pointer' do
|
106
|
-
context 'length is 1' do
|
107
|
-
let(:pointer) do
|
108
|
-
p = FFI::MemoryPointer.new(:int16)
|
109
|
-
p.write_int16(12_345)
|
110
|
-
|
111
|
-
p
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'returns the data value' do
|
115
|
-
expect(GDAL._read_pointer(pointer, :GDT_Int16)).to eq(12_345)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
context 'length is > 1' do
|
120
|
-
let(:pointer) do
|
121
|
-
p = FFI::MemoryPointer.new(:int16, 2)
|
122
|
-
p.write_array_of_int16([12_345, 222])
|
123
|
-
|
124
|
-
p
|
125
|
-
end
|
126
|
-
|
127
|
-
it 'returns the data value' do
|
128
|
-
expect(GDAL._read_pointer(pointer, :GDT_Int16, 2)).to eq([12_345, 222])
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
describe '._write_pointer' do
|
134
|
-
context 'data is not an Array' do
|
135
|
-
let(:pointer) { FFI::MemoryPointer.new(:int16) }
|
136
|
-
|
137
|
-
it 'writes the single value to the pointer' do
|
138
|
-
expect(pointer).to receive(:write_int16).with(12_345)
|
139
|
-
GDAL._write_pointer(pointer, :GDT_Int16, 12_345)
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
context 'data is an Array' do
|
144
|
-
let(:pointer) { FFI::MemoryPointer.new(:int16, 2) }
|
145
|
-
|
146
|
-
it 'writes the values to the pointer' do
|
147
|
-
expect(pointer).to receive(:write_array_of_int16).with([12_345, 222])
|
148
|
-
GDAL._write_pointer(pointer, :GDT_Int16, [12_345, 222])
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
describe '._supported?' do
|
154
|
-
context 'function is supported' do
|
155
|
-
subject { tester._supported?(:GDALAllRegister) }
|
156
|
-
it { is_expected.to eq true }
|
157
|
-
end
|
158
|
-
|
159
|
-
context 'function is not supported' do
|
160
|
-
subject { tester._supported?(:darrells) }
|
161
|
-
it { is_expected.to eq false }
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
describe '._gdal_data_type_to_narray' do
|
166
|
-
subject { GDAL._gdal_data_type_to_narray(data_type) }
|
167
|
-
|
168
|
-
context 'data_type is :GDT_Byte' do
|
169
|
-
let(:data_type) { :GDT_Byte }
|
170
|
-
it { is_expected.to eq(:byte) }
|
171
|
-
end
|
172
|
-
|
173
|
-
context 'data_type is :GDT_Int16' do
|
174
|
-
let(:data_type) { :GDT_Int16 }
|
175
|
-
it { is_expected.to eq(:sint) }
|
176
|
-
end
|
177
|
-
|
178
|
-
context 'data_type is :GDT_UInt16' do
|
179
|
-
let(:data_type) { :GDT_UInt16 }
|
180
|
-
it { is_expected.to eq(:int) }
|
181
|
-
end
|
182
|
-
|
183
|
-
context 'data_type is :GDT_Int32' do
|
184
|
-
let(:data_type) { :GDT_Int32 }
|
185
|
-
it { is_expected.to eq(:int) }
|
186
|
-
end
|
187
|
-
|
188
|
-
context 'data_type is :GDT_UInt32' do
|
189
|
-
let(:data_type) { :GDT_UInt32 }
|
190
|
-
it { is_expected.to eq(:int) }
|
191
|
-
end
|
192
|
-
|
193
|
-
context 'data_type is :GDT_Float32' do
|
194
|
-
let(:data_type) { :GDT_Float32 }
|
195
|
-
it { is_expected.to eq(:float) }
|
196
|
-
end
|
197
|
-
|
198
|
-
context 'data_type is :GDT_Float64' do
|
199
|
-
let(:data_type) { :GDT_Float64 }
|
200
|
-
it { is_expected.to eq(:dfloat) }
|
201
|
-
end
|
202
|
-
|
203
|
-
context 'data_type is :GDT_CInt16' do
|
204
|
-
let(:data_type) { :GDT_CInt16 }
|
205
|
-
it { is_expected.to eq(:scomplex) }
|
206
|
-
end
|
207
|
-
|
208
|
-
context 'data_type is :GDT_CInt32' do
|
209
|
-
let(:data_type) { :GDT_CInt32 }
|
210
|
-
it { is_expected.to eq(:scomplex) }
|
211
|
-
end
|
212
|
-
|
213
|
-
context 'data_type is :GDT_CFloat32' do
|
214
|
-
let(:data_type) { :GDT_CFloat32 }
|
215
|
-
it { is_expected.to eq(:complex) }
|
216
|
-
end
|
217
|
-
|
218
|
-
context 'data_type is :GDT_CFloat64' do
|
219
|
-
let(:data_type) { :GDT_CFloat64 }
|
220
|
-
it { is_expected.to eq(:dcomplex) }
|
221
|
-
end
|
222
|
-
|
223
|
-
context 'unknown data_type' do
|
224
|
-
it 'raises a GDAL::InvalidDataType exception' do
|
225
|
-
expect { GDAL._gdal_data_type_to_narray(:meow) }.
|
226
|
-
to raise_exception(GDAL::InvalidDataType)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
describe '._narray_from_data_type' do
|
232
|
-
context '0 narray_args and known GDAL data_type' do
|
233
|
-
subject { GDAL._narray_from_data_type(:GDT_Byte) }
|
234
|
-
it { is_expected.to be_a NArray }
|
235
|
-
|
236
|
-
it 'has size 0' do
|
237
|
-
expect(subject.size).to be_zero
|
238
|
-
end
|
239
|
-
|
240
|
-
it 'has shape []' do
|
241
|
-
expect(subject.shape).to eq([])
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
context '1 narray_args and known GDAL data_type' do
|
246
|
-
subject { GDAL._narray_from_data_type(:GDT_Byte, 2) }
|
247
|
-
it { is_expected.to be_a NArray }
|
248
|
-
|
249
|
-
it 'has size of the 2nd param' do
|
250
|
-
expect(subject.size).to eq(2)
|
251
|
-
end
|
252
|
-
|
253
|
-
it 'has 1D shape with size of the 2nd param' do
|
254
|
-
expect(subject.shape).to eq([2])
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
context '2 narray_args and known GDAL data_type' do
|
259
|
-
subject { GDAL._narray_from_data_type(:GDT_Byte, 2, 3) }
|
260
|
-
it { is_expected.to be_a NArray }
|
261
|
-
|
262
|
-
it 'has size of the 2nd param * 3rd param' do
|
263
|
-
expect(subject.size).to eq(6)
|
264
|
-
end
|
265
|
-
|
266
|
-
it 'has 2D shape with size of each of the params' do
|
267
|
-
expect(subject.shape).to eq([2, 3])
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
context 'unknown GDAL data_type' do
|
272
|
-
it 'raises a GDAL::InvalidDataType exception' do
|
273
|
-
expect { GDAL._narray_from_data_type(:bobo) }.
|
274
|
-
to raise_exception(GDAL::InvalidDataType)
|
275
|
-
end
|
276
|
-
end
|
277
|
-
end
|
278
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'gdal/options'
|
5
|
-
|
6
|
-
RSpec.describe GDAL::Options do
|
7
|
-
describe '.to_hash' do
|
8
|
-
subject { described_class.to_hash(pointer) }
|
9
|
-
|
10
|
-
context 'options are set' do
|
11
|
-
let(:pointer) { described_class.pointer(hash) }
|
12
|
-
|
13
|
-
let(:hash) do
|
14
|
-
{
|
15
|
-
one: 'ONE',
|
16
|
-
two: 'TWO'
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'returns the Ruby Hash' do
|
21
|
-
expect(subject).to eq(hash)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'pointer is null' do
|
26
|
-
let(:pointer) { FFI::MemoryPointer.new(:string) }
|
27
|
-
|
28
|
-
it 'returns an empty Hash' do
|
29
|
-
expect(subject).to eq({})
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,260 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'gdal/driver'
|
5
|
-
require 'gdal/raster_band_classifier'
|
6
|
-
|
7
|
-
RSpec.describe GDAL::RasterBandClassifier do
|
8
|
-
let(:driver) { GDAL::Driver.by_name('MEM') }
|
9
|
-
|
10
|
-
let(:dataset) do
|
11
|
-
d = driver.create_dataset('test dataset', 640, 480)
|
12
|
-
band = d.raster_band 1
|
13
|
-
new_values = band.to_na.indgen!
|
14
|
-
band.write_xy_narray(new_values)
|
15
|
-
|
16
|
-
d
|
17
|
-
end
|
18
|
-
|
19
|
-
let(:raster_band) { dataset.raster_band 1 }
|
20
|
-
subject(:classifier) { described_class.new(raster_band) }
|
21
|
-
|
22
|
-
describe '#add_range' do
|
23
|
-
context 'range param is a Range' do
|
24
|
-
it 'adds the hash to the list of @ranges' do
|
25
|
-
expect do
|
26
|
-
subject.add_range 0..10, 1
|
27
|
-
end.to change { subject.ranges.size }.by 1
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'range param is not a Range' do
|
32
|
-
it 'raises a RuntimeError' do
|
33
|
-
expect do
|
34
|
-
subject.add_range [1, 2, 3], 1
|
35
|
-
end.to raise_exception RuntimeError
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#add_ranges' do
|
41
|
-
let(:ranges) do
|
42
|
-
[
|
43
|
-
{ range: 0..10, map_to: 1000 },
|
44
|
-
{ range: 10..100, map_to: 1 }
|
45
|
-
]
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'adds a list of ranges to @ranges' do
|
49
|
-
expect do
|
50
|
-
subject.add_ranges(ranges)
|
51
|
-
end.to change { subject.ranges.size }.by ranges.size
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '#equal_count_ranges' do
|
56
|
-
context 'band type is :GDT_Byte' do
|
57
|
-
subject { classifier.equal_count_ranges(4) }
|
58
|
-
|
59
|
-
it 'is an Array of Hashes' do
|
60
|
-
expect(subject).to be_an Array
|
61
|
-
expect(subject.first).to be_a Hash
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'has map_to values that are between 1 and 4' do
|
65
|
-
map_to_values = subject.map { |range| range[:map_to] }.uniq
|
66
|
-
expect(map_to_values).to contain_exactly(1, 2, 3, 4)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'band type is :GDT_Float32' do
|
71
|
-
let(:raster_band) do
|
72
|
-
band = float_dataset.raster_band 1
|
73
|
-
new_values = band.to_na.indgen!
|
74
|
-
band.write_xy_narray(new_values)
|
75
|
-
band
|
76
|
-
end
|
77
|
-
|
78
|
-
let(:float_dataset) do
|
79
|
-
driver.create_dataset 'test dataset', 640, 480, data_type: :GDT_Float32
|
80
|
-
end
|
81
|
-
|
82
|
-
subject { classifier.equal_count_ranges(4) }
|
83
|
-
|
84
|
-
it 'is an Array of Hashes' do
|
85
|
-
expect(subject).to be_an Array
|
86
|
-
expect(subject.first).to be_a Hash
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'has map_to values that are between 1 and 4' do
|
90
|
-
map_to_values = subject.map { |range| range[:map_to] }.uniq
|
91
|
-
expect(map_to_values).to contain_exactly(1.0, 2.0, 3.0, 4.0)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context 'not enough values between breaks to generate unique break values' do
|
96
|
-
subject { classifier.equal_count_ranges(1_000) }
|
97
|
-
it { is_expected.to be_nil }
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'all same value' do
|
101
|
-
let(:band_narray) { Numo::Int8.new(3, 5).fill(1) }
|
102
|
-
before { allow(raster_band).to receive(:to_nna).and_return(band_narray) }
|
103
|
-
|
104
|
-
it 'returns a single range when 1 is requested' do
|
105
|
-
expect(subject.equal_count_ranges(1)).to eq [{ range: 1..1, map_to: 1 }]
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context 'all nodata pixels' do
|
110
|
-
let(:band_narray) { Numo::Int8.new(3, 5).fill(0) }
|
111
|
-
before { allow(raster_band).to receive(:to_nna).and_return(band_narray) }
|
112
|
-
|
113
|
-
it 'returns an empty Array' do
|
114
|
-
expect(subject.equal_count_ranges(10)).to eq([])
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe '#ensure_min_gap' do
|
120
|
-
let(:break_values) do
|
121
|
-
[29_491.177616329518, 34_999.999999999985, 34_999.99999999999, 35_000.0, 35_000.01582852495, 36_499.9508667737]
|
122
|
-
end
|
123
|
-
|
124
|
-
let(:expected_values) do
|
125
|
-
[29_438.61973121367, 34_947.44211488414, 34_982.48598113636, 35_017.52984738857, 35_052.57371364079,
|
126
|
-
36_552.508751889545]
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'ensures breakpoints have a gap between them of 0.5% of the total range' do
|
130
|
-
subject.send(:ensure_min_gap, break_values)
|
131
|
-
expect(break_values).to eq expected_values
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
describe '#classify!' do
|
136
|
-
before do
|
137
|
-
ranges = subject.equal_count_ranges(10)
|
138
|
-
subject.add_ranges(ranges)
|
139
|
-
end
|
140
|
-
|
141
|
-
context 'no_data_value is set to 0' do
|
142
|
-
before do
|
143
|
-
raster_band.no_data_value = 0
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'has a max value equal to the number of ranges' do
|
147
|
-
subject.classify!
|
148
|
-
min_max = raster_band.min_max
|
149
|
-
expect(min_max[:max]).to eq 10
|
150
|
-
end
|
151
|
-
|
152
|
-
it 'has a min value of 1' do
|
153
|
-
subject.classify!
|
154
|
-
min_max = raster_band.min_max
|
155
|
-
expect(min_max[:min]).to eq 1
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'retains its NODATA pixels' do
|
159
|
-
expect { subject.classify! }.to_not(change { raster_band.to_na.eq(-9999.0).count_true })
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
# Relevant because NArray inits its arrays to 0.
|
164
|
-
context 'no_data_value is set to non-0' do
|
165
|
-
let(:dataset) do
|
166
|
-
d = driver.create_dataset('test dataset', 640, 480, data_type: :GDT_Float32)
|
167
|
-
band = d.raster_band 1
|
168
|
-
band.no_data_value = -9999.0
|
169
|
-
new_values = band.to_na.indgen!
|
170
|
-
new_values[true, 0] = -9999.0
|
171
|
-
band.write_xy_narray(new_values)
|
172
|
-
|
173
|
-
d
|
174
|
-
end
|
175
|
-
|
176
|
-
it 'has a max value equal to the number of ranges' do
|
177
|
-
subject.classify!
|
178
|
-
min_max = raster_band.min_max
|
179
|
-
expect(min_max[:max]).to eq 10
|
180
|
-
end
|
181
|
-
|
182
|
-
it 'has a min value of 1' do
|
183
|
-
subject.classify!
|
184
|
-
min_max = raster_band.min_max
|
185
|
-
expect(min_max[:min]).to eq 1
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'retains its NODATA pixels' do
|
189
|
-
expect { subject.classify! }.to_not(change { raster_band.to_na.eq(-9999.0).count_true })
|
190
|
-
pixels = raster_band.to_na
|
191
|
-
expect(pixels.eq(-9999).count_true).to eq 640
|
192
|
-
expect(pixels.eq(0).count_true).to eq 0
|
193
|
-
expect(pixels.eq(1).count_true).to eq 30_656
|
194
|
-
expect(pixels.eq(2).count_true).to eq 30_656
|
195
|
-
expect(pixels.eq(3).count_true).to eq 30_656
|
196
|
-
expect(pixels.eq(4).count_true).to eq 30_656
|
197
|
-
expect(pixels.eq(5).count_true).to eq 30_656
|
198
|
-
expect(pixels.eq(6).count_true).to eq 30_656
|
199
|
-
expect(pixels.eq(7).count_true).to eq 30_656
|
200
|
-
expect(pixels.eq(8).count_true).to eq 30_656
|
201
|
-
expect(pixels.eq(9).count_true).to eq 30_656
|
202
|
-
expect(pixels.eq(10).count_true).to eq 30_656
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
context 'no_data_value is not set' do
|
207
|
-
it 'has a max value equal to the number of ranges' do
|
208
|
-
subject.classify!
|
209
|
-
min_max = raster_band.min_max
|
210
|
-
expect(min_max[:max]).to eq 10
|
211
|
-
end
|
212
|
-
|
213
|
-
it 'has a min value of 0' do
|
214
|
-
subject.classify!
|
215
|
-
min_max = raster_band.min_max
|
216
|
-
expect(min_max[:min]).to eq 0
|
217
|
-
end
|
218
|
-
|
219
|
-
it 'retains its NODATA pixels' do
|
220
|
-
expect { subject.classify! }.to_not(change { raster_band.to_na.eq(-9999.0).count_true })
|
221
|
-
end
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
describe '#masked_pixels' do
|
226
|
-
let(:pixels) { dataset.raster_band(1).to_nna }
|
227
|
-
let(:raster_band) { double 'Band', no_data_value: { value: nodata_value } }
|
228
|
-
|
229
|
-
before { subject.instance_variable_set(:@raster_band, raster_band) }
|
230
|
-
|
231
|
-
context 'nodata is NaN' do
|
232
|
-
let(:nodata_value) { Float::NAN }
|
233
|
-
let(:pixels) { Numo::DFloat.cast(dataset.raster_band(1).to_nna) }
|
234
|
-
|
235
|
-
before do
|
236
|
-
pixels[pixels.eq(0)] = nodata_value
|
237
|
-
end
|
238
|
-
|
239
|
-
it 'removes all nodata values' do
|
240
|
-
expect(subject.send(:masked_pixels, pixels).isnan.count_true).to eq 0
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
context 'nodata is a number' do
|
245
|
-
let(:nodata_value) { 0 }
|
246
|
-
|
247
|
-
it 'removes all nodata values' do
|
248
|
-
expect(subject.send(:masked_pixels, pixels).eq(0).count_true).to eq 0
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
context 'nodata is nil' do
|
253
|
-
let(:nodata_value) { nil }
|
254
|
-
|
255
|
-
it 'returns the original pixels' do
|
256
|
-
expect(subject.send(:masked_pixels, pixels)).to eq pixels
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'gdal/driver'
|
5
|
-
require 'gdal/raster_band'
|
6
|
-
|
7
|
-
RSpec.describe 'GDAL::RasterBandMixins::Extensions' do
|
8
|
-
let(:driver) { GDAL::Driver.by_name('MEM') }
|
9
|
-
let(:dataset_byte) { driver.create_dataset('test', 15, 25, data_type: :GDT_Byte) }
|
10
|
-
subject(:raster_band) { dataset_byte.raster_band(1) }
|
11
|
-
|
12
|
-
describe '#to_a' do
|
13
|
-
subject { raster_band.to_a }
|
14
|
-
it { is_expected.to eq(Array.new(25, Array.new(15, 0))) }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#to_na' do
|
18
|
-
context 'no conversion' do
|
19
|
-
subject { raster_band.to_na }
|
20
|
-
it { is_expected.to eq(NArray.byte(15, 25)) }
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'convert to Int16' do
|
24
|
-
subject { raster_band.to_na(:GDT_Int16) }
|
25
|
-
it { is_expected.to eq(NArray.sint(15, 25)) }
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'convert to UInt16' do
|
29
|
-
subject { raster_band.to_na(:GDT_UInt16) }
|
30
|
-
it { is_expected.to eq(NArray.int(15, 25)) }
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'convert to Int32' do
|
34
|
-
subject { raster_band.to_na(:GDT_Int32) }
|
35
|
-
it { is_expected.to eq(NArray.int(15, 25)) }
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'convert to UInt32' do
|
39
|
-
subject { raster_band.to_na(:GDT_UInt32) }
|
40
|
-
it { is_expected.to eq(NArray.int(15, 25)) }
|
41
|
-
end
|
42
|
-
|
43
|
-
context 'convert to Float32' do
|
44
|
-
subject { raster_band.to_na(:GDT_Float32) }
|
45
|
-
it { is_expected.to eq(NArray.sfloat(15, 25)) }
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'convert to Float64' do
|
49
|
-
subject { raster_band.to_na(:GDT_Float64) }
|
50
|
-
it { is_expected.to eq(NArray.float(15, 25)) }
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'convert to CInt16' do
|
54
|
-
subject { raster_band.to_na(:GDT_CInt16) }
|
55
|
-
it { is_expected.to eq(NArray.scomplex(15, 25)) }
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'convert to CInt32' do
|
59
|
-
subject { raster_band.to_na(:GDT_CInt32) }
|
60
|
-
it { is_expected.to eq(NArray.scomplex(15, 25)) }
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'convert to CFloat32' do
|
64
|
-
subject { raster_band.to_na(:GDT_CFloat32) }
|
65
|
-
it { is_expected.to eq(NArray.scomplex(15, 25)) }
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'convert to CFloat64' do
|
69
|
-
subject { raster_band.to_na(:GDT_CFloat64) }
|
70
|
-
it { is_expected.to eq(NArray.complex(15, 25)) }
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|