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,101 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'gdal/gridder'
|
5
|
-
|
6
|
-
RSpec.describe GDAL::Gridder do
|
7
|
-
let(:source_layer) { instance_double 'OGR::Layer' }
|
8
|
-
let(:dest_file_name) { 'blah.docx' }
|
9
|
-
let(:gridder_options) { instance_double 'GDAL::GridderOptions' }
|
10
|
-
|
11
|
-
subject(:gridder) { described_class.new(source_layer, dest_file_name, gridder_options) }
|
12
|
-
|
13
|
-
describe '#points' do
|
14
|
-
let(:clipping_geometry) { instance_double 'OGR::LineString' }
|
15
|
-
|
16
|
-
before do
|
17
|
-
expect(subject).to receive(:ensure_z_values)
|
18
|
-
allow(gridder_options).to receive(:input_clipping_geometry).and_return clipping_geometry
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'input_field_name is set' do
|
22
|
-
before { allow(gridder_options).to receive(:input_field_name).and_return 'things' }
|
23
|
-
|
24
|
-
it 'gets points with attributes by the input_field_name' do
|
25
|
-
expect(subject).to receive(:points_with_field_attributes).
|
26
|
-
with(source_layer, 'things', clipping_geometry).and_return [[0, 0, 0], [1, 1, 1]]
|
27
|
-
|
28
|
-
subject.points
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'returns an NArray' do
|
32
|
-
allow(subject).to receive(:points_with_field_attributes).
|
33
|
-
with(source_layer, 'things', clipping_geometry).and_return [[0, 0, 0], [1, 1, 1]]
|
34
|
-
|
35
|
-
expect(subject.points).to eq([[0, 0, 0], [1, 1, 1]])
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'input_field_name is not set' do
|
40
|
-
before { allow(gridder_options).to receive(:input_field_name).and_return nil }
|
41
|
-
|
42
|
-
it 'gets points with attributes without the input_field_name' do
|
43
|
-
expect(subject).to receive(:points_no_field_attributes).
|
44
|
-
with(source_layer, clipping_geometry).and_return [[0, 0, 0], [1, 1, 1]]
|
45
|
-
|
46
|
-
subject.points
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'returns an NArray' do
|
50
|
-
allow(subject).to receive(:points_no_field_attributes).
|
51
|
-
with(source_layer, clipping_geometry).and_return [[0, 0, 0], [1, 1, 1]]
|
52
|
-
|
53
|
-
expect(subject.points).to eq([[0, 0, 0], [1, 1, 1]])
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#ensure_z_values' do
|
59
|
-
context 'layer does not have a field by the requested name' do
|
60
|
-
before do
|
61
|
-
allow(subject).to receive(:layer_missing_specified_field?).and_return true
|
62
|
-
allow(gridder_options).to receive(:input_field_name).and_return 'meow'
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'raises an OGR::InvalidFieldName' do
|
66
|
-
expect { subject.send(:ensure_z_values) }.to raise_exception OGR::InvalidFieldName
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'no requested field name set and layer has no geometries with Z values' do
|
71
|
-
before do
|
72
|
-
allow(subject).to receive(:layer_missing_specified_field?).and_return false
|
73
|
-
allow(gridder_options).to receive(:input_field_name).and_return nil
|
74
|
-
allow(source_layer).to receive(:any_geometries_with_z?).and_return false
|
75
|
-
allow(source_layer).to receive(:name).and_return 'meow'
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'raises an GDAL::NoValuesToGrid' do
|
79
|
-
expect { subject.send(:ensure_z_values) }.to raise_exception GDAL::NoValuesToGrid
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe '#layer_missing_specified_field?' do
|
85
|
-
subject { gridder.send(:layer_missing_specified_field?) }
|
86
|
-
|
87
|
-
context 'input_field_name not set' do
|
88
|
-
before { allow(gridder_options).to receive(:input_field_name).and_return nil }
|
89
|
-
it { is_expected.to be false }
|
90
|
-
end
|
91
|
-
|
92
|
-
context 'input_field_name set but layer does not contain fields with that name' do
|
93
|
-
before do
|
94
|
-
allow(gridder_options).to receive(:input_field_name).and_return 'things'
|
95
|
-
expect(source_layer).to receive(:find_field_index).with('things').and_return nil
|
96
|
-
end
|
97
|
-
|
98
|
-
it { is_expected.to be true }
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,185 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'gdal/gridder_options'
|
5
|
-
|
6
|
-
RSpec.describe GDAL::GridderOptions do
|
7
|
-
subject(:gridder_options) { described_class.new(:metric_count) }
|
8
|
-
|
9
|
-
describe 'attributes' do
|
10
|
-
it { is_expected.to respond_to :input_clipping_geometry }
|
11
|
-
it { is_expected.to respond_to :input_clipping_geometry= }
|
12
|
-
it { is_expected.to respond_to :input_field_name }
|
13
|
-
it { is_expected.to respond_to :input_field_name= }
|
14
|
-
|
15
|
-
it { is_expected.to respond_to :progress_formatter }
|
16
|
-
it { is_expected.to respond_to :progress_formatter= }
|
17
|
-
it { is_expected.to respond_to :grid }
|
18
|
-
it { is_expected.to respond_to :algorithm_options }
|
19
|
-
|
20
|
-
it { is_expected.to respond_to :output_creation_options }
|
21
|
-
it { is_expected.to respond_to :output_creation_options= }
|
22
|
-
it { is_expected.to respond_to :output_format }
|
23
|
-
it { is_expected.to respond_to :output_format= }
|
24
|
-
it { is_expected.to respond_to :output_x_extent }
|
25
|
-
it { is_expected.to respond_to :output_x_extent= }
|
26
|
-
it { is_expected.to respond_to :output_y_extent }
|
27
|
-
it { is_expected.to respond_to :output_y_extent= }
|
28
|
-
it { is_expected.to respond_to :output_projection }
|
29
|
-
it { is_expected.to respond_to :output_projection= }
|
30
|
-
it { is_expected.to respond_to :output_size }
|
31
|
-
it { is_expected.to respond_to :output_size= }
|
32
|
-
it { is_expected.to respond_to :output_data_type }
|
33
|
-
it { is_expected.to respond_to :output_data_type= }
|
34
|
-
end
|
35
|
-
|
36
|
-
describe 'default values' do
|
37
|
-
describe '#output_data_type' do
|
38
|
-
subject { gridder_options.output_data_type }
|
39
|
-
it { is_expected.to eq :GDT_Float64 }
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '#output_format' do
|
43
|
-
subject { gridder_options.output_format }
|
44
|
-
it { is_expected.to eq 'GTiff' }
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#output_size' do
|
48
|
-
subject { gridder_options.output_size }
|
49
|
-
it { is_expected.to eq(width: 256, height: 256) }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#input_clipping_geometry=' do
|
54
|
-
context 'param is a OGR::Geometry' do
|
55
|
-
it 'sets the attribute' do
|
56
|
-
geom = OGR::Point.new
|
57
|
-
subject.input_clipping_geometry = geom
|
58
|
-
expect(subject.input_clipping_geometry).to eq geom
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'param is not a OGR::Geometry' do
|
63
|
-
it 'raises a OGR::InvalidGeometry exception' do
|
64
|
-
expect { subject.input_clipping_geometry = 'meow' }.
|
65
|
-
to raise_exception OGR::InvalidGeometry
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#output_data_type=' do
|
71
|
-
context 'param is a FFI::GDAL::GDAL::DataType' do
|
72
|
-
it 'sets the attribute and the grid data type' do
|
73
|
-
subject.output_data_type = :GDT_Byte
|
74
|
-
expect(subject.output_data_type).to eq :GDT_Byte
|
75
|
-
expect(subject.grid.data_type).to eq :GDT_Byte
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'param is not a FFI::GDAL::GDAL::DataType' do
|
80
|
-
it 'raises a OGR::InvalidGeometry exception' do
|
81
|
-
expect { subject.output_data_type = 'meow' }.
|
82
|
-
to raise_exception GDAL::InvalidDataType
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '#output_format=' do
|
88
|
-
context 'param is a GDAL::Driver short name' do
|
89
|
-
it 'sets the attribute' do
|
90
|
-
subject.output_format = 'SAGA'
|
91
|
-
expect(subject.output_format).to eq 'SAGA'
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context 'param is not a GDAL::Driver short name' do
|
96
|
-
it 'raises a GDAL::InvalidDriverName exception' do
|
97
|
-
expect { subject.output_format = 'meow' }.
|
98
|
-
to raise_exception GDAL::InvalidDriverName
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe '#output_x_extent=' do
|
104
|
-
it 'returns a Hash with min and max keys' do
|
105
|
-
expect(subject).to receive(:extract_min_max).with(%w[some values], :min, :max).
|
106
|
-
and_return(%w[some values])
|
107
|
-
subject.output_x_extent = %w[some values]
|
108
|
-
expect(subject.output_x_extent).to eq(min: 'some', max: 'values')
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe '#output_y_extent=' do
|
113
|
-
it 'returns a Hash with min and max keys' do
|
114
|
-
expect(subject).to receive(:extract_min_max).with(%w[some values], :min, :max).
|
115
|
-
and_return(%w[some values])
|
116
|
-
subject.output_y_extent = %w[some values]
|
117
|
-
expect(subject.output_y_extent).to eq(min: 'some', max: 'values')
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
describe '#output_size=' do
|
122
|
-
it 'returns a Hash with min and max keys' do
|
123
|
-
expect(subject).to receive(:extract_min_max).with(%w[some values], :width, :height).
|
124
|
-
and_return(%w[some values])
|
125
|
-
subject.output_size = %w[some values]
|
126
|
-
expect(subject.output_size).to eq(width: 'some', height: 'values')
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe '#output_projection=' do
|
131
|
-
context 'param is a OGR::SpatialReference' do
|
132
|
-
it 'sets the attribute' do
|
133
|
-
projection = OGR::SpatialReference.new_from_epsg(4326)
|
134
|
-
subject.output_projection = projection
|
135
|
-
expect(subject.output_projection).to eq projection
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
context 'param is not a OGR::SpatialReference' do
|
140
|
-
it 'raises a OGR::InvalidSpatialReference exception' do
|
141
|
-
expect { subject.output_projection = 'meow' }.
|
142
|
-
to raise_exception OGR::InvalidSpatialReference
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe '#extract_min_max_from_array' do
|
148
|
-
context 'param is a 2-element Array' do
|
149
|
-
it 'sets the attribute' do
|
150
|
-
expect(subject.send(:extract_min_max_from_array, [1, 20], :foo, :bar)).
|
151
|
-
to eq([1, 20])
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
context 'param is an Array with not 2 elements' do
|
156
|
-
it 'raises an ArgumentError' do
|
157
|
-
expect { subject.send(:extract_min_max_from_array, [1, 20, 30], :foo, :bar) }.
|
158
|
-
to raise_exception ArgumentError
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
describe '#extract_min_max_from_hash' do
|
164
|
-
context 'param is a Hash with :min and :max keys' do
|
165
|
-
it 'sets the attribute' do
|
166
|
-
expect(subject.send(:extract_min_max_from_hash, { min: 1, max: 20 }, :min, :max)).
|
167
|
-
to eq([1, 20])
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
context 'param is a Hash with :min, :max, and :other' do
|
172
|
-
it 'raises an ArgumentError' do
|
173
|
-
expect { subject.send(:extract_min_max_from_hash, { min: 1, max: 20, other: 30 }, :min, :max) }.
|
174
|
-
to raise_exception ArgumentError
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
context 'param is a Hash without :min and :max' do
|
179
|
-
it 'raises an ArgumentError' do
|
180
|
-
expect { subject.send(:extract_min_max_from_hash, { things: 1, stuff: 20 }, :min, :max) }.
|
181
|
-
to raise_exception ArgumentError
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
@@ -1,182 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'gdal/gridder'
|
5
|
-
|
6
|
-
RSpec.describe GDAL::Gridder do
|
7
|
-
let(:source_layer) { instance_double 'OGR::Layer' }
|
8
|
-
let(:dest_file_name) { 'blah.docx' }
|
9
|
-
let(:gridder_options) { instance_double 'GDAL::GridderOptions' }
|
10
|
-
|
11
|
-
subject(:gridder) { described_class.new(source_layer, dest_file_name, gridder_options) }
|
12
|
-
|
13
|
-
describe '#build_output_spatial_reference' do
|
14
|
-
let(:spatial_reference) { instance_double 'OGR::SpatialRefernce' }
|
15
|
-
|
16
|
-
context 'no output_projection given, source layer has one set' do
|
17
|
-
before do
|
18
|
-
allow(gridder_options).to receive(:output_projection).and_return nil
|
19
|
-
allow(source_layer).to receive(:spatial_reference).and_return spatial_reference
|
20
|
-
allow(spatial_reference).to receive(:to_wkt).and_return 'BLAH'
|
21
|
-
end
|
22
|
-
|
23
|
-
it "returns WKT of the source layer's SpatialReference" do
|
24
|
-
expect(subject.send(:build_output_spatial_reference)).to eq 'BLAH'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'output_projection given' do
|
29
|
-
before do
|
30
|
-
allow(gridder_options).to receive(:output_projection).and_return spatial_reference
|
31
|
-
allow(spatial_reference).to receive(:to_wkt).and_return 'MEOW'
|
32
|
-
end
|
33
|
-
|
34
|
-
it "returns WKT of the source layer's SpatialReference" do
|
35
|
-
expect(subject.send(:build_output_spatial_reference)).to eq 'MEOW'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'no output_projection given, source layer does not have one set' do
|
40
|
-
before do
|
41
|
-
allow(gridder_options).to receive(:output_projection).and_return nil
|
42
|
-
allow(source_layer).to receive(:spatial_reference).and_return nil
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'returns nil' do
|
46
|
-
expect(subject.send(:build_output_spatial_reference)).to eq nil
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '#x_min' do
|
52
|
-
context 'output_x_extent is set' do
|
53
|
-
before { allow(gridder_options).to receive(:output_x_extent).and_return(min: 123) }
|
54
|
-
|
55
|
-
it 'sets x_min to that value' do
|
56
|
-
expect(subject.send(:x_min)).to eq 123
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'output_x_extent is not set' do
|
61
|
-
let(:extent) { instance_double 'OGR::Envelope', x_min: 456 }
|
62
|
-
|
63
|
-
before do
|
64
|
-
allow(gridder_options).to receive(:output_x_extent).and_return({})
|
65
|
-
allow(source_layer).to receive(:extent).and_return extent
|
66
|
-
end
|
67
|
-
|
68
|
-
it "sets x_min to the source layer's extent's x_min value" do
|
69
|
-
expect(subject.send(:x_min)).to eq 456
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#x_max' do
|
75
|
-
context 'output_x_extent is set' do
|
76
|
-
before { allow(gridder_options).to receive(:output_x_extent).and_return(max: 321) }
|
77
|
-
|
78
|
-
it 'sets x_max to that value' do
|
79
|
-
expect(subject.send(:x_max)).to eq 321
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
context 'output_x_extent is not set' do
|
84
|
-
let(:extent) { instance_double 'OGR::Envelope', x_max: 654 }
|
85
|
-
|
86
|
-
before do
|
87
|
-
allow(gridder_options).to receive(:output_x_extent).and_return({})
|
88
|
-
allow(source_layer).to receive(:extent).and_return extent
|
89
|
-
end
|
90
|
-
|
91
|
-
it "sets x_max to the source layer's extent's x_max value" do
|
92
|
-
expect(subject.send(:x_max)).to eq 654
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '#y_min' do
|
98
|
-
context 'output_y_extent is set' do
|
99
|
-
before { allow(gridder_options).to receive(:output_y_extent).and_return(min: 123) }
|
100
|
-
|
101
|
-
it 'sets y_min to that value' do
|
102
|
-
expect(subject.send(:y_min)).to eq 123
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'output_y_extent is not set' do
|
107
|
-
let(:extent) { instance_double 'OGR::Envelope', y_min: 456 }
|
108
|
-
|
109
|
-
before do
|
110
|
-
allow(gridder_options).to receive(:output_y_extent).and_return({})
|
111
|
-
allow(source_layer).to receive(:extent).and_return extent
|
112
|
-
end
|
113
|
-
|
114
|
-
it "sets y_min to the source layer's extent's y_min value" do
|
115
|
-
expect(subject.send(:y_min)).to eq 456
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe '#y_max' do
|
121
|
-
context 'output_y_extent is set' do
|
122
|
-
before { allow(gridder_options).to receive(:output_y_extent).and_return(max: 321) }
|
123
|
-
|
124
|
-
it 'sets y_max to that value' do
|
125
|
-
expect(subject.send(:y_max)).to eq 321
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
context 'output_y_extent is not set' do
|
130
|
-
let(:extent) { instance_double 'OGR::Envelope', y_max: 654 }
|
131
|
-
|
132
|
-
before do
|
133
|
-
allow(gridder_options).to receive(:output_y_extent).and_return({})
|
134
|
-
allow(source_layer).to receive(:extent).and_return extent
|
135
|
-
end
|
136
|
-
|
137
|
-
it "sets y_max to the source layer's extent's y_max value" do
|
138
|
-
expect(subject.send(:y_max)).to eq 654
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe '#build_block_count' do
|
144
|
-
it 'builds block sizes for both x and y' do
|
145
|
-
raster_width = 4
|
146
|
-
block_x_size = 2
|
147
|
-
raster_height = 5
|
148
|
-
block_y_size = 3
|
149
|
-
|
150
|
-
expect(subject).to receive(:build_block_size).with(raster_width, block_x_size).
|
151
|
-
and_call_original
|
152
|
-
expect(subject).to receive(:build_block_size).with(raster_height, block_y_size).
|
153
|
-
and_call_original
|
154
|
-
|
155
|
-
subject.send(:build_block_count, block_x_size, block_y_size, raster_width, raster_height)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
describe '#build_block_size' do
|
160
|
-
context 'calculation should not be evenly divisible' do
|
161
|
-
it 'returns the floor of the count' do
|
162
|
-
raster_width = 4
|
163
|
-
block_x_size = 2
|
164
|
-
|
165
|
-
result = subject.send(:build_block_size, raster_width, block_x_size)
|
166
|
-
|
167
|
-
expect(result).to eq 2
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
context 'calculation should be evenly divisible' do
|
172
|
-
it 'returns the floor of the count' do
|
173
|
-
raster_width = 4
|
174
|
-
block_x_size = 1
|
175
|
-
|
176
|
-
result = subject.send(:build_block_size, raster_width, block_x_size)
|
177
|
-
|
178
|
-
expect(result).to eq 4
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|