ffi-geos 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +49 -0
- data/.rubocop.yml +342 -60
- data/Gemfile +1 -6
- data/ffi-geos.gemspec +5 -0
- data/lib/ffi-geos/buffer_params.rb +1 -1
- data/lib/ffi-geos/coordinate_sequence.rb +32 -32
- data/lib/ffi-geos/geometry.rb +5 -5
- data/lib/ffi-geos/geometry_collection.rb +4 -4
- data/lib/ffi-geos/line_string.rb +10 -10
- data/lib/ffi-geos/multi_line_string.rb +1 -1
- data/lib/ffi-geos/point.rb +4 -4
- data/lib/ffi-geos/polygon.rb +4 -4
- data/lib/ffi-geos/prepared_geometry.rb +1 -1
- data/lib/ffi-geos/strtree.rb +1 -1
- data/lib/ffi-geos/version.rb +1 -1
- data/lib/ffi-geos/wkb_reader.rb +1 -1
- data/lib/ffi-geos/wkb_writer.rb +2 -2
- data/lib/ffi-geos/wkt_reader.rb +1 -1
- data/lib/ffi-geos/wkt_writer.rb +2 -2
- data/lib/ffi-geos.rb +8 -4
- data/sonar-project.properties +4 -4
- data/test/coordinate_sequence_tests.rb +6 -6
- data/test/geometry_collection_tests.rb +4 -4
- data/test/geometry_tests.rb +57 -32
- data/test/line_string_tests.rb +13 -5
- data/test/point_tests.rb +3 -3
- data/test/polygon_tests.rb +3 -3
- data/test/strtree_tests.rb +8 -8
- data/test/test_helper.rb +37 -12
- metadata +7 -6
- data/.travis.yml +0 -32
data/Gemfile
CHANGED
@@ -11,11 +11,6 @@ gem 'minitest-reporters'
|
|
11
11
|
gem 'rake'
|
12
12
|
gem 'rdoc'
|
13
13
|
gem 'rubocop', require: false
|
14
|
-
gem 'simplecov',
|
15
|
-
|
16
|
-
platforms :rbx do
|
17
|
-
gem 'rubinius-developer_tools'
|
18
|
-
gem 'rubysl', '~> 2.0'
|
19
|
-
end
|
14
|
+
gem 'simplecov', require: false
|
20
15
|
|
21
16
|
instance_eval File.read('Gemfile.local') if File.exist?('Gemfile.local')
|
data/ffi-geos.gemspec
CHANGED
@@ -7,6 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Geos::VERSION
|
8
8
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
10
|
+
s.required_ruby_version = '>= 2.5'
|
11
|
+
|
10
12
|
s.authors = ['J Smith']
|
11
13
|
s.description = 'An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).'
|
12
14
|
s.summary = s.description
|
@@ -22,4 +24,7 @@ Gem::Specification.new do |s|
|
|
22
24
|
s.require_paths = ['lib']
|
23
25
|
|
24
26
|
s.add_dependency('ffi', ['>= 1.0.0'])
|
27
|
+
s.metadata = {
|
28
|
+
'rubygems_mfa_required' => 'true'
|
29
|
+
}
|
25
30
|
end
|
@@ -123,7 +123,7 @@ module Geos
|
|
123
123
|
@z = CoordinateAccessor.new(self, 2)
|
124
124
|
end
|
125
125
|
|
126
|
-
def self.release(ptr)
|
126
|
+
def self.release(ptr) # :nodoc:
|
127
127
|
FFIGeos.GEOSCoordSeq_destroy_r(Geos.current_handle_pointer, ptr)
|
128
128
|
end
|
129
129
|
|
@@ -287,7 +287,7 @@ module Geos
|
|
287
287
|
RUBY
|
288
288
|
end
|
289
289
|
|
290
|
-
def snap_to_grid!(*args)
|
290
|
+
def snap_to_grid!(*args, **kwargs)
|
291
291
|
grid = {
|
292
292
|
offset_x: 0, # 1
|
293
293
|
offset_y: 0, # 2
|
@@ -299,8 +299,8 @@ module Geos
|
|
299
299
|
|
300
300
|
if args.length == 1 && args[0].is_a?(Numeric)
|
301
301
|
grid[:size_x] = grid[:size_y] = grid[:size_z] = args[0]
|
302
|
-
elsif
|
303
|
-
grid.merge!(
|
302
|
+
elsif !kwargs.empty?
|
303
|
+
grid.merge!(kwargs)
|
304
304
|
end
|
305
305
|
|
306
306
|
grid[:size_x] = grid[:size_y] = grid[:size_z] = grid[:size] if grid[:size]
|
@@ -321,11 +321,11 @@ module Geos
|
|
321
321
|
end
|
322
322
|
|
323
323
|
length.times do |i|
|
324
|
-
x[i] = ((x[i] - grid[:offset_x]) / grid[:size_x]).round * grid[:size_x] + grid[:offset_x] if grid[:size_x] != 0
|
324
|
+
x[i] = (((x[i] - grid[:offset_x]) / grid[:size_x]).round * grid[:size_x]) + grid[:offset_x] if grid[:size_x] != 0
|
325
325
|
|
326
|
-
y[i] = ((y[i] - grid[:offset_y]) / grid[:size_y]).round * grid[:size_y] + grid[:offset_y] if grid[:size_y] != 0
|
326
|
+
y[i] = (((y[i] - grid[:offset_y]) / grid[:size_y]).round * grid[:size_y]) + grid[:offset_y] if grid[:size_y] != 0
|
327
327
|
|
328
|
-
z[i] = ((z[i] - grid[:offset_z]) / grid[:size_z]).round * grid[:size_z] + grid[:offset_z] if has_z? && grid[:size_z] != 0
|
328
|
+
z[i] = (((z[i] - grid[:offset_z]) / grid[:size_z]).round * grid[:size_z]) + grid[:offset_z] if has_z? && grid[:size_z] != 0
|
329
329
|
end
|
330
330
|
|
331
331
|
cs = remove_duplicate_coords
|
@@ -334,7 +334,7 @@ module Geos
|
|
334
334
|
self
|
335
335
|
end
|
336
336
|
|
337
|
-
def snap_to_grid(*args)
|
337
|
+
def snap_to_grid(*args, **)
|
338
338
|
dup.snap_to_grid!(*args)
|
339
339
|
end
|
340
340
|
|
@@ -353,17 +353,17 @@ module Geos
|
|
353
353
|
y = self.y[i]
|
354
354
|
z = self.z[i]
|
355
355
|
|
356
|
-
self.x[i] = options[:afac] * x + options[:bfac] * y + options[:cfac] * z + options[:xoff]
|
357
|
-
self.y[i] = options[:dfac] * x + options[:efac] * y + options[:ffac] * z + options[:yoff]
|
358
|
-
self.z[i] = options[:gfac] * x + options[:hfac] * y + options[:ifac] * z + options[:zoff]
|
356
|
+
self.x[i] = (options[:afac] * x) + (options[:bfac] * y) + (options[:cfac] * z) + options[:xoff]
|
357
|
+
self.y[i] = (options[:dfac] * x) + (options[:efac] * y) + (options[:ffac] * z) + options[:yoff]
|
358
|
+
self.z[i] = (options[:gfac] * x) + (options[:hfac] * y) + (options[:ifac] * z) + options[:zoff]
|
359
359
|
end
|
360
360
|
else
|
361
361
|
length.times do |i|
|
362
362
|
x = self.x[i]
|
363
363
|
y = self.y[i]
|
364
364
|
|
365
|
-
self.x[i] = options[:afac] * x + options[:bfac] * y + options[:xoff]
|
366
|
-
self.y[i] = options[:dfac] * x + options[:efac] * y + options[:yoff]
|
365
|
+
self.x[i] = (options[:afac] * x) + (options[:bfac] * y) + options[:xoff]
|
366
|
+
self.y[i] = (options[:dfac] * x) + (options[:efac] * y) + options[:yoff]
|
367
367
|
end
|
368
368
|
end
|
369
369
|
|
@@ -395,8 +395,8 @@ module Geos
|
|
395
395
|
gfac: 0,
|
396
396
|
hfac: 0,
|
397
397
|
ifac: 1,
|
398
|
-
xoff: origin[0] - Math.cos(radians) * origin[0] + Math.sin(radians) * origin[1],
|
399
|
-
yoff: origin[1] - Math.sin(radians) * origin[0] - Math.cos(radians) * origin[1],
|
398
|
+
xoff: origin[0] - (Math.cos(radians) * origin[0]) + (Math.sin(radians) * origin[1]),
|
399
|
+
yoff: origin[1] - (Math.sin(radians) * origin[0]) - (Math.cos(radians) * origin[1]),
|
400
400
|
zoff: 0
|
401
401
|
)
|
402
402
|
end
|
@@ -455,9 +455,9 @@ module Geos
|
|
455
455
|
dup.rotate!(radians)
|
456
456
|
end
|
457
457
|
|
458
|
-
def scale!(*args)
|
459
|
-
x, y, z = if
|
460
|
-
|
458
|
+
def scale!(*args, **kwargs)
|
459
|
+
x, y, z = if !kwargs.empty?
|
460
|
+
kwargs.values_at(:x, :y, :z)
|
461
461
|
elsif args.length.between?(1, 3)
|
462
462
|
args.values_at(0...3)
|
463
463
|
else
|
@@ -480,13 +480,13 @@ module Geos
|
|
480
480
|
)
|
481
481
|
end
|
482
482
|
|
483
|
-
def scale(*args)
|
484
|
-
dup.scale!(*args)
|
483
|
+
def scale(*args, **kwargs)
|
484
|
+
dup.scale!(*args, **kwargs)
|
485
485
|
end
|
486
486
|
|
487
|
-
def trans_scale!(*args)
|
488
|
-
delta_x, delta_y, x_factor, y_factor = if
|
489
|
-
|
487
|
+
def trans_scale!(*args, **kwargs)
|
488
|
+
delta_x, delta_y, x_factor, y_factor = if !kwargs.empty?
|
489
|
+
kwargs.values_at(:delta_x, :delta_y, :x_factor, :y_factor)
|
490
490
|
elsif args.length.between?(1, 4)
|
491
491
|
args.values_at(0...4)
|
492
492
|
else
|
@@ -514,13 +514,13 @@ module Geos
|
|
514
514
|
)
|
515
515
|
end
|
516
516
|
|
517
|
-
def trans_scale(*args)
|
518
|
-
dup.trans_scale!(*args)
|
517
|
+
def trans_scale(*args, **kwargs)
|
518
|
+
dup.trans_scale!(*args, **kwargs)
|
519
519
|
end
|
520
520
|
|
521
|
-
def translate!(*args)
|
522
|
-
x, y, z = if
|
523
|
-
|
521
|
+
def translate!(*args, **kwargs)
|
522
|
+
x, y, z = if !kwargs.empty?
|
523
|
+
kwargs.values_at(:x, :y, :z)
|
524
524
|
elsif args.length.between?(1, 3)
|
525
525
|
args.values_at(0...3)
|
526
526
|
else
|
@@ -543,17 +543,17 @@ module Geos
|
|
543
543
|
)
|
544
544
|
end
|
545
545
|
|
546
|
-
def translate(*args)
|
547
|
-
dup.translate!(*args)
|
546
|
+
def translate(*args, **kwargs)
|
547
|
+
dup.translate!(*args, **kwargs)
|
548
548
|
end
|
549
549
|
|
550
550
|
protected
|
551
551
|
|
552
|
-
def check_bounds(idx)
|
552
|
+
def check_bounds(idx) # :nodoc:
|
553
553
|
raise Geos::IndexBoundsError, 'Index out of bounds' if idx.negative? || idx >= length
|
554
554
|
end
|
555
555
|
|
556
|
-
def build_coordinate(n)
|
556
|
+
def build_coordinate(n) # :nodoc:
|
557
557
|
[
|
558
558
|
get_x(n),
|
559
559
|
(dimensions >= 2 ? get_y(n) : nil),
|
data/lib/ffi-geos/geometry.rb
CHANGED
@@ -38,7 +38,7 @@ module Geos
|
|
38
38
|
self.srid = source.srid
|
39
39
|
end
|
40
40
|
|
41
|
-
def self.release(ptr)
|
41
|
+
def self.release(ptr) # :nodoc:
|
42
42
|
FFIGeos.GEOSGeom_destroy_r(Geos.current_handle_pointer, ptr)
|
43
43
|
end
|
44
44
|
|
@@ -330,7 +330,7 @@ module Geos
|
|
330
330
|
bool_result(FFIGeos.GEOSCovers_r(Geos.current_handle_pointer, ptr, geom.ptr))
|
331
331
|
end
|
332
332
|
else
|
333
|
-
def covers?(geom)
|
333
|
+
def covers?(geom) # :nodoc:
|
334
334
|
check_geometry(geom)
|
335
335
|
!!%w{
|
336
336
|
T*****FF*
|
@@ -352,7 +352,7 @@ module Geos
|
|
352
352
|
bool_result(FFIGeos.GEOSCoveredBy_r(Geos.current_handle_pointer, ptr, geom.ptr))
|
353
353
|
end
|
354
354
|
else
|
355
|
-
def covered_by?(geom)
|
355
|
+
def covered_by?(geom) # :nodoc:
|
356
356
|
check_geometry(geom)
|
357
357
|
!!%w{
|
358
358
|
T*F**F***
|
@@ -386,7 +386,7 @@ module Geos
|
|
386
386
|
|
387
387
|
def eql_almost?(other, decimal = 6)
|
388
388
|
check_geometry(other)
|
389
|
-
bool_result(FFIGeos.GEOSEqualsExact_r(Geos.current_handle_pointer, ptr, other.ptr, 0.5 * 10 ** -decimal))
|
389
|
+
bool_result(FFIGeos.GEOSEqualsExact_r(Geos.current_handle_pointer, ptr, other.ptr, 0.5 * (10 ** -decimal)))
|
390
390
|
end
|
391
391
|
alias equals_almost? eql_almost?
|
392
392
|
alias almost_equals? eql_almost?
|
@@ -441,7 +441,7 @@ module Geos
|
|
441
441
|
|
442
442
|
# GEOS versions prior to 3.3.0 didn't handle exceptions and can crash on
|
443
443
|
# bad input.
|
444
|
-
if FFIGeos.respond_to?(:GEOSProject_r) && Geos::
|
444
|
+
if FFIGeos.respond_to?(:GEOSProject_r) && Geos::GEOS_NICE_VERSION >= '030300'
|
445
445
|
def project(geom, normalized = false)
|
446
446
|
raise TypeError, 'Expected Geos::Point type' unless geom.is_a?(Geos::Point)
|
447
447
|
|
@@ -82,18 +82,18 @@ module Geos
|
|
82
82
|
translate
|
83
83
|
}.each do |m|
|
84
84
|
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
85
|
-
def #{m}!(*args)
|
85
|
+
def #{m}!(*args, **kwargs)
|
86
86
|
unless self.empty?
|
87
87
|
self.num_geometries.times do |i|
|
88
|
-
self[i].#{m}!(*args)
|
88
|
+
self[i].#{m}!(*args, **kwargs)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
92
|
self
|
93
93
|
end
|
94
94
|
|
95
|
-
def #{m}(*args)
|
96
|
-
ret = self.dup.#{m}!(*args)
|
95
|
+
def #{m}(*args, **kwargs)
|
96
|
+
ret = self.dup.#{m}!(*args, **kwargs)
|
97
97
|
ret.srid = pick_srid_according_to_policy(self.srid)
|
98
98
|
ret
|
99
99
|
end
|
data/lib/ffi-geos/line_string.rb
CHANGED
@@ -42,7 +42,7 @@ module Geos
|
|
42
42
|
end
|
43
43
|
alias slice []
|
44
44
|
|
45
|
-
def offset_curve(width, options
|
45
|
+
def offset_curve(width, **options)
|
46
46
|
options = Constants::BUFFER_PARAM_DEFAULTS.merge(options)
|
47
47
|
|
48
48
|
cast_geometry_ptr(
|
@@ -81,7 +81,7 @@ module Geos
|
|
81
81
|
cur_path.concat(to_a)
|
82
82
|
end
|
83
83
|
|
84
|
-
def snap_to_grid!(*args)
|
84
|
+
def snap_to_grid!(*args, **)
|
85
85
|
unless empty?
|
86
86
|
cs = coord_seq.snap_to_grid!(*args)
|
87
87
|
|
@@ -97,7 +97,7 @@ module Geos
|
|
97
97
|
self
|
98
98
|
end
|
99
99
|
|
100
|
-
def snap_to_grid(*args)
|
100
|
+
def snap_to_grid(*args, **)
|
101
101
|
ret = dup.snap_to_grid!(*args)
|
102
102
|
ret.srid = pick_srid_according_to_policy(srid)
|
103
103
|
ret
|
@@ -126,9 +126,9 @@ module Geos
|
|
126
126
|
dseg = (fraction - total_length) / seg_length
|
127
127
|
|
128
128
|
args = []
|
129
|
-
args << p_1.x + ((p_2.x - p_1.x) * dseg)
|
130
|
-
args << p_1.y + ((p_2.y - p_1.y) * dseg)
|
131
|
-
args << p_1.z + ((p_2.z - p_1.z) * dseg) if has_z?
|
129
|
+
args << (p_1.x + ((p_2.x - p_1.x) * dseg))
|
130
|
+
args << (p_1.y + ((p_2.y - p_1.y) * dseg))
|
131
|
+
args << (p_1.z + ((p_2.z - p_1.z) * dseg)) if has_z?
|
132
132
|
|
133
133
|
args << { srid: pick_srid_according_to_policy(srid) } unless srid.zero?
|
134
134
|
|
@@ -193,16 +193,16 @@ module Geos
|
|
193
193
|
translate
|
194
194
|
}.each do |m|
|
195
195
|
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
196
|
-
def #{m}!(*args)
|
196
|
+
def #{m}!(*args, **kwargs)
|
197
197
|
unless self.empty?
|
198
|
-
self.coord_seq.#{m}!(*args)
|
198
|
+
self.coord_seq.#{m}!(*args, **kwargs)
|
199
199
|
end
|
200
200
|
|
201
201
|
self
|
202
202
|
end
|
203
203
|
|
204
|
-
def #{m}(*args)
|
205
|
-
ret = self.dup.#{m}!(*args)
|
204
|
+
def #{m}(*args, **kwargs)
|
205
|
+
ret = self.dup.#{m}!(*args, **kwargs)
|
206
206
|
ret.srid = pick_srid_according_to_policy(self.srid)
|
207
207
|
ret
|
208
208
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Geos
|
4
4
|
class MultiLineString < GeometryCollection
|
5
|
-
if FFIGeos.respond_to?(:GEOSisClosed_r) && Geos::
|
5
|
+
if FFIGeos.respond_to?(:GEOSisClosed_r) && Geos::GEOS_NICE_VERSION >= '030500'
|
6
6
|
# Available in GEOS 3.5.0+.
|
7
7
|
def closed?
|
8
8
|
bool_result(FFIGeos.GEOSisClosed_r(Geos.current_handle_pointer, ptr))
|
data/lib/ffi-geos/point.rb
CHANGED
@@ -118,16 +118,16 @@ module Geos
|
|
118
118
|
translate
|
119
119
|
}.each do |m|
|
120
120
|
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
121
|
-
def #{m}!(*args)
|
121
|
+
def #{m}!(*args, **kwargs)
|
122
122
|
unless empty?
|
123
|
-
coord_seq.#{m}!(*args)
|
123
|
+
coord_seq.#{m}!(*args, **kwargs)
|
124
124
|
end
|
125
125
|
|
126
126
|
self
|
127
127
|
end
|
128
128
|
|
129
|
-
def #{m}(*args)
|
130
|
-
ret = dup.#{m}!(*args)
|
129
|
+
def #{m}(*args, **kwargs)
|
130
|
+
ret = dup.#{m}!(*args, **kwargs)
|
131
131
|
ret.srid = pick_srid_according_to_policy(srid)
|
132
132
|
ret
|
133
133
|
end
|
data/lib/ffi-geos/polygon.rb
CHANGED
@@ -125,16 +125,16 @@ module Geos
|
|
125
125
|
translate
|
126
126
|
}.each do |m|
|
127
127
|
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
128
|
-
def #{m}!(*args)
|
129
|
-
exterior_ring.coord_seq.#{m}!(*args)
|
128
|
+
def #{m}!(*args, **kwargs)
|
129
|
+
exterior_ring.coord_seq.#{m}!(*args, **kwargs)
|
130
130
|
interior_rings.each do |ring|
|
131
131
|
ring.coord_seq.#{m}!(*args)
|
132
132
|
end
|
133
133
|
self
|
134
134
|
end
|
135
135
|
|
136
|
-
def #{m}(*args)
|
137
|
-
ret = dup.#{m}!(*args)
|
136
|
+
def #{m}(*args, **kwargs)
|
137
|
+
ret = dup.#{m}!(*args, **kwargs)
|
138
138
|
ret.srid = pick_srid_according_to_policy(srid)
|
139
139
|
ret
|
140
140
|
end
|
data/lib/ffi-geos/strtree.rb
CHANGED
data/lib/ffi-geos/version.rb
CHANGED
data/lib/ffi-geos/wkb_reader.rb
CHANGED
data/lib/ffi-geos/wkb_writer.rb
CHANGED
@@ -20,7 +20,7 @@ module Geos
|
|
20
20
|
set_options(options)
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.release(ptr)
|
23
|
+
def self.release(ptr) # :nodoc:
|
24
24
|
FFIGeos.GEOSWKBWriter_destroy_r(Geos.current_handle_pointer, ptr)
|
25
25
|
end
|
26
26
|
|
@@ -85,7 +85,7 @@ module Geos
|
|
85
85
|
|
86
86
|
private
|
87
87
|
|
88
|
-
def set_options(options)
|
88
|
+
def set_options(options) # :nodoc:
|
89
89
|
self.include_srid = options[:include_srid] if options.key?(:include_srid)
|
90
90
|
end
|
91
91
|
end
|
data/lib/ffi-geos/wkt_reader.rb
CHANGED
data/lib/ffi-geos/wkt_writer.rb
CHANGED
@@ -21,11 +21,11 @@ module Geos
|
|
21
21
|
set_options(options)
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.release(ptr)
|
24
|
+
def self.release(ptr) # :nodoc:
|
25
25
|
FFIGeos.GEOSWKTWriter_destroy_r(Geos.current_handle_pointer, ptr)
|
26
26
|
end
|
27
27
|
|
28
|
-
def set_options(options)
|
28
|
+
def set_options(options) # :nodoc:
|
29
29
|
[:trim, :old_3d, :rounding_precision, :output_dimensions].each do |k|
|
30
30
|
send("#{k}=", options[k]) if respond_to?("#{k}=") && options.key?(k)
|
31
31
|
end
|
data/lib/ffi-geos.rb
CHANGED
@@ -56,7 +56,7 @@ module Geos
|
|
56
56
|
elsif FFI::Platform::IS_WINDOWS
|
57
57
|
ENV['PATH'].split(File::PATH_SEPARATOR)
|
58
58
|
else
|
59
|
-
['/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}', '/usr/lib/{x86_64,i386}-linux-gnu']
|
59
|
+
['/usr/local/{lib64,lib}', '/opt/local/{lib64,lib}', '/usr/{lib64,lib}', '/usr/lib/{x86_64,i386,aarch64}-linux-gnu']
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -1363,12 +1363,14 @@ module Geos
|
|
1363
1363
|
GEOS_CAPI_VERSION,
|
1364
1364
|
GEOS_CAPI_VERSION_MAJOR, GEOS_CAPI_VERSION_MINOR, GEOS_CAPI_VERSION_PATCH,
|
1365
1365
|
GEOS_SVN_REVISION =
|
1366
|
-
if
|
1366
|
+
if (versions = Geos.version.scan(/^
|
1367
1367
|
((\d+)\.(\d+)\.(\d+)((?:dev|rc|beta|alpha)\d*)?)
|
1368
1368
|
-CAPI-
|
1369
1369
|
((\d+)\.(\d+)\.(\d+))
|
1370
1370
|
(?:\s+r?(\h+))?
|
1371
1371
|
$/x)).empty?
|
1372
|
+
['0.0.0', 0, 0, 0, nil, '0.0.0', 0, 0, 0]
|
1373
|
+
else
|
1372
1374
|
versions = versions[0]
|
1373
1375
|
[
|
1374
1376
|
versions[0],
|
@@ -1382,11 +1384,13 @@ module Geos
|
|
1382
1384
|
versions[8].to_i,
|
1383
1385
|
versions[9]&.to_i
|
1384
1386
|
]
|
1385
|
-
else
|
1386
|
-
['0.0.0', 0, 0, 0, nil, '0.0.0', 0, 0, 0]
|
1387
1387
|
end
|
1388
1388
|
GEOS_CAPI_FIRST_INTERFACE = GEOS_CAPI_VERSION_MAJOR.to_i
|
1389
1389
|
GEOS_CAPI_LAST_INTERFACE = GEOS_CAPI_VERSION_MAJOR.to_i + GEOS_CAPI_VERSION_MINOR.to_i
|
1390
|
+
|
1391
|
+
GEOS_NICE_VERSION = [GEOS_VERSION_MAJOR, GEOS_VERSION_MINOR, GEOS_VERSION_PATCH].collect { |version|
|
1392
|
+
version.to_s.rjust(2, '0')
|
1393
|
+
}.join
|
1390
1394
|
end
|
1391
1395
|
|
1392
1396
|
module Constants
|
data/sonar-project.properties
CHANGED
@@ -2,15 +2,15 @@ sonar.projectKey=dark-panda_ffi-geos
|
|
2
2
|
sonar.organization=dark-panda
|
3
3
|
|
4
4
|
# This is the name and version displayed in the SonarCloud UI.
|
5
|
-
|
6
|
-
|
5
|
+
sonar.projectName=ffi-geos
|
6
|
+
sonar.projectVersion=1.0
|
7
7
|
|
8
8
|
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
|
9
9
|
sonar.sources=lib, test
|
10
10
|
|
11
11
|
# Encoding of the source code. Default is default system encoding
|
12
|
-
|
12
|
+
sonar.sourceEncoding=UTF-8
|
13
13
|
|
14
14
|
# Additional reports
|
15
15
|
sonar.ruby.rubocop.reportPaths=rubocop-report.json
|
16
|
-
sonar.ruby.coverage.reportPaths=coverage
|
16
|
+
sonar.ruby.coverage.reportPaths=coverage/coverage.json
|
@@ -515,16 +515,16 @@ class CoordinateSequenceTests < Minitest::Test
|
|
515
515
|
end
|
516
516
|
|
517
517
|
undef :affine_tester
|
518
|
-
def affine_tester(method, expected, coords, *args)
|
518
|
+
def affine_tester(method, expected, coords, *args, **options)
|
519
519
|
cs = Geos::CoordinateSequence.new(coords)
|
520
|
-
cs.
|
520
|
+
cs.__safe_send__("#{method}!", *args, **options)
|
521
521
|
|
522
522
|
expected.length.times do |i|
|
523
523
|
assert_in_delta(expected[i], cs.get_ordinate(0, i), TOLERANCE)
|
524
524
|
end
|
525
525
|
|
526
526
|
cs = Geos::CoordinateSequence.new(coords)
|
527
|
-
cs_2 = cs.
|
527
|
+
cs_2 = cs.__safe_send__(method, *args, **options)
|
528
528
|
|
529
529
|
expected.length.times do |i|
|
530
530
|
assert_in_delta(coords[i], cs.get_ordinate(0, i), TOLERANCE)
|
@@ -542,21 +542,21 @@ class CoordinateSequenceTests < Minitest::Test
|
|
542
542
|
def test_rotate_x
|
543
543
|
affine_tester(:rotate_x, [1, -1, -1], [1, 1, 1], Math::PI)
|
544
544
|
affine_tester(:rotate_x, [1, -1, 1], [1, 1, 1], Math::PI / 2)
|
545
|
-
affine_tester(:rotate_x, [1, 1, -1], [1, 1, 1], Math::PI + Math::PI / 2)
|
545
|
+
affine_tester(:rotate_x, [1, 1, -1], [1, 1, 1], Math::PI + (Math::PI / 2))
|
546
546
|
affine_tester(:rotate_x, [1, 1, 1], [1, 1, 1], Math::PI * 2)
|
547
547
|
end
|
548
548
|
|
549
549
|
def test_rotate_y
|
550
550
|
affine_tester(:rotate_y, [-1, 1, -1], [1, 1, 1], Math::PI)
|
551
551
|
affine_tester(:rotate_y, [1, 1, -1], [1, 1, 1], Math::PI / 2)
|
552
|
-
affine_tester(:rotate_y, [-1, 1, 1], [1, 1, 1], Math::PI + Math::PI / 2)
|
552
|
+
affine_tester(:rotate_y, [-1, 1, 1], [1, 1, 1], Math::PI + (Math::PI / 2))
|
553
553
|
affine_tester(:rotate_y, [1, 1, 1], [1, 1, 1], Math::PI * 2)
|
554
554
|
end
|
555
555
|
|
556
556
|
def test_rotate_z
|
557
557
|
affine_tester(:rotate_z, [-1, -1], [1, 1], Math::PI)
|
558
558
|
affine_tester(:rotate_z, [-1, 1], [1, 1], Math::PI / 2)
|
559
|
-
affine_tester(:rotate_z, [1, -1], [1, 1], Math::PI + Math::PI / 2)
|
559
|
+
affine_tester(:rotate_z, [1, -1], [1, 1], Math::PI + (Math::PI / 2))
|
560
560
|
affine_tester(:rotate_z, [1, 1], [1, 1], Math::PI * 2)
|
561
561
|
end
|
562
562
|
|
@@ -174,7 +174,7 @@ class GeometryCollectionTests < Minitest::Test
|
|
174
174
|
|
175
175
|
def test_snap_to_grid
|
176
176
|
wkt = 'GEOMETRYCOLLECTION (LINESTRING (-10.12 0, -10.12 5, -10.12 5, -10.12 6, -10.12 6, -10.12 6, -10.12 7, -10.12 7, -10.12 7, -10.12 8, -10.12 8, -9 8, -9 9, -10.12 0), ' \
|
177
|
-
|
177
|
+
'POLYGON ((-10.12 0, -10.12 5, -10.12 5, -10.12 6, -10.12 6, -10.12 6, -10.12 7, -10.12 7, -10.12 7, -10.12 8, -10.12 8, -9 8, -9 9, -10.12 0)), POINT (10.12 10.12))'
|
178
178
|
|
179
179
|
expected = 'GEOMETRYCOLLECTION (LINESTRING (-10 0, -10 5, -10 5, -10 6, -10 6, -10 6, -10 7, -10 7, -10 7, -10 8, -10 8, -9 8, -9 9, -10 0), POLYGON ((-10 0, -10 5, -10 5, -10 6, -10 6, -10 6, -10 7, -10 7, -10 7, -10 8, -10 8, -9 8, -9 9, -10 0)), POINT (10 10))'
|
180
180
|
|
@@ -255,7 +255,7 @@ class GeometryCollectionTests < Minitest::Test
|
|
255
255
|
affine_tester(:rotate_x,
|
256
256
|
'GEOMETRYCOLLECTION Z (POINT Z (1 1 -1), LINESTRING Z (1 1 -1, 10 10 -10), POLYGON Z ((0 0 0, 5 0 0, 5 0 -5, 0 0 -5, 0 0 0)))',
|
257
257
|
wkt,
|
258
|
-
Math::PI + Math::PI / 2)
|
258
|
+
Math::PI + (Math::PI / 2))
|
259
259
|
|
260
260
|
affine_tester(:rotate_x,
|
261
261
|
wkt,
|
@@ -282,7 +282,7 @@ class GeometryCollectionTests < Minitest::Test
|
|
282
282
|
affine_tester(:rotate_y,
|
283
283
|
'GEOMETRYCOLLECTION Z (POINT Z (-1 1 1), LINESTRING Z (-1 1 1, -10 10 10), POLYGON Z ((0 0 0, 0 0 5, 0 5 5, 0 5 0, 0 0 0)))',
|
284
284
|
wkt,
|
285
|
-
Math::PI + Math::PI / 2)
|
285
|
+
Math::PI + (Math::PI / 2))
|
286
286
|
|
287
287
|
affine_tester(:rotate_y,
|
288
288
|
wkt,
|
@@ -308,7 +308,7 @@ class GeometryCollectionTests < Minitest::Test
|
|
308
308
|
affine_tester(:rotate_z,
|
309
309
|
'GEOMETRYCOLLECTION (POINT (1 -1), LINESTRING (0 0, 10 -10), POLYGON ((0 0, 0 -5, 5 -5, 5 0, 0 0)))',
|
310
310
|
wkt,
|
311
|
-
Math::PI + Math::PI / 2)
|
311
|
+
Math::PI + (Math::PI / 2))
|
312
312
|
|
313
313
|
affine_tester(:rotate_z,
|
314
314
|
wkt,
|