Sha256: 60bcf3c819710eb9e6f9cdeea45dcb51c93f692e11cbc8c48581c304a707adb8

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

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)

        # TODO: fasterer: each_with_index is slower than loop
        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)
      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

9 entries across 9 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta16 lib/gdal/transformers/tps_transformer.rb
ffi-gdal-1.0.0.beta15 lib/gdal/transformers/tps_transformer.rb
ffi-gdal-1.0.0.beta14 lib/gdal/transformers/tps_transformer.rb
ffi-gdal-1.0.0.beta13 lib/gdal/transformers/tps_transformer.rb
ffi-gdal-1.0.0.beta12 lib/gdal/transformers/tps_transformer.rb
ffi-gdal-1.0.0.beta11 lib/gdal/transformers/tps_transformer.rb
ffi-gdal-1.0.0.beta10 lib/gdal/transformers/tps_transformer.rb
ffi-gdal-1.0.0.beta9 lib/gdal/transformers/tps_transformer.rb
ffi-gdal-1.0.0.beta8 lib/gdal/transformers/tps_transformer.rb