class GDAL::WarpOptions

Attributes

c_struct[R]
cutline[R]
destination_dataset[R]
source_dataset[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/gdal/warp_options.rb, line 9
def initialize(options = {})
  @c_struct = FFI::GDAL::WarpOptions.new
  @source_dataset = nil
  @destination_dataset = nil

  options.each_key do |k|
    assign_meth = :"#{k}="

    begin
      if respond_to?(assign_meth)
        send(assign_meth, options[k])
      else
        @c_struct[k] = options[k]
      end
    rescue ArgumentError => e
      new_message = "#{k}; #{e.message}"
      raise $ERROR_INFO, new_message, $ERROR_INFO.backtrace
    end
  end
end

Public Instance Methods

c_pointer() click to toggle source
# File lib/gdal/warp_options.rb, line 30
def c_pointer
  @c_struct.to_ptr
end
cutline=(geometry) click to toggle source

@param geometry [OGR::Geometry]

# File lib/gdal/warp_options.rb, line 99
def cutline=(geometry)
  raise "Not a geom" unless geometry.is_a?(OGR::Geometry)

  @cutline = geometry

  @c_struct[:cutline] = geometry.c_pointer
end
destination_bands() click to toggle source

@return [Array<Integer>]

# File lib/gdal/warp_options.rb, line 85
def destination_bands
  pointer = @c_struct[:destination_bands]
  return [] if pointer.null?

  pointer.read_array_of_int(@c_struct[:band_count])
end
destination_bands=(band_numbers) click to toggle source

@param band_numbers [Array<Integer>]

# File lib/gdal/warp_options.rb, line 76
def destination_bands=(band_numbers)
  bands_ptr = FFI::MemoryPointer.new(:pointer, band_numbers.length)
  bands_ptr.write_array_of_int(band_numbers)

  @c_struct[:destination_bands] = bands_ptr
  @c_struct[:band_count] = band_numbers.length if band_numbers.length > @c_struct[:band_count]
end
destination_dataset=(dataset) click to toggle source

@param dataset [GDAL::Dataset]

# File lib/gdal/warp_options.rb, line 53
def destination_dataset=(dataset)
  @destination_dataset = dataset
  @c_struct[:destination_dataset] = dataset.c_pointer
end
destination_no_data_imaginary() click to toggle source

@return [Array<Float>]

# File lib/gdal/warp_options.rb, line 164
def destination_no_data_imaginary
  pointer = @c_struct[:destination_no_data_imaginary]
  return [] if pointer.null?

  pointer.read_array_of_double(@c_struct[:band_count])
end
destination_no_data_imaginary=(values) click to toggle source

@param values [Array<Float>]

# File lib/gdal/warp_options.rb, line 156
def destination_no_data_imaginary=(values)
  values_ptr = FFI::MemoryPointer.new(:double, values.length)
  values_ptr.write_array_of_double(values)

  @c_struct[:destination_no_data_imaginary] = values_ptr
end
destination_no_data_real() click to toggle source

@return [Array<Float>]

# File lib/gdal/warp_options.rb, line 148
def destination_no_data_real
  pointer = @c_struct[:destination_no_data_real]
  return [] if pointer.null?

  pointer.read_array_of_double(@c_struct[:band_count])
end
destination_no_data_real=(values) click to toggle source

@param values [Array<Float>]

# File lib/gdal/warp_options.rb, line 140
def destination_no_data_real=(values)
  values_ptr = FFI::MemoryPointer.new(:double, values.length)
  values_ptr.write_array_of_double(values)

  @c_struct[:destination_no_data_real] = values_ptr
end
method_missing(meth) click to toggle source

Used for getting attributes of the internal WarpOptions struct.

@param meth [Symbol] The FFI::GDAL::WarpOptions key.

Calls superclass method
# File lib/gdal/warp_options.rb, line 199
def method_missing(meth)
  super unless FFI::GDAL::WarpOptions.members.include?(meth)

  @c_struct[meth]
end
respond_to_missing?(method_name, include_private = false) click to toggle source
Calls superclass method
# File lib/gdal/warp_options.rb, line 205
def respond_to_missing?(method_name, include_private = false)
  FFI::GDAL::WarpOptions.members.include?(method_name) || super
end
source_bands() click to toggle source

@return [Array<Integer>]

# File lib/gdal/warp_options.rb, line 68
def source_bands
  pointer = @c_struct[:source_bands]
  return [] if pointer.null?

  pointer.read_array_of_int(@c_struct[:band_count])
end
source_bands=(band_numbers) click to toggle source

@param band_numbers [Array<Integer>]

# File lib/gdal/warp_options.rb, line 59
def source_bands=(band_numbers)
  bands_ptr = FFI::MemoryPointer.new(:int, band_numbers.length)
  bands_ptr.write_array_of_int(band_numbers)

  @c_struct[:source_bands] = bands_ptr
  @c_struct[:band_count] = band_numbers.length if band_numbers.length > @c_struct[:band_count]
end
source_dataset=(dataset) click to toggle source

@param dataset [GDAL::Dataset]

# File lib/gdal/warp_options.rb, line 47
def source_dataset=(dataset)
  @source_dataset = dataset
  @c_struct[:source_dataset] = dataset.c_pointer
end
source_no_data_imaginary() click to toggle source

@return [Array<Float>]

# File lib/gdal/warp_options.rb, line 132
def source_no_data_imaginary
  pointer = @c_struct[:source_no_data_imaginary]
  return [] if pointer.null?

  pointer.read_array_of_double(@c_struct[:band_count])
end
source_no_data_imaginary=(values) click to toggle source

@param values [Array<Float>]

# File lib/gdal/warp_options.rb, line 124
def source_no_data_imaginary=(values)
  values_ptr = FFI::MemoryPointer.new(:double, values.length)
  values_ptr.write_array_of_double(values)

  @c_struct[:source_no_data_imaginary] = values_ptr
end
source_no_data_real() click to toggle source

@return [Array<Float>]

# File lib/gdal/warp_options.rb, line 116
def source_no_data_real
  pointer = @c_struct[:source_no_data_real]
  return [] if pointer.null?

  pointer.read_array_of_double(@c_struct[:band_count])
end
source_no_data_real=(values) click to toggle source

@param values [Array<Float>]

# File lib/gdal/warp_options.rb, line 108
def source_no_data_real=(values)
  values_ptr = FFI::MemoryPointer.new(:double, values.length)
  values_ptr.write_array_of_double(values)

  @c_struct[:source_no_data_real] = values_ptr
end
source_per_band_validity_mask_function=(band_procs) click to toggle source

Set a Proc per source band; number of procs in band_procs should equal the internal band_count.

@param band_procs [Array<Proc>]

# File lib/gdal/warp_options.rb, line 175
def source_per_band_validity_mask_function=(band_procs)
  mask_func = FFI::GDAL::Warper::MaskFunc

  mask_func_return_type =
    if mask_func.respond_to?(:return_type)
      # `.return_type` is for FFI 1.16.0+;
      mask_func.return_type
    else
      # `.result_type` is for older FFI versions.
      mask_func.result_type
    end

  funcs = band_procs.map do |band_proc|
    FFI::Function.new(mask_func_return_type, mask_func.param_types, band_proc, blocking: true)
  end

  pointer = FFI::MemoryPointer.new(:pointer, band_procs.length)
  pointer.write_array_of_pointer(funcs)
  @c_struct[:source_per_band_validity_mask_function] = pointer
end
transformer_arg=(transformation_object) click to toggle source
# File lib/gdal/warp_options.rb, line 92
def transformer_arg=(transformation_object)
  @c_struct[:transformer_arg] = transformation_object.c_pointer

  @c_struct[:transformer] = transformation_object.function
end
warp_operation_options() click to toggle source

@return [Hash]

# File lib/gdal/warp_options.rb, line 40
def warp_operation_options
  options = @c_struct[:warp_operation_options]

  GDAL::Options.to_hash(options)
end
warp_operation_options=(options) click to toggle source

@param options [Hash]

# File lib/gdal/warp_options.rb, line 35
def warp_operation_options=(options)
  @c_struct[:warp_operation_options] = GDAL::Options.pointer(options)
end