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
data/lib/gdal/dataset.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require_relative '../gdal'
|
4
4
|
require_relative '../ogr'
|
5
5
|
require_relative 'major_object'
|
6
|
-
require_relative 'dataset_mixins/extensions'
|
7
6
|
require_relative 'dataset_mixins/matching'
|
8
7
|
require_relative 'dataset_mixins/algorithm_methods'
|
9
8
|
require_relative 'dataset_mixins/warp_methods'
|
@@ -14,7 +13,6 @@ module GDAL
|
|
14
13
|
# definition of all bands.
|
15
14
|
class Dataset
|
16
15
|
include MajorObject
|
17
|
-
include DatasetMixins::Extensions
|
18
16
|
include DatasetMixins::Matching
|
19
17
|
include DatasetMixins::AlgorithmMethods
|
20
18
|
include DatasetMixins::WarpMethods
|
@@ -28,10 +26,10 @@ module GDAL
|
|
28
26
|
# @param path [String] Path to the file that contains the dataset. Can be
|
29
27
|
# a local file or a URL.
|
30
28
|
# @param access_flag [String] 'r' or 'w'.
|
31
|
-
# @param
|
29
|
+
# @param shared [Boolean] Whether or not to open using GDALOpenShared
|
32
30
|
# vs GDALOpen. Defaults to +true+.
|
33
|
-
def self.open(path, access_flag,
|
34
|
-
ds = new(path, access_flag, shared_open)
|
31
|
+
def self.open(path, access_flag, shared: true)
|
32
|
+
ds = new(path, access_flag, shared_open: shared)
|
35
33
|
|
36
34
|
if block_given?
|
37
35
|
result = yield ds
|
@@ -42,6 +40,51 @@ module GDAL
|
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
43
|
+
# Copy all dataset raster data.
|
44
|
+
#
|
45
|
+
# This function copies the complete raster contents of one dataset to
|
46
|
+
# another similarly configured dataset. The source and destination dataset
|
47
|
+
# must have the same number of bands, and the same width and height. The
|
48
|
+
# bands do not have to have the same data type.
|
49
|
+
#
|
50
|
+
# This function is primarily intended to support implementation of driver
|
51
|
+
# specific CreateCopy() functions. It implements efficient copying, in
|
52
|
+
# particular "chunking" the copy in substantial blocks and, if appropriate,
|
53
|
+
# performing the transfer in a pixel interleaved fashion.
|
54
|
+
#
|
55
|
+
# @param source [GDAL::Dataset, FFI::Pointer]
|
56
|
+
# @param destination [GDAL::Dataset, FFI::Pointer]
|
57
|
+
# @param options [Hash]
|
58
|
+
# @option options interleave: 'pixel'
|
59
|
+
# @option options compressed: true
|
60
|
+
# @option options skip_holes: true
|
61
|
+
# @param progress_function [Proc]
|
62
|
+
# @raise [GDAL::Error]
|
63
|
+
def self.copy_whole_raster(source, destination, options = {}, progress_function = nil)
|
64
|
+
source_ptr = GDAL._pointer(GDAL::Dataset, source, autorelease: false)
|
65
|
+
dest_ptr = GDAL._pointer(GDAL::Dataset, destination, autorelease: false)
|
66
|
+
options_ptr = GDAL::Options.pointer(options)
|
67
|
+
|
68
|
+
GDAL::CPLErrorHandler.manually_handle('Unable to copy whole raster') do
|
69
|
+
FFI::GDAL::GDAL.GDALDatasetCopyWholeRaster(source_ptr, dest_ptr, options_ptr, progress_function, nil)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# @param dataset [GDAL::Dataset]
|
74
|
+
# @return [FFI::AutoPointer]
|
75
|
+
def self.new_pointer(dataset, warn_on_nil: true)
|
76
|
+
ptr = GDAL._pointer(GDAL::Dataset, dataset, warn_on_nil: warn_on_nil, autorelease: false)
|
77
|
+
|
78
|
+
FFI::AutoPointer.new(ptr, Dataset.method(:release))
|
79
|
+
end
|
80
|
+
|
81
|
+
# @param pointer [FFI::Pointer]
|
82
|
+
def self.release(pointer)
|
83
|
+
return unless pointer && !pointer.null?
|
84
|
+
|
85
|
+
FFI::GDAL::GDAL.GDALClose(pointer)
|
86
|
+
end
|
87
|
+
|
45
88
|
#---------------------------------------------------------------------------
|
46
89
|
# Instance methods
|
47
90
|
#---------------------------------------------------------------------------
|
@@ -56,7 +99,7 @@ module GDAL
|
|
56
99
|
# @param access_flag [String] 'r' or 'w'.
|
57
100
|
# @param shared_open [Boolean] Whether or not to open using GDALOpenShared
|
58
101
|
# vs GDALOpen. Defaults to +true+.
|
59
|
-
def initialize(path_or_pointer, access_flag, shared_open
|
102
|
+
def initialize(path_or_pointer, access_flag, shared_open: true)
|
60
103
|
@c_pointer =
|
61
104
|
if path_or_pointer.is_a? String
|
62
105
|
if shared_open
|
@@ -77,9 +120,8 @@ module GDAL
|
|
77
120
|
|
78
121
|
# Close the dataset.
|
79
122
|
def close
|
80
|
-
|
123
|
+
Dataset.release(@c_pointer)
|
81
124
|
|
82
|
-
FFI::GDAL::GDAL.GDALClose(@c_pointer)
|
83
125
|
@c_pointer = nil
|
84
126
|
end
|
85
127
|
|
@@ -103,6 +145,7 @@ module GDAL
|
|
103
145
|
def file_list
|
104
146
|
list_pointer = FFI::GDAL::GDAL.GDALGetFileList(@c_pointer)
|
105
147
|
return [] if list_pointer.null?
|
148
|
+
|
106
149
|
file_list = list_pointer.get_array_of_string(0)
|
107
150
|
FFI::CPL::String.CSLDestroy(list_pointer)
|
108
151
|
|
@@ -114,28 +157,28 @@ module GDAL
|
|
114
157
|
FFI::GDAL::GDAL.GDALFlushCache(@c_pointer)
|
115
158
|
end
|
116
159
|
|
117
|
-
# @return [
|
160
|
+
# @return [Integer]
|
118
161
|
def raster_x_size
|
119
162
|
return nil if null?
|
120
163
|
|
121
164
|
FFI::GDAL::GDAL.GDALGetRasterXSize(@c_pointer)
|
122
165
|
end
|
123
166
|
|
124
|
-
# @return [
|
167
|
+
# @return [Integer]
|
125
168
|
def raster_y_size
|
126
169
|
return nil if null?
|
127
170
|
|
128
171
|
FFI::GDAL::GDAL.GDALGetRasterYSize(@c_pointer)
|
129
172
|
end
|
130
173
|
|
131
|
-
# @return [
|
174
|
+
# @return [Integer]
|
132
175
|
def raster_count
|
133
176
|
return 0 if null?
|
134
177
|
|
135
178
|
FFI::GDAL::GDAL.GDALGetRasterCount(@c_pointer)
|
136
179
|
end
|
137
180
|
|
138
|
-
# @param raster_index [
|
181
|
+
# @param raster_index [Integer]
|
139
182
|
# @return [GDAL::RasterBand]
|
140
183
|
def raster_band(raster_index)
|
141
184
|
if raster_index > raster_count
|
@@ -143,16 +186,21 @@ module GDAL
|
|
143
186
|
end
|
144
187
|
|
145
188
|
raster_band_ptr = FFI::GDAL::GDAL.GDALGetRasterBand(@c_pointer, raster_index)
|
189
|
+
raster_band_ptr.autorelease = false
|
146
190
|
|
147
|
-
GDAL::RasterBand.new(raster_band_ptr)
|
191
|
+
GDAL::RasterBand.new(raster_band_ptr, self)
|
148
192
|
end
|
149
193
|
|
150
194
|
# @param type [FFI::GDAL::GDAL::DataType]
|
151
195
|
# @param options [Hash]
|
196
|
+
# @raise [GDAL::Error]
|
152
197
|
# @return [GDAL::RasterBand, nil]
|
153
198
|
def add_band(type, **options)
|
154
199
|
options_ptr = GDAL::Options.pointer(options)
|
155
|
-
|
200
|
+
|
201
|
+
GDAL::CPLErrorHandler.manually_handle('Unable to add band') do
|
202
|
+
FFI::GDAL::GDAL.GDALAddBand(@c_pointer, type, options_ptr)
|
203
|
+
end
|
156
204
|
|
157
205
|
raster_band(raster_count)
|
158
206
|
end
|
@@ -160,45 +208,61 @@ module GDAL
|
|
160
208
|
# Adds a mask band to the dataset.
|
161
209
|
#
|
162
210
|
# @param flags [Array<Symbol>, Symbol] Any of the :GMF symbols.
|
163
|
-
# @
|
211
|
+
# @raise [GDAL::Error]
|
164
212
|
def create_mask_band(*flags)
|
165
213
|
flag_value = parse_mask_flag_symbols(flags)
|
166
214
|
|
167
|
-
|
215
|
+
GDAL::CPLErrorHandler.manually_handle('Unable to create Dataset mask band') do
|
216
|
+
FFI::GDAL::GDAL.GDALCreateDatasetMaskBand(@c_pointer, flag_value)
|
217
|
+
end
|
168
218
|
end
|
169
219
|
|
170
220
|
# @return [String]
|
171
221
|
def projection
|
172
|
-
|
222
|
+
# Returns a pointer to an internal projection reference string. It should
|
223
|
+
# not be altered, freed or expected to last for long.
|
224
|
+
proj, ptr = FFI::GDAL::GDAL.GDALGetProjectionRef(@c_pointer)
|
225
|
+
ptr.autorelease = false
|
226
|
+
|
227
|
+
proj || ''
|
173
228
|
end
|
174
229
|
|
175
|
-
# @param new_projection [String]
|
176
|
-
# @
|
230
|
+
# @param new_projection [String] Should be in WKT or PROJ.4 format.
|
231
|
+
# @raise [GDAL::Error]
|
177
232
|
def projection=(new_projection)
|
178
|
-
|
233
|
+
GDAL::CPLErrorHandler.manually_handle('Unable to set projection') do
|
234
|
+
FFI::GDAL::GDAL.GDALSetProjection(@c_pointer, new_projection.to_s)
|
235
|
+
end
|
179
236
|
end
|
180
237
|
|
181
238
|
# @return [GDAL::GeoTransform]
|
239
|
+
# @raise [GDAL::Error]
|
182
240
|
def geo_transform
|
183
241
|
return @geo_transform if @geo_transform
|
184
242
|
|
185
243
|
geo_transform_pointer = GDAL::GeoTransform.new_pointer
|
186
|
-
|
187
|
-
|
244
|
+
|
245
|
+
GDAL::CPLErrorHandler.manually_handle('Unable to get geo_transform') do
|
246
|
+
FFI::GDAL::GDAL.GDALGetGeoTransform(@c_pointer, geo_transform_pointer)
|
247
|
+
end
|
188
248
|
|
189
249
|
@geo_transform = GeoTransform.new(geo_transform_pointer)
|
190
250
|
end
|
191
251
|
|
192
252
|
# @param new_transform [GDAL::GeoTransform, FFI::Pointer]
|
193
253
|
# @return [GDAL::GeoTransform]
|
254
|
+
# @raise [GDAL::Error]
|
194
255
|
def geo_transform=(new_transform)
|
195
256
|
new_pointer = GDAL._pointer(GDAL::GeoTransform, new_transform)
|
196
|
-
|
257
|
+
|
258
|
+
GDAL::CPLErrorHandler.manually_handle('Unable to set geo_transform') do
|
259
|
+
FFI::GDAL::GDAL.GDALSetGeoTransform(@c_pointer, new_pointer)
|
260
|
+
end
|
197
261
|
|
198
262
|
@geo_transform = new_transform.is_a?(FFI::Pointer) ? GeoTransform.new(new_pointer) : new_transform
|
199
263
|
end
|
200
264
|
|
201
|
-
# @return [
|
265
|
+
# @return [Integer]
|
202
266
|
def gcp_count
|
203
267
|
return 0 if null?
|
204
268
|
|
@@ -209,7 +273,10 @@ module GDAL
|
|
209
273
|
def gcp_projection
|
210
274
|
return '' if null?
|
211
275
|
|
212
|
-
FFI::GDAL::GDAL.GDALGetGCPProjection(@c_pointer)
|
276
|
+
proj, ptr = FFI::GDAL::GDAL.GDALGetGCPProjection(@c_pointer)
|
277
|
+
ptr.autorelease = false
|
278
|
+
|
279
|
+
proj
|
213
280
|
end
|
214
281
|
|
215
282
|
# @return [FFI::GDAL::GCP]
|
@@ -233,15 +300,17 @@ module GDAL
|
|
233
300
|
# * :mode - Selects the value that occurs most often
|
234
301
|
# * :average_magphase - Averages complex data in mag/phase space
|
235
302
|
# * :none
|
236
|
-
# @param overview_levels [Array<
|
303
|
+
# @param overview_levels [Array<Integer>] The list of overview decimation
|
237
304
|
# factors to build.
|
238
|
-
# @param band_numbers [Array<
|
305
|
+
# @param band_numbers [Array<Integer>] The numbers of the bands to build
|
239
306
|
# overviews from.
|
240
307
|
# @see http://www.gdal.org/gdaladdo.html
|
308
|
+
# @raise [GDAL::Error]
|
241
309
|
def build_overviews(resampling, overview_levels, band_numbers: nil, &progress)
|
242
|
-
resampling_string =
|
310
|
+
resampling_string = case resampling
|
311
|
+
when String
|
243
312
|
resampling.upcase
|
244
|
-
|
313
|
+
when Symbol
|
245
314
|
resampling.to_s.upcase
|
246
315
|
end
|
247
316
|
|
@@ -249,52 +318,57 @@ module GDAL
|
|
249
318
|
overview_levels_ptr.write_array_of_int(overview_levels)
|
250
319
|
band_numbers_ptr, band_count = band_numbers_args(band_numbers)
|
251
320
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
321
|
+
GDAL::CPLErrorHandler.manually_handle('Unable to build overviews') do
|
322
|
+
FFI::GDAL::GDAL.GDALBuildOverviews(
|
323
|
+
@c_pointer,
|
324
|
+
resampling_string,
|
325
|
+
overview_levels.size,
|
326
|
+
overview_levels_ptr,
|
327
|
+
band_count,
|
328
|
+
band_numbers_ptr,
|
329
|
+
progress,
|
330
|
+
nil
|
331
|
+
)
|
332
|
+
end
|
262
333
|
end
|
263
334
|
|
264
335
|
# @param access_flag [String] 'r' or 'w'.
|
265
336
|
# @param buffer [FFI::MemoryPointer] The pointer to the data to read/write
|
266
337
|
# to the dataset.
|
267
|
-
# @param x_size [
|
268
|
-
# @param y_size [
|
269
|
-
# @param x_offset [
|
270
|
-
# on. Note that when using this,
|
338
|
+
# @param x_size [Integer] If not given, uses {{#raster_x_size}}.
|
339
|
+
# @param y_size [Integer] If not given, uses {{#raster_y_size}}.
|
340
|
+
# @param x_offset [Integer] The pixel number in the line to start operating
|
341
|
+
# on. Note that when using this, +x_size+ - +x_offset+ should be >= 0,
|
271
342
|
# otherwise this means you're telling the method to read past the end of
|
272
343
|
# the line. Defaults to 0.
|
273
|
-
# @param y_offset [
|
274
|
-
# when using this,
|
344
|
+
# @param y_offset [Integer] The line number to start operating on. Note that
|
345
|
+
# when using this, +y_size+ - +y_offset+ should be >= 0, otherwise this
|
275
346
|
# means you're telling the method to read more lines than the raster has.
|
276
347
|
# Defaults to 0.
|
277
|
-
# @param buffer_x_size [
|
348
|
+
# @param buffer_x_size [Integer] The width of the buffer image in which to
|
278
349
|
# read/write the raster data into/from. Typically this should be the same
|
279
350
|
# size as +x_size+; if it's different, GDAL will resample accordingly.
|
280
|
-
# @param buffer_y_size [
|
351
|
+
# @param buffer_y_size [Integer] The height of the buffer image in which to
|
281
352
|
# read/write the raster data into/from. Typically this should be the same
|
282
353
|
# size as +y_size+; if it's different, GDAL will resample accordingly.
|
283
354
|
# @param buffer_data_type [FFI::GDAL::GDAL::DataType] Can be used to convert the
|
284
355
|
# data to a different type. You must account for this when reading/writing
|
285
356
|
# to/from your buffer--your buffer size must be +buffer_x_size+ *
|
286
357
|
# +buffer_y_size+.
|
287
|
-
# @param band_numbers [Array<
|
288
|
-
#
|
358
|
+
# @param band_numbers [Array<Integer>] The numbers of the bands to do IO on.
|
359
|
+
# Pass +nil+ defaults to choose the first band.
|
360
|
+
# @param pixel_space [Integer] The byte offset from the start of one pixel
|
289
361
|
# value in the buffer to the start of the next pixel value within a line.
|
290
362
|
# If defaulted (0), the size of +buffer_data_type+ is used.
|
291
|
-
# @param line_space [
|
363
|
+
# @param line_space [Integer] The byte offset from the start of one line in
|
292
364
|
# the buffer to the start of the next. If defaulted (0), the size of
|
293
365
|
# +buffer_data_type+ * +buffer_x_size* is used.
|
294
|
-
# @param band_space [
|
366
|
+
# @param band_space [Integer] The byte offset from the start of one band's
|
295
367
|
# data to the start of the next. If defaulted (0), the size of
|
296
368
|
# +line_space+ * +buffer_y_size* is used.
|
297
|
-
#
|
369
|
+
# @return [FFI::MemoryPointer] The buffer that was passed in.
|
370
|
+
# @raise [GDAL::Error] On failure.
|
371
|
+
# rubocop:disable Metrics/ParameterLists
|
298
372
|
def raster_io(access_flag, buffer = nil,
|
299
373
|
x_size: nil, y_size: nil, x_offset: 0, y_offset: 0,
|
300
374
|
buffer_x_size: nil, buffer_y_size: nil, buffer_data_type: nil,
|
@@ -305,6 +379,7 @@ module GDAL
|
|
305
379
|
buffer_x_size ||= x_size
|
306
380
|
buffer_y_size ||= y_size
|
307
381
|
buffer_data_type ||= raster_band(1).data_type
|
382
|
+
|
308
383
|
band_numbers_ptr, band_count = band_numbers_args(band_numbers)
|
309
384
|
band_count = raster_count if band_count.zero?
|
310
385
|
|
@@ -318,27 +393,40 @@ module GDAL
|
|
318
393
|
raise GDAL::BufferTooSmall, "Buffer size (#{buffer.size}) too small (#{min_buffer_size})"
|
319
394
|
end
|
320
395
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
396
|
+
GDAL::CPLErrorHandler.manually_handle('Unable to perform raster band IO') do
|
397
|
+
FFI::GDAL::GDAL::GDALDatasetRasterIO(
|
398
|
+
@c_pointer, # hDS
|
399
|
+
gdal_access_flag, # eRWFlag
|
400
|
+
x_offset, # nXOff
|
401
|
+
y_offset, # nYOff
|
402
|
+
x_size, # nXSize
|
403
|
+
y_size, # nYSize
|
404
|
+
buffer, # pData
|
405
|
+
buffer_x_size, # nBufXSize
|
406
|
+
buffer_y_size, # nBufYSize
|
407
|
+
buffer_data_type, # eBufType
|
408
|
+
band_count, # nBandCount
|
409
|
+
band_numbers_ptr, # panBandMap (WTH is this?)
|
410
|
+
pixel_space, # nPixelSpace
|
411
|
+
line_space, # nLineSpace
|
412
|
+
band_space # nBandSpace
|
413
|
+
)
|
414
|
+
end
|
338
415
|
|
339
416
|
buffer
|
340
417
|
end
|
341
|
-
# rubocop:enable
|
418
|
+
# rubocop:enable Metrics/ParameterLists
|
419
|
+
|
420
|
+
# Creates a OGR::SpatialReference object from the dataset's projection.
|
421
|
+
#
|
422
|
+
# @return [OGR::SpatialReference]
|
423
|
+
def spatial_reference
|
424
|
+
return @spatial_reference if @spatial_reference
|
425
|
+
|
426
|
+
return nil if projection.empty?
|
427
|
+
|
428
|
+
@spatial_reference = OGR::SpatialReference.new(projection)
|
429
|
+
end
|
342
430
|
|
343
431
|
private
|
344
432
|
|
@@ -346,7 +434,7 @@ module GDAL
|
|
346
434
|
# ors them.
|
347
435
|
#
|
348
436
|
# @param flags [Symbol]
|
349
|
-
# @return [
|
437
|
+
# @return [Integer]
|
350
438
|
def parse_mask_flag_symbols(*flags)
|
351
439
|
flags.reduce(0) do |result, flag|
|
352
440
|
result | case flag
|
@@ -360,9 +448,9 @@ module GDAL
|
|
360
448
|
end
|
361
449
|
|
362
450
|
# @param buffer_data_type [FFI::GDAL::GDAL::DataType]
|
363
|
-
# @param x_buffer_size [
|
364
|
-
# @param y_buffer_size [
|
365
|
-
# @return [
|
451
|
+
# @param x_buffer_size [Integer]
|
452
|
+
# @param y_buffer_size [Integer]
|
453
|
+
# @return [Integer]
|
366
454
|
def valid_min_buffer_size(buffer_data_type, x_buffer_size, y_buffer_size)
|
367
455
|
data_type_bytes = GDAL::DataType.size(buffer_data_type) / 8
|
368
456
|
|
@@ -371,19 +459,17 @@ module GDAL
|
|
371
459
|
|
372
460
|
# Makes a pointer of +band_numbers+.
|
373
461
|
#
|
374
|
-
# @param band_numbers [Array<
|
375
|
-
# @return [Array<FFI::
|
462
|
+
# @param band_numbers [Array<Integer>]
|
463
|
+
# @return [Array<FFI::MemoryPointer, Integer>]
|
376
464
|
def band_numbers_args(band_numbers)
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
band_count = 0
|
384
|
-
end
|
465
|
+
band_count = band_numbers&.size || 0
|
466
|
+
ptr = FFI::MemoryPointer.new(:int, band_count)
|
467
|
+
|
468
|
+
ptr.write_array_of_int(band_numbers) if band_numbers
|
469
|
+
|
470
|
+
ptr.autorelease = false
|
385
471
|
|
386
|
-
[
|
472
|
+
[ptr, band_count]
|
387
473
|
end
|
388
474
|
end
|
389
475
|
end
|
@@ -8,7 +8,7 @@ module GDAL
|
|
8
8
|
# +transformer+ can be nil as long as the +geometries+ are within the
|
9
9
|
# georeferenced coordinates of this raster's dataset.
|
10
10
|
#
|
11
|
-
# @param band_numbers [Array<
|
11
|
+
# @param band_numbers [Array<Integer>, Integer]
|
12
12
|
# @param geometries [Array<OGR::Geometry>, OGR::Geometry]
|
13
13
|
# @param burn_values [Array<Float>, Float]
|
14
14
|
# @param transformer [Proc]
|
@@ -29,9 +29,9 @@ module GDAL
|
|
29
29
|
end
|
30
30
|
|
31
31
|
gdal_options = GDAL::Options.pointer(options)
|
32
|
-
band_numbers = band_numbers
|
33
|
-
geometries = geometries
|
34
|
-
burn_values = burn_values
|
32
|
+
band_numbers = Array(band_numbers)
|
33
|
+
geometries = Array(geometries)
|
34
|
+
burn_values = Array(burn_values)
|
35
35
|
|
36
36
|
band_numbers_ptr = FFI::MemoryPointer.new(:pointer, band_numbers.size)
|
37
37
|
band_numbers_ptr.write_array_of_int(band_numbers)
|
@@ -43,26 +43,26 @@ module GDAL
|
|
43
43
|
burn_values_ptr.write_array_of_double(burn_values)
|
44
44
|
|
45
45
|
FFI::GDAL::Alg.GDALRasterizeGeometries(@c_pointer,
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
46
|
+
band_numbers.size,
|
47
|
+
band_numbers_ptr,
|
48
|
+
geometries.size,
|
49
|
+
geometries_ptr,
|
50
|
+
transformer,
|
51
|
+
transform_arg,
|
52
|
+
burn_values_ptr,
|
53
|
+
gdal_options,
|
54
|
+
progress_block,
|
55
|
+
nil)
|
56
56
|
end
|
57
57
|
|
58
|
-
# @param band_numbers [Array<
|
58
|
+
# @param band_numbers [Array<Integer>, Integer]
|
59
59
|
# @param layers [Array<OGR::Layer>, OGR::Layer]
|
60
60
|
# @param burn_values [Array<Float>, Float]
|
61
61
|
# @param transformer [Proc]
|
62
62
|
# @param options [Hash]
|
63
63
|
# @option options attribute [String] An attribute field on features to be
|
64
64
|
# used for a burn-in value, which will be burned into all output bands.
|
65
|
-
# @option options chunkysize [
|
65
|
+
# @option options chunkysize [Integer] The height in lines of the chunk to
|
66
66
|
# operate on.
|
67
67
|
# @option options all_touched [Boolean] If +true+, sets all pixels touched
|
68
68
|
# by the line or polygons, not just those whose center is within the
|
@@ -75,13 +75,13 @@ module GDAL
|
|
75
75
|
def rasterize_layers!(band_numbers, layers, burn_values,
|
76
76
|
transformer: nil, transform_arg: nil, **options, &progress_block)
|
77
77
|
gdal_options = GDAL::Options.pointer(options)
|
78
|
-
band_numbers = band_numbers
|
78
|
+
band_numbers = Array(band_numbers)
|
79
79
|
log "band numbers: #{band_numbers}"
|
80
80
|
|
81
|
-
layers = layers
|
81
|
+
layers = Array(layers)
|
82
82
|
log "layers: #{layers}"
|
83
83
|
|
84
|
-
burn_values = burn_values
|
84
|
+
burn_values = Array(burn_values)
|
85
85
|
log "burn values: #{burn_values}"
|
86
86
|
|
87
87
|
band_numbers_ptr = FFI::MemoryPointer.new(:pointer, band_numbers.size)
|
@@ -96,17 +96,17 @@ module GDAL
|
|
96
96
|
burn_values_ptr.write_array_of_double(burn_values)
|
97
97
|
log "burn value ptr null? #{burn_values_ptr.null?}"
|
98
98
|
|
99
|
-
FFI::GDAL::Alg.GDALRasterizeLayers(@c_pointer,
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
99
|
+
FFI::GDAL::Alg.GDALRasterizeLayers(@c_pointer, # hDS
|
100
|
+
band_numbers.size, # nBandCount
|
101
|
+
band_numbers_ptr, # panBandList
|
102
|
+
layers.size, # nLayerCount
|
103
|
+
layers_ptr, # pahLayers
|
104
|
+
transformer, # pfnTransformer
|
105
|
+
transform_arg, # pTransformerArg
|
106
|
+
burn_values_ptr, # padfLayerBurnValues
|
107
|
+
gdal_options, # papszOptions
|
108
|
+
progress_block, # pfnProgress
|
109
|
+
nil) # pProgressArg
|
110
110
|
end
|
111
111
|
|
112
112
|
# @param destination_dataset [String]
|
@@ -117,7 +117,7 @@ module GDAL
|
|
117
117
|
# @option warp_options [String] init Indicates that the output dataset should be
|
118
118
|
# initialized to the given value in any area where valid data isn't
|
119
119
|
# written. In form: "v[,v...]"
|
120
|
-
# @param band_numbers [
|
120
|
+
# @param band_numbers [Integer, Array<Integer>] Raster bands to include in the
|
121
121
|
# warping. 0 indicates all bands.
|
122
122
|
# @param progress [Proc]
|
123
123
|
# @return [GDAL::Dataset, nil] The new dataset or nil if the warping failed.
|
@@ -125,7 +125,7 @@ module GDAL
|
|
125
125
|
warp_options, band_numbers = 0, progress = nil)
|
126
126
|
destination_dataset_ptr = destination_dataset.c_pointer
|
127
127
|
|
128
|
-
band_numbers = band_numbers
|
128
|
+
band_numbers = Array(band_numbers)
|
129
129
|
log "band numbers: #{band_numbers}"
|
130
130
|
|
131
131
|
bands_ptr = FFI::MemoryPointer.new(:pointer, band_numbers.size)
|
@@ -133,20 +133,20 @@ module GDAL
|
|
133
133
|
log "band numbers ptr null? #{bands_ptr.null?}"
|
134
134
|
|
135
135
|
success = FFI::GDAL::Alg.GDALSimpleImageWarp(@c_pointer,
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
136
|
+
destination_dataset_ptr,
|
137
|
+
band_numbers.size,
|
138
|
+
bands_ptr,
|
139
|
+
transformer,
|
140
|
+
transformer_arg_ptr,
|
141
|
+
progress,
|
142
|
+
nil,
|
143
|
+
warp_options.c_pointer)
|
144
144
|
|
145
145
|
success ? destination_dataset : nil
|
146
146
|
end
|
147
147
|
|
148
148
|
# @param transformer [GDAL::Transformers]
|
149
|
-
# @return [Hash{geo_transform: GDAL::GeoTransform, lines:
|
149
|
+
# @return [Hash{geo_transform: GDAL::GeoTransform, lines: Integer, pixels: Integer}]
|
150
150
|
def suggested_warp_output(transformer)
|
151
151
|
geo_transform = GDAL::GeoTransform.new
|
152
152
|
pixels_ptr = FFI::MemoryPointer.new(:int)
|
@@ -169,9 +169,9 @@ module GDAL
|
|
169
169
|
end
|
170
170
|
|
171
171
|
# @param transformer [GDAL::Transformers]
|
172
|
-
# @return [Hash{extents: Hash{ min_x:
|
173
|
-
# max_y:
|
174
|
-
# pixels:
|
172
|
+
# @return [Hash{extents: Hash{ min_x: Integer, min_y: Integer, max_x: Integer,
|
173
|
+
# max_y: Integer }, geo_transform: GDAL::GeoTransform, lines: Integer,
|
174
|
+
# pixels: Integer}]
|
175
175
|
def suggested_warp_output2(transformer)
|
176
176
|
geo_transform = GDAL::GeoTransform.new
|
177
177
|
pixels_ptr = FFI::MemoryPointer.new(:int)
|
@@ -5,7 +5,7 @@ module GDAL
|
|
5
5
|
module Matching
|
6
6
|
# @param other_dataset [GDAL::Dataset]
|
7
7
|
# @param options [Hash]
|
8
|
-
# @return [Hash{count =>
|
8
|
+
# @return [Hash{count => Integer, gcp: => FFI::GDAL::GCP}] Not sure why,
|
9
9
|
# but the C function seems to return a single GCP instead of an Array of
|
10
10
|
# them.
|
11
11
|
def compute_matching_points(other_dataset, **options)
|