ffi-gdal 1.0.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/Dockerfile +9 -0
  3. data/.devcontainer/devcontainer.json +98 -0
  4. data/.github/CODEOWNERS +1 -0
  5. data/.github/workflows/codacy.yml +3 -3
  6. data/.github/workflows/codeql.yml +4 -4
  7. data/.github/workflows/continuous-integration.yml +30 -19
  8. data/.github/workflows/dependency-review.yml +2 -2
  9. data/.github/workflows/specs-in-docker.yml +12 -6
  10. data/.gitignore +4 -1
  11. data/Changelog.md +40 -5
  12. data/Gemfile +4 -2
  13. data/README.md +35 -0
  14. data/lib/ext/numeric_as_data_type.rb +1 -1
  15. data/lib/ffi/cpl/vsi.rb +10 -0
  16. data/lib/ffi/gdal/gdal.rb +9 -2
  17. data/lib/ffi/gdal/grid_data_metrics_options.rb +27 -5
  18. data/lib/ffi/gdal/grid_inverse_distance_to_a_power_options.rb +30 -10
  19. data/lib/ffi/gdal/grid_moving_average_options.rb +30 -5
  20. data/lib/ffi/gdal/grid_nearest_neighbor_options.rb +24 -4
  21. data/lib/ffi/gdal/internal_helpers/gdal_version.rb +15 -0
  22. data/lib/ffi/gdal/internal_helpers/layout_version.rb +9 -0
  23. data/lib/ffi/gdal/internal_helpers/layout_version_resolver.rb +24 -0
  24. data/lib/ffi/gdal/internal_helpers.rb +11 -0
  25. data/lib/ffi/gdal/utils.rb +984 -0
  26. data/lib/ffi/gdal/version.rb +1 -1
  27. data/lib/ffi/gdal.rb +3 -1
  28. data/lib/ffi/ogr/core.rb +1 -1
  29. data/lib/ffi/ogr/srs_api.rb +17 -0
  30. data/lib/gdal/cpl_error_handler.rb +30 -15
  31. data/lib/gdal/exceptions.rb +35 -16
  32. data/lib/gdal/extensions/color_table/extensions.rb +1 -1
  33. data/lib/gdal/extensions/gridder.rb +4 -0
  34. data/lib/gdal/geo_transform.rb +13 -0
  35. data/lib/gdal/grid_algorithms/algorithm_base.rb +35 -0
  36. data/lib/gdal/grid_algorithms/inverse_distance_to_a_power.rb +3 -7
  37. data/lib/gdal/grid_algorithms/metric_average_distance.rb +5 -4
  38. data/lib/gdal/grid_algorithms/metric_average_distance_pts.rb +5 -4
  39. data/lib/gdal/grid_algorithms/metric_count.rb +5 -4
  40. data/lib/gdal/grid_algorithms/metric_maximum.rb +5 -4
  41. data/lib/gdal/grid_algorithms/metric_minimum.rb +5 -4
  42. data/lib/gdal/grid_algorithms/metric_range.rb +5 -4
  43. data/lib/gdal/grid_algorithms/moving_average.rb +3 -7
  44. data/lib/gdal/grid_algorithms/nearest_neighbor.rb +3 -7
  45. data/lib/gdal/grid_algorithms.rb +2 -0
  46. data/lib/gdal/internal_helpers.rb +8 -5
  47. data/lib/gdal/major_object.rb +6 -0
  48. data/lib/gdal/raster_band.rb +16 -12
  49. data/lib/gdal/utils/dem/options.rb +52 -0
  50. data/lib/gdal/utils/dem.rb +108 -0
  51. data/lib/gdal/utils/grid/options.rb +52 -0
  52. data/lib/gdal/utils/grid.rb +72 -0
  53. data/lib/gdal/utils/helpers/dataset_list.rb +43 -0
  54. data/lib/gdal/utils/helpers/string_list.rb +47 -0
  55. data/lib/gdal/utils/helpers.rb +11 -0
  56. data/lib/gdal/utils/info/options.rb +52 -0
  57. data/lib/gdal/utils/info.rb +40 -0
  58. data/lib/gdal/utils/nearblack/options.rb +52 -0
  59. data/lib/gdal/utils/nearblack.rb +119 -0
  60. data/lib/gdal/utils/rasterize/options.rb +52 -0
  61. data/lib/gdal/utils/rasterize.rb +108 -0
  62. data/lib/gdal/utils/translate/options.rb +52 -0
  63. data/lib/gdal/utils/translate.rb +72 -0
  64. data/lib/gdal/utils/vector_translate/options.rb +52 -0
  65. data/lib/gdal/utils/vector_translate.rb +132 -0
  66. data/lib/gdal/utils/warp/options.rb +52 -0
  67. data/lib/gdal/utils/warp.rb +118 -0
  68. data/lib/gdal/utils.rb +22 -0
  69. data/lib/gdal/warp_options.rb +11 -2
  70. data/lib/gdal.rb +1 -0
  71. data/lib/ogr/extensions/layer/extensions.rb +1 -1
  72. data/lib/ogr/extensions/spatial_reference/extensions.rb +4 -4
  73. data/lib/ogr/geometry.rb +1 -6
  74. data/lib/ogr/layer.rb +1 -1
  75. data/lib/ogr/spatial_reference.rb +27 -2
  76. metadata +32 -5
  77. data/.ruby-version +0 -1
  78. data/lib/gdal/grid_algorithms/data_metrics_base.rb +0 -14
@@ -4,11 +4,31 @@ require "ffi"
4
4
 
5
5
  module FFI
6
6
  module GDAL
7
+ # FFI structure for GDALGridNearestNeighborOptions.
8
+ # @see https://gdal.org/api/gdal_alg.html#_CPPv430GDALGridNearestNeighborOptions
7
9
  class GridNearestNeighborOptions < FFI::Struct
8
- layout :radius1, :double,
9
- :radius2, :double,
10
- :angle, :double,
11
- :no_data_value, :double
10
+ DEFAULT_LAYOUT = %i[
11
+ radius1 double
12
+ radius2 double
13
+ angle double
14
+ no_data_value double
15
+ ].freeze
16
+
17
+ LAYOUT_VERSIONS = [
18
+ InternalHelpers::LayoutVersion.new(
19
+ version: "0000000", # Any old GDAL
20
+ layout: DEFAULT_LAYOUT
21
+ ),
22
+ InternalHelpers::LayoutVersion.new(
23
+ version: "3060000", # GDAL 3.6.0
24
+ layout: [
25
+ :n_size_of_structure, :size_t,
26
+ *DEFAULT_LAYOUT
27
+ ]
28
+ )
29
+ ].freeze
30
+
31
+ layout(*InternalHelpers::LayoutVersionResolver.resolve(versions: LAYOUT_VERSIONS))
12
32
  end
13
33
  end
14
34
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FFI
4
+ module GDAL
5
+ module InternalHelpers
6
+ # Version information for GDAL.
7
+ class GDALVersion
8
+ # @return [String] GDAL Version.
9
+ def self.version
10
+ ::FFI::GDAL.GDALVersionInfo("VERSION_NUM")
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FFI
4
+ module GDAL
5
+ module InternalHelpers
6
+ LayoutVersion = ::Struct.new(:version, :layout, keyword_init: true)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FFI
4
+ module GDAL
5
+ module InternalHelpers
6
+ # Resolve the layout version based on the GDAL version.
7
+ class LayoutVersionResolver
8
+ # Resolve the layout version based on the GDAL version.
9
+ # @param versions [Array<InternalHelpers::LayoutVersion>] The versions to resolve.
10
+ # @return [Array<Symbol, Integer>] The resolved layout.
11
+ def self.resolve(versions: [])
12
+ gdal_version = GDALVersion.version
13
+
14
+ versions
15
+ .sort_by(&:version)
16
+ .reverse_each
17
+ .find { |layout_version| gdal_version >= layout_version.version }
18
+ .layout
19
+ .freeze
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FFI
4
+ module GDAL
5
+ module InternalHelpers
6
+ autoload :GDALVersion, File.expand_path("internal_helpers/gdal_version", __dir__)
7
+ autoload :LayoutVersion, File.expand_path("internal_helpers/layout_version", __dir__)
8
+ autoload :LayoutVersionResolver, File.expand_path("internal_helpers/layout_version_resolver", __dir__)
9
+ end
10
+ end
11
+ end