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.
@@ -13,7 +13,7 @@ class GeometryTests < Minitest::Test
13
13
  def test_intersection
14
14
  comparison_tester(
15
15
  :intersection,
16
- if Geos::GEOS_VERSION > '3.9.0'
16
+ if Geos::GEOS_NICE_VERSION > '030900'
17
17
  'POLYGON ((10 10, 10 5, 5 5, 5 10, 10 10))'
18
18
  else
19
19
  'POLYGON ((5 10, 10 10, 10 5, 5 5, 5 10))'
@@ -36,7 +36,11 @@ class GeometryTests < Minitest::Test
36
36
 
37
37
  comparison_tester(
38
38
  :intersection,
39
- 'GEOMETRYCOLLECTION (LINESTRING (2 0, 4 0), POINT (0 0), POINT (10 0))',
39
+ if Geos::GEOS_NICE_VERSION >= '031000'
40
+ 'GEOMETRYCOLLECTION (LINESTRING (2 0, 4 0), POINT (10 0), POINT (0 0))'
41
+ else
42
+ 'GEOMETRYCOLLECTION (LINESTRING (2 0, 4 0), POINT (0 0), POINT (10 0))'
43
+ end,
40
44
  'LINESTRING(0 0, 10 0)',
41
45
  'LINESTRING(9 0, 12 0, 12 20, 4 0, 2 0, 2 10, 0 10, 0 -10)',
42
46
  precision: 2
@@ -119,7 +123,11 @@ class GeometryTests < Minitest::Test
119
123
 
120
124
  snapped_tester(
121
125
  :buffer,
122
- '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))',
126
+ if Geos::GEOS_NICE_VERSION >= '031100'
127
+ 'POLYGON ((90 10, 90 100, 93 107, 100 110, 107 107, 110 100, 110 -4, 104 -10, 0 -10, -7 -7, -10 0, -7 7, 0 10, 90 10))'
128
+ else
129
+ '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))'
130
+ end,
123
131
  'LINESTRING(0 0, 100 0, 100 100)',
124
132
  10,
125
133
  quad_segs: 2, join: :mitre, mitre_limit: 1.0
@@ -206,7 +214,7 @@ class GeometryTests < Minitest::Test
206
214
 
207
215
  comparison_tester(
208
216
  :difference,
209
- if Geos::GEOS_VERSION > '3.9.0'
217
+ if Geos::GEOS_NICE_VERSION > '030900'
210
218
  'POLYGON ((0 10, 5 10, 10 10, 10 0, 5 0, 0 0, 0 10))'
211
219
  else
212
220
  'POLYGON ((0 0, 0 10, 5 10, 10 10, 10 0, 5 0, 0 0))'
@@ -217,7 +225,7 @@ class GeometryTests < Minitest::Test
217
225
 
218
226
  comparison_tester(
219
227
  :difference,
220
- if Geos::GEOS_VERSION > '3.9.0'
228
+ if Geos::GEOS_NICE_VERSION > '030900'
221
229
  'POLYGON ((0 10, 10 10, 10 0, 0 0, 0 10))'
222
230
  else
223
231
  'POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))'
@@ -228,7 +236,7 @@ class GeometryTests < Minitest::Test
228
236
 
229
237
  comparison_tester(
230
238
  :difference,
231
- if Geos::GEOS_VERSION > '3.9.0'
239
+ if Geos::GEOS_NICE_VERSION > '030900'
232
240
  'POLYGON ((0 10, 10 10, 10 5, 5 5, 5 0, 0 0, 0 10))'
233
241
  else
234
242
  'POLYGON ((0 0, 0 10, 10 10, 10 5, 5 5, 5 0, 0 0))'
@@ -303,7 +311,7 @@ class GeometryTests < Minitest::Test
303
311
 
304
312
  comparison_tester(
305
313
  method,
306
- if Geos::GEOS_VERSION > '3.9.0'
314
+ if Geos::GEOS_NICE_VERSION > '030900'
307
315
  'GEOMETRYCOLLECTION (POLYGON ((0 10, 5 10, 10 10, 10 0, 5 0, 0 0, 0 10)), LINESTRING (5 -10, 5 0))'
308
316
  else
309
317
  'GEOMETRYCOLLECTION (LINESTRING (5 -10, 5 0), POLYGON ((0 0, 0 10, 5 10, 10 10, 10 0, 5 0, 0 0)))'
@@ -314,7 +322,7 @@ class GeometryTests < Minitest::Test
314
322
 
315
323
  comparison_tester(
316
324
  method,
317
- if Geos::GEOS_VERSION > '3.9.0'
325
+ if Geos::GEOS_NICE_VERSION > '030900'
318
326
  'GEOMETRYCOLLECTION (POLYGON ((0 10, 10 10, 10 0, 0 0, 0 10)), LINESTRING (10 0, 20 0))'
319
327
  else
320
328
  'GEOMETRYCOLLECTION (LINESTRING (10 0, 20 0), POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0)))'
@@ -325,7 +333,7 @@ class GeometryTests < Minitest::Test
325
333
 
326
334
  comparison_tester(
327
335
  method,
328
- if Geos::GEOS_VERSION > '3.9.0'
336
+ if Geos::GEOS_NICE_VERSION > '030900'
329
337
  'MULTIPOLYGON (((0 10, 10 10, 10 5, 5 5, 5 0, 0 0, 0 10)), ((10 0, 10 5, 15 5, 15 -5, 5 -5, 5 0, 10 0)))'
330
338
  else
331
339
  'MULTIPOLYGON (((0 0, 0 10, 10 10, 10 5, 5 5, 5 0, 0 0)), ((5 0, 10 0, 10 5, 15 5, 15 -5, 5 -5, 5 0)))'
@@ -420,7 +428,7 @@ class GeometryTests < Minitest::Test
420
428
 
421
429
  comparison_tester(
422
430
  :union,
423
- if Geos::GEOS_VERSION > '3.9.0'
431
+ if Geos::GEOS_NICE_VERSION > '030900'
424
432
  'GEOMETRYCOLLECTION (POLYGON ((0 10, 5 10, 10 10, 10 0, 5 0, 0 0, 0 10)), LINESTRING (5 -10, 5 0))'
425
433
  else
426
434
  'GEOMETRYCOLLECTION (LINESTRING (5 -10, 5 0), POLYGON ((0 0, 0 10, 5 10, 10 10, 10 0, 5 0, 0 0)))'
@@ -431,7 +439,7 @@ class GeometryTests < Minitest::Test
431
439
 
432
440
  comparison_tester(
433
441
  :union,
434
- if Geos::GEOS_VERSION > '3.9.0'
442
+ if Geos::GEOS_NICE_VERSION > '030900'
435
443
  'GEOMETRYCOLLECTION (POLYGON ((0 10, 10 10, 10 0, 0 0, 0 10)), LINESTRING (10 0, 20 0))'
436
444
  else
437
445
  'GEOMETRYCOLLECTION (LINESTRING (10 0, 20 0), POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0)))'
@@ -442,7 +450,7 @@ class GeometryTests < Minitest::Test
442
450
 
443
451
  comparison_tester(
444
452
  :union,
445
- if Geos::GEOS_VERSION > '3.9.0'
453
+ if Geos::GEOS_NICE_VERSION > '030900'
446
454
  'POLYGON ((0 10, 10 10, 10 5, 15 5, 15 -5, 5 -5, 5 0, 0 0, 0 10))'
447
455
  else
448
456
  'POLYGON ((0 0, 0 10, 10 10, 10 5, 15 5, 15 -5, 5 -5, 5 0, 0 0))'
@@ -468,7 +476,7 @@ class GeometryTests < Minitest::Test
468
476
 
469
477
  simple_tester(
470
478
  :union_cascaded,
471
- if Geos::GEOS_VERSION > '3.9.0'
479
+ if Geos::GEOS_NICE_VERSION > '030900'
472
480
  'POLYGON ((0 0, 0 1, 0 11, 10 11, 10 14, 14 14, 14 10, 11 10, 11 0, 1 0, 0 0), (12 12, 11 12, 11 11, 12 11, 12 12))'
473
481
  else
474
482
  'POLYGON ((1 0, 0 0, 0 1, 0 11, 10 11, 10 14, 14 14, 14 10, 11 10, 11 0, 1 0), (11 11, 12 11, 12 12, 11 12, 11 11))'
@@ -487,7 +495,7 @@ class GeometryTests < Minitest::Test
487
495
 
488
496
  simple_tester(
489
497
  :union_cascaded,
490
- if Geos::GEOS_VERSION > '3.9.0'
498
+ if Geos::GEOS_NICE_VERSION > '030900'
491
499
  'POLYGON ((0 1, 1 1, 2 1, 2 0, 1 0, 0 0, 0 1))'
492
500
  else
493
501
  'POLYGON ((0 0, 0 1, 1 1, 2 1, 2 0, 1 0, 0 0))'
@@ -504,7 +512,7 @@ class GeometryTests < Minitest::Test
504
512
 
505
513
  simple_tester(
506
514
  :unary_union,
507
- if Geos::GEOS_VERSION > '3.9.0'
515
+ if Geos::GEOS_NICE_VERSION > '030900'
508
516
  'POLYGON ((0 0, 0 1, 0 11, 10 11, 10 14, 14 14, 14 10, 11 10, 11 0, 1 0, 0 0), (12 12, 11 12, 11 11, 12 11, 12 12))'
509
517
  else
510
518
  'POLYGON ((1 0, 0 0, 0 1, 0 11, 10 11, 10 14, 14 14, 14 10, 11 10, 11 0, 1 0), (11 11, 12 11, 12 12, 11 12, 11 11))'
@@ -547,7 +555,7 @@ class GeometryTests < Minitest::Test
547
555
  def test_union_without_arguments
548
556
  simple_tester(
549
557
  :union,
550
- if Geos::GEOS_VERSION > '3.9.0'
558
+ if Geos::GEOS_NICE_VERSION > '030900'
551
559
  'POLYGON ((0 0, 0 1, 0 11, 10 11, 10 14, 14 14, 14 10, 11 10, 11 0, 1 0, 0 0), (12 12, 11 12, 11 11, 12 11, 12 12))'
552
560
  else
553
561
  'POLYGON ((1 0, 0 0, 0 1, 0 11, 10 11, 10 14, 14 14, 14 10, 11 10, 11 0, 1 0), (11 11, 12 11, 12 12, 11 12, 11 11))'
@@ -955,7 +963,13 @@ class GeometryTests < Minitest::Test
955
963
  }
956
964
 
957
965
  assert_nil(read('POINT(0 0)').valid_detail)
958
- tester['Invalid Coordinate', 'POINT (0 nan)', 'POINT(0 NaN)', 0]
966
+
967
+ if Geos::GEOS_NICE_VERSION >= '031000'
968
+ tester['Invalid Coordinate', 'POINT (0 NaN)', 'POINT(0 NaN)', 0]
969
+ else
970
+ tester['Invalid Coordinate', 'POINT (0 nan)', 'POINT(0 NaN)', 0]
971
+ end
972
+
959
973
  tester['Self-intersection', 'POINT (2.5 5)', 'POLYGON((0 0, 0 5, 5 5, 5 10, 0 0))', 0]
960
974
 
961
975
  tester['Ring Self-intersection', 'POINT (0 0)', 'POLYGON((0 0, -10 10, 10 10, 0 0, 4 5, -4 5, 0 0)))', 0]
@@ -1371,7 +1385,7 @@ class GeometryTests < Minitest::Test
1371
1385
  ]
1372
1386
 
1373
1387
  tester[
1374
- if Geos::GEOS_VERSION > '3.8'
1388
+ if Geos::GEOS_NICE_VERSION >= '030800'
1375
1389
  '5.0 5.0, 8.0 8.0'
1376
1390
  else
1377
1391
  '5.0 5.0 NaN, 8.0 8.0 NaN'
@@ -1471,7 +1485,11 @@ class GeometryTests < Minitest::Test
1471
1485
  def test_polygonize_full
1472
1486
  skip unless ENV['FORCE_TESTS'] || Geos::Geometry.method_defined?(:polygonize_full)
1473
1487
 
1474
- writer.rounding_precision = 3
1488
+ writer.rounding_precision = if Geos::GEOS_NICE_VERSION >= '031000'
1489
+ 0
1490
+ else
1491
+ 3
1492
+ end
1475
1493
 
1476
1494
  geom_a = read(
1477
1495
  'GEOMETRYCOLLECTION(
@@ -1556,7 +1574,7 @@ class GeometryTests < Minitest::Test
1556
1574
  geom = read('POLYGON((0 0, 1 1, 0 1, 1 0, 0 0))')
1557
1575
 
1558
1576
  assert_equal(
1559
- if Geos::GEOS_VERSION > '3.9.0'
1577
+ if Geos::GEOS_NICE_VERSION > '030900'
1560
1578
  'MULTIPOLYGON (((1 0, 0 0, 0.5 0.5, 1 0)), ((1 1, 0.5 0.5, 0 1, 1 1)))'
1561
1579
  else
1562
1580
  'MULTIPOLYGON (((0 0, 0.5 0.5, 1 0, 0 0)), ((0.5 0.5, 0 1, 1 1, 0.5 0.5)))'
@@ -1807,8 +1825,8 @@ class GeometryTests < Minitest::Test
1807
1825
  # polygon with a hole
1808
1826
  tester[
1809
1827
  '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)), ' \
1810
- '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)), ' \
1811
- '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)))',
1828
+ '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)), ' \
1829
+ '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)))',
1812
1830
  'POLYGON((0 0, 8.5 1, 10 10, 0.5 9, 0 0),(2 2, 3 8, 7 8, 8 2, 2 2)))',
1813
1831
  0
1814
1832
  ]
@@ -1842,7 +1860,7 @@ class GeometryTests < Minitest::Test
1842
1860
  geom = 'MULTIPOINT(0 0, 100 0, 100 100, 0 100)'
1843
1861
 
1844
1862
  tester[
1845
- if Geos::GEOS_VERSION > '3.9.0'
1863
+ if Geos::GEOS_NICE_VERSION > '030900'
1846
1864
  'GEOMETRYCOLLECTION (POLYGON ((200 200, 200 50, 50 50, 50 200, 200 200)), POLYGON ((-100 200, 50 200, 50 50, -100 50, -100 200)), POLYGON ((-100 -100, -100 50, 50 50, 50 -100, -100 -100)), POLYGON ((200 -100, 50 -100, 50 50, 200 50, 200 -100)))'
1847
1865
  else
1848
1866
  '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)))'
@@ -1858,9 +1876,16 @@ class GeometryTests < Minitest::Test
1858
1876
  ]
1859
1877
 
1860
1878
  # Allows a tolerance for the first argument
1861
- @writer.rounding_precision = 3
1879
+ writer.rounding_precision = if Geos::GEOS_NICE_VERSION >= '031000'
1880
+ 0
1881
+ else
1882
+ 3
1883
+ end
1884
+
1885
+ writer.trim = true
1886
+
1862
1887
  tester[
1863
- if Geos::GEOS_VERSION > '3.9.0'
1888
+ if Geos::GEOS_NICE_VERSION > '030900'
1864
1889
  'GEOMETRYCOLLECTION (POLYGON ((290 140, 185 140, 185 215, 188 235, 290 252, 290 140)), POLYGON ((80 340, 101 340, 188 235, 185 215, 80 215, 80 340)), POLYGON ((80 140, 80 215, 185 215, 185 140, 80 140)), POLYGON ((290 340, 290 252, 188 235, 101 340, 290 340)))'
1865
1890
  else
1866
1891
  'GEOMETRYCOLLECTION (POLYGON ((290 252, 290 140, 185 140, 185 215, 188 235, 290 252)), POLYGON ((80 215, 80 340, 101 340, 188 235, 185 215, 80 215)), POLYGON ((185 140, 80 140, 80 215, 185 215, 185 140)), POLYGON ((101 340, 290 340, 290 252, 188 235, 101 340)))'
@@ -1941,12 +1966,12 @@ class GeometryTests < Minitest::Test
1941
1966
  tester[
1942
1967
  'LINESTRING (-112.712119 33.575919, -112.712127 33.575885)',
1943
1968
  '0106000000010000000103000000010000001a00000035d42824992d5cc01b834e081dca404073b9c150872d5cc03465a71fd4c940400ec00644882d5cc03b8a' \
1944
- '73d4d1c94040376dc669882d5cc0bf9cd9aed0c940401363997e892d5cc002f4fbfecdc94040ca4e3fa88b2d5cc0a487a1d5c9c940408f1ce90c8c2d5cc06989' \
1945
- '95d1c8c94040fab836548c2d5cc0bd175fb4c7c940409f1f46088f2d5cc0962023a0c2c940407b15191d902d5cc068041bd7bfc940400397c79a912d5cc0287d' \
1946
- '21e4bcc940403201bf46922d5cc065e3c116bbc940409d9d0c8e922d5cc0060fd3beb9c940400ef7915b932d5cc09012bbb6b7c940404fe61f7d932d5cc0e4a0' \
1947
- '8499b6c94040fc71fbe5932d5cc0ea9106b7b5c94040eaec6470942d5cc0c2323674b3c94040601dc70f952d5cc043588d25acc94040aea06989952d5cc03ecf' \
1948
- '9f36aac94040307f85cc952d5cc0e5eb32fca7c94040dd0a6135962d5cc01b615111a7c9404048a7ae7c962d5cc00a2aaa7ea5c94040f4328ae5962d5cc05eb8' \
1949
- '7361a4c94040c49448a2972d5cc04d81cccea2c940407c80eecb992d5cc06745d4449fc9404035d42824992d5cc01b834e081dca4040'
1969
+ '73d4d1c94040376dc669882d5cc0bf9cd9aed0c940401363997e892d5cc002f4fbfecdc94040ca4e3fa88b2d5cc0a487a1d5c9c940408f1ce90c8c2d5cc06989' \
1970
+ '95d1c8c94040fab836548c2d5cc0bd175fb4c7c940409f1f46088f2d5cc0962023a0c2c940407b15191d902d5cc068041bd7bfc940400397c79a912d5cc0287d' \
1971
+ '21e4bcc940403201bf46922d5cc065e3c116bbc940409d9d0c8e922d5cc0060fd3beb9c940400ef7915b932d5cc09012bbb6b7c940404fe61f7d932d5cc0e4a0' \
1972
+ '8499b6c94040fc71fbe5932d5cc0ea9106b7b5c94040eaec6470942d5cc0c2323674b3c94040601dc70f952d5cc043588d25acc94040aea06989952d5cc03ecf' \
1973
+ '9f36aac94040307f85cc952d5cc0e5eb32fca7c94040dd0a6135962d5cc01b615111a7c9404048a7ae7c962d5cc00a2aaa7ea5c94040f4328ae5962d5cc05eb8' \
1974
+ '7361a4c94040c49448a2972d5cc04d81cccea2c940407c80eecb992d5cc06745d4449fc9404035d42824992d5cc01b834e081dca4040'
1950
1975
  ]
1951
1976
  tester['LINESTRING EMPTY', 'POLYGON EMPTY']
1952
1977
  end
@@ -2038,7 +2063,7 @@ class GeometryTests < Minitest::Test
2038
2063
  simple_tester(:reverse, 'MULTIPOINT (100 100, 10 100, 30 100)', 'MULTIPOINT (100 100, 10 100, 30 100)')
2039
2064
  simple_tester(:reverse, 'LINESTRING (200 200, 200 100)', 'LINESTRING (200 100, 200 200)')
2040
2065
 
2041
- if Geos::GEOS_VERSION >= '3.8.1'
2066
+ if Geos::GEOS_NICE_VERSION >= '030801'
2042
2067
  simple_tester(:reverse, 'MULTILINESTRING ((3 3, 4 4), (1 1, 2 2))', 'MULTILINESTRING ((4 4, 3 3), (2 2, 1 1))')
2043
2068
  else
2044
2069
  simple_tester(:reverse, 'MULTILINESTRING ((1 1, 2 2), (3 3, 4 4))', 'MULTILINESTRING ((4 4, 3 3), (2 2, 1 1))')
@@ -80,7 +80,11 @@ class LineStringTests < Minitest::Test
80
80
  # straight right
81
81
  simple_tester(
82
82
  :offset_curve,
83
- 'LINESTRING (10 -2, 0 -2)',
83
+ if Geos::GEOS_NICE_VERSION >= '031100'
84
+ 'LINESTRING (0 -2, 10 -2)'
85
+ else
86
+ 'LINESTRING (10 -2, 0 -2)'
87
+ end,
84
88
  'LINESTRING (0 0, 10 0)',
85
89
  -2,
86
90
  quad_segs: 0,
@@ -91,7 +95,11 @@ class LineStringTests < Minitest::Test
91
95
  # outside curve
92
96
  simple_tester(
93
97
  :offset_curve,
94
- 'LINESTRING (12 10, 12 0, 10 -2, 0 -2)',
98
+ if Geos::GEOS_NICE_VERSION >= '031100'
99
+ 'LINESTRING (0 -2, 10 -2, 12 0, 12 10)'
100
+ else
101
+ 'LINESTRING (12 10, 12 0, 10 -2, 0 -2)'
102
+ end,
95
103
  'LINESTRING (0 0, 10 0, 10 10)',
96
104
  -2,
97
105
  quad_segs: 1,
@@ -264,7 +272,7 @@ class LineStringTests < Minitest::Test
264
272
 
265
273
  affine_tester(:rotate_x, 'LINESTRING Z (1 -1 -1, 10 -10 -10)', wkt, Math::PI)
266
274
  affine_tester(:rotate_x, 'LINESTRING Z (1 -1 1, 10 -10 10)', wkt, Math::PI / 2)
267
- affine_tester(:rotate_x, 'LINESTRING Z (1 1 -1, 10 10 -10)', wkt, Math::PI + Math::PI / 2)
275
+ affine_tester(:rotate_x, 'LINESTRING Z (1 1 -1, 10 10 -10)', wkt, Math::PI + (Math::PI / 2))
268
276
  affine_tester(:rotate_x, wkt, wkt, Math::PI * 2)
269
277
  end
270
278
 
@@ -276,7 +284,7 @@ class LineStringTests < Minitest::Test
276
284
 
277
285
  affine_tester(:rotate_y, 'LINESTRING Z (-1 1 -1, -10 10 -10)', wkt, Math::PI)
278
286
  affine_tester(:rotate_y, 'LINESTRING Z (1 1 -1, 10 10 -10)', wkt, Math::PI / 2)
279
- affine_tester(:rotate_y, 'LINESTRING Z (-1 1 1, -10 10 10)', wkt, Math::PI + Math::PI / 2)
287
+ affine_tester(:rotate_y, 'LINESTRING Z (-1 1 1, -10 10 10)', wkt, Math::PI + (Math::PI / 2))
280
288
  affine_tester(:rotate_y, wkt, wkt, Math::PI * 2)
281
289
  end
282
290
 
@@ -287,7 +295,7 @@ class LineStringTests < Minitest::Test
287
295
 
288
296
  affine_tester(:rotate_z, 'LINESTRING (-1 -1, -10 -10)', wkt, Math::PI)
289
297
  affine_tester(:rotate_z, 'LINESTRING (-1 1, -10 10)', wkt, Math::PI / 2)
290
- affine_tester(:rotate_z, 'LINESTRING (1 -1, 10 -10)', wkt, Math::PI + Math::PI / 2)
298
+ affine_tester(:rotate_z, 'LINESTRING (1 -1, 10 -10)', wkt, Math::PI + (Math::PI / 2))
291
299
  affine_tester(:rotate_z, wkt, wkt, Math::PI * 2)
292
300
  end
293
301
 
data/test/point_tests.rb CHANGED
@@ -177,7 +177,7 @@ class PointTests < Minitest::Test
177
177
 
178
178
  affine_tester(:rotate_x, 'POINT Z (1 -1 -1)', wkt, Math::PI)
179
179
  affine_tester(:rotate_x, 'POINT Z (1 -1 1)', wkt, Math::PI / 2)
180
- affine_tester(:rotate_x, 'POINT Z (1 1 -1)', wkt, Math::PI + Math::PI / 2)
180
+ affine_tester(:rotate_x, 'POINT Z (1 1 -1)', wkt, Math::PI + (Math::PI / 2))
181
181
  affine_tester(:rotate_x, wkt, wkt, Math::PI * 2)
182
182
  end
183
183
 
@@ -189,7 +189,7 @@ class PointTests < Minitest::Test
189
189
 
190
190
  affine_tester(:rotate_y, 'POINT Z (-1 1 -1)', wkt, Math::PI)
191
191
  affine_tester(:rotate_y, 'POINT Z (1 1 -1)', wkt, Math::PI / 2)
192
- affine_tester(:rotate_y, 'POINT Z (-1 1 1)', wkt, Math::PI + Math::PI / 2)
192
+ affine_tester(:rotate_y, 'POINT Z (-1 1 1)', wkt, Math::PI + (Math::PI / 2))
193
193
  affine_tester(:rotate_y, wkt, wkt, Math::PI * 2)
194
194
  end
195
195
 
@@ -200,7 +200,7 @@ class PointTests < Minitest::Test
200
200
 
201
201
  affine_tester(:rotate_z, 'POINT (-1 -1)', wkt, Math::PI)
202
202
  affine_tester(:rotate_z, 'POINT (-1 1)', wkt, Math::PI / 2)
203
- affine_tester(:rotate_z, 'POINT (1 -1)', wkt, Math::PI + Math::PI / 2)
203
+ affine_tester(:rotate_z, 'POINT (1 -1)', wkt, Math::PI + (Math::PI / 2))
204
204
  affine_tester(:rotate_z, wkt, wkt, Math::PI * 2)
205
205
  end
206
206
 
@@ -147,7 +147,7 @@ class PolygonTests < Minitest::Test
147
147
  affine_tester(:rotate_x,
148
148
  'POLYGON Z ((0 0 0, 5 0 0, 5 0 -5, 0 0 -5, 0 0 0))',
149
149
  wkt,
150
- Math::PI + Math::PI / 2)
150
+ Math::PI + (Math::PI / 2))
151
151
 
152
152
  affine_tester(:rotate_x,
153
153
  wkt,
@@ -173,7 +173,7 @@ class PolygonTests < Minitest::Test
173
173
  affine_tester(:rotate_y,
174
174
  'POLYGON Z ((0 0 0, 0 0 5, 0 5 5, 0 5 0, 0 0 0))',
175
175
  wkt,
176
- Math::PI + Math::PI / 2)
176
+ Math::PI + (Math::PI / 2))
177
177
 
178
178
  affine_tester(:rotate_y,
179
179
  wkt,
@@ -195,7 +195,7 @@ class PolygonTests < Minitest::Test
195
195
  affine_tester(:rotate_z,
196
196
  'POLYGON ((0 0, 0 -5, 5 -5, 5 0, 0 0))',
197
197
  'POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0))',
198
- Math::PI + Math::PI / 2)
198
+ Math::PI + (Math::PI / 2))
199
199
 
200
200
  affine_tester(:rotate_z,
201
201
  'POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0))',
@@ -233,7 +233,7 @@ class STRtreeTests < Minitest::Test
233
233
  end
234
234
 
235
235
  def test_nearest
236
- skip unless ENV['FORCE_TESTS'] || defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest)
236
+ skip unless ENV['FORCE_TESTS'] || (defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest))
237
237
 
238
238
  geom_1 = read('POINT (3 3)')
239
239
  geom_2 = read('POINT (2 7)')
@@ -250,7 +250,7 @@ class STRtreeTests < Minitest::Test
250
250
  end
251
251
 
252
252
  def test_nearest_with_depth
253
- skip unless ENV['FORCE_TESTS'] || defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest)
253
+ skip unless ENV['FORCE_TESTS'] || (defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest))
254
254
 
255
255
  number_of_geoms = 100
256
256
  geoms = []
@@ -284,7 +284,7 @@ class STRtreeTests < Minitest::Test
284
284
  end
285
285
 
286
286
  def test_nearest_with_empty_tree
287
- skip unless ENV['FORCE_TESTS'] || defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest)
287
+ skip unless ENV['FORCE_TESTS'] || (defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest))
288
288
 
289
289
  tree = Geos::STRtree.new(10)
290
290
  geom_1 = read('POINT (3 3)')
@@ -294,7 +294,7 @@ class STRtreeTests < Minitest::Test
294
294
  end
295
295
 
296
296
  def test_nearest_with_some_empty_geometries
297
- skip unless ENV['FORCE_TESTS'] || defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest)
297
+ skip unless ENV['FORCE_TESTS'] || (defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest))
298
298
 
299
299
  geom_1 = read('LINESTRING EMPTY')
300
300
  geom_2 = read('POINT (2 7)')
@@ -312,8 +312,8 @@ class STRtreeTests < Minitest::Test
312
312
  end
313
313
 
314
314
  def test_nearest_with_only_empty_geometries
315
- skip unless ENV['FORCE_TESTS'] || defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest)
316
- skip if Geos::GEOS_VERSION > '3.9.0'
315
+ skip unless ENV['FORCE_TESTS'] || (defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest))
316
+ skip if Geos::GEOS_NICE_VERSION > '030900'
317
317
 
318
318
  geom_1 = read('LINESTRING EMPTY')
319
319
  geom_2 = read('POINT (2 7)')
@@ -327,7 +327,7 @@ class STRtreeTests < Minitest::Test
327
327
  end
328
328
 
329
329
  def test_disallowed_inserts_on_nearest
330
- skip unless ENV['FORCE_TESTS'] || defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest)
330
+ skip unless ENV['FORCE_TESTS'] || (defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest))
331
331
 
332
332
  setup_tree
333
333
 
@@ -339,7 +339,7 @@ class STRtreeTests < Minitest::Test
339
339
  end
340
340
 
341
341
  def test_nearest_item
342
- skip unless ENV['FORCE_TESTS'] || defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest_item)
342
+ skip unless ENV['FORCE_TESTS'] || (defined?(Geos::STRtree) && Geos::STRtree.method_defined?(:nearest_item))
343
343
 
344
344
  geom_1 = read('POINT (3 3)')
345
345
  geom_2 = read('POINT (2 7)')
data/test/test_helper.rb CHANGED
@@ -23,25 +23,26 @@ puts "Ruby version #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} - #{RbConfig::CONFIG['RUB
23
23
  puts "ffi version #{Gem.loaded_specs['ffi'].version}" if Gem.loaded_specs['ffi']
24
24
 
25
25
  if Geos.respond_to?(:version)
26
- puts "GEOS version #{Geos.version}"
26
+ puts "GEOS version #{Geos.version} (#{Geos::GEOS_NICE_VERSION})"
27
27
  else
28
- puts "GEOS version #{Geos::GEOS_VERSION}"
28
+ puts "GEOS version #{Geos::GEOS_VERSION} (#{Geos::GEOS_NICE_VERSION})"
29
29
  end
30
30
 
31
31
  puts "ffi-geos version #{Geos::VERSION}" if defined?(Geos::VERSION)
32
32
  puts "Using #{Geos::FFIGeos.geos_library_path}" if defined?(Geos::FFIGeos)
33
+ puts "Process #{$PID}"
33
34
 
34
35
  module TestHelper
35
36
  TOLERANCE = 0.0000000000001
36
37
 
37
- EMPTY_GEOMETRY = if Geos::GEOS_VERSION > '3.8'
38
+ EMPTY_GEOMETRY = if Geos::GEOS_NICE_VERSION >= '030800'
38
39
  'POINT EMPTY'
39
40
  else
40
41
  'GEOMETRYCOLLECTION EMPTY'
41
42
  end
42
43
 
43
44
  EMPTY_BLOCK = proc do
44
- nil
45
+ # no-op
45
46
  end
46
47
 
47
48
  def self.included(base)
@@ -81,7 +82,8 @@ module TestHelper
81
82
  geom = read(wkt)
82
83
  geom.srid = 4326
83
84
  Geos.srid_copy_policy = srid_policy
84
- geom_b = geom.send(method, *args, **options)
85
+
86
+ geom_b = geom.__safe_send__(method, *args, **options)
85
87
  assert_equal(4326, geom.srid)
86
88
  assert_equal(expected_srid, geom_b.srid)
87
89
  assert_equal(expected, write(geom_b))
@@ -115,13 +117,14 @@ module TestHelper
115
117
  def snapped_tester(method, expected, geom, *args, **options)
116
118
  geom = geom_from_geom_or_wkt(geom)
117
119
 
118
- result = geom.send(method, *args, **options)
120
+ result = geom.__safe_send__(method, *args, **options)
119
121
  assert_equal(expected, write(result.snap_to_grid(1)))
120
122
  end
121
123
 
122
124
  def simple_tester(method, expected, geom, *args, **options)
123
125
  geom = geom_from_geom_or_wkt(geom)
124
- result = geom.send(method, *args, **options)
126
+
127
+ result = geom.__safe_send__(method, *args, **options)
125
128
  result = write(result) if result.is_a?(Geos::Geometry)
126
129
 
127
130
  if expected.nil?
@@ -133,13 +136,13 @@ module TestHelper
133
136
 
134
137
  def simple_bang_tester(method, expected, wkt, *args, **options)
135
138
  geom = read(wkt)
136
- result = geom.send(method, *args, **options)
139
+ result = geom.__safe_send__(method, *args, **options)
137
140
 
138
141
  assert_equal(wkt, write(geom))
139
142
  assert_equal(expected, write(result))
140
143
 
141
144
  geom = read(wkt)
142
- geom.send("#{method}!", *args, **options)
145
+ geom.__safe_send__("#{method}!", *args, **options)
143
146
 
144
147
  assert_equal(expected, write(geom))
145
148
  end
@@ -153,7 +156,7 @@ module TestHelper
153
156
 
154
157
  def array_tester(method, expected, geom, *args, **options)
155
158
  geom = geom_from_geom_or_wkt(geom)
156
- result = geom.send(method, *args, **options)
159
+ result = geom.__safe_send__(method, *args, **options)
157
160
 
158
161
  case result
159
162
  when Geos::Geometry
@@ -171,16 +174,38 @@ module TestHelper
171
174
  writer.trim = true
172
175
 
173
176
  geom = read(wkt)
174
- geom.send("#{method}!", *args, **options).snap_to_grid!(0.1)
177
+ geom.__safe_send__("#{method}!", *args, **options).snap_to_grid!(0.1)
175
178
 
176
179
  assert_equal(expected, write(geom))
177
180
 
178
181
  geom = read(wkt)
179
- geom_2 = geom.send(method, *args, **options).snap_to_grid(0.1)
182
+ geom_2 = geom.__safe_send__(method, *args, **options).snap_to_grid(0.1)
180
183
 
181
184
  assert_equal(wkt, write(geom))
182
185
  assert_equal(expected, write(geom_2, trim: true))
183
186
  end
184
187
  end
185
188
 
189
+ class Object
190
+ if RUBY_VERSION >= '2.7'
191
+ def __safe_send__(method_name, *args, **kwargs)
192
+ send(method_name, *args, **kwargs)
193
+ end
194
+ else
195
+ def __safe_send__(method_name, *args, **kwargs)
196
+ raise NoMethodError unless respond_to?(method_name)
197
+
198
+ arity = method(method_name).arity
199
+
200
+ if arity.zero?
201
+ send(method_name)
202
+ elsif arity.negative? && !kwargs.empty?
203
+ send(method_name, *args, **kwargs)
204
+ else
205
+ send(method_name, *args)
206
+ end
207
+ end
208
+ end
209
+ end
210
+
186
211
  Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-geos
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - J Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-18 00:00:00.000000000 Z
11
+ date: 2022-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -31,9 +31,9 @@ extensions: []
31
31
  extra_rdoc_files:
32
32
  - README.rdoc
33
33
  files:
34
+ - ".github/workflows/main.yml"
34
35
  - ".gitignore"
35
36
  - ".rubocop.yml"
36
- - ".travis.yml"
37
37
  - FUNDING.yml
38
38
  - Gemfile
39
39
  - Guardfile
@@ -87,7 +87,8 @@ files:
87
87
  homepage: http://github.com/dark-panda/ffi-geos
88
88
  licenses:
89
89
  - MIT
90
- metadata: {}
90
+ metadata:
91
+ rubygems_mfa_required: 'true'
91
92
  post_install_message:
92
93
  rdoc_options: []
93
94
  require_paths:
@@ -96,14 +97,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
97
  requirements:
97
98
  - - ">="
98
99
  - !ruby/object:Gem::Version
99
- version: '0'
100
+ version: '2.5'
100
101
  required_rubygems_version: !ruby/object:Gem::Requirement
101
102
  requirements:
102
103
  - - ">="
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  requirements: []
106
- rubygems_version: 3.2.16
107
+ rubygems_version: 3.2.32
107
108
  signing_key:
108
109
  specification_version: 4
109
110
  summary: An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).
data/.travis.yml DELETED
@@ -1,32 +0,0 @@
1
- cache: bundler
2
- sudo: false
3
- language: ruby
4
- dist: trusty
5
-
6
- rvm:
7
- - '2.7'
8
- - '2.6'
9
- - '2.5'
10
- - jruby-head
11
-
12
- addons:
13
- apt:
14
- packages:
15
- - libgeos-c1
16
- sonarcloud:
17
- organization: "dark-panda"
18
- token:
19
- secure: UiS3BU1SUSbIynvaup+3w9NNa85mH3lXSa+iCQx9luhp5Nc5Zg4xedycfGylCzpr6D6vRRH3gYefafitcvjS8LbhtNd2Z4oezp2T4fRt8W387HJ3wIcRkyOwBhmQqt/SiPiQr/rkDE9VomelLe7RSkelfAQQvpka5TMzc4wKYd4=
20
-
21
- git:
22
- depth: false
23
-
24
- before_install:
25
- - gem install bundler
26
-
27
- before_script:
28
- - bundle exec rubocop --format=json > rubocop-report.json || true
29
-
30
- script:
31
- - bundle exec rake test
32
- - sonar-scanner