Sha256: d0ad8087d7482dd92bc8524cc8c4e20dcae7a6d396f11b2c0e0d1114c31b18d3

Contents?: true

Size: 1.57 KB

Versions: 6

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

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

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

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

      # @return [FFI::Pointer]
      attr_reader :c_pointer

      def destroy!
        BaseGeneralImageProjectionTransformer.release(@c_pointer)

        @c_pointer = nil
      end

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

      # Normally the destination geotransform is extracted from the destination
      # file by the transformer and stored in internal private info. However,
      # sometimes it is inconvenient to have an output file handle with
      # appropriate geotransform information when creating the transformation.
      # For these cases, this function can be used to apply the destination
      # geotransform.
      #
      # @param [FFI::Pointer, GDAL::GeoTransform] geo_transform
      def destination_geo_transform=(geo_transform)
        geo_transform_ptr = GDAL._pointer(GDAL::GeoTransform, geo_transform)

        FFI::GDAL::Alg.GDALSetGenImgProjTransformerDstGeoTransform(
          @c_pointer, geo_transform_ptr
        )
      end

      private

      def init_pointer(pointer)
        @c_pointer = FFI::AutoPointer.new(pointer, BaseGeneralImageProjectionTransformer.method(:release))
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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