ffi-geos 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3954 -4
- data/.travis.yml +23 -11
- data/Gemfile +7 -9
- data/Guardfile +3 -4
- data/MIT-LICENSE +1 -1
- data/README.rdoc +2 -20
- data/Rakefile +3 -2
- data/ffi-geos.gemspec +2 -2
- data/lib/ffi-geos.rb +93 -44
- data/lib/ffi-geos/coordinate_sequence.rb +147 -145
- data/lib/ffi-geos/geometry.rb +68 -17
- data/lib/ffi-geos/geometry_collection.rb +22 -8
- data/lib/ffi-geos/interrupt.rb +11 -14
- data/lib/ffi-geos/line_string.rb +57 -42
- data/lib/ffi-geos/point.rb +16 -16
- data/lib/ffi-geos/polygon.rb +42 -28
- data/lib/ffi-geos/strtree.rb +3 -5
- data/lib/ffi-geos/tools.rb +1 -1
- data/lib/ffi-geos/utils.rb +4 -12
- data/lib/ffi-geos/version.rb +1 -1
- data/lib/ffi-geos/wkb_writer.rb +2 -3
- data/lib/ffi-geos/wkt_writer.rb +4 -7
- data/sonar-project.properties +16 -0
- data/test/coordinate_sequence_tests.rb +144 -122
- data/test/geometry_collection_tests.rb +38 -65
- data/test/geometry_tests.rb +106 -17
- data/test/interrupt_tests.rb +7 -7
- data/test/line_string_tests.rb +10 -10
- data/test/point_tests.rb +2 -2
- data/test/polygon_tests.rb +3 -4
- data/test/prepared_geometry_tests.rb +8 -8
- data/test/strtree_tests.rb +5 -5
- data/test/test_helper.rb +20 -35
- data/test/utils_tests.rb +69 -59
- data/test/wkb_reader_tests.rb +9 -9
- data/test/wkb_writer_tests.rb +14 -12
- data/test/wkt_reader_tests.rb +0 -1
- data/test/wkt_writer_tests.rb +2 -5
- metadata +4 -4
data/test/interrupt_tests.rb
CHANGED
@@ -39,7 +39,7 @@ class InterruptTests < Minitest::Test
|
|
39
39
|
|
40
40
|
begin
|
41
41
|
buffer = geom.buffer(1, 8)
|
42
|
-
rescue => e
|
42
|
+
rescue StandardError => e
|
43
43
|
# no-op
|
44
44
|
ensure
|
45
45
|
assert_match(/^InterruptedException/, e.message)
|
@@ -62,7 +62,7 @@ class InterruptTests < Minitest::Test
|
|
62
62
|
|
63
63
|
begin
|
64
64
|
buffer = geom.buffer(1, 8)
|
65
|
-
rescue => e
|
65
|
+
rescue StandardError => e
|
66
66
|
# no-op
|
67
67
|
ensure
|
68
68
|
assert_match(/^InterruptedException/, e.message)
|
@@ -87,7 +87,7 @@ class InterruptTests < Minitest::Test
|
|
87
87
|
|
88
88
|
begin
|
89
89
|
buffer = geom.buffer(1, 8)
|
90
|
-
rescue => e
|
90
|
+
rescue StandardError => e
|
91
91
|
# no-op
|
92
92
|
ensure
|
93
93
|
assert_match(/^InterruptedException/, e.message)
|
@@ -114,7 +114,7 @@ class InterruptTests < Minitest::Test
|
|
114
114
|
prc_1 = proc {
|
115
115
|
interrupt_called
|
116
116
|
called << :prc_1
|
117
|
-
prev
|
117
|
+
prev&.call
|
118
118
|
}
|
119
119
|
|
120
120
|
Geos::Interrupt.register(prc_0)
|
@@ -122,13 +122,13 @@ class InterruptTests < Minitest::Test
|
|
122
122
|
|
123
123
|
begin
|
124
124
|
buffer = geom.buffer(1, 8)
|
125
|
-
rescue => e
|
125
|
+
rescue StandardError => e
|
126
126
|
# no-op
|
127
127
|
ensure
|
128
128
|
assert_match(/^InterruptedException/, e.message)
|
129
129
|
assert_nil(buffer)
|
130
130
|
assert_interrupt_called(1)
|
131
|
-
assert_equal([
|
131
|
+
assert_equal([:prc_1, :prc_0], called)
|
132
132
|
end
|
133
133
|
end
|
134
134
|
end
|
@@ -160,7 +160,7 @@ class InterruptTests < Minitest::Test
|
|
160
160
|
|
161
161
|
begin
|
162
162
|
buffer = geom.buffer(1, 8)
|
163
|
-
rescue => e
|
163
|
+
rescue StandardError => e
|
164
164
|
assert_match(/^InterruptedException/, e.message)
|
165
165
|
assert_nil(buffer)
|
166
166
|
end
|
data/test/line_string_tests.rb
CHANGED
@@ -250,8 +250,8 @@ class LineStringTests < Minitest::Test
|
|
250
250
|
|
251
251
|
wkt = 'LINESTRING (0 0, 10 10)'
|
252
252
|
|
253
|
-
affine_tester(:rotate, 'LINESTRING (30 10, 20 20)', wkt, Math::PI / 2, [
|
254
|
-
affine_tester(:rotate, 'LINESTRING (-3 1, 7 -9)', wkt, -Math::PI / 2, [
|
253
|
+
affine_tester(:rotate, 'LINESTRING (30 10, 20 20)', wkt, Math::PI / 2, [10.0, 20.0])
|
254
|
+
affine_tester(:rotate, 'LINESTRING (-3 1, 7 -9)', wkt, -Math::PI / 2, [-1.0, 2.0])
|
255
255
|
affine_tester(:rotate, 'LINESTRING (2 2, -8 -8)', wkt, Math::PI, read('POINT(1 1)'))
|
256
256
|
affine_tester(:rotate, 'LINESTRING (0.5 -0.5, -9.5 9.5)', wkt, Math::PI / 2, read('LINESTRING(0 0, 1 0)'))
|
257
257
|
end
|
@@ -300,11 +300,11 @@ class LineStringTests < Minitest::Test
|
|
300
300
|
end
|
301
301
|
|
302
302
|
def test_scale_hash
|
303
|
-
affine_tester(:scale, 'LINESTRING (5 5, 50 50)', 'LINESTRING (1 1, 10 10)', :
|
304
|
-
affine_tester(:scale, 'LINESTRING (3 2, 30 20)', 'LINESTRING (1 1, 10 10)', :
|
303
|
+
affine_tester(:scale, 'LINESTRING (5 5, 50 50)', 'LINESTRING (1 1, 10 10)', x: 5, y: 5)
|
304
|
+
affine_tester(:scale, 'LINESTRING (3 2, 30 20)', 'LINESTRING (1 1, 10 10)', x: 3, y: 2)
|
305
305
|
|
306
306
|
writer.output_dimensions = 3
|
307
|
-
affine_tester(:scale, 'LINESTRING Z (40 40 40, 80 80 80)', 'LINESTRING Z (10 20 -5, 20 40 -10)', :
|
307
|
+
affine_tester(:scale, 'LINESTRING Z (40 40 40, 80 80 80)', 'LINESTRING Z (10 20 -5, 20 40 -10)', x: 4, y: 2, z: -8)
|
308
308
|
end
|
309
309
|
|
310
310
|
def test_trans_scale
|
@@ -326,11 +326,11 @@ class LineStringTests < Minitest::Test
|
|
326
326
|
end
|
327
327
|
|
328
328
|
def test_trans_scale_hash
|
329
|
-
affine_tester(:trans_scale, 'LINESTRING (2 2, 11 11)', 'LINESTRING (1 1, 10 10)', :
|
329
|
+
affine_tester(:trans_scale, 'LINESTRING (2 2, 11 11)', 'LINESTRING (1 1, 10 10)', delta_x: 1, delta_y: 1, x_factor: 1, y_factor: 1)
|
330
330
|
|
331
331
|
writer.output_dimensions = 3
|
332
|
-
affine_tester(:trans_scale, 'LINESTRING Z (15 28 1, 60 91 10)', 'LINESTRING Z (1 1 1, 10 10 10)', :
|
333
|
-
affine_tester(:trans_scale, 'LINESTRING Z (3 1 1, 12 10 10)', 'LINESTRING Z (1 1 1, 10 10 10)', :
|
332
|
+
affine_tester(:trans_scale, 'LINESTRING Z (15 28 1, 60 91 10)', 'LINESTRING Z (1 1 1, 10 10 10)', delta_x: 2, delta_y: 3, x_factor: 5, y_factor: 7)
|
333
|
+
affine_tester(:trans_scale, 'LINESTRING Z (3 1 1, 12 10 10)', 'LINESTRING Z (1 1 1, 10 10 10)', delta_x: 2, z_factor: 2)
|
334
334
|
end
|
335
335
|
|
336
336
|
def test_translate
|
@@ -341,10 +341,10 @@ class LineStringTests < Minitest::Test
|
|
341
341
|
end
|
342
342
|
|
343
343
|
def test_translate_hash
|
344
|
-
affine_tester(:translate, 'LINESTRING (5 12, 15 22)', 'LINESTRING (0 0, 10 10)', :
|
344
|
+
affine_tester(:translate, 'LINESTRING (5 12, 15 22)', 'LINESTRING (0 0, 10 10)', x: 5, y: 12)
|
345
345
|
|
346
346
|
writer.output_dimensions = 3
|
347
|
-
affine_tester(:translate, 'LINESTRING Z (-3 -7 3, 7 3 13)', 'LINESTRING Z (0 0 0, 10 10 10)', :
|
347
|
+
affine_tester(:translate, 'LINESTRING Z (-3 -7 3, 7 3 13)', 'LINESTRING Z (0 0 0, 10 10 10)', x: -3, y: -7, z: 3)
|
348
348
|
end
|
349
349
|
|
350
350
|
def test_line_interpolate_point
|
data/test/point_tests.rb
CHANGED
@@ -163,8 +163,8 @@ class PointTests < Minitest::Test
|
|
163
163
|
|
164
164
|
wkt = 'POINT (1 1)'
|
165
165
|
|
166
|
-
affine_tester(:rotate, 'POINT (29 11)', wkt, Math::PI / 2, [
|
167
|
-
affine_tester(:rotate, 'POINT (-2 0)', wkt, -Math::PI / 2, [
|
166
|
+
affine_tester(:rotate, 'POINT (29 11)', wkt, Math::PI / 2, [10.0, 20.0])
|
167
|
+
affine_tester(:rotate, 'POINT (-2 0)', wkt, -Math::PI / 2, [-1.0, 2.0])
|
168
168
|
affine_tester(:rotate, 'POINT (19 1)', wkt, Math::PI / 2, read('POINT(10 10)'))
|
169
169
|
affine_tester(:rotate, 'POINT (-0.5 0.5)', wkt, Math::PI / 2, read('LINESTRING(0 0, 1 0)'))
|
170
170
|
end
|
data/test/polygon_tests.rb
CHANGED
@@ -79,8 +79,7 @@ class PolygonTests < Minitest::Test
|
|
79
79
|
|
80
80
|
def test_snap_to_grid_with_illegal_result
|
81
81
|
assert_raises(Geos::InvalidGeometryError) do
|
82
|
-
read('POLYGON ((1 1, 10 10, 10 10, 1 1))').
|
83
|
-
snap_to_grid
|
82
|
+
read('POLYGON ((1 1, 10 10, 10 10, 1 1))').snap_to_grid
|
84
83
|
end
|
85
84
|
end
|
86
85
|
|
@@ -110,13 +109,13 @@ class PolygonTests < Minitest::Test
|
|
110
109
|
'POLYGON ((30 10, 30 15, 25 15, 25 10, 30 10))',
|
111
110
|
wkt,
|
112
111
|
Math::PI / 2,
|
113
|
-
[
|
112
|
+
[10.0, 20.0])
|
114
113
|
|
115
114
|
affine_tester(:rotate,
|
116
115
|
'POLYGON ((-3 1, -3 -4, 2 -4, 2 1, -3 1))',
|
117
116
|
wkt,
|
118
117
|
-Math::PI / 2,
|
119
|
-
[
|
118
|
+
[-1.0, 2.0])
|
120
119
|
|
121
120
|
affine_tester(:rotate,
|
122
121
|
'POLYGON ((2 2, -3 2, -3 -3, 2 -3, 2 2))',
|
@@ -17,14 +17,14 @@ class PreparedGeometryTests < Minitest::Test
|
|
17
17
|
|
18
18
|
def relationship_tester(method, *expected)
|
19
19
|
[
|
20
|
-
[
|
21
|
-
[
|
22
|
-
[
|
23
|
-
[
|
24
|
-
[
|
25
|
-
[
|
26
|
-
[
|
27
|
-
[
|
20
|
+
[POINT_A, POINT_A],
|
21
|
+
[POINT_A, LINESTRING_A],
|
22
|
+
[POINT_B, LINESTRING_A],
|
23
|
+
[LINESTRING_B, LINESTRING_A],
|
24
|
+
[LINESTRING_C, LINESTRING_A],
|
25
|
+
[LINESTRING_D, LINESTRING_A],
|
26
|
+
[POLYGON_A, POLYGON_B],
|
27
|
+
[POLYGON_A, POINT_C]
|
28
28
|
].each_with_index do |(geom_a, geom_b), i|
|
29
29
|
geom_a = read(geom_a).to_prepared
|
30
30
|
geom_b = read(geom_b)
|
data/test/strtree_tests.rb
CHANGED
@@ -8,7 +8,7 @@ class STRtreeTests < Minitest::Test
|
|
8
8
|
def setup_tree
|
9
9
|
@tree = Geos::STRtree.new(3)
|
10
10
|
@item_1 = { item_1: :test }
|
11
|
-
@item_2 = [
|
11
|
+
@item_2 = [:test]
|
12
12
|
@item_3 = Object.new
|
13
13
|
|
14
14
|
@geom_1 = read('LINESTRING(0 0, 10 10)')
|
@@ -183,9 +183,9 @@ class STRtreeTests < Minitest::Test
|
|
183
183
|
skip unless ENV['FORCE_TESTS'] || defined?(Geos::STRtree)
|
184
184
|
|
185
185
|
tree = Geos::STRtree.new(
|
186
|
-
[
|
187
|
-
[
|
188
|
-
[
|
186
|
+
[read('LINESTRING(0 0, 10 10)'), item_1 = { item_1: :test }],
|
187
|
+
[read('LINESTRING(20 20, 30 30)'), item_2 = [:test]],
|
188
|
+
[read('LINESTRING(20 20, 30 30)'), item_3 = Object.new]
|
189
189
|
)
|
190
190
|
|
191
191
|
assert_equal([item_1],
|
@@ -346,7 +346,7 @@ class STRtreeTests < Minitest::Test
|
|
346
346
|
geom_4 = read('POINT (3 8)')
|
347
347
|
|
348
348
|
item_1 = { item_1: :test }
|
349
|
-
item_2 = [
|
349
|
+
item_2 = [:test]
|
350
350
|
item_3 = Object.new
|
351
351
|
|
352
352
|
tree = Geos::STRtree.new(2)
|
data/test/test_helper.rb
CHANGED
@@ -1,19 +1,17 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'simplecov'
|
3
|
+
require 'simplecov'
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
5
|
+
SimpleCov.command_name('Unit Tests')
|
6
|
+
SimpleCov.merge_timeout(3600)
|
7
|
+
SimpleCov.start do
|
8
|
+
add_filter '/test/'
|
9
|
+
add_filter '/.bundle/'
|
12
10
|
end
|
13
11
|
|
14
12
|
require 'rubygems'
|
15
13
|
require 'minitest/autorun'
|
16
|
-
require 'minitest/reporters'
|
14
|
+
require 'minitest/reporters'
|
17
15
|
|
18
16
|
if ENV['USE_BINARY_GEOS']
|
19
17
|
require 'geos'
|
@@ -36,6 +34,12 @@ puts "Using #{Geos::FFIGeos.geos_library_path}" if defined?(Geos::FFIGeos)
|
|
36
34
|
module TestHelper
|
37
35
|
TOLERANCE = 0.0000000000001
|
38
36
|
|
37
|
+
EMPTY_GEOMETRY = if Geos::GEOS_VERSION > '3.8'
|
38
|
+
'POINT EMPTY'
|
39
|
+
else
|
40
|
+
'GEOMETRYCOLLECTION EMPTY'
|
41
|
+
end
|
42
|
+
|
39
43
|
def self.included(base)
|
40
44
|
base.class_eval do
|
41
45
|
attr_reader :reader, :reader_hex, :writer
|
@@ -145,11 +149,11 @@ module TestHelper
|
|
145
149
|
|
146
150
|
case result
|
147
151
|
when Geos::Geometry
|
148
|
-
result = [
|
152
|
+
result = [write(result)]
|
149
153
|
when Array
|
150
|
-
result = result.collect
|
154
|
+
result = result.collect do |r|
|
151
155
|
write(r)
|
152
|
-
|
156
|
+
end
|
153
157
|
end
|
154
158
|
|
155
159
|
assert_equal(expected, result)
|
@@ -164,30 +168,11 @@ module TestHelper
|
|
164
168
|
assert_equal(expected, write(geom))
|
165
169
|
|
166
170
|
geom = read(wkt)
|
167
|
-
|
171
|
+
geom_2 = geom.send(method, *args).snap_to_grid(0.1)
|
168
172
|
|
169
173
|
assert_equal(wkt, write(geom))
|
170
|
-
assert_equal(expected, write(
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
if RUBY_VERSION >= '1.9'
|
175
|
-
Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
|
176
|
-
end
|
177
|
-
|
178
|
-
if !Fixnum.method_defined?(:negative?)
|
179
|
-
class Fixnum
|
180
|
-
def negative?
|
181
|
-
self < 0
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
if !Fixnum.method_defined?(:positive?)
|
187
|
-
class Fixnum
|
188
|
-
def positive?
|
189
|
-
self > 0
|
190
|
-
end
|
174
|
+
assert_equal(expected, write(geom_2, trim: true))
|
191
175
|
end
|
192
176
|
end
|
193
177
|
|
178
|
+
Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
|
data/test/utils_tests.rb
CHANGED
@@ -22,8 +22,8 @@ class UtilsTests < Minitest::Test
|
|
22
22
|
assert_equal(1, Geos::Utils.orientation_index(0, 0, 10, 10, 5, 20))
|
23
23
|
assert_equal(-1, Geos::Utils.orientation_index(0, 0, 10, 10, 5, 3))
|
24
24
|
assert_equal(-1, Geos::Utils.orientation_index(0, 0, 10, 10, 5, -2))
|
25
|
-
assert_equal(1, Geos::Utils.orientation_index(0, 0, 10, 10,
|
26
|
-
assert_equal(-1, Geos::Utils.orientation_index(0, 0, 10, 10,
|
25
|
+
assert_equal(1, Geos::Utils.orientation_index(0, 0, 10, 10, 1_000_000, 1_000_001))
|
26
|
+
assert_equal(-1, Geos::Utils.orientation_index(0, 0, 10, 10, 1_000_000, 999_999))
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_relate_match
|
@@ -48,7 +48,7 @@ class UtilsTests < Minitest::Test
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_create_point
|
51
|
-
cs = Geos::CoordinateSequence.new([[
|
51
|
+
cs = Geos::CoordinateSequence.new([[10, 20]])
|
52
52
|
create_method_tester('POINT (10 20)', :create_point, cs, Geos::GEOS_POINT, Geos::Point)
|
53
53
|
end
|
54
54
|
|
@@ -75,8 +75,8 @@ class UtilsTests < Minitest::Test
|
|
75
75
|
|
76
76
|
def test_create_line_string
|
77
77
|
cs = Geos::CoordinateSequence.new([
|
78
|
-
[
|
79
|
-
[
|
78
|
+
[10, 20, 30],
|
79
|
+
[30, 20, 10]
|
80
80
|
])
|
81
81
|
|
82
82
|
writer.output_dimensions = 3
|
@@ -103,7 +103,7 @@ class UtilsTests < Minitest::Test
|
|
103
103
|
create_method_tester(
|
104
104
|
'LINESTRING Z (10 20 30, 30 20 10)',
|
105
105
|
:create_line_string,
|
106
|
-
[[
|
106
|
+
[[10, 20, 30], [30, 20, 10]],
|
107
107
|
Geos::GEOS_LINESTRING,
|
108
108
|
Geos::LineString
|
109
109
|
) do |geom|
|
@@ -125,10 +125,10 @@ class UtilsTests < Minitest::Test
|
|
125
125
|
|
126
126
|
def test_create_linear_ring
|
127
127
|
cs = Geos::CoordinateSequence.new([
|
128
|
-
[
|
129
|
-
[
|
130
|
-
[
|
131
|
-
[
|
128
|
+
[7, 8, 9],
|
129
|
+
[3, 3, 3],
|
130
|
+
[11, 15.2, 2],
|
131
|
+
[7, 8, 9]
|
132
132
|
])
|
133
133
|
|
134
134
|
writer.output_dimensions = 3
|
@@ -155,7 +155,7 @@ class UtilsTests < Minitest::Test
|
|
155
155
|
create_method_tester(
|
156
156
|
'LINEARRING Z (7 8 9, 3 3 3, 11 15.2 2, 7 8 9)',
|
157
157
|
:create_linear_ring,
|
158
|
-
[[
|
158
|
+
[[7, 8, 9], [3, 3, 3], [11, 15.2, 2], [7, 8, 9]],
|
159
159
|
Geos::GEOS_LINEARRING,
|
160
160
|
Geos::LinearRing
|
161
161
|
) do |geom|
|
@@ -178,11 +178,11 @@ class UtilsTests < Minitest::Test
|
|
178
178
|
|
179
179
|
def test_create_polygon
|
180
180
|
cs = Geos::CoordinateSequence.new([
|
181
|
-
[
|
182
|
-
[
|
183
|
-
[
|
184
|
-
[
|
185
|
-
[
|
181
|
+
[0, 0],
|
182
|
+
[0, 10],
|
183
|
+
[10, 10],
|
184
|
+
[10, 0],
|
185
|
+
[0, 0]
|
186
186
|
])
|
187
187
|
|
188
188
|
exterior_ring = Geos.create_linear_ring(cs)
|
@@ -196,19 +196,19 @@ class UtilsTests < Minitest::Test
|
|
196
196
|
|
197
197
|
def test_create_polygon_with_coordinate_sequences
|
198
198
|
outer = Geos::CoordinateSequence.new(
|
199
|
-
[
|
200
|
-
[
|
201
|
-
[
|
202
|
-
[
|
203
|
-
[
|
199
|
+
[0, 0],
|
200
|
+
[0, 10],
|
201
|
+
[10, 10],
|
202
|
+
[10, 0],
|
203
|
+
[0, 0]
|
204
204
|
)
|
205
205
|
|
206
206
|
inner = Geos::CoordinateSequence.new(
|
207
|
-
[
|
208
|
-
[
|
209
|
-
[
|
210
|
-
[
|
211
|
-
[
|
207
|
+
[2, 2],
|
208
|
+
[2, 4],
|
209
|
+
[4, 4],
|
210
|
+
[4, 2],
|
211
|
+
[2, 2]
|
212
212
|
)
|
213
213
|
|
214
214
|
geom = Geos.create_polygon(outer, inner)
|
@@ -220,30 +220,30 @@ class UtilsTests < Minitest::Test
|
|
220
220
|
|
221
221
|
def test_create_polygon_with_holes
|
222
222
|
exterior_ring = Geos::CoordinateSequence.new(
|
223
|
-
[
|
224
|
-
[
|
225
|
-
[
|
226
|
-
[
|
227
|
-
[
|
223
|
+
[0, 0],
|
224
|
+
[0, 10],
|
225
|
+
[10, 10],
|
226
|
+
[10, 0],
|
227
|
+
[0, 0]
|
228
228
|
)
|
229
229
|
|
230
230
|
hole_1 = Geos::CoordinateSequence.new(
|
231
|
-
[
|
232
|
-
[
|
233
|
-
[
|
234
|
-
[
|
235
|
-
[
|
231
|
+
[2, 2],
|
232
|
+
[2, 4],
|
233
|
+
[4, 4],
|
234
|
+
[4, 2],
|
235
|
+
[2, 2]
|
236
236
|
)
|
237
237
|
|
238
238
|
hole_2 = Geos::CoordinateSequence.new(
|
239
|
-
[
|
240
|
-
[
|
241
|
-
[
|
242
|
-
[
|
243
|
-
[
|
239
|
+
[6, 6],
|
240
|
+
[6, 8],
|
241
|
+
[8, 8],
|
242
|
+
[8, 6],
|
243
|
+
[6, 6]
|
244
244
|
)
|
245
245
|
|
246
|
-
geom = Geos.create_polygon(exterior_ring, [
|
246
|
+
geom = Geos.create_polygon(exterior_ring, [hole_1, hole_2])
|
247
247
|
assert_instance_of(Geos::Polygon, geom)
|
248
248
|
assert_equal('Polygon', geom.geom_type)
|
249
249
|
assert_equal(Geos::GEOS_POLYGON, geom.type_id)
|
@@ -261,10 +261,13 @@ class UtilsTests < Minitest::Test
|
|
261
261
|
skip unless ENV['FORCE_TESTS'] || Geos.respond_to?(:create_multi_point)
|
262
262
|
|
263
263
|
assert_equal('MULTIPOINT EMPTY', write(Geos.create_multi_point))
|
264
|
-
assert_equal('MULTIPOINT (0 0, 10 10)',
|
265
|
-
|
266
|
-
|
267
|
-
|
264
|
+
assert_equal('MULTIPOINT (0 0, 10 10)',
|
265
|
+
write(
|
266
|
+
Geos.create_multi_point(
|
267
|
+
read('POINT(0 0)'),
|
268
|
+
read('POINT(10 10)')
|
269
|
+
)
|
270
|
+
))
|
268
271
|
end
|
269
272
|
|
270
273
|
def test_create_bad_multi_point
|
@@ -282,10 +285,13 @@ class UtilsTests < Minitest::Test
|
|
282
285
|
skip unless ENV['FORCE_TESTS'] || Geos.respond_to?(:create_multi_line_string)
|
283
286
|
|
284
287
|
assert_equal('MULTILINESTRING EMPTY', write(Geos.create_multi_line_string))
|
285
|
-
assert_equal('MULTILINESTRING ((0 0, 10 10), (10 10, 20 20))',
|
286
|
-
|
287
|
-
|
288
|
-
|
288
|
+
assert_equal('MULTILINESTRING ((0 0, 10 10), (10 10, 20 20))',
|
289
|
+
write(
|
290
|
+
Geos.create_multi_line_string(
|
291
|
+
read('LINESTRING(0 0, 10 10)'),
|
292
|
+
read('LINESTRING(10 10, 20 20)')
|
293
|
+
)
|
294
|
+
))
|
289
295
|
end
|
290
296
|
|
291
297
|
def test_create_bad_multi_line_string
|
@@ -303,10 +309,13 @@ class UtilsTests < Minitest::Test
|
|
303
309
|
skip unless ENV['FORCE_TESTS'] || Geos.respond_to?(:create_multi_polygon)
|
304
310
|
|
305
311
|
assert_equal('MULTIPOLYGON EMPTY', write(Geos.create_multi_polygon))
|
306
|
-
assert_equal('MULTIPOLYGON (((0 0, 0 5, 5 5, 5 0, 0 0)), ((10 10, 10 15, 15 15, 15 10, 10 10)))',
|
307
|
-
|
308
|
-
|
309
|
-
|
312
|
+
assert_equal('MULTIPOLYGON (((0 0, 0 5, 5 5, 5 0, 0 0)), ((10 10, 10 15, 15 15, 15 10, 10 10)))',
|
313
|
+
write(
|
314
|
+
Geos.create_multi_polygon(
|
315
|
+
read('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'),
|
316
|
+
read('POLYGON((10 10, 10 15, 15 15, 15 10, 10 10))')
|
317
|
+
)
|
318
|
+
))
|
310
319
|
end
|
311
320
|
|
312
321
|
def test_create_bad_multi_polygon
|
@@ -325,11 +334,12 @@ class UtilsTests < Minitest::Test
|
|
325
334
|
|
326
335
|
assert_equal('GEOMETRYCOLLECTION EMPTY', write(Geos.create_geometry_collection))
|
327
336
|
assert_equal('GEOMETRYCOLLECTION (POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0)), POLYGON ((10 10, 10 15, 15 15, 15 10, 10 10)))',
|
328
|
-
write(
|
329
|
-
|
330
|
-
|
337
|
+
write(
|
338
|
+
Geos.create_geometry_collection(
|
339
|
+
read('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'),
|
340
|
+
read('POLYGON((10 10, 10 15, 15 15, 15 10, 10 10))')
|
341
|
+
)
|
331
342
|
))
|
332
|
-
)
|
333
343
|
end
|
334
344
|
|
335
345
|
def test_create_geometry_collection_with_constants_and_symbols
|
@@ -339,7 +349,6 @@ class UtilsTests < Minitest::Test
|
|
339
349
|
assert_kind_of(Geos::MultiLineString, Geos.create_collection(:multi_line_string))
|
340
350
|
end
|
341
351
|
|
342
|
-
|
343
352
|
def test_create_bad_geometry_collection
|
344
353
|
skip unless ENV['FORCE_TESTS'] || Geos.respond_to?(:create_geometry_collection)
|
345
354
|
|
@@ -440,6 +449,7 @@ class UtilsTests < Minitest::Test
|
|
440
449
|
[5, 5],
|
441
450
|
[0, 5]
|
442
451
|
])
|
452
|
+
|
443
453
|
Geos.create_linear_ring(cs)
|
444
454
|
GC.start
|
445
455
|
end
|