Skip to content

Commit

Permalink
ci: add ubuntu 24.04 with GDAL 3.8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksii-leonov committed May 24, 2024
1 parent 88c1636 commit 27f4060
Show file tree
Hide file tree
Showing 36 changed files with 423 additions and 90 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
# NOTE:
# - ubuntu-20.04 has GDAL 3.0.4, PROJ 6.3.1, GEOS 3.8.0
# - ubuntu-22.04 has GDAL 3.4.1, PROJ 8.2.1, GEOS 3.10.2
os: ["ubuntu-20.04", "ubuntu-22.04"]
# - ubuntu-24.04 has GDAL 3.8.4, PROJ 9.4.0, GEOS 3.12.1
os: ["ubuntu-20.04", "ubuntu-22.04", "ubuntu-24.04"]
ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
name: "Ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ FFI::CPL::Conv.CPLSetConfigOption('CPL_LOG_ERRORS', 'ON')
## Compatibility

CI is run against:
- Ruby 2.6, 2.7, 3.0, 3.1, 3.2, 3.3 for Ubuntu 24.04
(**GDAL 3.8.4**, PROJ 9.4.0, GEOS 3.12.1)
- Ruby 2.6, 2.7, 3.0, 3.1, 3.2, 3.3 for Ubuntu 22.04
(**GDAL 3.4.1**, PROJ 8.2.1, GEOS 3.10.2)
- Ruby 2.6, 2.7, 3.0, 3.1, 3.2, 3.3 for Ubuntu 20.04
Expand Down
1 change: 1 addition & 0 deletions lib/ffi/gdal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module GDAL
File.expand_path("gdal/grid_inverse_distance_to_a_power_options.rb", __dir__)
autoload :GridMovingAverageOptions, File.expand_path("gdal/grid_moving_average_options.rb", __dir__)
autoload :GridNearestNeighborOptions, File.expand_path("gdal/grid_nearest_neighbor_options.rb", __dir__)
autoload :InternalHelpers, File.expand_path("gdal/internal_helpers.rb", __dir__)
autoload :Matching, File.expand_path("gdal/matching.rb", __dir__)
autoload :RPCInfo, File.expand_path("gdal/rpc_info.rb", __dir__)
autoload :TransformerInfo, File.expand_path("gdal/transformer_info.rb", __dir__)
Expand Down
32 changes: 27 additions & 5 deletions lib/ffi/gdal/grid_data_metrics_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,34 @@

module FFI
module GDAL
# FFI structure for GDALGridDataMetricsOptions.
# @see https://gdal.org/api/gdal_alg.html#_CPPv426GDALGridDataMetricsOptions
class GridDataMetricsOptions < FFI::Struct
layout :radius1, :double,
:radius2, :double,
:angle, :double,
:min_points, CPL::Port.find_type(:GUInt32),
:no_data_value, :double
DEFAULT_LAYOUT = [
:radius1, :double,
:radius2, :double,
:angle, :double,
:min_points, CPL::Port.find_type(:GUInt32),
:no_data_value, :double
].freeze

LAYOUT_VERSIONS = [
InternalHelpers::LayoutVersion.new(
version: "0000000", # Any old GDAL
layout: DEFAULT_LAYOUT
),
InternalHelpers::LayoutVersion.new(
version: "3060000", # GDAL 3.6.0
layout: [
:n_size_of_structure, :size_t,
*DEFAULT_LAYOUT,
:max_points_per_quadrant, CPL::Port.find_type(:GUInt32),
:min_points_per_quadrant, CPL::Port.find_type(:GUInt32)
]
)
].freeze

layout(*InternalHelpers::LayoutVersionResolver.resolve(versions: LAYOUT_VERSIONS))
end
end
end
40 changes: 30 additions & 10 deletions lib/ffi/gdal/grid_inverse_distance_to_a_power_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,37 @@

module FFI
module GDAL
# FFI structure for GDALGridInverseDistanceToAPowerOptions.
# @see https://gdal.org/api/gdal_alg.html#_CPPv438GDALGridInverseDistanceToAPowerOptions
class GridInverseDistanceToAPowerOptions < FFI::Struct
layout :power, :double,
:smoothing, :double,
:anisotropy_ratio, :double,
:anisotropy_angle, :double,
:radius1, :double,
:radius2, :double,
:angle, :double,
:max_points, CPL::Port.find_type(:GUInt32),
:min_points, CPL::Port.find_type(:GUInt32),
:no_data_value, :double
DEFAULT_LAYOUT = [
:power, :double,
:smoothing, :double,
:anisotropy_ratio, :double,
:anisotropy_angle, :double,
:radius1, :double,
:radius2, :double,
:angle, :double,
:max_points, CPL::Port.find_type(:GUInt32),
:min_points, CPL::Port.find_type(:GUInt32),
:no_data_value, :double
].freeze

LAYOUT_VERSIONS = [
InternalHelpers::LayoutVersion.new(
version: "0000000", # Any old GDAL
layout: DEFAULT_LAYOUT
),
InternalHelpers::LayoutVersion.new(
version: "3060000", # GDAL 3.6.0
layout: [
:n_size_of_structure, :size_t,
*DEFAULT_LAYOUT
]
)
].freeze

layout(*InternalHelpers::LayoutVersionResolver.resolve(versions: LAYOUT_VERSIONS))
end
end
end
35 changes: 30 additions & 5 deletions lib/ffi/gdal/grid_moving_average_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,37 @@

module FFI
module GDAL
# FFI structure for GDALGridMovingAverageOptions.
# @see https://gdal.org/api/gdal_alg.html#_CPPv428GDALGridMovingAverageOptions
class GridMovingAverageOptions < FFI::Struct
layout :radius1, :double,
:radius2, :double,
:angle, :double,
:min_points, CPL::Port.find_type(:GUInt32),
:no_data_value, :double
LAYOUT_VERSIONS = [
InternalHelpers::LayoutVersion.new(
version: "0000000", # Any old GDAL
layout: [
:radius1, :double,
:radius2, :double,
:angle, :double,
:min_points, CPL::Port.find_type(:GUInt32),
:no_data_value, :double
]
),
InternalHelpers::LayoutVersion.new(
version: "3060000", # GDAL 3.6.0
layout: [
:n_size_of_structure, :size_t,
:radius1, :double,
:radius2, :double,
:angle, :double,
:max_points, CPL::Port.find_type(:GUInt32),
:min_points, CPL::Port.find_type(:GUInt32),
:no_data_value, :double,
:max_points_per_quadrant, CPL::Port.find_type(:GUInt32),
:min_points_per_quadrant, CPL::Port.find_type(:GUInt32)
]
)
].freeze

layout(*InternalHelpers::LayoutVersionResolver.resolve(versions: LAYOUT_VERSIONS))
end
end
end
28 changes: 24 additions & 4 deletions lib/ffi/gdal/grid_nearest_neighbor_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,31 @@

module FFI
module GDAL
# FFI structure for GDALGridNearestNeighborOptions.
# @see https://gdal.org/api/gdal_alg.html#_CPPv430GDALGridNearestNeighborOptions
class GridNearestNeighborOptions < FFI::Struct
layout :radius1, :double,
:radius2, :double,
:angle, :double,
:no_data_value, :double
DEFAULT_LAYOUT = %i[
radius1 double
radius2 double
angle double
no_data_value double
].freeze

LAYOUT_VERSIONS = [
InternalHelpers::LayoutVersion.new(
version: "0000000", # Any old GDAL
layout: DEFAULT_LAYOUT
),
InternalHelpers::LayoutVersion.new(
version: "3060000", # GDAL 3.6.0
layout: [
:n_size_of_structure, :size_t,
*DEFAULT_LAYOUT
]
)
].freeze

layout(*InternalHelpers::LayoutVersionResolver.resolve(versions: LAYOUT_VERSIONS))
end
end
end
11 changes: 11 additions & 0 deletions lib/ffi/gdal/internal_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module FFI
module GDAL
module InternalHelpers
autoload :GDALVersion, File.expand_path("internal_helpers/gdal_version", __dir__)
autoload :LayoutVersion, File.expand_path("internal_helpers/layout_version", __dir__)
autoload :LayoutVersionResolver, File.expand_path("internal_helpers/layout_version_resolver", __dir__)
end
end
end
15 changes: 15 additions & 0 deletions lib/ffi/gdal/internal_helpers/gdal_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module FFI
module GDAL
module InternalHelpers
# Version information for GDAL.
class GDALVersion
# @return [String] GDAL Version.
def self.version
::FFI::GDAL.GDALVersionInfo("VERSION_NUM")
end
end
end
end
end
9 changes: 9 additions & 0 deletions lib/ffi/gdal/internal_helpers/layout_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module FFI
module GDAL
module InternalHelpers
LayoutVersion = ::Struct.new(:version, :layout, keyword_init: true)
end
end
end
24 changes: 24 additions & 0 deletions lib/ffi/gdal/internal_helpers/layout_version_resolver.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

module FFI
module GDAL
module InternalHelpers
# Resolve the layout version based on the GDAL version.
class LayoutVersionResolver
# Resolve the layout version based on the GDAL version.
# @param versions [Array<InternalHelpers::LayoutVersion>] The versions to resolve.
# @return [Array<Symbol, Integer>] The resolved layout.
def self.resolve(versions: [])
gdal_version = GDALVersion.version

versions
.sort_by(&:version)
.reverse_each
.find { |layout_version| gdal_version >= layout_version.version }
.layout
.freeze
end
end
end
end
end
4 changes: 4 additions & 0 deletions lib/gdal/extensions/gridder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
require "gdal"
require "gdal/options"
require "ogr"
require "ogr/extensions/envelope/extensions"
require "ogr/extensions/layer/extensions"
require "gdal/extensions/geo_transform/extensions"

require_relative "gridder_options"
require_relative "gridder/point_extracting"

Expand Down
2 changes: 2 additions & 0 deletions lib/gdal/grid_algorithms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module GDAL
module GridAlgorithms
autoload :AlgorithmBase,
File.expand_path("grid_algorithms/algorithm_base", __dir__)
autoload :InverseDistanceToAPower,
File.expand_path("grid_algorithms/inverse_distance_to_a_power", __dir__)
autoload :MetricAverageDistance,
Expand Down
35 changes: 35 additions & 0 deletions lib/gdal/grid_algorithms/algorithm_base.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

module GDAL
module GridAlgorithms
# Base abstract class for all grid algorithms.
class AlgorithmBase
# @return Options object.
attr_reader :options

def initialize
@options = options_class.new
assign_size_of_structure
end

# @return [Class] Options class.
def options_class
# This method must be overridden in subclasses.
end

# @return [Symbol] C identifier for the algorithm.
def c_identifier
# This method must be overridden in subclasses.
end

private

def assign_size_of_structure
# Starting GDAL 3.6.0 we must assign nSizeOfStructure to the size of the structure.
return unless @options.members.include?(:n_size_of_structure)

@options[:n_size_of_structure] = @options.size
end
end
end
end
14 changes: 0 additions & 14 deletions lib/gdal/grid_algorithms/data_metrics_base.rb

This file was deleted.

10 changes: 3 additions & 7 deletions lib/gdal/grid_algorithms/inverse_distance_to_a_power.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

module GDAL
module GridAlgorithms
class InverseDistanceToAPower
# @return [FFI::GDAL::GridInverseDistanceToAPowerOptions]
attr_reader :options

def initialize
@options = FFI::GDAL::GridInverseDistanceToAPowerOptions.new
class InverseDistanceToAPower < AlgorithmBase
def options_class
::FFI::GDAL::GridInverseDistanceToAPowerOptions
end

# @return [Symbol]
def c_identifier
:GGA_InverseDistanceToAPower
end
Expand Down
9 changes: 5 additions & 4 deletions lib/gdal/grid_algorithms/metric_average_distance.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# frozen_string_literal: true

require_relative "data_metrics_base"

module GDAL
module GridAlgorithms
class MetricAverageDistance < DataMetricsBase
# @return [Symbol]
class MetricAverageDistance < AlgorithmBase
def options_class
::FFI::GDAL::GridDataMetricsOptions
end

def c_identifier
:GGA_MetricAverageDistance
end
Expand Down
9 changes: 5 additions & 4 deletions lib/gdal/grid_algorithms/metric_average_distance_pts.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# frozen_string_literal: true

require_relative "data_metrics_base"

module GDAL
module GridAlgorithms
class MetricAverageDistancePts < DataMetricsBase
# @return [Symbol]
class MetricAverageDistancePts < AlgorithmBase
def options_class
::FFI::GDAL::GridDataMetricsOptions
end

def c_identifier
:GGA_MetricAverageDistancePts
end
Expand Down
9 changes: 5 additions & 4 deletions lib/gdal/grid_algorithms/metric_count.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# frozen_string_literal: true

require_relative "data_metrics_base"

module GDAL
module GridAlgorithms
class MetricCount < DataMetricsBase
# @return [Symbol]
class MetricCount < AlgorithmBase
def options_class
::FFI::GDAL::GridDataMetricsOptions
end

def c_identifier
:GGA_MetricCount
end
Expand Down
Loading

0 comments on commit 27f4060

Please sign in to comment.