Class: GDAL::WarpOptions
- Inherits:
-
Object
show all
- Defined in:
- lib/gdal/warp_options.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ WarpOptions
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# 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
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth) ⇒ Object
Used for getting attributes of the internal WarpOptions struct.
199
200
201
202
203
|
# File 'lib/gdal/warp_options.rb', line 199
def method_missing(meth)
super unless FFI::GDAL::WarpOptions.members.include?(meth)
@c_struct[meth]
end
|
Instance Attribute Details
#c_struct ⇒ Object
Returns the value of attribute c_struct.
7
8
9
|
# File 'lib/gdal/warp_options.rb', line 7
def c_struct
@c_struct
end
|
#cutline ⇒ Object
Returns the value of attribute cutline.
7
8
9
|
# File 'lib/gdal/warp_options.rb', line 7
def cutline
@cutline
end
|
#destination_dataset ⇒ Object
Returns the value of attribute destination_dataset.
7
8
9
|
# File 'lib/gdal/warp_options.rb', line 7
def destination_dataset
@destination_dataset
end
|
#source_dataset ⇒ Object
Returns the value of attribute source_dataset.
7
8
9
|
# File 'lib/gdal/warp_options.rb', line 7
def source_dataset
@source_dataset
end
|
Instance Method Details
#c_pointer ⇒ Object
30
31
32
|
# File 'lib/gdal/warp_options.rb', line 30
def c_pointer
@c_struct.to_ptr
end
|
#destination_bands ⇒ Array<Integer>
85
86
87
88
89
90
|
# 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) ⇒ Object
76
77
78
79
80
81
82
|
# 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_no_data_imaginary ⇒ Array<Float>
164
165
166
167
168
169
|
# 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) ⇒ Object
156
157
158
159
160
161
|
# 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 ⇒ Array<Float>
148
149
150
151
152
153
|
# 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) ⇒ Object
140
141
142
143
144
145
|
# 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
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
205
206
207
|
# 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 ⇒ Array<Integer>
68
69
70
71
72
73
|
# 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) ⇒ Object
59
60
61
62
63
64
65
|
# 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_no_data_imaginary ⇒ Array<Float>
132
133
134
135
136
137
|
# 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) ⇒ Object
124
125
126
127
128
129
|
# 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 ⇒ Array<Float>
116
117
118
119
120
121
|
# 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) ⇒ Object
108
109
110
111
112
113
|
# 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) ⇒ Object
Set a Proc per source band; number of procs in band_procs
should equal the internal band_count
.
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
# 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)
mask_func.return_type
else
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
|
92
93
94
95
96
|
# 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 ⇒ Hash
40
41
42
43
44
|
# 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) ⇒ Object
35
36
37
|
# File 'lib/gdal/warp_options.rb', line 35
def warp_operation_options=(options)
@c_struct[:warp_operation_options] = GDAL::Options.pointer(options)
end
|