Sha256: 9ba6da7fe3cd5cfb6fc52846831d16c60b5d7d93937ca3a412f84ed968b5aac7

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module GDAL
  module Transformers
    class ReprojectionTransformer
      # @return [FFI::Pointer]
      def self.function
        FFI::GDAL::Alg::ReprojectionTransform
      end

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

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

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

      # @param source_wkt [String]
      # @param destination_wkt [String]
      def initialize(source_wkt, destination_wkt)
        pointer = FFI::GDAL::Alg.GDALCreateReprojectionTransformer(source_wkt, destination_wkt)

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

      def destroy!
        ReprojectionTransformer.release(@c_pointer)

        @c_pointer = nil
      end

      # @return [FFI::Pointer]
      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/reprojection_transformer.rb
ffi-gdal-1.0.4 lib/gdal/transformers/reprojection_transformer.rb
ffi-gdal-1.0.3 lib/gdal/transformers/reprojection_transformer.rb
ffi-gdal-1.0.2 lib/gdal/transformers/reprojection_transformer.rb
ffi-gdal-1.0.1 lib/gdal/transformers/reprojection_transformer.rb
ffi-gdal-1.0.0 lib/gdal/transformers/reprojection_transformer.rb