Sha256: 29d4fb8d5bd70c73c143a8164f4b197ee8019bed8f4d140a60081189467c4475

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

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

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

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

      # @param gcp_list [Array<FFI::GDAL::GCP>]
      # @param reversed [Boolean]
      def initialize(gcp_list, reversed = false)
        gcp_list_ptr = FFI::MemoryPointer.new(:pointer, gcp_list.size)

        gcp_list.each_with_index do |gcp, i|
          gcp_list_ptr[i].put_pointer(0, gcp.to_ptr)
        end

        @c_pointer = FFI::GDAL::Alg.GDALCreateTPSTransformer(gcp_list.size, gcp_list_ptr, reversed)
        ObjectSpace.define_finalizer self, -> { destroy! }
      end

      def destroy!
        return unless @c_pointer

        FFI::GDAL::Alg.GDALDestroyTPSTransformer(@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/tps_transformer.rb
ffi-gdal-1.0.0.beta4 lib/gdal/transformers/tps_transformer.rb