Sha256: 3209606fef7c3bbc6ae069b289dd4f86805cba323ca4ad1213b76672abe98d5e

Contents?: true

Size: 1.53 KB

Versions: 6

Compression:

Stored size: 1.53 KB

Contents

# frozen_string_literal: true

module GDAL
  module Transformers
    class ApproximateTransformer
      # @return [FFI::Function]
      def self.function
        FFI::GDAL::Alg::ApproxTransform
      end

      # @param pointer [FFI::Pointer]
      def self.release(pointer)
        return unless pointer && !pointer.null?

        FFI::GDAL::Alg.GDALDestroyApproxTransformer(pointer)
      end

      # @return [FFI::Pointer]
      attr_reader :c_pointer

      # @param base_transformer [GDAL::Transformer]
      # @param max_error [Float] The maximum cartesian error in the "output" space
      #   that will be accepted in the linear approximation.
      def initialize(base_transformer, max_error)
        base_transformer_function = base_transformer.function
        transformer_arg_ptr = base_transformer.c_pointer

        pointer = FFI::GDAL::Alg.GDALCreateApproxTransformer(
          base_transformer_function,
          transformer_arg_ptr,
          max_error
        )

        @c_pointer = FFI::AutoPointer.new(pointer, ApproximateTransformer.method(:destroy))
      end

      def destroy!
        ApproximateTransformer.destroy(@c_pointer)

        @c_pointer = nil
      end

      # @return [FFI::Function]
      def function
        self.class.function
      end

      # @param data [FFI::Pointer] Pointer to the data that is passed to
      #   #function.
      # @param own_flag [Boolean]
      def owns_subtransformer(data, own_flag)
        FFI::GDAL::Alg.GDALApproxTransformerOwnsSubtransformer(data, own_flag)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ffi-gdal-1.1.0 lib/gdal/transformers/approximate_transformer.rb
ffi-gdal-1.0.4 lib/gdal/transformers/approximate_transformer.rb
ffi-gdal-1.0.3 lib/gdal/transformers/approximate_transformer.rb
ffi-gdal-1.0.2 lib/gdal/transformers/approximate_transformer.rb
ffi-gdal-1.0.1 lib/gdal/transformers/approximate_transformer.rb
ffi-gdal-1.0.0 lib/gdal/transformers/approximate_transformer.rb