ffi-gdal 1.0.0.beta6 → 1.0.0.beta7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +40 -0
- data/bitbucket-pipelines.yml +16 -0
- data/lib/ffi/gdal/version.rb +1 -1
- data/lib/ffi/gdal/warp_options.rb +18 -4
- data/lib/ffi/gdal/warper.rb +17 -1
- data/lib/ffi/gdal.rb +1 -1
- data/lib/gdal/color_entry_mixins/extensions.rb +0 -14
- data/lib/gdal/color_table_mixins/extensions.rb +0 -14
- data/lib/gdal/dataset_mixins/algorithm_methods.rb +2 -2
- data/lib/gdal/dataset_mixins/extensions.rb +3 -43
- data/lib/gdal/dataset_mixins/warp_methods.rb +50 -11
- data/lib/gdal/geo_transform_mixins/extensions.rb +0 -17
- data/lib/gdal/grid.rb +2 -1
- data/lib/gdal/gridder/point_extracting.rb +1 -2
- data/lib/gdal/gridder.rb +7 -2
- data/lib/gdal/options.rb +14 -13
- data/lib/gdal/raster_attribute_table_mixins/extensions.rb +0 -15
- data/lib/gdal/raster_band.rb +5 -3
- data/lib/gdal/raster_band_classifier.rb +5 -3
- data/lib/gdal/raster_band_mixins/extensions.rb +0 -35
- data/lib/gdal/raster_band_mixins/io_extensions.rb +4 -3
- data/lib/gdal/warp_options.rb +99 -35
- data/lib/gdal.rb +1 -0
- data/lib/ogr/data_source_extensions.rb +0 -19
- data/lib/ogr/envelope_extensions.rb +0 -22
- data/lib/ogr/feature_definition_extensions.rb +0 -18
- data/lib/ogr/feature_extensions.rb +0 -27
- data/lib/ogr/field_definition.rb +0 -3
- data/lib/ogr/geometry.rb +0 -1
- data/lib/ogr/geometry_field_definition.rb +0 -4
- data/lib/ogr/geometry_mixins/extensions.rb +0 -29
- data/lib/ogr/geometry_types/curve.rb +1 -1
- data/lib/ogr/layer.rb +3 -1
- data/lib/ogr/layer_mixins/extensions.rb +1 -25
- data/lib/ogr/spatial_reference.rb +10 -2
- data/lib/ogr/spatial_reference_extensions.rb +0 -26
- data/lib/ogr/style_table_extensions.rb +0 -10
- data/spec/integration/gdal/raster_band_info_spec.rb +27 -5
- data/spec/integration/ogr/layer_spec.rb +0 -6
- data/spec/support/images/123.tiff +0 -0
- data/spec/unit/ffi/gdal_spec.rb +1 -0
- data/spec/unit/gdal/dataset_mixins/warp_methods_spec.rb +52 -0
- data/spec/unit/gdal/geo_transform_spec.rb +0 -13
- data/spec/unit/gdal/grid_spec.rb +8 -0
- data/spec/unit/gdal/gridder_spec.rb +40 -0
- data/spec/unit/gdal/options_spec.rb +26 -1
- data/spec/unit/gdal/warp_options_spec.rb +336 -0
- data/spec/unit/ogr/feature_definition_spec.rb +0 -19
- data/spec/unit/ogr/feature_extensions_spec.rb +1 -1
- data/spec/unit/ogr/field_definition_spec.rb +0 -19
- data/spec/unit/ogr/geometry_field_definition_spec.rb +0 -16
- data/spec/unit/ogr/style_table_spec.rb +0 -26
- metadata +10 -5
- data/lib/ogr/field_definition_extensions.rb +0 -22
- data/lib/ogr/geometry_field_definition_extensions.rb +0 -19
@@ -24,6 +24,7 @@ module GDAL
|
|
24
24
|
# @param pixel_array [NArray] The 2d list of pixels.
|
25
25
|
def write_xy_narray(pixel_array)
|
26
26
|
data_pointer = FFI::MemoryPointer.new(:buffer_out, block_buffer_size)
|
27
|
+
read_start = 0
|
27
28
|
|
28
29
|
block_count[:y].times do |y_block_number|
|
29
30
|
block_count[:x].times do |x_block_number|
|
@@ -31,14 +32,14 @@ module GDAL
|
|
31
32
|
x_block_size = calculate_x_block_size(x_block_number)
|
32
33
|
|
33
34
|
pixel_count_per_block = x_block_size * y_block_size
|
34
|
-
|
35
|
-
read_range = ((read_offset - 1) * pixel_count_per_block)...(read_offset * pixel_count_per_block)
|
35
|
+
read_range = (read_start...(read_start + pixel_count_per_block))
|
36
36
|
pixels = pixel_array[read_range]
|
37
37
|
GDAL._write_pointer(data_pointer, data_type, pixels.to_a)
|
38
38
|
|
39
39
|
write_block(x_block_number, y_block_number, data_pointer)
|
40
40
|
|
41
41
|
data_pointer.clear
|
42
|
+
read_start = read_range.end
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
@@ -69,7 +70,7 @@ module GDAL
|
|
69
70
|
# Determines not only x and y block counts (how many blocks there are in
|
70
71
|
# the raster band when using GDAL's suggested block size), but remainder
|
71
72
|
# x and y counts for when the total number of pixels and lines does not
|
72
|
-
# divide
|
73
|
+
# divide evenly using GDAL's block count.
|
73
74
|
#
|
74
75
|
# @return [Hash{x => Fixnum, x_remainder => Fixnum, y => Fixnum,
|
75
76
|
# y_remainder => Fixnum}]
|
data/lib/gdal/warp_options.rb
CHANGED
@@ -3,12 +3,28 @@ require_relative '../gdal'
|
|
3
3
|
module GDAL
|
4
4
|
class WarpOptions
|
5
5
|
attr_reader :c_struct
|
6
|
+
attr_reader :source_dataset
|
7
|
+
attr_reader :destination_dataset
|
8
|
+
attr_reader :cutline
|
6
9
|
|
7
10
|
def initialize(options = {})
|
8
11
|
@c_struct = FFI::GDAL::WarpOptions.new
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
@source_dataset = nil
|
13
|
+
@destination_dataset = nil
|
14
|
+
|
15
|
+
options.each_key do |k|
|
16
|
+
assign_meth = "#{k}=".to_sym
|
17
|
+
|
18
|
+
begin
|
19
|
+
if respond_to?(assign_meth)
|
20
|
+
send(assign_meth, options[k])
|
21
|
+
else
|
22
|
+
@c_struct[k] = options[k]
|
23
|
+
end
|
24
|
+
rescue ArgumentError => ex
|
25
|
+
new_message = "#{k}; #{ex.message}"
|
26
|
+
raise $ERROR_INFO, new_message, $ERROR_INFO.backtrace
|
27
|
+
end
|
12
28
|
end
|
13
29
|
end
|
14
30
|
|
@@ -21,42 +37,40 @@ module GDAL
|
|
21
37
|
@c_struct[:warp_operation_options] = GDAL::Options.pointer(options)
|
22
38
|
end
|
23
39
|
|
24
|
-
# @
|
25
|
-
def
|
26
|
-
@c_struct[:
|
27
|
-
end
|
40
|
+
# @return [Hash]
|
41
|
+
def warp_operation_options
|
42
|
+
options = @c_struct[:warp_operation_options]
|
28
43
|
|
29
|
-
|
30
|
-
def resample_algorithm=(algorithm_type)
|
31
|
-
@c_struct[:resample_alg] = algorithm_type
|
32
|
-
end
|
33
|
-
|
34
|
-
# @param data_type [FFI::GDAL::GDAL::DataType]
|
35
|
-
def working_data_type=(data_type)
|
36
|
-
@c_struct[:working_data_type] = data_type
|
44
|
+
GDAL::Options.to_hash(options)
|
37
45
|
end
|
38
46
|
|
39
47
|
# @param dataset [GDAL::Dataset]
|
40
48
|
def source_dataset=(dataset)
|
49
|
+
@source_dataset = dataset
|
41
50
|
@c_struct[:source_dataset] = dataset.c_pointer
|
42
51
|
end
|
43
52
|
|
44
53
|
# @param dataset [GDAL::Dataset]
|
45
54
|
def destination_dataset=(dataset)
|
55
|
+
@destination_dataset = dataset
|
46
56
|
@c_struct[:destination_dataset] = dataset.c_pointer
|
47
57
|
end
|
48
58
|
|
49
|
-
# @param count [Fixnum]
|
50
|
-
def band_count=(count)
|
51
|
-
@c_struct[:band_count] = count
|
52
|
-
end
|
53
|
-
|
54
59
|
# @param band_numbers [Array<Fixnum>]
|
55
60
|
def source_bands=(band_numbers)
|
56
|
-
bands_ptr = FFI::MemoryPointer.new(:
|
61
|
+
bands_ptr = FFI::MemoryPointer.new(:int, band_numbers.length)
|
57
62
|
bands_ptr.write_array_of_int(band_numbers)
|
58
63
|
|
59
64
|
@c_struct[:source_bands] = bands_ptr
|
65
|
+
@c_struct[:band_count] = band_numbers.length if band_numbers.length > @c_struct[:band_count]
|
66
|
+
end
|
67
|
+
|
68
|
+
# @return [Array<Fixnum>]
|
69
|
+
def source_bands
|
70
|
+
pointer = @c_struct[:source_bands]
|
71
|
+
return [] if pointer.null?
|
72
|
+
|
73
|
+
pointer.read_array_of_int(@c_struct[:band_count])
|
60
74
|
end
|
61
75
|
|
62
76
|
# @param band_numbers [Array<Fixnum>]
|
@@ -65,33 +79,32 @@ module GDAL
|
|
65
79
|
bands_ptr.write_array_of_int(band_numbers)
|
66
80
|
|
67
81
|
@c_struct[:destination_bands] = bands_ptr
|
82
|
+
@c_struct[:band_count] = band_numbers.length if band_numbers.length > @c_struct[:band_count]
|
68
83
|
end
|
69
84
|
|
70
|
-
|
71
|
-
|
85
|
+
# @return [Array<Fixnum>]
|
86
|
+
def destination_bands
|
87
|
+
pointer = @c_struct[:destination_bands]
|
88
|
+
return [] if pointer.null?
|
72
89
|
|
73
|
-
@c_struct[:
|
90
|
+
pointer.read_array_of_int(@c_struct[:band_count])
|
74
91
|
end
|
75
92
|
|
76
|
-
def
|
77
|
-
@c_struct[:
|
78
|
-
end
|
93
|
+
def transformer_arg=(transformation_object)
|
94
|
+
@c_struct[:transformer_arg] = transformation_object.c_pointer
|
79
95
|
|
80
|
-
|
81
|
-
@c_struct[:progress] = output_proc
|
96
|
+
@c_struct[:transformer] = transformation_object.function
|
82
97
|
end
|
83
98
|
|
84
|
-
|
99
|
+
# @param geometry [OGR::Geometry]
|
100
|
+
def cutline=(geometry)
|
85
101
|
raise 'Not a geom' unless geometry.is_a?(OGR::Geometry)
|
102
|
+
@cutline = geometry
|
86
103
|
|
87
104
|
@c_struct[:cutline] = geometry.c_pointer
|
88
|
-
# @c_struct[:cutline] = geometry.clone.c_pointer
|
89
|
-
end
|
90
|
-
|
91
|
-
def cutline_blend_distance=(distance)
|
92
|
-
@c_struct[:cutline_blend_distance] = distance
|
93
105
|
end
|
94
106
|
|
107
|
+
# @param values [Array<Float>]
|
95
108
|
def source_no_data_real=(values)
|
96
109
|
values_ptr = FFI::MemoryPointer.new(:double, values.length)
|
97
110
|
values_ptr.write_array_of_double(values)
|
@@ -99,6 +112,15 @@ module GDAL
|
|
99
112
|
@c_struct[:source_no_data_real] = values_ptr
|
100
113
|
end
|
101
114
|
|
115
|
+
# @return [Array<Float>]
|
116
|
+
def source_no_data_real
|
117
|
+
pointer = @c_struct[:source_no_data_real]
|
118
|
+
return [] if pointer.null?
|
119
|
+
|
120
|
+
pointer.read_array_of_double(@c_struct[:band_count])
|
121
|
+
end
|
122
|
+
|
123
|
+
# @param values [Array<Float>]
|
102
124
|
def source_no_data_imaginary=(values)
|
103
125
|
values_ptr = FFI::MemoryPointer.new(:double, values.length)
|
104
126
|
values_ptr.write_array_of_double(values)
|
@@ -106,6 +128,15 @@ module GDAL
|
|
106
128
|
@c_struct[:source_no_data_imaginary] = values_ptr
|
107
129
|
end
|
108
130
|
|
131
|
+
# @return [Array<Float>]
|
132
|
+
def source_no_data_imaginary
|
133
|
+
pointer = @c_struct[:source_no_data_imaginary]
|
134
|
+
return [] if pointer.null?
|
135
|
+
|
136
|
+
pointer.read_array_of_double(@c_struct[:band_count])
|
137
|
+
end
|
138
|
+
|
139
|
+
# @param values [Array<Float>]
|
109
140
|
def destination_no_data_real=(values)
|
110
141
|
values_ptr = FFI::MemoryPointer.new(:double, values.length)
|
111
142
|
values_ptr.write_array_of_double(values)
|
@@ -113,6 +144,15 @@ module GDAL
|
|
113
144
|
@c_struct[:destination_no_data_real] = values_ptr
|
114
145
|
end
|
115
146
|
|
147
|
+
# @return [Array<Float>]
|
148
|
+
def destination_no_data_real
|
149
|
+
pointer = @c_struct[:destination_no_data_real]
|
150
|
+
return [] if pointer.null?
|
151
|
+
|
152
|
+
pointer.read_array_of_double(@c_struct[:band_count])
|
153
|
+
end
|
154
|
+
|
155
|
+
# @param values [Array<Float>]
|
116
156
|
def destination_no_data_imaginary=(values)
|
117
157
|
values_ptr = FFI::MemoryPointer.new(:double, values.length)
|
118
158
|
values_ptr.write_array_of_double(values)
|
@@ -120,6 +160,30 @@ module GDAL
|
|
120
160
|
@c_struct[:destination_no_data_imaginary] = values_ptr
|
121
161
|
end
|
122
162
|
|
163
|
+
# @return [Array<Float>]
|
164
|
+
def destination_no_data_imaginary
|
165
|
+
pointer = @c_struct[:destination_no_data_imaginary]
|
166
|
+
return [] if pointer.null?
|
167
|
+
|
168
|
+
pointer.read_array_of_double(@c_struct[:band_count])
|
169
|
+
end
|
170
|
+
|
171
|
+
# Set a Proc per source band; number of procs in +band_procs+ should equal
|
172
|
+
# {band_count}.
|
173
|
+
#
|
174
|
+
# @param band_procs [Array<Proc>]
|
175
|
+
def source_per_band_validity_mask_function=(band_procs)
|
176
|
+
mask_func = FFI::GDAL::Warper::MaskFunc
|
177
|
+
|
178
|
+
funcs = band_procs.map do |band_proc|
|
179
|
+
FFI::Function.new(mask_func.result_type, mask_func.param_types, band_proc, blocking: true)
|
180
|
+
end
|
181
|
+
|
182
|
+
pointer = FFI::MemoryPointer.new(:pointer, band_procs.length)
|
183
|
+
pointer.write_array_of_pointer(funcs)
|
184
|
+
@c_struct[:source_per_band_validity_mask_function] = pointer
|
185
|
+
end
|
186
|
+
|
123
187
|
# Used for getting attributes of the internal WarpOptions struct.
|
124
188
|
#
|
125
189
|
# @param meth [Symbol] The FFI::GDAL::WarpOptions key.
|
data/lib/gdal.rb
CHANGED
@@ -30,6 +30,7 @@ module GDAL
|
|
30
30
|
autoload :Driver, gdal_require('gdal/driver')
|
31
31
|
autoload :GeoTransform, gdal_require('gdal/geo_transform')
|
32
32
|
autoload :Logger, gdal_require('gdal/logger')
|
33
|
+
autoload :MajorObject, gdal_require('gdal/major_object')
|
33
34
|
autoload :Options, gdal_require('gdal/options')
|
34
35
|
autoload :RasterAttributeTable, gdal_require('gdal/raster_attribute_table')
|
35
36
|
autoload :RasterBand, gdal_require('gdal/raster_band')
|
@@ -4,24 +4,5 @@ module OGR
|
|
4
4
|
def layers
|
5
5
|
@layers = Array.new(layer_count) { |i| layer(i) }
|
6
6
|
end
|
7
|
-
|
8
|
-
# @return [Hash]
|
9
|
-
def as_json(options = nil)
|
10
|
-
{
|
11
|
-
data_source: {
|
12
|
-
driver: driver.name,
|
13
|
-
layer_count: layer_count,
|
14
|
-
layers: layers.map(&:as_json),
|
15
|
-
name: name,
|
16
|
-
style_table: style_table ? style_table.as_json(options) : nil
|
17
|
-
},
|
18
|
-
metadata: all_metadata
|
19
|
-
}
|
20
|
-
end
|
21
|
-
|
22
|
-
# @return [String]
|
23
|
-
def to_json(options = nil)
|
24
|
-
as_json(options).to_json
|
25
|
-
end
|
26
7
|
end
|
27
8
|
end
|
@@ -101,28 +101,6 @@ module OGR
|
|
101
101
|
polygon
|
102
102
|
end
|
103
103
|
|
104
|
-
# @return [Hash]
|
105
|
-
def as_json(_options = nil)
|
106
|
-
json = {
|
107
|
-
x_min: x_min,
|
108
|
-
x_max: x_max,
|
109
|
-
y_min: y_min,
|
110
|
-
y_max: y_max
|
111
|
-
}
|
112
|
-
|
113
|
-
if @c_struct.is_a? FFI::OGR::Envelope3D
|
114
|
-
json[:z_min] = z_min
|
115
|
-
json[:z_max] = z_max
|
116
|
-
end
|
117
|
-
|
118
|
-
json
|
119
|
-
end
|
120
|
-
|
121
|
-
# @return [String]
|
122
|
-
def to_json(options = nil)
|
123
|
-
as_json(options).to_json
|
124
|
-
end
|
125
|
-
|
126
104
|
def to_a
|
127
105
|
[x_min, y_min, x_max, y_max]
|
128
106
|
end
|
@@ -33,23 +33,5 @@ module OGR
|
|
33
33
|
|
34
34
|
geometry_field_definition(g)
|
35
35
|
end
|
36
|
-
|
37
|
-
# @return [Hash]
|
38
|
-
def as_json(_options = nil)
|
39
|
-
{
|
40
|
-
field_count: field_count,
|
41
|
-
field_definitions: field_definitions.map(&:as_json),
|
42
|
-
geometry_field_count: geometry_field_count,
|
43
|
-
geometry_type: geometry_type,
|
44
|
-
is_geometry_ignored: geometry_ignored?,
|
45
|
-
is_style_ignored: style_ignored?,
|
46
|
-
name: name
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
# @return [String]
|
51
|
-
def to_json(options = nil)
|
52
|
-
as_json(options).to_json
|
53
|
-
end
|
54
36
|
end
|
55
37
|
end
|
@@ -81,32 +81,5 @@ module OGR
|
|
81
81
|
def geometry_fields
|
82
82
|
each_geometry_field.to_a
|
83
83
|
end
|
84
|
-
|
85
|
-
# @return [Hash]
|
86
|
-
def as_json(options = nil)
|
87
|
-
fields_with_nested_json = fields.map.with_index do |f, i|
|
88
|
-
{
|
89
|
-
field_definition: field_definition(i).as_json(options),
|
90
|
-
value: f
|
91
|
-
}
|
92
|
-
end
|
93
|
-
|
94
|
-
{
|
95
|
-
definition: definition.as_json(options),
|
96
|
-
fid: fid,
|
97
|
-
field_count: field_count,
|
98
|
-
fields: fields_with_nested_json,
|
99
|
-
geometry: geometry ? geometry.as_json(options) : nil,
|
100
|
-
geometry_field_count: geometry_field_count,
|
101
|
-
geometry_field_definition: each_geometry_field_definition.map { |gfd| gfd.as_json(options) },
|
102
|
-
style_string: style_string,
|
103
|
-
style_table: style_table ? style_table.as_json(options) : nil
|
104
|
-
}
|
105
|
-
end
|
106
|
-
|
107
|
-
# @return [String]
|
108
|
-
def to_json(options = nil)
|
109
|
-
as_json(options).to_json
|
110
|
-
end
|
111
84
|
end
|
112
85
|
end
|
data/lib/ogr/field_definition.rb
CHANGED
data/lib/ogr/geometry.rb
CHANGED
@@ -53,35 +53,6 @@ module OGR
|
|
53
53
|
!valid?
|
54
54
|
end
|
55
55
|
|
56
|
-
# @return [Hash]
|
57
|
-
def as_json(options = nil)
|
58
|
-
json = {
|
59
|
-
coordinate_dimension: coordinate_dimension,
|
60
|
-
geometry_count: geometry_count,
|
61
|
-
dimension: dimension,
|
62
|
-
is_empty: empty?,
|
63
|
-
is_ring: ring?,
|
64
|
-
is_simple: simple?,
|
65
|
-
is_valid: valid?,
|
66
|
-
name: name,
|
67
|
-
point_count: point_count,
|
68
|
-
spatial_reference: spatial_reference.nil? ? nil : spatial_reference.as_json(options),
|
69
|
-
type: type_to_name,
|
70
|
-
wkb_size: wkb_size
|
71
|
-
}
|
72
|
-
|
73
|
-
json[:area] = area if respond_to? :area
|
74
|
-
json[:length] = length if respond_to? :length
|
75
|
-
json[:points] = points if respond_to? :points
|
76
|
-
|
77
|
-
json
|
78
|
-
end
|
79
|
-
|
80
|
-
# @return [String]
|
81
|
-
def to_json(options = nil)
|
82
|
-
as_json(options).to_json
|
83
|
-
end
|
84
|
-
|
85
56
|
def collection?
|
86
57
|
false
|
87
58
|
end
|
@@ -102,7 +102,7 @@ module OGR
|
|
102
102
|
y_buffer = FFI::MemoryPointer.new(:buffer_out, buffer_size)
|
103
103
|
z_buffer = FFI::MemoryPointer.new(:buffer_out, buffer_size) if coordinate_dimension == 3
|
104
104
|
|
105
|
-
FFI::OGR::API.OGR_G_GetPoints(@c_pointer,
|
105
|
+
num_points = FFI::OGR::API.OGR_G_GetPoints(@c_pointer,
|
106
106
|
x_buffer, x_stride, y_buffer,
|
107
107
|
y_stride, z_buffer, z_stride)
|
108
108
|
|
data/lib/ogr/layer.rb
CHANGED
@@ -20,7 +20,9 @@ module OGR
|
|
20
20
|
include LayerMixins::OGRQueryFilterMethods
|
21
21
|
include LayerMixins::OGRSQLMethods
|
22
22
|
|
23
|
-
|
23
|
+
FFI::OGR::Core::OGR_ALTER.constants.each do |_name, obj|
|
24
|
+
const_set(obj.ruby_name, obj.value.to_i(16))
|
25
|
+
end
|
24
26
|
|
25
27
|
# @return [FFI::Pointer] C pointer to the C Layer.
|
26
28
|
attr_reader :c_pointer
|
@@ -66,7 +66,7 @@ module OGR
|
|
66
66
|
#
|
67
67
|
# @return [Array<OGR::Feature>]
|
68
68
|
def features
|
69
|
-
each_feature.map
|
69
|
+
each_feature.map(&:clone)
|
70
70
|
end
|
71
71
|
|
72
72
|
# @return [OGR::Polygon] A polygon derived from a LinearRing that connects
|
@@ -229,30 +229,6 @@ module OGR
|
|
229
229
|
found_z_geom
|
230
230
|
end
|
231
231
|
|
232
|
-
# @return [Hash]
|
233
|
-
def as_json(options = nil)
|
234
|
-
{
|
235
|
-
layer: {
|
236
|
-
extent: extent.as_json(options),
|
237
|
-
feature_count: feature_count,
|
238
|
-
feature_definition: feature_definition.as_json(options),
|
239
|
-
features: each_feature.map { |f| f.as_json(options) },
|
240
|
-
fid_column: fid_column,
|
241
|
-
geometry_column: geometry_column,
|
242
|
-
geometry_type: geometry_type,
|
243
|
-
name: name,
|
244
|
-
spatial_reference: spatial_reference ? spatial_reference.as_json(options) : nil,
|
245
|
-
style_table: style_table ? style_table.as_json(options) : nil
|
246
|
-
},
|
247
|
-
metadata: nil # all_metadata
|
248
|
-
}
|
249
|
-
end
|
250
|
-
|
251
|
-
# @return [String]
|
252
|
-
def to_json(options = nil)
|
253
|
-
as_json(options).to_json
|
254
|
-
end
|
255
|
-
|
256
232
|
private
|
257
233
|
|
258
234
|
# @param geometry_ptr [FFI::Pointer]
|
@@ -22,9 +22,17 @@ module OGR
|
|
22
22
|
include SpatialReferenceMixins::ParameterGetterSetters
|
23
23
|
include SpatialReferenceMixins::TypeChecks
|
24
24
|
|
25
|
-
class_eval FFI::OGR::SRSAPI::SRS_UL.to_ruby
|
25
|
+
# class_eval FFI::OGR::SRSAPI::SRS_UL.to_ruby
|
26
|
+
FFI::OGR::SRSAPI::SRS_UL.constants.each do |_name, obj|
|
27
|
+
const_set(obj.ruby_name, obj.value)
|
28
|
+
end
|
29
|
+
|
26
30
|
METER_TO_METER = 1.0
|
27
|
-
|
31
|
+
|
32
|
+
FFI::OGR::SRSAPI::SRS_UA.constants.each do |_name, obj|
|
33
|
+
const_set(obj.ruby_name, obj.value)
|
34
|
+
end
|
35
|
+
|
28
36
|
RADIAN_TO_RADIAN = 1.0
|
29
37
|
|
30
38
|
# @return [Array<String>]
|
@@ -28,31 +28,5 @@ module OGR
|
|
28
28
|
rescue NameError
|
29
29
|
raise NameError, "Param must be a known linear unit type: #{unit_label}"
|
30
30
|
end
|
31
|
-
|
32
|
-
# @return [Hash]
|
33
|
-
def as_json(_options = nil)
|
34
|
-
{
|
35
|
-
angular_units: angular_units,
|
36
|
-
epsg_treats_as_lat_long: epsg_treats_as_lat_long?,
|
37
|
-
epsg_treats_as_northing_easting: epsg_treats_as_northing_easting?,
|
38
|
-
is_compound: compound?,
|
39
|
-
is_geocentric: geocentric?,
|
40
|
-
is_geographic: geographic?,
|
41
|
-
is_local: local?,
|
42
|
-
is_projected: projected?,
|
43
|
-
is_vertical: vertical?,
|
44
|
-
linear_units: linear_units,
|
45
|
-
prime_meridian: prime_meridian,
|
46
|
-
semi_major: semi_major,
|
47
|
-
semi_minor: semi_minor,
|
48
|
-
spheroid_inverse_flattening: spheroid_inverse_flattening,
|
49
|
-
utm_zone: utm_zone
|
50
|
-
}
|
51
|
-
end
|
52
|
-
|
53
|
-
# @return [String]
|
54
|
-
def to_json(options = nil)
|
55
|
-
as_json(options).to_json
|
56
|
-
end
|
57
31
|
end
|
58
32
|
end
|
@@ -8,6 +8,13 @@ RSpec.describe 'Raster Band Info', type: :integration do
|
|
8
8
|
File.expand_path(path, __dir__)
|
9
9
|
end
|
10
10
|
|
11
|
+
let(:nodata_tiff) do
|
12
|
+
path = '../../../spec/support/images/123.tiff'
|
13
|
+
File.expand_path(path, __dir__)
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:nodata_dataset) { GDAL::Dataset.open(nodata_tiff, 'r') }
|
17
|
+
|
11
18
|
let(:tmp_tiff) { make_temp_test_file(original_tiff) }
|
12
19
|
let(:dataset) { GDAL::Dataset.open(tmp_tiff, 'w') }
|
13
20
|
after { dataset.close }
|
@@ -89,12 +96,27 @@ RSpec.describe 'Raster Band Info', type: :integration do
|
|
89
96
|
end
|
90
97
|
end
|
91
98
|
|
92
|
-
|
93
|
-
|
94
|
-
|
99
|
+
context 'no data not set' do
|
100
|
+
describe '#no_data_value' do
|
101
|
+
it 'is a Hash with :value and :is_associated keys' do
|
102
|
+
expect(subject.no_data_value).to be_an Hash
|
95
103
|
|
96
|
-
|
97
|
-
|
104
|
+
expect(subject.no_data_value[:value]).to be_nil
|
105
|
+
expect(subject.no_data_value[:is_associated]).to_not be_nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'no data is set' do
|
111
|
+
subject { nodata_dataset.raster_band(1) }
|
112
|
+
|
113
|
+
describe '#no_data_value' do
|
114
|
+
it 'is a Hash with :value and :is_associated keys' do
|
115
|
+
expect(subject.no_data_value).to be_an Hash
|
116
|
+
|
117
|
+
expect(subject.no_data_value[:value]).to be_a Float
|
118
|
+
expect(subject.no_data_value[:is_associated]).to_not be_nil
|
119
|
+
end
|
98
120
|
end
|
99
121
|
end
|
100
122
|
|
Binary file
|
data/spec/unit/ffi/gdal_spec.rb
CHANGED
@@ -9,6 +9,7 @@ RSpec.describe FFI::GDAL do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'returns GDAL_LIBRARY_PATH + libgdal file name' do
|
12
|
+
expect(Dir).to receive(:[]).with(%r{/pants/stuff\.+}).and_return '/pants/stuff.dylib'
|
12
13
|
expect(described_class.find_lib('stuff')).to match %r{\A/pants/stuff\.+}
|
13
14
|
end
|
14
15
|
end
|