Sha256: ceea4815a699c365ff75432415b24aa4c990ac0f98f9b717103e30cf4fb7a8fe

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

# frozen_string_literal: true

require_relative '../ogr'
require_relative 'envelope_extensions'

module OGR
  class Envelope
    include EnvelopeExtensions

    # @return [FFI::OGR::Envelope, FFI::OGR::Envelope3D] The C struct that this
    #   object wraps.
    attr_reader :c_struct

    # @param envelope_struct [FFI::OGR::Envelope]
    def initialize(envelope_struct = nil, three_d: false)
      @c_struct = envelope_struct
      @c_struct ||= three_d ? FFI::OGR::Envelope3D.new : FFI::OGR::Envelope.new
    end

    # @return [FFI::Pointer] Pointer to the C struct.
    def c_pointer
      @c_struct.to_ptr
    end

    # @return [Float]
    def x_min
      @c_struct[:min_x]
    end

    # @param new_x_min [Float]
    def x_min=(new_x_min)
      @c_struct[:min_x] = new_x_min
    end

    # @return [Float]
    def x_max
      @c_struct[:max_x]
    end

    # @param new_x_max [Float]
    def x_max=(new_x_max)
      @c_struct[:max_x] = new_x_max
    end

    # @return [Float]
    def y_min
      @c_struct[:min_y]
    end

    # @param new_y_min [Float]
    def y_min=(new_y_min)
      @c_struct[:min_y] = new_y_min
    end

    # @return [Float]
    def y_max
      @c_struct[:max_y]
    end

    # @param new_y_max [Float]
    def y_max=(new_y_max)
      @c_struct[:max_y] = new_y_max
    end

    # @return [Float, nil]
    def z_min
      return nil unless @c_struct.is_a? FFI::OGR::Envelope3D

      @c_struct[:min_z]
    end

    # @param new_z_min [Float]
    def z_min=(new_z_min)
      return nil unless @c_struct.is_a? FFI::OGR::Envelope3D

      @c_struct[:min_z] = new_z_min
    end

    # @return [Float, nil]
    def z_max
      return nil unless @c_struct.is_a? FFI::OGR::Envelope3D

      @c_struct[:max_z]
    end

    # @param new_z_max [Float]
    def z_max=(new_z_max)
      return nil unless @c_struct.is_a? FFI::OGR::Envelope3D

      @c_struct[:max_z] = new_z_max
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta8 lib/ogr/envelope.rb