ffi-gdal 1.0.0.beta11 → 1.0.0.beta14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c68052761a1e7169e0827a611d99b825c0922bad173fc449133522d27e53d2bc
4
- data.tar.gz: 307f6323e07aa67f3232b9bb2ce4ad3c8aff4722498344cfeb2c3db9dfdc31da
3
+ metadata.gz: 3afcc101b07f1be65e2cce03ed7d925ae1d94a2fb8f36e6b32c9738f97002619
4
+ data.tar.gz: caeedcff346cadb107ed4a91970b61a93f61959d6e0f0e69cc96dafc290a8851
5
5
  SHA512:
6
- metadata.gz: 96bb0bbd71290fc05806883cce455c8000ee494644db02b3c8203f305dea236272713ef02b2c10ef0912e28dd5c4916580b2b33efff2ee67c5ac253004cec2d5
7
- data.tar.gz: d8371066d7e1ab28235b1d42397864aade41d2921b7149dd23c2fc3574c0c8c4ac4bc42c663949929adf90f418e7bdcd7e1f4c948a6c6ea11dcf11359ac78d14
6
+ metadata.gz: 55f9c4e293410626d9fda5e624589f24fede9aeb8faff2378ab72c2fe2cd9d7f412eebfa3dddb313719710d950167e894b4a6abe4833997d27483046cf4f65c5
7
+ data.tar.gz: b315fe3b339d8d7c1479fd609660cb38e2872e5007500bb896175cd47fbd9322f8ac19f584cd9a8cf55163c5121574670ace63d5d6c6a33e300190a35ad46a04
data/.gitignore CHANGED
@@ -1,38 +1,39 @@
1
+ *.a
2
+ *.bundle
3
+ *.dbf
1
4
  *.gem
5
+ *.o
2
6
  *.rbc
7
+ *.shx
8
+ *.so
9
+ *.sqlite
10
+ *.swp
11
+ *.xml
12
+ *.xsd
13
+
3
14
  .bundle
15
+ .byebug_history
4
16
  .config
17
+ .idea/
18
+ .rake_tasks
19
+ .tags
5
20
  .yardoc
21
+
6
22
  Gemfile.lock
7
23
  InstalledFiles
8
24
  _yardoc
9
25
  coverage
10
26
  doc/
11
27
  lib/bundler/man
28
+ mkmf.log
29
+ open-datasets-dump
12
30
  pkg
13
31
  rdoc
32
+ spec/examples.txt
14
33
  spec/reports
34
+ tags
15
35
  test/tmp
16
36
  test/version_tmp
17
37
  tmp/*
18
- *.bundle
19
- *.so
20
- *.o
21
- *.a
22
- mkmf.log
23
- .idea/
24
- tags
25
- *.sqlite
26
- vendor/bundle
27
- *.xml
28
- *.dbf
29
- *.shx
30
- .rake_tasks
31
38
  valgrind_output.log
32
- *.xsd
33
-
34
- *.swp
35
-
36
- .byebug_history
37
-
38
- .tags
39
+ vendor/bundle
data/History.md CHANGED
@@ -2,6 +2,29 @@
2
2
 
3
3
  Format for this file derived from [http://keepachangelog.com](http://keepachangelog.com).
4
4
 
5
+ ## 1.0.0.beta14 / 2022-05-06
6
+
7
+ ### Bug Fixes
8
+
9
+ * [DEV-34133] Don't URI.parse path in `GDAL::Dataset#initialize` and `OGR::DataSource#initialize`.
10
+
11
+ ## 1.0.0.beta13 / 2022-04-20
12
+
13
+ ### Bug Fixes
14
+
15
+ * [DEV-20247] Fix return value for `OGR::LayerMixins::Extensions#point_values` when no features are found.
16
+
17
+ ## 1.0.0.beta12 / 2021-06-07
18
+
19
+ ### Removed
20
+
21
+ * Removed `GDAL::MajorObject#description=`, as this shouldn't be called and
22
+ causes problems.
23
+
24
+ ### Bug Fixes
25
+
26
+ * [DEV-15804] Remove data that is outside all ranges when classifying.
27
+
5
28
  ## 1.0.0.beta11 / 2020-06-02
6
29
 
7
30
  ### Bug Fixes
@@ -2,6 +2,6 @@
2
2
 
3
3
  module FFI
4
4
  module GDAL
5
- VERSION = '1.0.0.beta11'
5
+ VERSION = '1.0.0.beta14'
6
6
  end
7
7
  end
data/lib/ffi/ogr/api.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'ffi'
4
+ require_relative '../gdal'
3
5
  require_relative '../../ext/ffi_library_function_checks'
4
6
 
5
7
  module FFI
data/lib/ffi/ogr/core.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'ffi'
4
+ require_relative '../gdal'
4
5
  require_relative '../../ext/ffi_library_function_checks'
5
6
  require_relative 'field'
6
7
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'ffi'
4
+ require_relative '../gdal'
3
5
  require_relative '../../ext/ffi_library_function_checks'
4
6
 
5
7
  module FFI
@@ -166,7 +168,7 @@ module FFI
166
168
  attach_function :OSRExportToXML, %i[OGRSpatialReferenceH pointer buffer_out], FFI::OGR::Core::Err
167
169
  attach_function :OSRExportToMICoordSys, %i[OGRSpatialReferenceH pointer], FFI::OGR::Core::Err
168
170
  attach_function :OSRExportToERM,
169
- %i[OGRSpatialReferenceH buffer_out buffer_out buffer_out],
171
+ %i[OGRSpatialReferenceH pointer pointer pointer],
170
172
  FFI::OGR::Core::Err
171
173
  attach_function :OSRMorphToESRI, %i[OGRSpatialReferenceH], FFI::OGR::Core::Err
172
174
  attach_function :OSRMorphFromESRI, %i[OGRSpatialReferenceH], FFI::OGR::Core::Err
data/lib/gdal/dataset.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'uri'
4
3
  require_relative '../gdal'
5
4
  require_relative '../ogr'
6
5
  require_relative 'major_object'
@@ -60,17 +59,10 @@ module GDAL
60
59
  def initialize(path_or_pointer, access_flag, shared_open = true)
61
60
  @c_pointer =
62
61
  if path_or_pointer.is_a? String
63
- file_path = begin
64
- uri = URI.parse(path_or_pointer)
65
- uri.scheme.nil? ? ::File.expand_path(path_or_pointer) : path_or_pointer
66
- rescue URI::InvalidURIError
67
- path_or_pointer
68
- end
69
-
70
62
  if shared_open
71
- FFI::GDAL::GDAL.GDALOpenShared(file_path, ACCESS_FLAGS[access_flag])
63
+ FFI::GDAL::GDAL.GDALOpenShared(path_or_pointer, ACCESS_FLAGS[access_flag])
72
64
  else
73
- FFI::GDAL::GDAL.GDALOpen(file_path, ACCESS_FLAGS[access_flag])
65
+ FFI::GDAL::GDAL.GDALOpen(path_or_pointer, ACCESS_FLAGS[access_flag])
74
66
  end
75
67
  else
76
68
  path_or_pointer
@@ -281,7 +281,7 @@ module GDAL
281
281
  pixel_value_field = layer.feature_definition.field_index(field_name)
282
282
  options = { pixel_value_field: pixel_value_field }
283
283
  options[:mask_band] = band.mask_band if use_band_masks
284
- band.polygonize(layer, options)
284
+ band.polygonize(layer, **options)
285
285
  end
286
286
 
287
287
  if block_given?
@@ -67,11 +67,6 @@ module GDAL
67
67
  FFI::GDAL::GDAL.GDALGetDescription(@c_pointer)
68
68
  end
69
69
 
70
- # @param new_description [String]
71
- def description=(new_description)
72
- FFI::GDAL::GDAL.GDALSetDescription(@c_pointer, new_description.to_s)
73
- end
74
-
75
70
  def null?
76
71
  @c_pointer.null?
77
72
  end
@@ -99,6 +99,9 @@ module GDAL
99
99
  new_band_pixels[data_pixels & band_pixels.le(r[:range].max) & band_pixels.ge(r[:range].min)] = r[:map_to]
100
100
  end
101
101
 
102
+ in_range = @ranges.map { |r| band_pixels.le(r[:range].max) & band_pixels.ge(r[:range].min) }.reduce(:|)
103
+ new_band_pixels[data_pixels & ~in_range] = 0 if in_range
104
+
102
105
  mask_nan(new_band_pixels, data_pixels) if nodata_is_nan?
103
106
  @raster_band.write_xy_narray(new_band_pixels)
104
107
  end
data/lib/gdal.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'ffi-gdal'
4
+ require_relative 'ffi/gdal'
4
5
 
5
6
  module GDAL
6
7
  class << self
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'uri'
4
3
  require 'json'
5
4
  require_relative '../gdal'
6
5
  require_relative '../ogr'
@@ -41,14 +40,12 @@ module OGR
41
40
  def initialize(path_or_pointer, access_flag)
42
41
  @c_pointer =
43
42
  if path_or_pointer.is_a?(String)
44
- uri = URI.parse(path_or_pointer)
45
- file_path = uri.scheme.nil? ? ::File.expand_path(path_or_pointer) : path_or_pointer
46
- FFI::OGR::API.OGROpen(file_path, OGR._boolean_access_flag(access_flag), nil)
43
+ FFI::OGR::API.OGROpen(path_or_pointer, OGR._boolean_access_flag(access_flag), nil)
47
44
  else
48
45
  path_or_pointer
49
46
  end
50
47
 
51
- raise OGR::OpenFailure, file_path if @c_pointer.null?
48
+ raise OGR::OpenFailure, path_or_pointer if @c_pointer.null?
52
49
 
53
50
  @layers = []
54
51
  end
@@ -112,7 +112,7 @@ module OGR
112
112
  # encountered that the method doesn't know how to extract point values
113
113
  # from.
114
114
  def point_values(with_attributes = {})
115
- return [[]] if feature_count.zero?
115
+ return [] if feature_count.zero?
116
116
 
117
117
  field_indices = with_attributes.keys.map { |field_name| find_field_index(field_name) }
118
118
  values = Array.new(feature_count) { Array.new(2 + with_attributes.size) }
@@ -6,9 +6,9 @@ module OGR
6
6
  # @return [Hash]
7
7
  # @raise [OGR::NotEnoughData] If name, datum name, and units are not set.
8
8
  def to_erm
9
- projection_name = FFI::MemoryPointer.new(:string)
10
- datum_name = FFI::MemoryPointer.new(:string)
11
- units = FFI::MemoryPointer.new(:string)
9
+ projection_name = FFI::MemoryPointer.new(:string, 32)
10
+ datum_name = FFI::MemoryPointer.new(:string, 32)
11
+ units = FFI::MemoryPointer.new(:string, 32)
12
12
 
13
13
  ogr_err = FFI::OGR::SRSAPI.OSRExportToERM(@c_pointer, projection_name, datum_name, units)
14
14
  ogr_err.handle_result 'Required parameters (name, datum name, units) are not defined'
@@ -36,7 +36,7 @@ RSpec.describe 'Driver Info', type: :integration do
36
36
 
37
37
  describe '#short_name' do
38
38
  it 'is GTiff' do
39
- expect(subject.short_name).to eq 'GTiff'
39
+ expect(subject.short_name).to eq('GTiff')
40
40
  end
41
41
  end
42
42
 
@@ -49,15 +49,6 @@ RSpec.shared_examples 'a major object' do
49
49
  end
50
50
  end
51
51
 
52
- describe '#description=' do
53
- context 'new description is a string' do
54
- it 'sets the items description' do
55
- subject.description = 'a test description'
56
- expect(subject.description).to eq 'a test description'
57
- end
58
- end
59
- end
60
-
61
52
  describe '#null?' do
62
53
  it { is_expected.to_not be_null }
63
54
  end
@@ -26,7 +26,7 @@ RSpec.describe OGR::DataSource do
26
26
 
27
27
  describe '#supports_curve_geometries?' do
28
28
  subject { data_source.supports_curve_geometries? }
29
- it { is_expected.to eq false }
29
+ it { is_expected.to eq true }
30
30
  end
31
31
  end
32
32
  end
@@ -210,10 +210,10 @@ RSpec.describe OGR::Feature do
210
210
  end
211
211
  end
212
212
 
213
- context 'value is not an array of strings' do
214
- it 'returns an empty Array' do
215
- subject.set_field_integer_list(5, [1, 2, 3])
216
- expect(subject.field_as_string_list(5)).to eq []
213
+ context 'value is an Array of Integers' do
214
+ it 'returns an Array of Strings' do
215
+ subject.set_field_string_list(5, [1, 2, 3])
216
+ expect(subject.field_as_string_list(5)).to eq %w[1 2 3]
217
217
  end
218
218
  end
219
219
  end
@@ -237,7 +237,7 @@ RSpec.describe OGR::Point do
237
237
  let(:wkt) { 'POINT EMPTY' }
238
238
 
239
239
  describe '#coordinate_dimension' do
240
- specify { expect(subject.coordinate_dimension).to eq 0 }
240
+ specify { expect(subject.coordinate_dimension).to eq 2 }
241
241
  end
242
242
 
243
243
  describe '#geometry_count' do
@@ -299,8 +299,8 @@ RSpec.describe OGR::Point do
299
299
  end
300
300
 
301
301
  describe '#envelope' do
302
- it 'returns nil' do
303
- expect(subject.envelope).to be_nil
302
+ it 'returns an OGR::Envelope' do
303
+ expect(subject.envelope).to be_a OGR::Envelope
304
304
  end
305
305
  end
306
306
  end
@@ -673,7 +673,8 @@ RSpec.describe OGR::Geometry do
673
673
 
674
674
  context 'wkbLinearRing' do
675
675
  subject { described_class.type_to_name(:wkbLinearRing) }
676
- it { is_expected.to eq 'Unrecognised: 101' }
676
+ # Per GDAL docs, LinearRing is only used for geometry creation.
677
+ it { is_expected.to eq 'Unrecognized: 101' }
677
678
  end
678
679
  end
679
680
 
@@ -84,7 +84,7 @@ RSpec.describe OGR::Layer do
84
84
 
85
85
  describe '#supports_curve_geometries?' do
86
86
  subject { layer.supports_curve_geometries? }
87
- it { is_expected.to eq false }
87
+ it { is_expected.to eq true }
88
88
  end
89
89
  end
90
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-gdal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta11
4
+ version: 1.0.0.beta14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Loveless
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-02 00:00:00.000000000 Z
11
+ date: 2022-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -192,7 +192,7 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0.9'
195
- description:
195
+ description:
196
196
  email:
197
197
  - steve@agrian.com
198
198
  executables: []
@@ -528,7 +528,7 @@ homepage: http://bitbucket.org/agrian/ffi-gdal
528
528
  licenses:
529
529
  - MIT
530
530
  metadata: {}
531
- post_install_message:
531
+ post_install_message:
532
532
  rdoc_options: []
533
533
  require_paths:
534
534
  - lib
@@ -543,8 +543,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
543
543
  - !ruby/object:Gem::Version
544
544
  version: 1.3.1
545
545
  requirements: []
546
- rubygems_version: 3.1.2
547
- signing_key:
546
+ rubygems_version: 3.0.9
547
+ signing_key:
548
548
  specification_version: 4
549
549
  summary: FFI wrapper for GDAL/OGR.
550
550
  test_files: