ffi-gdal 1.0.0.beta6 → 1.0.0.beta11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.rubocop.yml +54 -19
- data/.rubocop_todo.yml +65 -0
- data/.ruby-version +1 -1
- data/Gemfile +2 -0
- data/History.md +74 -0
- data/README.md +5 -0
- data/Rakefile +11 -1
- data/bitbucket-pipelines.yml +16 -0
- data/examples/extract_and_colorize.rb +7 -10
- data/examples/geometries.rb +68 -1
- data/examples/gridding.rb +2 -0
- data/examples/ogr_layer_to_layer.rb +2 -0
- data/examples/raster_erasing.rb +15 -8
- data/examples/remove_small_polygons.rb +2 -0
- data/examples/testing_gdal.rb +9 -2
- data/examples/warping.rb +23 -5
- data/ffi-gdal.gemspec +7 -4
- data/lib/ext/error_symbols.rb +2 -0
- data/lib/ext/ffi_library_function_checks.rb +2 -0
- data/lib/ext/float_ext.rb +2 -0
- data/lib/ext/narray_ext.rb +2 -0
- data/lib/ext/numeric_as_data_type.rb +2 -0
- data/lib/ext/to_bool.rb +5 -3
- data/lib/ffi-gdal.rb +2 -0
- data/lib/ffi/cpl.rb +2 -0
- data/lib/ffi/cpl/conv.rb +4 -2
- data/lib/ffi/cpl/error.rb +2 -0
- data/lib/ffi/cpl/hash_set.rb +2 -0
- data/lib/ffi/cpl/http.rb +2 -0
- data/lib/ffi/cpl/http_result.rb +2 -0
- data/lib/ffi/cpl/list.rb +2 -0
- data/lib/ffi/cpl/mime_part.rb +2 -0
- data/lib/ffi/cpl/minixml.rb +2 -0
- data/lib/ffi/cpl/port.rb +2 -0
- data/lib/ffi/cpl/progress.rb +2 -0
- data/lib/ffi/cpl/quad_tree.rb +2 -0
- data/lib/ffi/cpl/rect_obj.rb +2 -0
- data/lib/ffi/cpl/string.rb +2 -0
- data/lib/ffi/cpl/vsi.rb +2 -0
- data/lib/ffi/cpl/xml_node.rb +2 -0
- data/lib/ffi/gdal.rb +3 -3
- data/lib/ffi/gdal/alg.rb +2 -0
- data/lib/ffi/gdal/color_entry.rb +2 -0
- data/lib/ffi/gdal/exceptions.rb +2 -0
- data/lib/ffi/gdal/gcp.rb +2 -0
- data/lib/ffi/gdal/gdal.rb +2 -0
- data/lib/ffi/gdal/grid.rb +2 -0
- data/lib/ffi/gdal/grid_data_metrics_options.rb +2 -0
- data/lib/ffi/gdal/grid_inverse_distance_to_a_power_options.rb +2 -0
- data/lib/ffi/gdal/grid_moving_average_options.rb +2 -0
- data/lib/ffi/gdal/grid_nearest_neighbor_options.rb +2 -0
- data/lib/ffi/gdal/matching.rb +2 -0
- data/lib/ffi/gdal/rpc_info.rb +2 -0
- data/lib/ffi/gdal/transformer_info.rb +2 -0
- data/lib/ffi/gdal/version.rb +3 -1
- data/lib/ffi/gdal/vrt.rb +2 -0
- data/lib/ffi/gdal/warp_options.rb +9 -4
- data/lib/ffi/gdal/warper.rb +19 -1
- data/lib/ffi/ogr.rb +2 -0
- data/lib/ffi/ogr/api.rb +2 -0
- data/lib/ffi/ogr/contour_writer_info.rb +2 -0
- data/lib/ffi/ogr/core.rb +2 -0
- data/lib/ffi/ogr/envelope.rb +2 -0
- data/lib/ffi/ogr/envelope_3d.rb +2 -0
- data/lib/ffi/ogr/featurestyle.rb +2 -0
- data/lib/ffi/ogr/field.rb +2 -0
- data/lib/ffi/ogr/geocoding.rb +2 -0
- data/lib/ffi/ogr/srs_api.rb +3 -0
- data/lib/ffi/ogr/style_param.rb +2 -0
- data/lib/ffi/ogr/style_value.rb +2 -0
- data/lib/gdal.rb +3 -0
- data/lib/gdal/color_entry.rb +2 -0
- data/lib/gdal/color_entry_mixins/extensions.rb +2 -14
- data/lib/gdal/color_interpretation.rb +2 -0
- data/lib/gdal/color_table.rb +2 -0
- data/lib/gdal/color_table_mixins/extensions.rb +3 -17
- data/lib/gdal/color_table_types/cmyk.rb +2 -0
- data/lib/gdal/color_table_types/gray.rb +2 -0
- data/lib/gdal/color_table_types/hls.rb +2 -0
- data/lib/gdal/color_table_types/rgb.rb +2 -0
- data/lib/gdal/cpl_error_handler.rb +2 -0
- data/lib/gdal/data_type.rb +2 -0
- data/lib/gdal/dataset.rb +11 -7
- data/lib/gdal/dataset_mixins/algorithm_methods.rb +7 -4
- data/lib/gdal/dataset_mixins/extensions.rb +7 -47
- data/lib/gdal/dataset_mixins/matching.rb +4 -1
- data/lib/gdal/dataset_mixins/warp_methods.rb +52 -11
- data/lib/gdal/driver.rb +6 -8
- data/lib/gdal/driver_mixins/extensions.rb +2 -0
- data/lib/gdal/environment_methods.rb +2 -0
- data/lib/gdal/exceptions.rb +2 -0
- data/lib/gdal/geo_transform.rb +3 -3
- data/lib/gdal/geo_transform_mixins/extensions.rb +2 -17
- data/lib/gdal/grid.rb +4 -1
- data/lib/gdal/grid_algorithms.rb +2 -0
- data/lib/gdal/grid_algorithms/data_metrics_base.rb +2 -0
- data/lib/gdal/grid_algorithms/inverse_distance_to_a_power.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_average_distance.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_average_distance_pts.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_count.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_maximum.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_minimum.rb +2 -0
- data/lib/gdal/grid_algorithms/metric_range.rb +2 -0
- data/lib/gdal/grid_algorithms/moving_average.rb +2 -0
- data/lib/gdal/grid_algorithms/nearest_neighbor.rb +2 -0
- data/lib/gdal/gridder.rb +11 -3
- data/lib/gdal/gridder/point_extracting.rb +3 -2
- data/lib/gdal/gridder_options.rb +2 -0
- data/lib/gdal/internal_helpers.rb +3 -4
- data/lib/gdal/logger.rb +2 -0
- data/lib/gdal/major_object.rb +2 -0
- data/lib/gdal/merger.rb +2 -0
- data/lib/gdal/options.rb +16 -13
- data/lib/gdal/raster_attribute_table.rb +2 -0
- data/lib/gdal/raster_attribute_table_mixins/extensions.rb +3 -16
- data/lib/gdal/raster_band.rb +11 -6
- data/lib/gdal/raster_band_classifier.rb +52 -19
- data/lib/gdal/raster_band_mixins/algorithm_extensions.rb +2 -0
- data/lib/gdal/raster_band_mixins/algorithm_methods.rb +12 -5
- data/lib/gdal/raster_band_mixins/coloring_extensions.rb +3 -1
- data/lib/gdal/raster_band_mixins/extensions.rb +6 -35
- data/lib/gdal/raster_band_mixins/io_extensions.rb +7 -4
- data/lib/gdal/rpc_info.rb +2 -0
- data/lib/gdal/transformer.rb +2 -0
- data/lib/gdal/transformers/approximate_transformer.rb +4 -1
- data/lib/gdal/transformers/base_general_image_projection_transformer.rb +4 -1
- data/lib/gdal/transformers/gcp_transformer.rb +6 -2
- data/lib/gdal/transformers/general_image_projection_transformer.rb +2 -0
- data/lib/gdal/transformers/general_image_projection_transformer2.rb +4 -1
- data/lib/gdal/transformers/general_image_projection_transformer3.rb +4 -1
- data/lib/gdal/transformers/geolocation_transformer.rb +4 -1
- data/lib/gdal/transformers/reprojection_transformer.rb +2 -0
- data/lib/gdal/transformers/rpc_transformer.rb +4 -1
- data/lib/gdal/transformers/tps_transformer.rb +2 -0
- data/lib/gdal/version_info.rb +9 -7
- data/lib/gdal/virtual_dataset.rb +2 -0
- data/lib/gdal/warp_operation.rb +2 -0
- data/lib/gdal/warp_options.rb +105 -35
- data/lib/ogr.rb +2 -0
- data/lib/ogr/coordinate_transformation.rb +2 -0
- data/lib/ogr/data_source.rb +5 -9
- data/lib/ogr/data_source_extensions.rb +2 -19
- data/lib/ogr/data_source_mixins/capability_methods.rb +2 -0
- data/lib/ogr/driver.rb +4 -6
- data/lib/ogr/driver_mixins/capability_methods.rb +2 -0
- data/lib/ogr/envelope.rb +4 -2
- data/lib/ogr/envelope_extensions.rb +2 -22
- data/lib/ogr/error_handling.rb +3 -1
- data/lib/ogr/exceptions.rb +3 -1
- data/lib/ogr/feature.rb +17 -9
- data/lib/ogr/feature_definition.rb +7 -4
- data/lib/ogr/feature_definition_extensions.rb +2 -18
- data/lib/ogr/feature_extensions.rb +2 -27
- data/lib/ogr/field.rb +5 -1
- data/lib/ogr/field_definition.rb +5 -6
- data/lib/ogr/geocoder.rb +2 -0
- data/lib/ogr/geometries/geometry_collection.rb +2 -0
- data/lib/ogr/geometries/geometry_collection_25d.rb +2 -0
- data/lib/ogr/geometries/line_string.rb +2 -1
- data/lib/ogr/geometries/line_string_25d.rb +2 -0
- data/lib/ogr/geometries/linear_ring.rb +2 -0
- data/lib/ogr/geometries/multi_line_string.rb +2 -0
- data/lib/ogr/geometries/multi_line_string_25d.rb +2 -0
- data/lib/ogr/geometries/multi_point.rb +2 -0
- data/lib/ogr/geometries/multi_point_25d.rb +2 -0
- data/lib/ogr/geometries/multi_polygon.rb +2 -0
- data/lib/ogr/geometries/multi_polygon_25d.rb +2 -0
- data/lib/ogr/geometries/none_geometry.rb +2 -0
- data/lib/ogr/geometries/point.rb +2 -0
- data/lib/ogr/geometries/point_25d.rb +2 -0
- data/lib/ogr/geometries/polygon.rb +2 -0
- data/lib/ogr/geometries/polygon_25d.rb +2 -0
- data/lib/ogr/geometries/unknown_geometry.rb +2 -0
- data/lib/ogr/geometry.rb +3 -4
- data/lib/ogr/geometry_field_definition.rb +3 -4
- data/lib/ogr/geometry_mixins/container_mixins.rb +2 -0
- data/lib/ogr/geometry_mixins/extensions.rb +10 -39
- data/lib/ogr/geometry_types/container.rb +2 -0
- data/lib/ogr/geometry_types/curve.rb +3 -1
- data/lib/ogr/geometry_types/surface.rb +2 -0
- data/lib/ogr/internal_helpers.rb +2 -0
- data/lib/ogr/layer.rb +5 -1
- data/lib/ogr/layer_mixins/capability_methods.rb +2 -0
- data/lib/ogr/layer_mixins/extensions.rb +9 -27
- data/lib/ogr/layer_mixins/ogr_feature_methods.rb +6 -12
- data/lib/ogr/layer_mixins/ogr_field_methods.rb +10 -14
- data/lib/ogr/layer_mixins/ogr_layer_method_methods.rb +2 -0
- data/lib/ogr/layer_mixins/ogr_query_filter_methods.rb +8 -3
- data/lib/ogr/layer_mixins/ogr_sql_methods.rb +3 -3
- data/lib/ogr/spatial_reference.rb +12 -2
- data/lib/ogr/spatial_reference_extensions.rb +2 -26
- data/lib/ogr/spatial_reference_mixins/coordinate_system_getter_setters.rb +12 -5
- data/lib/ogr/spatial_reference_mixins/exporters.rb +2 -0
- data/lib/ogr/spatial_reference_mixins/importers.rb +6 -2
- data/lib/ogr/spatial_reference_mixins/morphers.rb +2 -0
- data/lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb +2 -0
- data/lib/ogr/spatial_reference_mixins/type_checks.rb +2 -0
- data/lib/ogr/style_table.rb +2 -0
- data/lib/ogr/style_table_extensions.rb +2 -10
- data/lib/ogr/style_tool.rb +2 -0
- data/spec/ffi-gdal_spec.rb +2 -0
- data/spec/integration/gdal/color_table_info_spec.rb +2 -0
- data/spec/integration/gdal/dataset_info_spec.rb +15 -13
- data/spec/integration/gdal/driver_info_spec.rb +3 -1
- data/spec/integration/gdal/geo_transform_info_spec.rb +2 -0
- data/spec/integration/gdal/gridder_spec.rb +2 -0
- data/spec/integration/gdal/raster_attribute_table_info_spec.rb +2 -0
- data/spec/integration/gdal/raster_band_algorithms_spec.rb +2 -0
- data/spec/integration/gdal/raster_band_info_spec.rb +37 -15
- data/spec/integration/ogr/layer_spec.rb +2 -6
- data/spec/spec_helper.rb +3 -1
- data/spec/support/images/123.tiff +0 -0
- data/spec/support/integration_help.rb +2 -0
- data/spec/support/shared_contexts.rb +2 -0
- data/spec/support/shared_examples/gdal/major_object_examples.rb +2 -0
- data/spec/support/shared_examples/ogr/{a_25D_geometry.rb → a_25d_geometry.rb} +2 -0
- data/spec/support/shared_examples/ogr/a_container_geometry.rb +2 -0
- data/spec/support/shared_examples/ogr/a_geometry.rb +3 -1
- data/spec/support/shared_examples/ogr/a_line_string.rb +2 -0
- data/spec/unit/ext/error_symbols_spec.rb +2 -0
- data/spec/unit/ext/numeric_as_data_type_spec.rb +2 -0
- data/spec/unit/ffi/gdal_spec.rb +3 -0
- data/spec/unit/gdal/color_entry_spec.rb +2 -0
- data/spec/unit/gdal/color_interpretation_spec.rb +2 -0
- data/spec/unit/gdal/color_table_mixins/extensions_spec.rb +2 -0
- data/spec/unit/gdal/color_table_spec.rb +2 -0
- data/spec/unit/gdal/data_type_spec.rb +2 -0
- data/spec/unit/gdal/dataset_mixins/warp_methods_spec.rb +55 -0
- data/spec/unit/gdal/dataset_spec.rb +2 -0
- data/spec/unit/gdal/driver_mixins/extensions_spec.rb +2 -0
- data/spec/unit/gdal/driver_spec.rb +2 -0
- data/spec/unit/gdal/environment_methods_spec.rb +2 -0
- data/spec/unit/gdal/geo_transform_mixins/extensions_spec.rb +2 -0
- data/spec/unit/gdal/geo_transform_spec.rb +2 -13
- data/spec/unit/gdal/grid_spec.rb +10 -0
- data/spec/unit/gdal/gridder/point_extracting_spec.rb +2 -0
- data/spec/unit/gdal/gridder_options_spec.rb +2 -0
- data/spec/unit/gdal/gridder_spec.rb +42 -0
- data/spec/unit/gdal/internal_helpers_spec.rb +2 -0
- data/spec/unit/gdal/major_object_spec.rb +2 -0
- data/spec/unit/gdal/options_spec.rb +28 -1
- data/spec/unit/gdal/raster_attribute_table_spec.rb +2 -0
- data/spec/unit/gdal/raster_band_classifier_spec.rb +43 -5
- data/spec/unit/gdal/raster_band_mixins/extensions_spec.rb +2 -0
- data/spec/unit/gdal/raster_band_mixins/io_extensions_spec.rb +2 -0
- data/spec/unit/gdal/raster_band_spec.rb +2 -0
- data/spec/unit/gdal/rpc_info_spec.rb +2 -0
- data/spec/unit/gdal/version_info_spec.rb +2 -0
- data/spec/unit/gdal/virtual_dataset_spec.rb +2 -0
- data/spec/unit/gdal/warp_operation_spec.rb +2 -0
- data/spec/unit/gdal/warp_options_spec.rb +338 -0
- data/spec/unit/ogr/coordinate_transformation_spec.rb +2 -0
- data/spec/unit/ogr/data_source_mixins/capability_methods_spec.rb +2 -0
- data/spec/unit/ogr/data_source_spec.rb +2 -0
- data/spec/unit/ogr/driver_mixins/capability_methods_spec.rb +2 -0
- data/spec/unit/ogr/driver_spec.rb +3 -1
- data/spec/unit/ogr/envelope_spec.rb +2 -0
- data/spec/unit/ogr/feature_definition_spec.rb +2 -19
- data/spec/unit/ogr/feature_extensions_spec.rb +3 -1
- data/spec/unit/ogr/feature_spec.rb +3 -3
- data/spec/unit/ogr/field_definition_spec.rb +2 -19
- data/spec/unit/ogr/field_spec.rb +3 -1
- data/spec/unit/ogr/geometries/geometry_collection_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/geometry_collection_spec.rb +2 -0
- data/spec/unit/ogr/geometries/line_string_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/line_string_spec.rb +2 -0
- data/spec/unit/ogr/geometries/linear_ring_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_line_string_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_line_string_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_point_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_point_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_polygon_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/multi_polygon_spec.rb +2 -0
- data/spec/unit/ogr/geometries/none_geometry_spec.rb +2 -0
- data/spec/unit/ogr/geometries/point_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/point_spec.rb +2 -0
- data/spec/unit/ogr/geometries/polygon_25d_spec.rb +2 -0
- data/spec/unit/ogr/geometries/polygon_spec.rb +2 -0
- data/spec/unit/ogr/geometries/unknown_geometry_spec.rb +2 -0
- data/spec/unit/ogr/geometry_field_definition_spec.rb +2 -16
- data/spec/unit/ogr/geometry_spec.rb +2 -0
- data/spec/unit/ogr/internal_helpers_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/capability_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_feature_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_field_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_layer_method_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_query_filter_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_mixins/ogr_sql_methods_spec.rb +2 -0
- data/spec/unit/ogr/layer_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_mixins/coordinate_system_getter_setters_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_mixins/exporters_spec.rb +19 -15
- data/spec/unit/ogr/spatial_reference_mixins/importers_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_mixins/morphers_spec.rb +9 -7
- data/spec/unit/ogr/spatial_reference_mixins/parameter_getter_setters_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_mixins/type_checks_spec.rb +2 -0
- data/spec/unit/ogr/spatial_reference_spec.rb +4 -2
- data/spec/unit/ogr/style_table_spec.rb +2 -26
- data/spec/unit/ogr/style_tool_spec.rb +2 -0
- data/spec/unit/version_info_spec.rb +2 -0
- metadata +47 -15
- data/lib/ogr/field_definition_extensions.rb +0 -22
- data/lib/ogr/geometry_field_definition_extensions.rb +0 -19
@@ -0,0 +1,338 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'gdal/warp_options'
|
5
|
+
|
6
|
+
RSpec.describe GDAL::WarpOptions do
|
7
|
+
shared_examples 'a WarpOptions object' do
|
8
|
+
it 'inits proper types' do
|
9
|
+
expect(subject.warp_operation_options).to be_a Hash
|
10
|
+
|
11
|
+
expect(subject.source_bands).to be_a Array
|
12
|
+
expect(subject.destination_bands).to be_a Array
|
13
|
+
|
14
|
+
expect(subject.source_no_data_real).to be_a Array
|
15
|
+
expect(subject.source_no_data_imaginary).to be_a Array
|
16
|
+
expect(subject.destination_no_data_real).to be_a Array
|
17
|
+
expect(subject.destination_no_data_imaginary).to be_a Array
|
18
|
+
|
19
|
+
expect(subject.progress).to be_a FFI::Function
|
20
|
+
expect(subject.progress_arg).to be_a FFI::Pointer
|
21
|
+
expect(subject.transformer).to be_a FFI::Function
|
22
|
+
expect(subject.transformer_arg).to be_a FFI::Pointer
|
23
|
+
|
24
|
+
expect(subject.source_per_band_validity_mask_function).to be_a FFI::Pointer
|
25
|
+
expect(subject.source_per_band_validity_mask_function_arg).to be_a FFI::Pointer
|
26
|
+
expect(subject.source_validity_mask_function).to be_a FFI::Function
|
27
|
+
expect(subject.source_validity_mask_function_arg).to be_a FFI::Pointer
|
28
|
+
expect(subject.source_density_mask_function).to be_a FFI::Function
|
29
|
+
expect(subject.source_density_mask_function_arg).to be_a FFI::Pointer
|
30
|
+
|
31
|
+
expect(subject.destination_density_mask_function).to be_a FFI::Function
|
32
|
+
expect(subject.destination_density_mask_function_arg).to be_a FFI::Pointer
|
33
|
+
expect(subject.destination_validity_mask_function).to be_a FFI::Function
|
34
|
+
expect(subject.destination_validity_mask_function_arg).to be_a FFI::Pointer
|
35
|
+
|
36
|
+
expect(subject.pre_warp_chunk_processor).to be_a FFI::Function
|
37
|
+
expect(subject.pre_warp_processor_arg).to be_a FFI::Pointer
|
38
|
+
expect(subject.post_warp_chunk_processor).to be_a FFI::Function
|
39
|
+
expect(subject.post_warp_processor_arg).to be_a FFI::Pointer
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#initialize' do
|
44
|
+
context 'with no options' do
|
45
|
+
it_behaves_like 'a WarpOptions object'
|
46
|
+
|
47
|
+
it 'inits a FFI::GDAL::WarpOptions struct internally, with nothing set' do
|
48
|
+
expect(subject.warp_operation_options).to eq({})
|
49
|
+
|
50
|
+
expect(subject.warp_memory_limit).to be_zero
|
51
|
+
expect(subject.resample_alg).to eq(:GRA_NearestNeighbor) # 0 enum
|
52
|
+
expect(subject.working_data_type).to eq(:GDT_Unknown) # 0 enum
|
53
|
+
|
54
|
+
expect(subject.source_dataset).to be_nil
|
55
|
+
expect(subject.destination_dataset).to be_nil
|
56
|
+
|
57
|
+
expect(subject.band_count).to be_zero
|
58
|
+
expect(subject.source_bands).to be_empty
|
59
|
+
expect(subject.destination_bands).to be_empty
|
60
|
+
|
61
|
+
expect(subject.source_alpha_band).to be_zero
|
62
|
+
expect(subject.destination_alpha_band).to be_zero
|
63
|
+
|
64
|
+
expect(subject.source_no_data_real).to eq([])
|
65
|
+
expect(subject.source_no_data_imaginary).to eq([])
|
66
|
+
expect(subject.destination_no_data_real).to eq([])
|
67
|
+
expect(subject.destination_no_data_imaginary).to eq([])
|
68
|
+
|
69
|
+
expect(subject.progress).to_not be_null
|
70
|
+
expect(subject.progress_arg).to be_null
|
71
|
+
|
72
|
+
expect(subject.transformer).to be_null
|
73
|
+
expect(subject.transformer_arg).to be_null
|
74
|
+
|
75
|
+
expect(subject.source_per_band_validity_mask_function).to be_null
|
76
|
+
expect(subject.source_per_band_validity_mask_function_arg).to be_null
|
77
|
+
|
78
|
+
expect(subject.source_validity_mask_function).to be_null
|
79
|
+
expect(subject.source_validity_mask_function_arg).to be_null
|
80
|
+
|
81
|
+
expect(subject.source_density_mask_function).to be_null
|
82
|
+
expect(subject.source_density_mask_function_arg).to be_null
|
83
|
+
|
84
|
+
expect(subject.destination_density_mask_function).to be_null
|
85
|
+
expect(subject.destination_density_mask_function_arg).to be_null
|
86
|
+
|
87
|
+
expect(subject.destination_validity_mask_function).to be_null
|
88
|
+
expect(subject.destination_validity_mask_function_arg).to be_null
|
89
|
+
|
90
|
+
expect(subject.pre_warp_chunk_processor).to be_null
|
91
|
+
expect(subject.pre_warp_processor_arg).to be_null
|
92
|
+
expect(subject.post_warp_chunk_processor).to be_null
|
93
|
+
expect(subject.post_warp_processor_arg).to be_null
|
94
|
+
|
95
|
+
expect(subject.cutline).to be_nil
|
96
|
+
expect(subject.cutline_blend_distance).to eq(0.0)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'passing in options that are also accessor methods' do
|
101
|
+
let(:warp_operation_options) do
|
102
|
+
{
|
103
|
+
init_dest: 'NODATA',
|
104
|
+
write_flush: 'YES',
|
105
|
+
skip_nosource: 'NO',
|
106
|
+
sample_grid: 'YES'
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
110
|
+
let(:memory_driver) { GDAL::Driver.by_name('MEM') }
|
111
|
+
let(:source_dataset) { memory_driver.create_dataset 'source', 10, 20 }
|
112
|
+
let(:dest_dataset) { memory_driver.create_dataset 'dest', 20, 30 }
|
113
|
+
let(:cutline) { OGR::LineString.new }
|
114
|
+
let(:spb_validity_mask_function1) { proc { true } }
|
115
|
+
let(:spb_validity_mask_function2) { proc { false } }
|
116
|
+
|
117
|
+
after do
|
118
|
+
source_dataset.close
|
119
|
+
dest_dataset.close
|
120
|
+
end
|
121
|
+
|
122
|
+
subject do
|
123
|
+
described_class.new warp_operation_options: warp_operation_options,
|
124
|
+
source_dataset: source_dataset,
|
125
|
+
destination_dataset: dest_dataset,
|
126
|
+
source_bands: [1, 2, 3],
|
127
|
+
destination_bands: [2, 4, 6],
|
128
|
+
cutline: cutline,
|
129
|
+
source_no_data_real: [123.456, 78.9, -999.9],
|
130
|
+
source_no_data_imaginary: [1.2, 3.4, -5.6],
|
131
|
+
destination_no_data_real: [11.1, 22.2, 33.3],
|
132
|
+
destination_no_data_imaginary: [-44.4, -55.5, -66.6],
|
133
|
+
source_per_band_validity_mask_function: [
|
134
|
+
spb_validity_mask_function1,
|
135
|
+
spb_validity_mask_function2
|
136
|
+
]
|
137
|
+
end
|
138
|
+
|
139
|
+
it_behaves_like 'a WarpOptions object'
|
140
|
+
|
141
|
+
it 'sets warp_operation_options' do
|
142
|
+
expect(subject.warp_operation_options).to eq(warp_operation_options)
|
143
|
+
end
|
144
|
+
|
145
|
+
it' sets source_dataset and the internal pointer' do
|
146
|
+
expect(subject.source_dataset).to eq(source_dataset)
|
147
|
+
expect(subject.c_struct[:source_dataset]).to eq(source_dataset.c_pointer)
|
148
|
+
end
|
149
|
+
|
150
|
+
it' sets destination_dataset' do
|
151
|
+
expect(subject.destination_dataset).to eq(dest_dataset)
|
152
|
+
expect(subject.c_struct[:destination_dataset]).to eq(dest_dataset.c_pointer)
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'sets source_bands' do
|
156
|
+
expect(subject.source_bands).to eq([1, 2, 3])
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'sets destination_bands' do
|
160
|
+
expect(subject.destination_bands).to eq([2, 4, 6])
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'sets band_count and the internal to 3' do
|
164
|
+
expect(subject.band_count).to eq 3
|
165
|
+
expect(subject.c_struct[:band_count]).to eq 3
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'sets cutline and its internal pointer' do
|
169
|
+
expect(subject.cutline).to eq(cutline)
|
170
|
+
expect(subject.c_struct[:cutline]).to eq(cutline.c_pointer)
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'sets source_no_data_real' do
|
174
|
+
expect(subject.source_no_data_real).to eq([123.456, 78.9, -999.9])
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'sets source_no_data_imaginary' do
|
178
|
+
expect(subject.source_no_data_imaginary).to eq([1.2, 3.4, -5.6])
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'sets destination_no_data_real' do
|
182
|
+
expect(subject.destination_no_data_real).to eq([11.1, 22.2, 33.3])
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'sets destination_no_data_imaginary' do
|
186
|
+
expect(subject.destination_no_data_imaginary).to eq([-44.4, -55.5, -66.6])
|
187
|
+
end
|
188
|
+
|
189
|
+
it 'sets source_per_band_validity_mask_function' do
|
190
|
+
function_ptr = subject.source_per_band_validity_mask_function
|
191
|
+
expect(function_ptr).to be_a(FFI::Pointer)
|
192
|
+
|
193
|
+
function = function_ptr.read_pointer
|
194
|
+
expect(function).to_not be_null
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
context 'passing in options that are NOT accessor methods' do
|
199
|
+
def make_int_pointer(int)
|
200
|
+
i = FFI::MemoryPointer.new(:int)
|
201
|
+
i.write_int(int)
|
202
|
+
i
|
203
|
+
end
|
204
|
+
|
205
|
+
let(:progress) { proc { true } }
|
206
|
+
let(:test_mask_function) { proc { true } }
|
207
|
+
|
208
|
+
let(:source_per_band_validity_mask_function_arg) { make_int_pointer(5) }
|
209
|
+
let(:source_validity_mask_function_arg) { make_int_pointer(3) }
|
210
|
+
let(:source_density_mask_function_arg) { make_int_pointer(2) }
|
211
|
+
let(:destination_validity_mask_function_arg) { make_int_pointer(4) }
|
212
|
+
let(:destination_density_mask_function_arg) { make_int_pointer(11) }
|
213
|
+
let(:pre_warp_processor_arg) { make_int_pointer(7) }
|
214
|
+
let(:post_warp_processor_arg) { make_int_pointer(9) }
|
215
|
+
|
216
|
+
subject do
|
217
|
+
described_class.new warp_memory_limit: 123,
|
218
|
+
resample_alg: :GRA_Lanczos,
|
219
|
+
working_data_type: :GDT_CInt32,
|
220
|
+
band_count: 3,
|
221
|
+
source_alpha_band: 1,
|
222
|
+
destination_alpha_band: 5,
|
223
|
+
progress: progress,
|
224
|
+
progress_arg: FFI::CPL::Progress::ScaledProgress,
|
225
|
+
source_per_band_validity_mask_function_arg: source_per_band_validity_mask_function_arg,
|
226
|
+
source_validity_mask_function: test_mask_function,
|
227
|
+
source_validity_mask_function_arg: source_validity_mask_function_arg,
|
228
|
+
source_density_mask_function: test_mask_function,
|
229
|
+
source_density_mask_function_arg: source_density_mask_function_arg,
|
230
|
+
destination_validity_mask_function: test_mask_function,
|
231
|
+
destination_validity_mask_function_arg: destination_validity_mask_function_arg,
|
232
|
+
destination_density_mask_function: test_mask_function,
|
233
|
+
destination_density_mask_function_arg: destination_density_mask_function_arg,
|
234
|
+
pre_warp_chunk_processor: proc { :CE_Warning },
|
235
|
+
pre_warp_processor_arg: pre_warp_processor_arg,
|
236
|
+
post_warp_chunk_processor: proc { :CE_Failure },
|
237
|
+
post_warp_processor_arg: post_warp_processor_arg,
|
238
|
+
cutline_blend_distance: 3.3
|
239
|
+
end
|
240
|
+
|
241
|
+
it_behaves_like 'a WarpOptions object'
|
242
|
+
|
243
|
+
it 'sets warp_memory_limit' do
|
244
|
+
expect(subject.warp_memory_limit).to eq(123)
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'sets resample_alg' do
|
248
|
+
expect(subject.resample_alg).to eq(:GRA_Lanczos)
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'sets working_data_type' do
|
252
|
+
expect(subject.working_data_type).to eq(:GDT_CInt32)
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'sets band_count' do
|
256
|
+
expect(subject.band_count).to eq(3)
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'sets source_alpha_band' do
|
260
|
+
expect(subject.source_alpha_band).to eq(1)
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'sets destination_alpha_band' do
|
264
|
+
expect(subject.destination_alpha_band).to eq(5)
|
265
|
+
end
|
266
|
+
|
267
|
+
it 'sets progress_arg' do
|
268
|
+
expect(subject.progress_arg).to eq(FFI::CPL::Progress::ScaledProgress)
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'sets source_per_band_validity_mask_function_arg' do
|
272
|
+
pointer = subject.source_per_band_validity_mask_function_arg
|
273
|
+
pointer.autorelease = false
|
274
|
+
expect(pointer.read_int).to eq 5
|
275
|
+
end
|
276
|
+
|
277
|
+
it 'sets source_validity_mask_function' do
|
278
|
+
expect(subject.source_validity_mask_function).to_not be_null
|
279
|
+
end
|
280
|
+
|
281
|
+
it 'sets source_validity_mask_function_arg' do
|
282
|
+
pointer = subject.source_validity_mask_function_arg
|
283
|
+
pointer.autorelease = false
|
284
|
+
expect(pointer.read_int).to eq 3
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'sets source_density_mask_function' do
|
288
|
+
expect(subject.source_density_mask_function).to_not be_null
|
289
|
+
end
|
290
|
+
|
291
|
+
it 'sets source_density_mask_function_arg' do
|
292
|
+
pointer = subject.source_density_mask_function_arg
|
293
|
+
pointer.autorelease = false
|
294
|
+
expect(pointer.read_int).to eq 2
|
295
|
+
end
|
296
|
+
|
297
|
+
it 'sets destination_validity_mask_function' do
|
298
|
+
expect(subject.destination_validity_mask_function).to_not be_null
|
299
|
+
end
|
300
|
+
|
301
|
+
it 'sets destination_validity_mask_function_arg' do
|
302
|
+
pointer = subject.destination_validity_mask_function_arg
|
303
|
+
pointer.autorelease = false
|
304
|
+
expect(pointer.read_int).to eq 4
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'sets destination_density_mask_function' do
|
308
|
+
expect(subject.destination_density_mask_function).to_not be_null
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'sets destination_density_mask_function_arg' do
|
312
|
+
pointer = subject.destination_density_mask_function_arg
|
313
|
+
pointer.autorelease = false
|
314
|
+
expect(pointer.read_int).to eq 11
|
315
|
+
end
|
316
|
+
|
317
|
+
it 'sets pre_warp_chunk_processor' do
|
318
|
+
expect(subject.pre_warp_chunk_processor.call(nil, nil)).to eq(:CE_Warning)
|
319
|
+
end
|
320
|
+
|
321
|
+
it 'sets pre_warp_chunk_processor_arg' do
|
322
|
+
expect(subject.pre_warp_processor_arg).to_not be_null
|
323
|
+
end
|
324
|
+
|
325
|
+
it 'sets post_warp_chunk_processor' do
|
326
|
+
expect(subject.post_warp_chunk_processor.call(nil, nil)).to eq(:CE_Failure)
|
327
|
+
end
|
328
|
+
|
329
|
+
it 'sets post_warp_chunk_processor_arg' do
|
330
|
+
expect(subject.post_warp_processor_arg).to_not be_null
|
331
|
+
end
|
332
|
+
|
333
|
+
it 'sets cutline_blend_distance' do
|
334
|
+
expect(subject.cutline_blend_distance).to eq(3.3)
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'ogr/driver'
|
3
5
|
|
4
6
|
RSpec.describe OGR::Driver do
|
5
7
|
describe '.count' do
|
6
8
|
subject { described_class.count }
|
7
|
-
it { is_expected.to be_a
|
9
|
+
it { is_expected.to be_a Integer }
|
8
10
|
end
|
9
11
|
|
10
12
|
describe '.by_name' do
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'ogr/feature_definition'
|
3
5
|
|
@@ -291,23 +293,4 @@ RSpec.describe OGR::FeatureDefinition do
|
|
291
293
|
end
|
292
294
|
end
|
293
295
|
end
|
294
|
-
|
295
|
-
describe '#as_json' do
|
296
|
-
it 'returns a Hash of all attributes and values' do
|
297
|
-
expect(subject.as_json).to eq(field_count: 0,
|
298
|
-
field_definitions: [],
|
299
|
-
geometry_field_count: 1,
|
300
|
-
geometry_type: :wkbMultiPolygon,
|
301
|
-
is_geometry_ignored: false,
|
302
|
-
is_style_ignored: false,
|
303
|
-
name: 'spec feature definition')
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
describe '#to_json' do
|
308
|
-
it 'is a String' do
|
309
|
-
expect(subject.to_json).to be_a String
|
310
|
-
expect(subject.to_json).to_not be_empty
|
311
|
-
end
|
312
|
-
end
|
313
296
|
end
|