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,170 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'ffi-gdal'
|
5
|
-
require 'gdal'
|
6
|
-
|
7
|
-
RSpec.describe 'Driver Info', type: :integration do
|
8
|
-
# Without this before block, tests fail--seemingly due to too many instances
|
9
|
-
# of the same driver open. Seems like there might be a better solution than
|
10
|
-
# this here, but I'm not sure what it is yet.
|
11
|
-
before { ::FFI::GDAL::GDAL.GDALAllRegister }
|
12
|
-
let(:tmp_source_tiff) { make_temp_test_file(original_source_tiff) }
|
13
|
-
|
14
|
-
let(:original_source_tiff) do
|
15
|
-
path = '../../../spec/support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif'
|
16
|
-
File.expand_path(path, __dir__)
|
17
|
-
end
|
18
|
-
|
19
|
-
subject { GDAL::Driver.by_name 'GTiff' }
|
20
|
-
|
21
|
-
it_behaves_like 'a major object'
|
22
|
-
|
23
|
-
describe '.count' do
|
24
|
-
it 'is a non-zero Integer' do
|
25
|
-
expect(GDAL::Driver.count).to be_a Integer
|
26
|
-
expect(GDAL::Driver.count).to be > 0
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#c_pointer' do
|
31
|
-
it 'is a FFI::Pointer to the actual C driver' do
|
32
|
-
expect(subject.c_pointer).to be_a FFI::Pointer
|
33
|
-
expect(subject.c_pointer).to_not be_null
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#short_name' do
|
38
|
-
it 'is GTiff' do
|
39
|
-
expect(subject.short_name).to eq('GTiff')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#long_name' do
|
44
|
-
it 'is GeoTiff' do
|
45
|
-
expect(subject.long_name).to eq 'GeoTIFF'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#help_topic' do
|
50
|
-
it 'is http://gdal.org/frmt_gtiff.html' do
|
51
|
-
expect(subject.help_topic).to eq 'http://gdal.org/frmt_gtiff.html'
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '#creation_option_list' do
|
56
|
-
it 'is an Array of Hashes' do
|
57
|
-
expect(subject.creation_option_list).to be_an Array
|
58
|
-
expect(subject.creation_option_list.first).to be_a Hash
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe '#validate_creation_options' do
|
63
|
-
context 'valid options for the driver' do
|
64
|
-
let(:options) do
|
65
|
-
{
|
66
|
-
'COMPRESS' => 'JPEG',
|
67
|
-
'JPEG_QUALITY' => 90,
|
68
|
-
'INTERLEAVE' => 'BAND'
|
69
|
-
}
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'returns true' do
|
73
|
-
expect(subject.validate_creation_options(options)).to eq true
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'invalid options for the driver' do
|
78
|
-
let(:options) do
|
79
|
-
{ 'THINGS' => 123 }
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'returns false' do
|
83
|
-
expect(subject.validate_creation_options(options)).to eq false
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe '#copy_dataset_files' do
|
89
|
-
let(:dest_tiff) { File.expand_path('copied_tiff.tif', 'tmp') }
|
90
|
-
after { File.unlink(dest_tiff) if File.exist?(dest_tiff) }
|
91
|
-
|
92
|
-
context 'source is a GTiff' do
|
93
|
-
it 'copies the file' do
|
94
|
-
subject.copy_dataset_files(tmp_source_tiff, dest_tiff)
|
95
|
-
expect(File.exist?(dest_tiff)).to eq true
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context 'source is of a different file type than the driver supports' do
|
100
|
-
let(:source_file) { __FILE__ }
|
101
|
-
|
102
|
-
it 'copies the file' do
|
103
|
-
expect { subject.copy_dataset_files(source_file, dest_tiff) }.
|
104
|
-
to raise_exception(GDAL::OpenFailure)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe '#create_dataset' do
|
110
|
-
let(:new_dataset_path) { 'tmp/driver_create_dataset.tif' }
|
111
|
-
after { File.unlink(new_dataset_path) if File.exist?(new_dataset_path) }
|
112
|
-
|
113
|
-
it 'creates a dataset' do
|
114
|
-
dataset = subject.create_dataset(new_dataset_path, 2, 2)
|
115
|
-
|
116
|
-
expect(File.exist?(new_dataset_path)).to eq true
|
117
|
-
expect(dataset).to be_a GDAL::Dataset
|
118
|
-
expect(dataset.raster_x_size).to eq 2
|
119
|
-
expect(dataset.raster_y_size).to eq 2
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
describe '#copy_dataset' do
|
124
|
-
let(:copy_dataset_path) { 'tmp/driver_copy_dataset.tif' }
|
125
|
-
let(:source_dataset) { GDAL::Dataset.open(tmp_source_tiff, 'r') }
|
126
|
-
after { source_dataset.close }
|
127
|
-
|
128
|
-
it 'copies the dataset and yields a GDAL::Dataset' do
|
129
|
-
subject.copy_dataset(source_dataset, copy_dataset_path) do |dest_dataset|
|
130
|
-
expect(dest_dataset).to be_a GDAL::Dataset
|
131
|
-
expect(dest_dataset.driver.short_name).to eq 'GTiff'
|
132
|
-
expect(dest_dataset.access_flag).to eq :GA_Update
|
133
|
-
end
|
134
|
-
|
135
|
-
expect(File.exist?(copy_dataset_path)).to eq true
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
describe '#delete_dataset' do
|
140
|
-
context 'dataset exists' do
|
141
|
-
it 'removes the related files' do
|
142
|
-
expect { subject.delete_dataset(tmp_source_tiff) }.
|
143
|
-
to change { File.exist?(tmp_source_tiff) }.from(true).to(false)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
context 'dataset does not exist' do
|
148
|
-
it 'removes the related files' do
|
149
|
-
expect { subject.delete_dataset('meow.tif') }.to raise_exception(GDAL::OpenFailure)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe 'rename_dataset' do
|
155
|
-
context 'dataset exists' do
|
156
|
-
after { File.unlink('tmp/meow.tif') if File.exist?('tmp/meow.tif') }
|
157
|
-
|
158
|
-
it 'removes the related files' do
|
159
|
-
expect { subject.rename_dataset(tmp_source_tiff, 'tmp/meow.tif') }.
|
160
|
-
to change { File.exist?('tmp/meow.tif') }.from(false).to(true)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
context 'dataset does not exist' do
|
165
|
-
it 'removes the related files' do
|
166
|
-
expect { subject.rename_dataset('meow1.tif', 'meow2.tif') }.to raise_exception(GDAL::OpenFailure)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
@@ -1,226 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'ffi-gdal'
|
5
|
-
require 'gdal'
|
6
|
-
|
7
|
-
RSpec.describe 'GeoTransform Info', type: :integration do
|
8
|
-
let(:file) { make_temp_test_file(original_source_tiff) }
|
9
|
-
|
10
|
-
let(:original_source_tiff) do
|
11
|
-
path = '../../../spec/support/images/osgeo/geotiff/zi_imaging/image0.tif'
|
12
|
-
File.expand_path(path, __dir__)
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:dataset) { GDAL::Dataset.open(file, 'r') }
|
16
|
-
after { dataset.close }
|
17
|
-
subject { dataset.geo_transform }
|
18
|
-
|
19
|
-
describe '#x_origin' do
|
20
|
-
it 'is a Float' do
|
21
|
-
expect(subject.x_origin).to be_a Float
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#x_origin=' do
|
26
|
-
context 'param is a number' do
|
27
|
-
it 'sets the value' do
|
28
|
-
expect { subject.x_origin = 12.34 }.to change { subject.x_origin }.
|
29
|
-
from(-12.51100000000001).to(12.34)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'param is not a number' do
|
34
|
-
it 'raises a TypeError' do
|
35
|
-
expect { subject.x_origin = [] }.to raise_exception TypeError
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '#y_origin' do
|
41
|
-
it 'is a Float' do
|
42
|
-
expect(subject.y_origin).to be_a Float
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe '#y_origin=' do
|
47
|
-
context 'param is a number' do
|
48
|
-
it 'sets the value' do
|
49
|
-
expect { subject.y_origin = 12.34 }.to change { subject.y_origin }.
|
50
|
-
from(109.03599999999999).to(12.34)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'param is not a number' do
|
55
|
-
it 'raises a TypeError' do
|
56
|
-
expect { subject.y_origin = [] }.to raise_exception TypeError
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe '#pixel_width' do
|
62
|
-
it 'is a Float' do
|
63
|
-
expect(subject.pixel_width).to be_a Float
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#pixel_width=' do
|
68
|
-
context 'param is a number' do
|
69
|
-
it 'sets the value' do
|
70
|
-
expect { subject.pixel_width = 12.34 }.to change { subject.pixel_width }.
|
71
|
-
from(0).to(12.34)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'param is not a number' do
|
76
|
-
it 'raises a TypeError' do
|
77
|
-
expect { subject.pixel_width = [] }.to raise_exception TypeError
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe '#x_rotation' do
|
83
|
-
it 'is a Float' do
|
84
|
-
expect(subject.x_rotation).to be_a Float
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe '#x_rotation=' do
|
89
|
-
context 'param is a number' do
|
90
|
-
it 'sets the value' do
|
91
|
-
expect { subject.x_rotation = 12.34 }.to change { subject.x_rotation }.
|
92
|
-
from(0.1850509803921595).to(12.34)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'param is not a number' do
|
97
|
-
it 'raises a TypeError' do
|
98
|
-
expect { subject.x_rotation = [] }.to raise_exception TypeError
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe '#y_rotation' do
|
104
|
-
it 'is a Float' do
|
105
|
-
expect(subject.y_rotation).to be_a Float
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe '#y_rotation=' do
|
110
|
-
context 'param is a number' do
|
111
|
-
it 'sets the value' do
|
112
|
-
expect { subject.y_rotation = 12.34 }.to change { subject.y_rotation }.
|
113
|
-
from(-0.3001842105263167).to(12.34)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context 'param is not a number' do
|
118
|
-
it 'raises a TypeError' do
|
119
|
-
expect { subject.y_rotation = [] }.to raise_exception TypeError
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe '#pixel_height' do
|
125
|
-
it 'is a Float' do
|
126
|
-
expect(subject.pixel_height).to be_a Float
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe '#pixel_height=' do
|
131
|
-
context 'param is a number' do
|
132
|
-
it 'sets the value' do
|
133
|
-
expect { subject.pixel_height = 12.34 }.to change { subject.pixel_height }.
|
134
|
-
from(0.0).to(12.34)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context 'param is not a number' do
|
139
|
-
it 'raises a TypeError' do
|
140
|
-
expect { subject.pixel_height = [] }.to raise_exception TypeError
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
describe '#apply_geo_transform' do
|
146
|
-
context 'valid pixel and line' do
|
147
|
-
it 'returns a Hash with mapped geo values' do
|
148
|
-
expect(subject.apply_geo_transform(1, 1)).to eq(x_geo: -12.325949019607851, y_geo: 108.73581578947368)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'really large pixel and line' do
|
153
|
-
it '(oddly) returns a Hash with mapped geo values' do
|
154
|
-
expect(subject.apply_geo_transform(1_000_000_000_000, 10_000_000_000_000)).
|
155
|
-
to eq(x_geo: 1_850_509_803_909.084, y_geo: -300_184_210_417.2807)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
context 'pixel and line are not numbers' do
|
160
|
-
it 'raises a TypeError' do
|
161
|
-
expect { subject.apply_geo_transform({}, 'stuff') }.to raise_exception(TypeError)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
describe '#compose' do
|
167
|
-
let(:other_geo_transform) do
|
168
|
-
gt = GDAL::GeoTransform.new
|
169
|
-
gt.x_origin = -1
|
170
|
-
gt.y_origin = 1
|
171
|
-
gt.pixel_width = 2
|
172
|
-
gt.pixel_height = 0.5
|
173
|
-
gt.x_rotation = 1
|
174
|
-
gt.y_rotation = -1
|
175
|
-
|
176
|
-
gt
|
177
|
-
end
|
178
|
-
|
179
|
-
it 'returns a new GeoTransform' do
|
180
|
-
composed_gt = subject.compose(other_geo_transform)
|
181
|
-
expect(composed_gt).to be_a GDAL::GeoTransform
|
182
|
-
|
183
|
-
expect(composed_gt.x_origin).to eq(83.01399999999997)
|
184
|
-
expect(composed_gt.y_origin).to eq(68.029)
|
185
|
-
expect(composed_gt.pixel_width).to eq(-0.3001842105263167)
|
186
|
-
expect(composed_gt.pixel_height).to eq(-0.1850509803921595)
|
187
|
-
expect(composed_gt.x_rotation).to eq(0.370101960784319)
|
188
|
-
expect(composed_gt.y_rotation).to eq(-0.15009210526315836)
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
describe '#invert' do
|
193
|
-
it 'returns a new GeoTransform' do
|
194
|
-
inverted_gt = subject.invert
|
195
|
-
|
196
|
-
expect(inverted_gt).to be_a GDAL::GeoTransform
|
197
|
-
expect(inverted_gt.x_origin).to eq(363.2302971859373)
|
198
|
-
expect(inverted_gt.y_origin).to eq(67.60839620242344)
|
199
|
-
expect(inverted_gt.pixel_width).to eq(0)
|
200
|
-
expect(inverted_gt.pixel_height).to eq(0)
|
201
|
-
expect(inverted_gt.x_rotation).to eq(-3.3312878057333113)
|
202
|
-
expect(inverted_gt.y_rotation).to eq(5.403916249893964)
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
describe '#to_world_file' do
|
207
|
-
after { File.unlink('tmp/meow') if File.exist?('tmp/meow') }
|
208
|
-
|
209
|
-
it 'writes out to a file with the given extension' do
|
210
|
-
subject.to_world_file('tmp/meow', 'wld')
|
211
|
-
|
212
|
-
file = File.expand_path('tmp/meow.wld')
|
213
|
-
expect(File.exist?(file)).to eq true
|
214
|
-
contents = File.readlines(file).map(&:strip)
|
215
|
-
|
216
|
-
# I don't understand why the resulting world file has slightly different
|
217
|
-
# values than those from the GeoTransform...
|
218
|
-
expect(contents[0].to_f).to eq(subject.pixel_width)
|
219
|
-
expect(contents[1].to_f).to be_within(0.00000001).of(subject.y_rotation)
|
220
|
-
expect(contents[2].to_f).to be_within(0.00000001).of(subject.x_rotation)
|
221
|
-
expect(contents[3].to_f).to eq(subject.pixel_height)
|
222
|
-
expect(contents[4].to_f).to be_within(0.1).of(subject.x_origin)
|
223
|
-
expect(contents[5].to_f).to be_within(0.3).of(subject.y_origin)
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|