Sha256: 2f3600cd01a0c251af9adc495f6d2c98c559bc594c740a53c3cabaad3a5883d3

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require_relative '../../ffi/gdal/alg'

module GDAL
  module Transformers
    class GeolocationTransformer
      # @return [FFI::Function]
      def self.function
        FFI::GDAL::Alg::GeoLocTransform
      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)

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

        ObjectSpace.define_finalizer self, -> { destroy! }
      end

      def destroy!
        return unless @c_pointer

        FFI::GDAL::Alg.GDALDestroyGeoLocTransformer(@c_pointer)
        @c_pointer = nil
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta5 lib/gdal/transformers/geolocation_transformer.rb
ffi-gdal-1.0.0.beta4 lib/gdal/transformers/geolocation_transformer.rb