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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +40 -0
  3. data/bitbucket-pipelines.yml +16 -0
  4. data/lib/ffi/gdal/version.rb +1 -1
  5. data/lib/ffi/gdal/warp_options.rb +18 -4
  6. data/lib/ffi/gdal/warper.rb +17 -1
  7. data/lib/ffi/gdal.rb +1 -1
  8. data/lib/gdal/color_entry_mixins/extensions.rb +0 -14
  9. data/lib/gdal/color_table_mixins/extensions.rb +0 -14
  10. data/lib/gdal/dataset_mixins/algorithm_methods.rb +2 -2
  11. data/lib/gdal/dataset_mixins/extensions.rb +3 -43
  12. data/lib/gdal/dataset_mixins/warp_methods.rb +50 -11
  13. data/lib/gdal/geo_transform_mixins/extensions.rb +0 -17
  14. data/lib/gdal/grid.rb +2 -1
  15. data/lib/gdal/gridder/point_extracting.rb +1 -2
  16. data/lib/gdal/gridder.rb +7 -2
  17. data/lib/gdal/options.rb +14 -13
  18. data/lib/gdal/raster_attribute_table_mixins/extensions.rb +0 -15
  19. data/lib/gdal/raster_band.rb +5 -3
  20. data/lib/gdal/raster_band_classifier.rb +5 -3
  21. data/lib/gdal/raster_band_mixins/extensions.rb +0 -35
  22. data/lib/gdal/raster_band_mixins/io_extensions.rb +4 -3
  23. data/lib/gdal/warp_options.rb +99 -35
  24. data/lib/gdal.rb +1 -0
  25. data/lib/ogr/data_source_extensions.rb +0 -19
  26. data/lib/ogr/envelope_extensions.rb +0 -22
  27. data/lib/ogr/feature_definition_extensions.rb +0 -18
  28. data/lib/ogr/feature_extensions.rb +0 -27
  29. data/lib/ogr/field_definition.rb +0 -3
  30. data/lib/ogr/geometry.rb +0 -1
  31. data/lib/ogr/geometry_field_definition.rb +0 -4
  32. data/lib/ogr/geometry_mixins/extensions.rb +0 -29
  33. data/lib/ogr/geometry_types/curve.rb +1 -1
  34. data/lib/ogr/layer.rb +3 -1
  35. data/lib/ogr/layer_mixins/extensions.rb +1 -25
  36. data/lib/ogr/spatial_reference.rb +10 -2
  37. data/lib/ogr/spatial_reference_extensions.rb +0 -26
  38. data/lib/ogr/style_table_extensions.rb +0 -10
  39. data/spec/integration/gdal/raster_band_info_spec.rb +27 -5
  40. data/spec/integration/ogr/layer_spec.rb +0 -6
  41. data/spec/support/images/123.tiff +0 -0
  42. data/spec/unit/ffi/gdal_spec.rb +1 -0
  43. data/spec/unit/gdal/dataset_mixins/warp_methods_spec.rb +52 -0
  44. data/spec/unit/gdal/geo_transform_spec.rb +0 -13
  45. data/spec/unit/gdal/grid_spec.rb +8 -0
  46. data/spec/unit/gdal/gridder_spec.rb +40 -0
  47. data/spec/unit/gdal/options_spec.rb +26 -1
  48. data/spec/unit/gdal/warp_options_spec.rb +336 -0
  49. data/spec/unit/ogr/feature_definition_spec.rb +0 -19
  50. data/spec/unit/ogr/feature_extensions_spec.rb +1 -1
  51. data/spec/unit/ogr/field_definition_spec.rb +0 -19
  52. data/spec/unit/ogr/geometry_field_definition_spec.rb +0 -16
  53. data/spec/unit/ogr/style_table_spec.rb +0 -26
  54. metadata +10 -5
  55. data/lib/ogr/field_definition_extensions.rb +0 -22
  56. data/lib/ogr/geometry_field_definition_extensions.rb +0 -19
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+ require 'gdal'
3
+
4
+ RSpec.describe GDAL::Dataset do
5
+ let(:source_file_path) do
6
+ File.expand_path('../../../support/images/osgeo/geotiff/GeogToWGS84GeoKey/GeogToWGS84GeoKey5.tif', __dir__)
7
+ end
8
+
9
+ let(:output_dir) { Dir.mktmpdir(File.basename(__FILE__, '.rb')) }
10
+ let(:output_file) { File.join(output_dir, 'reprojected_image.tif') }
11
+
12
+ after { FileUtils.rm_rf(output_dir) if Dir.exist?(output_dir) }
13
+
14
+ subject { described_class.open(source_file_path, 'r', false) }
15
+
16
+ describe '#reproject_image' do
17
+ let(:dest_dataset) do
18
+ dest_width = subject.raster_x_size / 4
19
+ dest_height = subject.raster_y_size / 4
20
+ dataset = GDAL::Driver.by_name('GTiff').create_dataset(output_file, dest_width, dest_height,
21
+ data_type: subject.raster_band(1).data_type)
22
+ dataset.geo_transform = subject.geo_transform.dup
23
+ dataset.projection = OGR::SpatialReference.new_from_epsg(3857).to_wkt
24
+ dataset
25
+ end
26
+
27
+ after { dest_dataset.close }
28
+
29
+ it 'creates a valid dataset' do
30
+ subject.reproject_image(dest_dataset, :GRA_CubicSpline)
31
+
32
+ dest_dataset.flush_cache
33
+ expect(dest_dataset.projection).to match(/AUTHORITY\[\"EPSG\",\"3857\"\]/)
34
+ expect(dest_dataset.raster_count).to eq(subject.raster_count)
35
+ end
36
+ end
37
+
38
+ describe '#create_and_reproject_image' do
39
+ let(:output_projection) { OGR::SpatialReference.new_from_epsg(3857).to_wkt }
40
+
41
+ it 'creates a valid dataset' do
42
+ subject.create_and_reproject_image(output_file, :GRA_NearestNeighbor, OGR::SpatialReference.new_from_epsg(3857).to_wkt, GDAL::Driver.by_name('GTiff'))
43
+
44
+ dest_dataset = GDAL::Dataset.open(output_file, 'r')
45
+ expect(dest_dataset.projection).to match(/AUTHORITY\[\"EPSG\",\"3857\"\]/)
46
+ expect(dest_dataset.raster_count).to eq(subject.raster_count)
47
+
48
+ dest_driver = dest_dataset.driver
49
+ expect(dest_driver.long_name).to eq 'GeoTIFF'
50
+ end
51
+ end
52
+ end
@@ -259,18 +259,5 @@ RSpec.describe GDAL::GeoTransform do
259
259
  expect(result).to eq pixel: -9000, line: -19_000
260
260
  end
261
261
  end
262
-
263
- describe '#as_json' do
264
- it 'returns the attributes as a Hash' do
265
- expect(subject.as_json).to eq(
266
- x_origin: 0.0,
267
- x_rotation: 0.0,
268
- pixel_width: 0.0,
269
- y_origin: 0.0,
270
- y_rotation: 0.0,
271
- pixel_height: 0.0
272
- )
273
- end
274
- end
275
262
  end
276
263
  end
@@ -12,6 +12,14 @@ RSpec.describe GDAL::Grid do
12
12
  it { is_expected.to respond_to :algorithm_type }
13
13
  end
14
14
 
15
+ describe '#create' do
16
+ context 'no points to grid' do
17
+ it 'raises a GDAL::NoValuesToGrid' do
18
+ expect { subject.create([], {}, nil) }.to raise_exception GDAL::NoValuesToGrid
19
+ end
20
+ end
21
+ end
22
+
15
23
  describe '#make_points_pointer' do
16
24
  context 'array has values' do
17
25
  let(:points) { [1, 2, 3, 4] }
@@ -137,4 +137,44 @@ RSpec.describe GDAL::Gridder do
137
137
  end
138
138
  end
139
139
  end
140
+
141
+ describe '#build_block_count' do
142
+ it 'builds block sizes for both x and y' do
143
+ raster_width = 4
144
+ block_x_size = 2
145
+ raster_height = 5
146
+ block_y_size = 3
147
+
148
+ expect(subject).to receive(:build_block_size).with(raster_width, block_x_size).
149
+ and_call_original
150
+ expect(subject).to receive(:build_block_size).with(raster_height, block_y_size).
151
+ and_call_original
152
+
153
+ subject.send(:build_block_count, block_x_size, block_y_size, raster_width, raster_height)
154
+ end
155
+ end
156
+
157
+ describe '#build_block_size' do
158
+ context 'calculation should not be evenly divisible' do
159
+ it 'returns the floor of the count' do
160
+ raster_width = 4
161
+ block_x_size = 2
162
+
163
+ result = subject.send(:build_block_size, raster_width, block_x_size)
164
+
165
+ expect(result).to eq 2
166
+ end
167
+ end
168
+
169
+ context 'calculation should be evenly divisible' do
170
+ it 'returns the floor of the count' do
171
+ raster_width = 4
172
+ block_x_size = 1
173
+
174
+ result = subject.send(:build_block_size, raster_width, block_x_size)
175
+
176
+ expect(result).to eq 4
177
+ end
178
+ end
179
+ end
140
180
  end
@@ -2,5 +2,30 @@ require 'spec_helper'
2
2
  require 'gdal/options'
3
3
 
4
4
  RSpec.describe GDAL::Options do
5
- pending 'Add some tests!'
5
+ describe '.to_hash' do
6
+ subject { described_class.to_hash(pointer) }
7
+
8
+ context 'options are set' do
9
+ let(:pointer) { described_class.pointer(hash) }
10
+
11
+ let(:hash) do
12
+ {
13
+ one: 'ONE',
14
+ two: 'TWO'
15
+ }
16
+ end
17
+
18
+ it 'returns the Ruby Hash' do
19
+ expect(subject).to eq(hash)
20
+ end
21
+ end
22
+
23
+ context 'pointer is null' do
24
+ let(:pointer) { FFI::MemoryPointer.new(:string) }
25
+
26
+ it 'returns an empty Hash' do
27
+ expect(subject).to eq({})
28
+ end
29
+ end
30
+ end
6
31
  end
@@ -0,0 +1,336 @@
1
+ require 'spec_helper'
2
+ require 'gdal/warp_options'
3
+
4
+ RSpec.describe GDAL::WarpOptions do
5
+ shared_examples 'a WarpOptions object' do
6
+ it 'inits proper types' do
7
+ expect(subject.warp_operation_options).to be_a Hash
8
+
9
+ expect(subject.source_bands).to be_a Array
10
+ expect(subject.destination_bands).to be_a Array
11
+
12
+ expect(subject.source_no_data_real).to be_a Array
13
+ expect(subject.source_no_data_imaginary).to be_a Array
14
+ expect(subject.destination_no_data_real).to be_a Array
15
+ expect(subject.destination_no_data_imaginary).to be_a Array
16
+
17
+ expect(subject.progress).to be_a FFI::Function
18
+ expect(subject.progress_arg).to be_a FFI::Pointer
19
+ expect(subject.transformer).to be_a FFI::Function
20
+ expect(subject.transformer_arg).to be_a FFI::Pointer
21
+
22
+ expect(subject.source_per_band_validity_mask_function).to be_a FFI::Pointer
23
+ expect(subject.source_per_band_validity_mask_function_arg).to be_a FFI::Pointer
24
+ expect(subject.source_validity_mask_function).to be_a FFI::Function
25
+ expect(subject.source_validity_mask_function_arg).to be_a FFI::Pointer
26
+ expect(subject.source_density_mask_function).to be_a FFI::Function
27
+ expect(subject.source_density_mask_function_arg).to be_a FFI::Pointer
28
+
29
+ expect(subject.destination_density_mask_function).to be_a FFI::Function
30
+ expect(subject.destination_density_mask_function_arg).to be_a FFI::Pointer
31
+ expect(subject.destination_validity_mask_function).to be_a FFI::Function
32
+ expect(subject.destination_validity_mask_function_arg).to be_a FFI::Pointer
33
+
34
+ expect(subject.pre_warp_chunk_processor).to be_a FFI::Function
35
+ expect(subject.pre_warp_processor_arg).to be_a FFI::Pointer
36
+ expect(subject.post_warp_chunk_processor).to be_a FFI::Function
37
+ expect(subject.post_warp_processor_arg).to be_a FFI::Pointer
38
+ end
39
+ end
40
+
41
+ describe '#initialize' do
42
+ context 'with no options' do
43
+ it_behaves_like 'a WarpOptions object'
44
+
45
+ it 'inits a FFI::GDAL::WarpOptions struct internally, with nothing set' do
46
+ expect(subject.warp_operation_options).to eq({})
47
+
48
+ expect(subject.warp_memory_limit).to be_zero
49
+ expect(subject.resample_alg).to eq(:GRA_NearestNeighbor) # 0 enum
50
+ expect(subject.working_data_type).to eq(:GDT_Unknown) # 0 enum
51
+
52
+ expect(subject.source_dataset).to be_nil
53
+ expect(subject.destination_dataset).to be_nil
54
+
55
+ expect(subject.band_count).to be_zero
56
+ expect(subject.source_bands).to be_empty
57
+ expect(subject.destination_bands).to be_empty
58
+
59
+ expect(subject.source_alpha_band).to be_zero
60
+ expect(subject.destination_alpha_band).to be_zero
61
+
62
+ expect(subject.source_no_data_real).to eq([])
63
+ expect(subject.source_no_data_imaginary).to eq([])
64
+ expect(subject.destination_no_data_real).to eq([])
65
+ expect(subject.destination_no_data_imaginary).to eq([])
66
+
67
+ expect(subject.progress).to_not be_null
68
+ expect(subject.progress_arg).to be_null
69
+
70
+ expect(subject.transformer).to be_null
71
+ expect(subject.transformer_arg).to be_null
72
+
73
+ expect(subject.source_per_band_validity_mask_function).to be_null
74
+ expect(subject.source_per_band_validity_mask_function_arg).to be_null
75
+
76
+ expect(subject.source_validity_mask_function).to be_null
77
+ expect(subject.source_validity_mask_function_arg).to be_null
78
+
79
+ expect(subject.source_density_mask_function).to be_null
80
+ expect(subject.source_density_mask_function_arg).to be_null
81
+
82
+ expect(subject.destination_density_mask_function).to be_null
83
+ expect(subject.destination_density_mask_function_arg).to be_null
84
+
85
+ expect(subject.destination_validity_mask_function).to be_null
86
+ expect(subject.destination_validity_mask_function_arg).to be_null
87
+
88
+ expect(subject.pre_warp_chunk_processor).to be_null
89
+ expect(subject.pre_warp_processor_arg).to be_null
90
+ expect(subject.post_warp_chunk_processor).to be_null
91
+ expect(subject.post_warp_processor_arg).to be_null
92
+
93
+ expect(subject.cutline).to be_nil
94
+ expect(subject.cutline_blend_distance).to eq(0.0)
95
+ end
96
+ end
97
+
98
+ context 'passing in options that are also accessor methods' do
99
+ let(:warp_operation_options) do
100
+ {
101
+ init_dest: 'NODATA',
102
+ write_flush: 'YES',
103
+ skip_nosource: 'NO',
104
+ sample_grid: 'YES'
105
+ }
106
+ end
107
+
108
+ let(:memory_driver) { GDAL::Driver.by_name('MEM') }
109
+ let(:source_dataset) { memory_driver.create_dataset 'source', 10, 20 }
110
+ let(:dest_dataset) { memory_driver.create_dataset 'dest', 20, 30 }
111
+ let(:cutline) { OGR::LineString.new }
112
+ let(:spb_validity_mask_function1) { proc { true } }
113
+ let(:spb_validity_mask_function2) { proc { false } }
114
+
115
+ after do
116
+ source_dataset.close
117
+ dest_dataset.close
118
+ end
119
+
120
+ subject do
121
+ described_class.new warp_operation_options: warp_operation_options,
122
+ source_dataset: source_dataset,
123
+ destination_dataset: dest_dataset,
124
+ source_bands: [1, 2, 3],
125
+ destination_bands: [2, 4, 6],
126
+ cutline: cutline,
127
+ source_no_data_real: [123.456, 78.9, -999.9],
128
+ source_no_data_imaginary: [1.2, 3.4, -5.6],
129
+ destination_no_data_real: [11.1, 22.2, 33.3],
130
+ destination_no_data_imaginary: [-44.4, -55.5, -66.6],
131
+ source_per_band_validity_mask_function: [
132
+ spb_validity_mask_function1,
133
+ spb_validity_mask_function2
134
+ ]
135
+ end
136
+
137
+ it_behaves_like 'a WarpOptions object'
138
+
139
+ it 'sets warp_operation_options' do
140
+ expect(subject.warp_operation_options).to eq(warp_operation_options)
141
+ end
142
+
143
+ it' sets source_dataset and the internal pointer' do
144
+ expect(subject.source_dataset).to eq(source_dataset)
145
+ expect(subject.c_struct[:source_dataset]).to eq(source_dataset.c_pointer)
146
+ end
147
+
148
+ it' sets destination_dataset' do
149
+ expect(subject.destination_dataset).to eq(dest_dataset)
150
+ expect(subject.c_struct[:destination_dataset]).to eq(dest_dataset.c_pointer)
151
+ end
152
+
153
+ it 'sets source_bands' do
154
+ expect(subject.source_bands).to eq([1, 2, 3])
155
+ end
156
+
157
+ it 'sets destination_bands' do
158
+ expect(subject.destination_bands).to eq([2, 4, 6])
159
+ end
160
+
161
+ it 'sets band_count and the internal to 3' do
162
+ expect(subject.band_count).to eq 3
163
+ expect(subject.c_struct[:band_count]).to eq 3
164
+ end
165
+
166
+ it 'sets cutline and its internal pointer' do
167
+ expect(subject.cutline).to eq(cutline)
168
+ expect(subject.c_struct[:cutline]).to eq(cutline.c_pointer)
169
+ end
170
+
171
+ it 'sets source_no_data_real' do
172
+ expect(subject.source_no_data_real).to eq([123.456, 78.9, -999.9])
173
+ end
174
+
175
+ it 'sets source_no_data_imaginary' do
176
+ expect(subject.source_no_data_imaginary).to eq([1.2, 3.4, -5.6])
177
+ end
178
+
179
+ it 'sets destination_no_data_real' do
180
+ expect(subject.destination_no_data_real).to eq([11.1, 22.2, 33.3])
181
+ end
182
+
183
+ it 'sets destination_no_data_imaginary' do
184
+ expect(subject.destination_no_data_imaginary).to eq([-44.4, -55.5, -66.6])
185
+ end
186
+
187
+ it 'sets source_per_band_validity_mask_function' do
188
+ function_ptr = subject.source_per_band_validity_mask_function
189
+ expect(function_ptr).to be_a(FFI::Pointer)
190
+
191
+ function = function_ptr.read_pointer
192
+ expect(function).to_not be_null
193
+ end
194
+ end
195
+
196
+ context 'passing in options that are NOT accessor methods' do
197
+ def make_int_pointer(int)
198
+ i = FFI::MemoryPointer.new(:int)
199
+ i.write_int(int)
200
+ i
201
+ end
202
+
203
+ let(:progress) { proc { true } }
204
+ let(:test_mask_function) { proc { true } }
205
+
206
+ let(:source_per_band_validity_mask_function_arg) { make_int_pointer(5) }
207
+ let(:source_validity_mask_function_arg) { make_int_pointer(3) }
208
+ let(:source_density_mask_function_arg) { make_int_pointer(2) }
209
+ let(:destination_validity_mask_function_arg) { make_int_pointer(4) }
210
+ let(:destination_density_mask_function_arg) { make_int_pointer(11) }
211
+ let(:pre_warp_processor_arg) { make_int_pointer(7) }
212
+ let(:post_warp_processor_arg) { make_int_pointer(9) }
213
+
214
+ subject do
215
+ described_class.new warp_memory_limit: 123,
216
+ resample_alg: :GRA_Lanczos,
217
+ working_data_type: :GDT_CInt32,
218
+ band_count: 3,
219
+ source_alpha_band: 1,
220
+ destination_alpha_band: 5,
221
+ progress: progress,
222
+ progress_arg: FFI::CPL::Progress::ScaledProgress,
223
+ source_per_band_validity_mask_function_arg: source_per_band_validity_mask_function_arg,
224
+ source_validity_mask_function: test_mask_function,
225
+ source_validity_mask_function_arg: source_validity_mask_function_arg,
226
+ source_density_mask_function: test_mask_function,
227
+ source_density_mask_function_arg: source_density_mask_function_arg,
228
+ destination_validity_mask_function: test_mask_function,
229
+ destination_validity_mask_function_arg: destination_validity_mask_function_arg,
230
+ destination_density_mask_function: test_mask_function,
231
+ destination_density_mask_function_arg: destination_density_mask_function_arg,
232
+ pre_warp_chunk_processor: proc { :CE_Warning },
233
+ pre_warp_processor_arg: pre_warp_processor_arg,
234
+ post_warp_chunk_processor: proc { :CE_Failure },
235
+ post_warp_processor_arg: post_warp_processor_arg,
236
+ cutline_blend_distance: 3.3
237
+ end
238
+
239
+ it_behaves_like 'a WarpOptions object'
240
+
241
+ it 'sets warp_memory_limit' do
242
+ expect(subject.warp_memory_limit).to eq(123)
243
+ end
244
+
245
+ it 'sets resample_alg' do
246
+ expect(subject.resample_alg).to eq(:GRA_Lanczos)
247
+ end
248
+
249
+ it 'sets working_data_type' do
250
+ expect(subject.working_data_type).to eq(:GDT_CInt32)
251
+ end
252
+
253
+ it 'sets band_count' do
254
+ expect(subject.band_count).to eq(3)
255
+ end
256
+
257
+ it 'sets source_alpha_band' do
258
+ expect(subject.source_alpha_band).to eq(1)
259
+ end
260
+
261
+ it 'sets destination_alpha_band' do
262
+ expect(subject.destination_alpha_band).to eq(5)
263
+ end
264
+
265
+ it 'sets progress_arg' do
266
+ expect(subject.progress_arg).to eq(FFI::CPL::Progress::ScaledProgress)
267
+ end
268
+
269
+ it 'sets source_per_band_validity_mask_function_arg' do
270
+ pointer = subject.source_per_band_validity_mask_function_arg
271
+ pointer.autorelease = false
272
+ expect(pointer.read_int).to eq 5
273
+ end
274
+
275
+ it 'sets source_validity_mask_function' do
276
+ expect(subject.source_validity_mask_function).to_not be_null
277
+ end
278
+
279
+ it 'sets source_validity_mask_function_arg' do
280
+ pointer = subject.source_validity_mask_function_arg
281
+ pointer.autorelease = false
282
+ expect(pointer.read_int).to eq 3
283
+ end
284
+
285
+ it 'sets source_density_mask_function' do
286
+ expect(subject.source_density_mask_function).to_not be_null
287
+ end
288
+
289
+ it 'sets source_density_mask_function_arg' do
290
+ pointer = subject.source_density_mask_function_arg
291
+ pointer.autorelease = false
292
+ expect(pointer.read_int).to eq 2
293
+ end
294
+
295
+ it 'sets destination_validity_mask_function' do
296
+ expect(subject.destination_validity_mask_function).to_not be_null
297
+ end
298
+
299
+ it 'sets destination_validity_mask_function_arg' do
300
+ pointer = subject.destination_validity_mask_function_arg
301
+ pointer.autorelease = false
302
+ expect(pointer.read_int).to eq 4
303
+ end
304
+
305
+ it 'sets destination_density_mask_function' do
306
+ expect(subject.destination_density_mask_function).to_not be_null
307
+ end
308
+
309
+ it 'sets destination_density_mask_function_arg' do
310
+ pointer = subject.destination_density_mask_function_arg
311
+ pointer.autorelease = false
312
+ expect(pointer.read_int).to eq 11
313
+ end
314
+
315
+ it 'sets pre_warp_chunk_processor' do
316
+ expect(subject.pre_warp_chunk_processor.call(nil, nil)).to eq(:CE_Warning)
317
+ end
318
+
319
+ it 'sets pre_warp_chunk_processor_arg' do
320
+ expect(subject.pre_warp_processor_arg).to_not be_null
321
+ end
322
+
323
+ it 'sets post_warp_chunk_processor' do
324
+ expect(subject.post_warp_chunk_processor.call(nil, nil)).to eq(:CE_Failure)
325
+ end
326
+
327
+ it 'sets post_warp_chunk_processor_arg' do
328
+ expect(subject.post_warp_processor_arg).to_not be_null
329
+ end
330
+
331
+ it 'sets cutline_blend_distance' do
332
+ expect(subject.cutline_blend_distance).to eq(3.3)
333
+ end
334
+ end
335
+ end
336
+ end
@@ -291,23 +291,4 @@ RSpec.describe OGR::FeatureDefinition do
291
291
  end
292
292
  end
293
293
  end
294
-
295
- describe '#as_json' do
296
- it 'returns a Hash of all attributes and values' do
297
- expect(subject.as_json).to eq(field_count: 0,
298
- field_definitions: [],
299
- geometry_field_count: 1,
300
- geometry_type: :wkbMultiPolygon,
301
- is_geometry_ignored: false,
302
- is_style_ignored: false,
303
- name: 'spec feature definition')
304
- end
305
- end
306
-
307
- describe '#to_json' do
308
- it 'is a String' do
309
- expect(subject.to_json).to be_a String
310
- expect(subject.to_json).to_not be_empty
311
- end
312
- end
313
294
  end
@@ -6,7 +6,7 @@ RSpec.describe OGR::Feature do
6
6
 
7
7
  let(:feature_definition) do
8
8
  fd = OGR::FeatureDefinition.new('test FD')
9
- fd.add_field_definition(integer_field_def) # 0
9
+ fd.add_field_definition(integer_field_def) # 0
10
10
 
11
11
  gfd = fd.geometry_field_definition(0)
12
12
  gfd.type = :wkbPoint
@@ -113,23 +113,4 @@ RSpec.describe OGR::FieldDefinition do
113
113
  expect(subject).to be_ignored
114
114
  end
115
115
  end
116
-
117
- describe '#as_json' do
118
- it 'returns a Hash of attributes' do
119
- expect(subject.as_json).to eq(
120
- is_ignored: false,
121
- justification: :OJUndefined,
122
- name: 'test field',
123
- precision: 0,
124
- type: :OFTInteger,
125
- width: 0
126
- )
127
- end
128
- end
129
-
130
- describe '#to_json' do
131
- it 'returns a string' do
132
- expect(subject.to_json).to be_a String
133
- end
134
- end
135
116
  end
@@ -68,20 +68,4 @@ RSpec.describe OGR::GeometryFieldDefinition do
68
68
  end
69
69
  end
70
70
  end
71
-
72
- describe '#as_json' do
73
- it 'returns a Hash of attributes' do
74
- expect(subject.as_json). to eq(
75
- is_ignored: false,
76
- name: 'test gfld',
77
- spatial_reference: nil,
78
- type: :wkbUnknown
79
- )
80
- end
81
- end
82
-
83
- describe '#to_json' do
84
- subject { geometry_field_definition.to_json }
85
- it { is_expected.to be_a String }
86
- end
87
71
  end
@@ -103,30 +103,4 @@ RSpec.describe OGR::StyleTable do
103
103
  expect(subject.styles).to eq('style1' => '12345', 'style2' => '67890')
104
104
  end
105
105
  end
106
-
107
- describe '#as_json' do
108
- subject do
109
- st = described_class.new
110
- st.add_style('style1', '12345')
111
- st.add_style('style2', '67890')
112
- st
113
- end
114
-
115
- it 'returns the styles as a Hash' do
116
- expect(subject.as_json).to eq('style1' => '12345', 'style2' => '67890')
117
- end
118
- end
119
-
120
- describe '#to_json' do
121
- subject do
122
- st = described_class.new
123
- st.add_style('style1', '12345')
124
- st.add_style('style2', '67890')
125
- st
126
- end
127
-
128
- it 'returns the styles' do
129
- expect(subject.to_json).to eq('{"style1":"12345","style2":"67890"}')
130
- end
131
- end
132
106
  end