Skip to content

Commit e98c1d2

Browse files
committed
Fix tests for GEOS 3.12+.
1 parent 9854a54 commit e98c1d2

File tree

6 files changed

+106
-28
lines changed

6 files changed

+106
-28
lines changed

test/geojson_reader_tests.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ def test_polygon_with_inner_ring
5555

5656
def test_multi_point
5757
geojson_tester(
58-
'MULTIPOINT (10.000 40.000, 40.000 30.000, 20.000 20.000, 30.000 10.000)',
58+
if Geos::GEOS_NICE_VERSION >= '031200'
59+
'MULTIPOINT ((10.000 40.000), (40.000 30.000), (20.000 20.000), (30.000 10.000))'
60+
else
61+
'MULTIPOINT (10.000 40.000, 40.000 30.000, 20.000 20.000, 30.000 10.000)'
62+
end,
5963
'{"type":"MultiPoint","coordinates":[[10, 40], [40, 30], [20, 20], [30, 10]]}'
6064
)
6165
end

test/geometry_tests.rb

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,11 @@ def test_sym_difference
269269

270270
comparison_tester(
271271
method,
272-
'MULTIPOINT (0 0, 1 0)',
272+
if Geos::GEOS_NICE_VERSION >= '031200'
273+
'MULTIPOINT ((0 0), (1 0))'
274+
else
275+
'MULTIPOINT (0 0, 1 0)'
276+
end,
273277
'POINT(0 0)',
274278
'POINT(1 0)'
275279
)
@@ -365,7 +369,11 @@ def test_boundary
365369

366370
simple_tester(
367371
:boundary,
368-
'MULTIPOINT (0 0, 10 10)',
372+
if Geos::GEOS_NICE_VERSION >= '031200'
373+
'MULTIPOINT ((0 0), (10 10))'
374+
else
375+
'MULTIPOINT (0 0, 10 10)'
376+
end,
369377
'LINESTRING(0 0, 10 10)'
370378
)
371379

@@ -386,7 +394,11 @@ def test_union
386394

387395
comparison_tester(
388396
:union,
389-
'MULTIPOINT (0 0, 1 0)',
397+
if Geos::GEOS_NICE_VERSION >= '031200'
398+
'MULTIPOINT ((0 0), (1 0))'
399+
else
400+
'MULTIPOINT (0 0, 1 0)'
401+
end,
390402
'POINT(0 0)',
391403
'POINT(1 0)'
392404
)
@@ -468,7 +480,14 @@ def test_union_with_precision
468480

469481
result = geom_a.union(geom_b, precision: 2)
470482

471-
assert_equal('MULTIPOINT (2 8, 4 10)', write(result))
483+
assert_equal(
484+
if Geos::GEOS_NICE_VERSION >= '031200'
485+
'MULTIPOINT ((2 8), (4 10))'
486+
else
487+
'MULTIPOINT (2 8, 4 10)'
488+
end,
489+
write(result)
490+
)
472491
end
473492

474493
def test_union_cascaded
@@ -486,7 +505,7 @@ def test_union_cascaded
486505
((10 10, 10 14, 14 14, 14 10, 10 10),
487506
(11 11, 11 12, 12 12, 12 11, 11 11)),
488507
((0 0, 11 0, 11 11, 0 11, 0 0))
489-
))'
508+
)'
490509
)
491510
end
492511

@@ -503,7 +522,7 @@ def test_coverage_union
503522
'MULTIPOLYGON(
504523
((0 0, 0 1, 1 1, 1 0, 0 0)),
505524
((1 0, 1 1, 2 1, 2 0, 1 0))
506-
))'
525+
)'
507526
)
508527
end
509528

@@ -522,7 +541,7 @@ def test_unary_union
522541
((10 10, 10 14, 14 14, 14 10, 10 10),
523542
(11 11, 11 12, 12 12, 12 11, 11 11)),
524543
((0 0, 11 0, 11 11, 0 11, 0 0))
525-
))'
544+
)'
526545
)
527546
end
528547

@@ -537,7 +556,7 @@ def test_unary_union_with_precision
537556
((10 10, 10 14, 14 14, 14 10, 10 10),
538557
(11 11, 11 12, 12 12, 12 11, 11 11)),
539558
((0 0, 11 0, 11 11, 0 11, 0 0))
540-
))',
559+
)',
541560
3
542561
)
543562
end
@@ -565,7 +584,7 @@ def test_union_without_arguments
565584
((10 10, 10 14, 14 14, 14 10, 10 10),
566585
(11 11, 11 12, 12 12, 12 11, 11 11)),
567586
((0 0, 11 0, 11 11, 0 11, 0 0))
568-
))'
587+
)'
569588
)
570589
end
571590

@@ -792,13 +811,17 @@ def test_extract_unique_points
792811
LINESTRING (0 0, 2 3),
793812
MULTIPOINT (0 0, 2 3),
794813
POINT (9 0),
795-
POINT(1 0)),
814+
POINT (1 0),
796815
LINESTRING EMPTY
797-
')
816+
)')
798817

799818
simple_tester(
800819
:extract_unique_points,
801-
'MULTIPOINT (0 0, 1 0, 1 1, 0 1, 10 10, 10 14, 14 14, 14 10, 11 11, 11 12, 12 12, 12 11, 2 3, 3 4, 9 0)',
820+
if Geos::GEOS_NICE_VERSION >= '031200'
821+
'MULTIPOINT ((0 0), (1 0), (1 1), (0 1), (10 10), (10 14), (14 14), (14 10), (11 11), (11 12), (12 12), (12 11), (2 3), (3 4), (9 0))'
822+
else
823+
'MULTIPOINT (0 0, 1 0, 1 1, 0 1, 10 10, 10 14, 14 14, 14 10, 11 11, 11 12, 12 12, 12 11, 2 3, 3 4, 9 0)'
824+
end,
802825
geom.extract_unique_points
803826
)
804827
end
@@ -972,10 +995,10 @@ def test_valid_detail
972995

973996
tester['Self-intersection', 'POINT (2.5 5)', 'POLYGON((0 0, 0 5, 5 5, 5 10, 0 0))', 0]
974997

975-
tester['Ring Self-intersection', 'POINT (0 0)', 'POLYGON((0 0, -10 10, 10 10, 0 0, 4 5, -4 5, 0 0)))', 0]
998+
tester['Ring Self-intersection', 'POINT (0 0)', 'POLYGON((0 0, -10 10, 10 10, 0 0, 4 5, -4 5, 0 0))', 0]
976999

9771000
assert_nil(
978-
read('POLYGON((0 0, -10 10, 10 10, 0 0, 4 5, -4 5, 0 0)))').valid_detail(
1001+
read('POLYGON((0 0, -10 10, 10 10, 0 0, 4 5, -4 5, 0 0))').valid_detail(
9791002
:allow_selftouching_ring_forming_hole
9801003
)
9811004
)
@@ -1635,7 +1658,7 @@ def test_dup_srid
16351658
end
16361659

16371660
def test_line_string_enumerator
1638-
geom = read('LINESTRING(0 0, 10 10))')
1661+
geom = read('LINESTRING(0 0, 10 10)')
16391662
assert_kind_of(Enumerable, geom.each)
16401663
assert_kind_of(Enumerable, geom.to_enum)
16411664
assert_equal(geom, geom.each(&EMPTY_BLOCK))
@@ -1827,13 +1850,13 @@ def test_delaunay_triangulation
18271850
'GEOMETRYCOLLECTION (POLYGON ((8 2, 10 10, 8.5 1, 8 2)), POLYGON ((7 8, 10 10, 8 2, 7 8)), POLYGON ((3 8, 10 10, 7 8, 3 8)), ' \
18281851
'POLYGON ((2 2, 8 2, 8.5 1, 2 2)), POLYGON ((2 2, 7 8, 8 2, 2 2)), POLYGON ((2 2, 3 8, 7 8, 2 2)), POLYGON ((0.5 9, 10 10, 3 8, 0.5 9)), ' \
18291852
'POLYGON ((0.5 9, 3 8, 2 2, 0.5 9)), POLYGON ((0 0, 2 2, 8.5 1, 0 0)), POLYGON ((0 0, 0.5 9, 2 2, 0 0)))',
1830-
'POLYGON((0 0, 8.5 1, 10 10, 0.5 9, 0 0),(2 2, 3 8, 7 8, 8 2, 2 2)))',
1853+
'POLYGON((0 0, 8.5 1, 10 10, 0.5 9, 0 0),(2 2, 3 8, 7 8, 8 2, 2 2))',
18311854
0
18321855
]
18331856

18341857
tester[
18351858
'MULTILINESTRING ((8.5 1, 10 10), (8 2, 10 10), (8 2, 8.5 1), (7 8, 10 10), (7 8, 8 2), (3 8, 10 10), (3 8, 7 8), (2 2, 8.5 1), (2 2, 8 2), (2 2, 7 8), (2 2, 3 8), (0.5 9, 10 10), (0.5 9, 3 8), (0.5 9, 2 2), (0 0, 8.5 1), (0 0, 2 2), (0 0, 0.5 9))',
1836-
'POLYGON((0 0, 8.5 1, 10 10, 0.5 9, 0 0),(2 2, 3 8, 7 8, 8 2, 2 2)))',
1859+
'POLYGON((0 0, 8.5 1, 10 10, 0.5 9, 0 0),(2 2, 3 8, 7 8, 8 2, 2 2))',
18371860
0,
18381861
only_edges: true
18391862
]
@@ -1945,7 +1968,14 @@ def test_minimum_rotated_rectangle
19451968
geom = read('POLYGON ((1 6, 6 11, 11 6, 6 1, 1 6))')
19461969
minimum_rotated_rectangle = geom.minimum_rotated_rectangle
19471970

1948-
assert_equal('POLYGON ((6 1, 11 6, 6 11, 1 6, 6 1))', write(minimum_rotated_rectangle))
1971+
assert_equal(
1972+
if Geos::GEOS_NICE_VERSION >= '031200'
1973+
'POLYGON ((6 1, 1 6, 6 11, 11 6, 6 1))'
1974+
else
1975+
'POLYGON ((6 1, 11 6, 6 11, 1 6, 6 1))'
1976+
end,
1977+
write(minimum_rotated_rectangle)
1978+
)
19491979
end
19501980

19511981
def test_minimum_clearance
@@ -2078,7 +2108,13 @@ def test_reverse
20782108
skip unless ENV['FORCE_TESTS'] || Geos::Geometry.method_defined?(:reverse)
20792109

20802110
simple_tester(:reverse, 'POINT (3 5)', 'POINT (3 5)')
2081-
simple_tester(:reverse, 'MULTIPOINT (100 100, 10 100, 30 100)', 'MULTIPOINT (100 100, 10 100, 30 100)')
2111+
2112+
if Geos::GEOS_NICE_VERSION >= '031200'
2113+
simple_tester(:reverse, 'MULTIPOINT ((100 100), (10 100), (30 100))', 'MULTIPOINT (100 100, 10 100, 30 100)')
2114+
else
2115+
simple_tester(:reverse, 'MULTIPOINT (100 100, 10 100, 30 100)', 'MULTIPOINT (100 100, 10 100, 30 100)')
2116+
end
2117+
20822118
simple_tester(:reverse, 'LINESTRING (200 200, 200 100)', 'LINESTRING (200 100, 200 200)')
20832119

20842120
if Geos::GEOS_NICE_VERSION >= '030801'

test/line_string_tests.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ def test_offset_curve
9595
# outside curve
9696
simple_tester(
9797
:offset_curve,
98-
if Geos::GEOS_NICE_VERSION >= '031100'
98+
if Geos::GEOS_NICE_VERSION >= '031200'
99+
'LINESTRING (0 -2, 10 -2, 10.390180644032256 -1.9615705608064609, 10.76536686473018 -1.8477590650225735, ' \
100+
'11.111140466039204 -1.6629392246050902, 11.414213562373096 -1.414213562373095, 11.66293922460509 -1.1111404660392044, '\
101+
'11.847759065022574 -0.7653668647301796, 11.96157056080646 -0.3901806440322565, 12 0, 12 10)'
102+
elsif Geos::GEOS_NICE_VERSION >= '031100'
99103
'LINESTRING (0 -2, 10 -2, 12 0, 12 10)'
100104
else
101105
'LINESTRING (12 10, 12 0, 10 -2, 0 -2)'

test/utils_tests.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,13 @@ def test_create_multi_point
261261
skip unless ENV['FORCE_TESTS'] || Geos.respond_to?(:create_multi_point)
262262

263263
assert_equal('MULTIPOINT EMPTY', write(Geos.create_multi_point))
264-
assert_equal('MULTIPOINT (0 0, 10 10)',
264+
265+
assert_equal(
266+
if Geos::GEOS_NICE_VERSION >= '031200'
267+
'MULTIPOINT ((0 0), (10 10))'
268+
else
269+
'MULTIPOINT (0 0, 10 10)'
270+
end,
265271
write(
266272
Geos.create_multi_point(
267273
read('POINT(0 0)'),

test/wkb_writer_tests.rb

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,20 @@ def test_write_with_options
433433
}
434434

435435
tester[
436-
[1, 1, 0, 0, 32, 230, 16, 0, 0, 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 0, 64].pack('C*'),
436+
if Geos::GEOS_NICE_VERSION >= '031200'
437+
[1, 1, 0, 0, 160, 230, 16, 0, 0, 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 8, 64].pack('C*')
438+
else
439+
[1, 1, 0, 0, 32, 230, 16, 0, 0, 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 0, 64].pack('C*')
440+
end,
437441
include_srid: true
438442
]
439443

440444
tester[
441-
[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 0, 64].pack('C*')
445+
if Geos::GEOS_NICE_VERSION >= '031200'
446+
[1, 1, 0, 0, 128, 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 8, 64].pack('C*')
447+
else
448+
[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 63, 0, 0, 0, 0, 0, 0, 0, 64].pack('C*')
449+
end
442450
]
443451
end
444452

@@ -448,13 +456,25 @@ def test_write_hex_with_options
448456
geom = read('POINT(1 2 3)')
449457
geom.srid = 4326
450458

451-
assert_equal('0101000020E6100000000000000000F03F0000000000000040',
459+
assert_equal(
460+
if Geos::GEOS_NICE_VERSION >= '031200'
461+
'01010000A0E6100000000000000000F03F00000000000000400000000000000840'
462+
else
463+
'0101000020E6100000000000000000F03F0000000000000040'
464+
end,
452465
@wkb_writer.write_hex(
453466
geom,
454467
include_srid: true
455468
))
456469

457-
assert_equal('0101000000000000000000F03F0000000000000040', @wkb_writer.write_hex(geom))
470+
assert_equal(
471+
if Geos::GEOS_NICE_VERSION >= '031200'
472+
'0101000080000000000000F03F00000000000000400000000000000840'
473+
else
474+
'0101000000000000000000F03F0000000000000040'
475+
end,
476+
@wkb_writer.write_hex(geom)
477+
)
458478
end
459479

460480
def test_illegal_output_dimensions

test/wkt_writer_tests.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ def test_round_trip
3535
[
3636
'POINT (0 0)',
3737
'POINT EMPTY',
38-
'MULTIPOINT (0 1, 2 3)',
38+
if Geos::GEOS_NICE_VERSION >= '031200'
39+
'MULTIPOINT ((0 1), (2 3))'
40+
else
41+
'MULTIPOINT (0 1, 2 3)'
42+
end,
3943
'MULTIPOINT EMPTY',
4044
'LINESTRING (0 0, 2 3)',
4145
'LINESTRING EMPTY',
@@ -45,7 +49,11 @@ def test_round_trip
4549
'POLYGON EMPTY',
4650
'MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((10 10, 10 14, 14 14, 14 10, 10 10), (11 11, 11 12, 12 12, 12 11, 11 11)))',
4751
'MULTIPOLYGON EMPTY',
48-
'GEOMETRYCOLLECTION (MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((10 10, 10 14, 14 14, 14 10, 10 10), (11 11, 11 12, 12 12, 12 11, 11 11))), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), MULTILINESTRING ((0 0, 2 3), (10 10, 3 4)), LINESTRING (0 0, 2 3), MULTIPOINT (0 0, 2 3), POINT (9 0))',
52+
if Geos::GEOS_NICE_VERSION >= '031200'
53+
'GEOMETRYCOLLECTION (MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((10 10, 10 14, 14 14, 14 10, 10 10), (11 11, 11 12, 12 12, 12 11, 11 11))), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), MULTILINESTRING ((0 0, 2 3), (10 10, 3 4)), LINESTRING (0 0, 2 3), MULTIPOINT ((0 0), (2 3)), POINT (9 0))'
54+
else
55+
'GEOMETRYCOLLECTION (MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((10 10, 10 14, 14 14, 14 10, 10 10), (11 11, 11 12, 12 12, 12 11, 11 11))), POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)), MULTILINESTRING ((0 0, 2 3), (10 10, 3 4)), LINESTRING (0 0, 2 3), MULTIPOINT (0 0, 2 3), POINT (9 0))'
56+
end,
4957
'GEOMETRYCOLLECTION EMPTY'
5058
].each do |g|
5159
assert_equal(g, write(read(g)))

0 commit comments

Comments
 (0)