Sha256: f853b0c506f9da20fedc09bec1448b851bd1c1bfe9ae57735ffd31549ab6003a

Contents?: true

Size: 1.28 KB

Versions: 6

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

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

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

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

      # @return [FFI::Pointer] C pointer to the C geolocation transformer.
      attr_reader :c_pointer

      # @param base_dataset [GDAL::Dataset]
      # @param geolocation_info [Array<String>]
      # @param reversed [Boolean]
      def intialize(base_dataset, geolocation_info, reversed: false)
        base_dataset_ptr = GDAL._pointer(GDAL::Dataset, base_dataset)
        geolocation_info_ptr = GDAL._string_array_to_pointer(geolocation_info)

        pointer = FFI::GDAL::Alg.CreateGeoLocTransformer(
          base_dataset_ptr,
          geolocation_info_ptr,
          reversed
        )

        @c_pointer = FFI::AutoPointer.new(pointer, GeolocationTransformer.method(:release))
      end

      def destroy!
        GeolocationTransformer.release(@c_pointer)

        @c_pointer = nil
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

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