ffi-geos 1.2.1 → 1.2.2
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 +5 -5
- data/.rubocop.yml +20 -0
- data/.travis.yml +7 -3
- data/Gemfile +1 -1
- data/Guardfile +4 -5
- data/ffi-geos.gemspec +1 -1
- data/lib/ffi-geos.rb +212 -196
- data/lib/ffi-geos/buffer_params.rb +9 -20
- data/lib/ffi-geos/coordinate_sequence.rb +342 -58
- data/lib/ffi-geos/geometry.rb +167 -178
- data/lib/ffi-geos/geometry_collection.rb +60 -12
- data/lib/ffi-geos/interrupt.rb +2 -4
- data/lib/ffi-geos/line_string.rb +146 -37
- data/lib/ffi-geos/linear_ring.rb +2 -3
- data/lib/ffi-geos/multi_line_string.rb +1 -2
- data/lib/ffi-geos/multi_point.rb +0 -1
- data/lib/ffi-geos/multi_polygon.rb +0 -1
- data/lib/ffi-geos/point.rb +69 -14
- data/lib/ffi-geos/polygon.rb +110 -21
- data/lib/ffi-geos/prepared_geometry.rb +11 -12
- data/lib/ffi-geos/strtree.rb +41 -52
- data/lib/ffi-geos/tools.rb +15 -18
- data/lib/ffi-geos/utils.rb +27 -44
- data/lib/ffi-geos/version.rb +1 -3
- data/lib/ffi-geos/wkb_reader.rb +4 -9
- data/lib/ffi-geos/wkb_writer.rb +14 -18
- data/lib/ffi-geos/wkt_reader.rb +2 -5
- data/lib/ffi-geos/wkt_writer.rb +17 -22
- data/test/.rubocop.yml +36 -0
- data/test/coordinate_sequence_tests.rb +263 -14
- data/test/geometry_collection_tests.rb +412 -1
- data/test/geometry_tests.rb +156 -86
- data/test/interrupt_tests.rb +2 -4
- data/test/line_string_tests.rb +212 -23
- data/test/linear_ring_tests.rb +1 -2
- data/test/misc_tests.rb +28 -29
- data/test/multi_line_string_tests.rb +0 -1
- data/test/point_tests.rb +158 -1
- data/test/polygon_tests.rb +284 -1
- data/test/prepared_geometry_tests.rb +1 -3
- data/test/strtree_tests.rb +9 -10
- data/test/test_helper.rb +49 -18
- data/test/tools_tests.rb +1 -3
- data/test/utils_tests.rb +22 -22
- data/test/wkb_reader_tests.rb +10 -9
- data/test/wkb_writer_tests.rb +5 -13
- data/test/wkt_reader_tests.rb +1 -2
- data/test/wkt_writer_tests.rb +9 -14
- metadata +6 -3
data/test/geometry_tests.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'test_helper'
|
@@ -21,8 +20,6 @@ class GeometryTests < Minitest::Test
|
|
21
20
|
end
|
22
21
|
|
23
22
|
def test_buffer
|
24
|
-
writer.rounding_precision = 2
|
25
|
-
|
26
23
|
simple_tester(
|
27
24
|
:buffer,
|
28
25
|
'POLYGON EMPTY',
|
@@ -30,95 +27,95 @@ class GeometryTests < Minitest::Test
|
|
30
27
|
0
|
31
28
|
)
|
32
29
|
|
33
|
-
|
30
|
+
snapped_tester(
|
34
31
|
:buffer,
|
35
|
-
'POLYGON ((10 0,
|
32
|
+
'POLYGON ((10 0, 10 -2, 9 -4, 8 -6, 7 -7, 6 -8, 4 -9, 2 -10, 0 -10, -2 -10, -4 -9, -6 -8, -7 -7, -8 -6, -9 -4, -10 -2, -10 0, -10 2, -9 4, -8 6, -7 7, -6 8, -4 9, -2 10, 0 10, 2 10, 4 9, 6 8, 7 7, 8 6, 9 4, 10 2, 10 0))',
|
36
33
|
'POINT(0 0)',
|
37
34
|
10
|
38
35
|
)
|
39
36
|
|
40
37
|
# One segment per quadrant
|
41
|
-
|
38
|
+
snapped_tester(
|
42
39
|
:buffer,
|
43
|
-
'POLYGON ((10 0,
|
40
|
+
'POLYGON ((10 0, 0 -10, -10 0, 0 10, 10 0))',
|
44
41
|
'POINT(0 0)',
|
45
42
|
10,
|
46
|
-
|
43
|
+
quad_segs: 1
|
47
44
|
)
|
48
45
|
|
49
46
|
# End cap styles
|
50
|
-
|
47
|
+
snapped_tester(
|
51
48
|
:buffer,
|
52
|
-
'POLYGON ((
|
49
|
+
'POLYGON ((100 10, 110 0, 100 -10, 0 -10, -10 0, 0 10, 100 10))',
|
53
50
|
'LINESTRING(0 0, 100 0)',
|
54
51
|
10,
|
55
|
-
|
52
|
+
quad_segs: 1, endcap: :round
|
56
53
|
)
|
57
54
|
|
58
|
-
|
55
|
+
snapped_tester(
|
59
56
|
:buffer,
|
60
|
-
'POLYGON ((
|
57
|
+
'POLYGON ((100 10, 100 -10, 0 -10, 0 10, 100 10))',
|
61
58
|
'LINESTRING(0 0, 100 0)',
|
62
59
|
10,
|
63
|
-
|
60
|
+
quad_segs: 1, endcap: :flat
|
64
61
|
)
|
65
62
|
|
66
|
-
|
63
|
+
snapped_tester(
|
67
64
|
:buffer,
|
68
|
-
'POLYGON ((
|
65
|
+
'POLYGON ((100 10, 110 10, 110 -10, 0 -10, -10 -10, -10 10, 100 10))',
|
69
66
|
'LINESTRING(0 0, 100 0)',
|
70
67
|
10,
|
71
|
-
|
68
|
+
quad_segs: 1, endcap: :square
|
72
69
|
)
|
73
70
|
|
74
71
|
# Join styles
|
75
|
-
|
72
|
+
snapped_tester(
|
76
73
|
:buffer,
|
77
|
-
'POLYGON ((90 10, 90
|
74
|
+
'POLYGON ((90 10, 90 100, 93 107, 100 110, 107 107, 110 100, 110 0, 107 -7, 100 -10, 0 -10, -7 -7, -10 0, -7 7, 0 10, 90 10))',
|
78
75
|
'LINESTRING(0 0, 100 0, 100 100)',
|
79
76
|
10,
|
80
|
-
|
77
|
+
quad_segs: 2, join: :round
|
81
78
|
)
|
82
79
|
|
83
|
-
|
80
|
+
snapped_tester(
|
84
81
|
:buffer,
|
85
|
-
'POLYGON ((90 10, 90
|
82
|
+
'POLYGON ((90 10, 90 100, 93 107, 100 110, 107 107, 110 100, 110 0, 100 -10, 0 -10, -7 -7, -10 0, -7 7, 0 10, 90 10))',
|
86
83
|
'LINESTRING(0 0, 100 0, 100 100)',
|
87
84
|
10,
|
88
|
-
|
85
|
+
quad_segs: 2, join: :bevel
|
89
86
|
)
|
90
87
|
|
91
|
-
|
88
|
+
snapped_tester(
|
92
89
|
:buffer,
|
93
|
-
'POLYGON ((90 10, 90
|
90
|
+
'POLYGON ((90 10, 90 100, 93 107, 100 110, 107 107, 110 100, 110 -10, 0 -10, -7 -7, -10 0, -7 7, 0 10, 90 10))',
|
94
91
|
'LINESTRING(0 0, 100 0, 100 100)',
|
95
92
|
10,
|
96
|
-
|
93
|
+
quad_segs: 2, join: :mitre
|
97
94
|
)
|
98
95
|
|
99
|
-
|
96
|
+
snapped_tester(
|
100
97
|
:buffer,
|
101
|
-
'POLYGON ((90 10, 90
|
98
|
+
'POLYGON ((90 10, 90 100, 93 107, 100 110, 107 107, 110 100, 109 -5, 105 -9, 0 -10, -7 -7, -10 0, -7 7, 0 10, 90 10))',
|
102
99
|
'LINESTRING(0 0, 100 0, 100 100)',
|
103
100
|
10,
|
104
|
-
|
101
|
+
quad_segs: 2, join: :mitre, mitre_limit: 1.0
|
105
102
|
)
|
106
103
|
|
107
104
|
# Single-sided buffering
|
108
|
-
|
105
|
+
snapped_tester(
|
109
106
|
:buffer,
|
110
|
-
'POLYGON ((
|
107
|
+
'POLYGON ((100 0, 0 0, 0 10, 100 10, 100 0))',
|
111
108
|
'LINESTRING(0 0, 100 0)',
|
112
109
|
10,
|
113
|
-
|
110
|
+
single_sided: true
|
114
111
|
)
|
115
112
|
|
116
|
-
|
113
|
+
snapped_tester(
|
117
114
|
:buffer,
|
118
|
-
'POLYGON ((0 0,
|
115
|
+
'POLYGON ((0 0, 100 0, 100 -10, 0 -10, 0 0))',
|
119
116
|
'LINESTRING(0 0, 100 0)',
|
120
117
|
-10,
|
121
|
-
|
118
|
+
single_sided: true
|
122
119
|
)
|
123
120
|
end
|
124
121
|
|
@@ -510,10 +507,7 @@ class GeometryTests < Minitest::Test
|
|
510
507
|
'LINESTRING(0 0, 10 10)'
|
511
508
|
)
|
512
509
|
|
513
|
-
|
514
|
-
writer.rounding_precision = 0
|
515
|
-
|
516
|
-
simple_tester(
|
510
|
+
snapped_tester(
|
517
511
|
method,
|
518
512
|
'POINT (5 4)',
|
519
513
|
'POLYGON((0 0, 0 10, 5 5, 10 10, 10 0, 0 0))'
|
@@ -794,10 +788,10 @@ class GeometryTests < Minitest::Test
|
|
794
788
|
def test_valid_reason
|
795
789
|
skip unless ENV['FORCE_TESTS'] || Geos::Geometry.method_defined?(:valid_reason)
|
796
790
|
|
797
|
-
assert_equal(
|
798
|
-
assert_equal(
|
799
|
-
assert_equal(
|
800
|
-
assert_equal(
|
791
|
+
assert_equal('Valid Geometry', read('POINT(0 0)').valid_reason)
|
792
|
+
assert_equal('Invalid Coordinate[0 nan]', read('POINT(0 NaN)').valid_reason)
|
793
|
+
assert_equal('Invalid Coordinate[0 nan]', read('POINT(0 nan)').valid_reason)
|
794
|
+
assert_equal('Self-intersection[2.5 5]', read('POLYGON((0 0, 0 5, 5 5, 5 10, 0 0))').valid_reason)
|
801
795
|
end
|
802
796
|
|
803
797
|
def test_valid_detail
|
@@ -810,14 +804,16 @@ class GeometryTests < Minitest::Test
|
|
810
804
|
}
|
811
805
|
|
812
806
|
assert_nil(read('POINT(0 0)').valid_detail)
|
813
|
-
tester[
|
814
|
-
tester[
|
807
|
+
tester['Invalid Coordinate', 'POINT (0 nan)', 'POINT(0 NaN)', 0]
|
808
|
+
tester['Self-intersection', 'POINT (2.5 5)', 'POLYGON((0 0, 0 5, 5 5, 5 10, 0 0))', 0]
|
815
809
|
|
816
|
-
tester[
|
810
|
+
tester['Ring Self-intersection', 'POINT (0 0)', 'POLYGON((0 0, -10 10, 10 10, 0 0, 4 5, -4 5, 0 0)))', 0]
|
817
811
|
|
818
|
-
assert_nil(
|
819
|
-
|
820
|
-
|
812
|
+
assert_nil(
|
813
|
+
read('POLYGON((0 0, -10 10, 10 10, 0 0, 4 5, -4 5, 0 0)))').valid_detail(
|
814
|
+
:allow_selftouching_ring_forming_hole
|
815
|
+
)
|
816
|
+
)
|
821
817
|
end
|
822
818
|
|
823
819
|
def test_simple
|
@@ -846,8 +842,7 @@ class GeometryTests < Minitest::Test
|
|
846
842
|
simple_tester(:num_geometries, 2, 'MULTIPOLYGON(
|
847
843
|
((0 0, 1 0, 1 1, 0 1, 0 0)),
|
848
844
|
((10 10, 10 14, 14 14, 14 10, 10 10),
|
849
|
-
(11 11, 11 12, 12 12, 12 11, 11 11)))'
|
850
|
-
)
|
845
|
+
(11 11, 11 12, 12 12, 12 11, 11 11)))')
|
851
846
|
simple_tester(:num_geometries, 6, 'GEOMETRYCOLLECTION (
|
852
847
|
MULTIPOLYGON (
|
853
848
|
((0 0, 1 0, 1 1, 0 1, 0 0)),
|
@@ -858,8 +853,7 @@ class GeometryTests < Minitest::Test
|
|
858
853
|
MULTILINESTRING ((0 0, 2 3), (10 10, 3 4)),
|
859
854
|
LINESTRING (0 0, 2 3),
|
860
855
|
MULTIPOINT (0 0, 2 3),
|
861
|
-
POINT (9 0))'
|
862
|
-
)
|
856
|
+
POINT (9 0))')
|
863
857
|
end
|
864
858
|
|
865
859
|
# get_geometry_n is segfaulting in the binary GEOS build
|
@@ -880,8 +874,7 @@ class GeometryTests < Minitest::Test
|
|
880
874
|
simple_tester(:num_interior_rings, 2, 'POLYGON (
|
881
875
|
(10 10, 10 14, 14 14, 14 10, 10 10),
|
882
876
|
(11 11, 11 12, 12 12, 12 11, 11 11),
|
883
|
-
(13 11, 13 12, 13.5 12, 13.5 11, 13 11))'
|
884
|
-
)
|
877
|
+
(13 11, 13 12, 13.5 12, 13.5 11, 13 11))')
|
885
878
|
|
886
879
|
assert_raises(NoMethodError) do
|
887
880
|
read('POINT (0 0)').num_interior_rings
|
@@ -1023,12 +1016,12 @@ class GeometryTests < Minitest::Test
|
|
1023
1016
|
|
1024
1017
|
def test_dimensions
|
1025
1018
|
types = {
|
1026
|
-
:
|
1027
|
-
:
|
1028
|
-
:
|
1029
|
-
:
|
1030
|
-
:
|
1031
|
-
:
|
1019
|
+
dontcare: -3,
|
1020
|
+
non_empty: -2,
|
1021
|
+
empty: -1,
|
1022
|
+
point: 0,
|
1023
|
+
curve: 1,
|
1024
|
+
surface: 2
|
1032
1025
|
}
|
1033
1026
|
|
1034
1027
|
simple_tester(:dimensions, types[:point], 'POINT(0 0)')
|
@@ -1201,10 +1194,7 @@ class GeometryTests < Minitest::Test
|
|
1201
1194
|
geom_2 = read(g2)
|
1202
1195
|
|
1203
1196
|
cs = geom_1.nearest_points(geom_2)
|
1204
|
-
|
1205
|
-
result = if cs
|
1206
|
-
cs.to_s
|
1207
|
-
end
|
1197
|
+
result = cs.to_s if cs
|
1208
1198
|
|
1209
1199
|
assert_equal(expected, result)
|
1210
1200
|
}
|
@@ -1248,11 +1238,11 @@ class GeometryTests < Minitest::Test
|
|
1248
1238
|
assert_equal(2, polygonized.length)
|
1249
1239
|
assert_equal(
|
1250
1240
|
'POLYGON ((185 221, 88 275, 180 316, 292 281, 185 221))',
|
1251
|
-
write(polygonized[0])
|
1241
|
+
write(polygonized[0].snap_to_grid(0.1))
|
1252
1242
|
)
|
1253
1243
|
assert_equal(
|
1254
1244
|
'POLYGON ((189 98, 83 187, 185 221, 325 168, 189 98))',
|
1255
|
-
write(polygonized[1])
|
1245
|
+
write(polygonized[1].snap_to_grid(0.1))
|
1256
1246
|
)
|
1257
1247
|
end
|
1258
1248
|
|
@@ -1287,7 +1277,8 @@ class GeometryTests < Minitest::Test
|
|
1287
1277
|
LINESTRING(185 221, 292 281, 180 316),
|
1288
1278
|
LINESTRING(189 98, 83 187, 185 221),
|
1289
1279
|
LINESTRING(189 98, 325 168, 185 221)
|
1290
|
-
)'
|
1280
|
+
)'
|
1281
|
+
)
|
1291
1282
|
|
1292
1283
|
polygonized = geom_a.polygonize_full
|
1293
1284
|
|
@@ -1437,9 +1428,9 @@ class GeometryTests < Minitest::Test
|
|
1437
1428
|
geom_a = read('POINT(1.0 1.0)')
|
1438
1429
|
geom_b = read('POINT(2.0 2.0)')
|
1439
1430
|
|
1440
|
-
assert(geom_a == geom_a,
|
1441
|
-
refute(geom_a == geom_b,
|
1442
|
-
refute(geom_a ==
|
1431
|
+
assert(geom_a == geom_a, 'Expected geoms to be equal using ==')
|
1432
|
+
refute(geom_a == geom_b, 'Expected geoms to not be equal using ==')
|
1433
|
+
refute(geom_a == 'test', 'Expected geoms to not be equal using ==')
|
1443
1434
|
end
|
1444
1435
|
|
1445
1436
|
def test_eql_exact
|
@@ -1572,19 +1563,19 @@ class GeometryTests < Minitest::Test
|
|
1572
1563
|
|
1573
1564
|
# empty polygon
|
1574
1565
|
tester['GEOMETRYCOLLECTION EMPTY', 'POLYGON EMPTY', 0]
|
1575
|
-
tester['MULTILINESTRING EMPTY', 'POLYGON EMPTY', 0,
|
1566
|
+
tester['MULTILINESTRING EMPTY', 'POLYGON EMPTY', 0, only_edges: true]
|
1576
1567
|
|
1577
1568
|
# single point
|
1578
1569
|
tester['GEOMETRYCOLLECTION EMPTY', 'POINT (0 0)', 0]
|
1579
|
-
tester['MULTILINESTRING EMPTY', 'POINT (0 0)', 0,
|
1570
|
+
tester['MULTILINESTRING EMPTY', 'POINT (0 0)', 0, only_edges: true]
|
1580
1571
|
|
1581
1572
|
# three collinear points
|
1582
1573
|
tester['GEOMETRYCOLLECTION EMPTY', 'MULTIPOINT(0 0, 5 0, 10 0)', 0]
|
1583
|
-
tester['MULTILINESTRING ((5 0, 10 0), (0 0, 5 0))', 'MULTIPOINT(0 0, 5 0, 10 0)', 0,
|
1574
|
+
tester['MULTILINESTRING ((5 0, 10 0), (0 0, 5 0))', 'MULTIPOINT(0 0, 5 0, 10 0)', 0, only_edges: true]
|
1584
1575
|
|
1585
1576
|
# three points
|
1586
1577
|
tester['GEOMETRYCOLLECTION (POLYGON ((0 0, 10 10, 5 0, 0 0)))', 'MULTIPOINT(0 0, 5 0, 10 10)', 0]
|
1587
|
-
tester['MULTILINESTRING ((5 0, 10 10), (0 0, 10 10), (0 0, 5 0))', 'MULTIPOINT(0 0, 5 0, 10 10)', 0,
|
1578
|
+
tester['MULTILINESTRING ((5 0, 10 10), (0 0, 10 10), (0 0, 5 0))', 'MULTIPOINT(0 0, 5 0, 10 10)', 0, only_edges: true]
|
1588
1579
|
|
1589
1580
|
# polygon with a hole
|
1590
1581
|
tester[
|
@@ -1596,16 +1587,15 @@ class GeometryTests < Minitest::Test
|
|
1596
1587
|
tester[
|
1597
1588
|
'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))',
|
1598
1589
|
'POLYGON((0 0, 8.5 1, 10 10, 0.5 9, 0 0),(2 2, 3 8, 7 8, 8 2, 2 2)))',
|
1599
|
-
0,
|
1600
|
-
|
1601
|
-
}
|
1590
|
+
0,
|
1591
|
+
only_edges: true
|
1602
1592
|
]
|
1603
1593
|
|
1604
1594
|
# four points with a tolerance making one collapse
|
1605
|
-
tester['MULTILINESTRING ((10 0, 10 10), (0 0, 10 10), (0 0, 10 0))', 'MULTIPOINT(0 0, 10 0, 10 10, 11 10)', 2.0,
|
1595
|
+
tester['MULTILINESTRING ((10 0, 10 10), (0 0, 10 10), (0 0, 10 0))', 'MULTIPOINT(0 0, 10 0, 10 10, 11 10)', 2.0, only_edges: true]
|
1606
1596
|
|
1607
1597
|
# tolerance as an option
|
1608
|
-
tester['MULTILINESTRING ((10 0, 10 10), (0 0, 10 10), (0 0, 10 0))', 'MULTIPOINT(0 0, 10 0, 10 10, 11 10)',
|
1598
|
+
tester['MULTILINESTRING ((10 0, 10 10), (0 0, 10 10), (0 0, 10 0))', 'MULTIPOINT(0 0, 10 0, 10 10, 11 10)', tolerance: 2.0, only_edges: true]
|
1609
1599
|
end
|
1610
1600
|
|
1611
1601
|
def test_voronoi_diagram
|
@@ -1624,12 +1614,12 @@ class GeometryTests < Minitest::Test
|
|
1624
1614
|
|
1625
1615
|
tester['GEOMETRYCOLLECTION (POLYGON ((50 200, 200 200, 200 50, 50 50, 50 200)), POLYGON ((-100 50, -100 200, 50 200, 50 50, -100 50)), POLYGON ((50 -100, -100 -100, -100 50, 50 50, 50 -100)), POLYGON ((200 50, 200 -100, 50 -100, 50 50, 200 50)))', geom]
|
1626
1616
|
|
1627
|
-
tester['MULTILINESTRING ((50 50, 50 200), (200 50, 50 50), (50 50, -100 50), (50 50, 50 -100))', geom,
|
1617
|
+
tester['MULTILINESTRING ((50 50, 50 200), (200 50, 50 50), (50 50, -100 50), (50 50, 50 -100))', geom, tolerance: 0, only_edges: true]
|
1628
1618
|
|
1629
|
-
tester['MULTILINESTRING ((50 50, 50 1100), (1100 50, 50 50), (50 50, -1000 50), (50 50, 50 -1000))', geom,
|
1630
|
-
:
|
1631
|
-
:
|
1632
|
-
|
1619
|
+
tester['MULTILINESTRING ((50 50, 50 1100), (1100 50, 50 50), (50 50, -1000 50), (50 50, 50 -1000))', geom,
|
1620
|
+
only_edges: true,
|
1621
|
+
envelope: read(geom).buffer(1000)
|
1622
|
+
]
|
1633
1623
|
|
1634
1624
|
# Allows a tolerance for the first argument
|
1635
1625
|
@writer.rounding_precision = 3
|
@@ -1658,7 +1648,7 @@ class GeometryTests < Minitest::Test
|
|
1658
1648
|
geom_with_precision = geom.with_precision(5.0)
|
1659
1649
|
assert_equal('LINESTRING EMPTY', write(geom_with_precision))
|
1660
1650
|
|
1661
|
-
geom_with_precision = geom.with_precision(5.0, :
|
1651
|
+
geom_with_precision = geom.with_precision(5.0, keep_collapsed: true)
|
1662
1652
|
assert_equal('LINESTRING (0 0, 0 0)', write(geom_with_precision))
|
1663
1653
|
end
|
1664
1654
|
|
@@ -1722,4 +1712,84 @@ class GeometryTests < Minitest::Test
|
|
1722
1712
|
output = geom.minimum_width
|
1723
1713
|
assert_equal('LINESTRING (5 5, 0 10)', write(output))
|
1724
1714
|
end
|
1715
|
+
|
1716
|
+
def test_dump_points
|
1717
|
+
geom = read('GEOMETRYCOLLECTION(
|
1718
|
+
MULTILINESTRING((0 0, 10 10, 20 20), (100 100, 200 200, 300 300)),
|
1719
|
+
|
1720
|
+
POINT(10 10),
|
1721
|
+
|
1722
|
+
POLYGON((0 0, 5 0, 5 5, 0 5, 0 0), (1 1, 4 1, 4 4, 1 4, 1 1))
|
1723
|
+
)')
|
1724
|
+
|
1725
|
+
assert_equal([
|
1726
|
+
[
|
1727
|
+
[
|
1728
|
+
Geos.create_point(0, 0),
|
1729
|
+
Geos.create_point(10, 10),
|
1730
|
+
Geos.create_point(20, 20)
|
1731
|
+
],
|
1732
|
+
|
1733
|
+
[
|
1734
|
+
Geos.create_point(100, 100),
|
1735
|
+
Geos.create_point(200, 200),
|
1736
|
+
Geos.create_point(300, 300)
|
1737
|
+
]
|
1738
|
+
],
|
1739
|
+
|
1740
|
+
[
|
1741
|
+
Geos.create_point(10, 10)
|
1742
|
+
],
|
1743
|
+
|
1744
|
+
[
|
1745
|
+
[
|
1746
|
+
Geos.create_point(0, 0),
|
1747
|
+
Geos.create_point(5, 0),
|
1748
|
+
Geos.create_point(5, 5),
|
1749
|
+
Geos.create_point(0, 5),
|
1750
|
+
Geos.create_point(0, 0)
|
1751
|
+
],
|
1752
|
+
|
1753
|
+
[
|
1754
|
+
Geos.create_point(1, 1),
|
1755
|
+
Geos.create_point(4, 1),
|
1756
|
+
Geos.create_point(4, 4),
|
1757
|
+
Geos.create_point(1, 4),
|
1758
|
+
Geos.create_point(1, 1)
|
1759
|
+
]
|
1760
|
+
]
|
1761
|
+
], geom.dump_points)
|
1762
|
+
end
|
1763
|
+
|
1764
|
+
def test_reverse
|
1765
|
+
skip unless ENV['FORCE_TESTS'] || Geos::Geometry.method_defined?(:reverse)
|
1766
|
+
|
1767
|
+
simple_tester(:reverse, 'POINT (3 5)', 'POINT (3 5)')
|
1768
|
+
simple_tester(:reverse, 'MULTIPOINT (100 100, 10 100, 30 100)', 'MULTIPOINT (100 100, 10 100, 30 100)')
|
1769
|
+
simple_tester(:reverse, 'LINESTRING (200 200, 200 100)', 'LINESTRING (200 100, 200 200)')
|
1770
|
+
simple_tester(:reverse, 'MULTILINESTRING ((1 1, 2 2), (3 3, 4 4))', 'MULTILINESTRING ((4 4, 3 3), (2 2, 1 1))')
|
1771
|
+
simple_tester(:reverse, 'POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1))', 'POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1))')
|
1772
|
+
simple_tester(:reverse, 'MULTIPOLYGON (((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((100 100, 100 200, 200 200, 100 100)))', 'MULTIPOLYGON (((0 0, 0 10, 10 10, 10 0, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)), ((100 100, 200 200, 100 200, 100 100)))')
|
1773
|
+
simple_tester(:reverse, 'GEOMETRYCOLLECTION (LINESTRING (1 1, 2 2), GEOMETRYCOLLECTION (LINESTRING (3 5, 2 9)))', 'GEOMETRYCOLLECTION (LINESTRING (2 2, 1 1), GEOMETRYCOLLECTION(LINESTRING (2 9, 3 5)))')
|
1774
|
+
simple_tester(:reverse, 'POINT EMPTY', 'POINT EMPTY')
|
1775
|
+
simple_tester(:reverse, 'LINESTRING EMPTY', 'LINESTRING EMPTY')
|
1776
|
+
simple_tester(:reverse, 'LINEARRING EMPTY', 'LINEARRING EMPTY')
|
1777
|
+
simple_tester(:reverse, 'POLYGON EMPTY', 'POLYGON EMPTY')
|
1778
|
+
simple_tester(:reverse, 'MULTIPOINT EMPTY', 'MULTIPOINT EMPTY')
|
1779
|
+
simple_tester(:reverse, 'MULTILINESTRING EMPTY', 'MULTILINESTRING EMPTY')
|
1780
|
+
simple_tester(:reverse, 'MULTIPOLYGON EMPTY', 'MULTIPOLYGON EMPTY')
|
1781
|
+
simple_tester(:reverse, 'GEOMETRYCOLLECTION EMPTY', 'GEOMETRYCOLLECTION EMPTY')
|
1782
|
+
end
|
1783
|
+
|
1784
|
+
def test_frechet_distance
|
1785
|
+
skip unless ENV['FORCE_TESTS'] || Geos::Geometry.method_defined?(:frechet_distance)
|
1786
|
+
|
1787
|
+
assert_in_delta(read('LINESTRING (0 0, 100 0)').frechet_distance(read('LINESTRING (0 0, 50 50, 100 0)')), 70.7106781186548, TOLERANCE)
|
1788
|
+
end
|
1789
|
+
|
1790
|
+
def test_frechet_distance_with_densify
|
1791
|
+
skip unless ENV['FORCE_TESTS'] || Geos::Geometry.method_defined?(:frechet_distance)
|
1792
|
+
|
1793
|
+
assert_in_delta(read('LINESTRING (0 0, 100 0)').frechet_distance(read('LINESTRING (0 0, 50 50, 100 0)'), 0.5), 50.0, TOLERANCE)
|
1794
|
+
end
|
1725
1795
|
end
|
data/test/interrupt_tests.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'test_helper'
|
@@ -36,7 +35,7 @@ class InterruptTests < Minitest::Test
|
|
36
35
|
interrupt_tester do
|
37
36
|
geom = read('LINESTRING(0 0, 1 0)')
|
38
37
|
|
39
|
-
Geos::Interrupt.register(
|
38
|
+
Geos::Interrupt.register(method(:interrupt_method))
|
40
39
|
|
41
40
|
begin
|
42
41
|
buffer = geom.buffer(1, 8)
|
@@ -183,7 +182,7 @@ class InterruptTests < Minitest::Test
|
|
183
182
|
skip unless ENV['FORCE_TESTS'] || Geos::Interrupt.available?
|
184
183
|
|
185
184
|
assert_raises(ArgumentError) do
|
186
|
-
Geos::Interrupt.register(
|
185
|
+
Geos::Interrupt.register(method(:interrupt_method)) do
|
187
186
|
# no-op
|
188
187
|
end
|
189
188
|
end
|
@@ -197,4 +196,3 @@ class InterruptTests < Minitest::Test
|
|
197
196
|
end
|
198
197
|
end
|
199
198
|
end
|
200
|
-
|