ffi-geos 1.2.2 → 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 +5117 -4
- data/FUNDING.yml +2 -0
- data/Gemfile +9 -16
- data/Guardfile +3 -4
- data/MIT-LICENSE +1 -1
- data/README.rdoc +2 -20
- data/Rakefile +3 -2
- data/ffi-geos.gemspec +7 -2
- data/lib/ffi-geos/buffer_params.rb +1 -1
- data/lib/ffi-geos/coordinate_sequence.rb +179 -177
- data/lib/ffi-geos/geometry.rb +118 -31
- data/lib/ffi-geos/geometry_collection.rb +26 -12
- data/lib/ffi-geos/interrupt.rb +11 -14
- data/lib/ffi-geos/line_string.rb +64 -49
- data/lib/ffi-geos/multi_line_string.rb +1 -1
- data/lib/ffi-geos/point.rb +18 -18
- data/lib/ffi-geos/polygon.rb +44 -30
- data/lib/ffi-geos/prepared_geometry.rb +1 -1
- data/lib/ffi-geos/strtree.rb +28 -30
- data/lib/ffi-geos/tools.rb +1 -1
- data/lib/ffi-geos/utils.rb +16 -23
- data/lib/ffi-geos/version.rb +1 -1
- data/lib/ffi-geos/wkb_reader.rb +1 -1
- data/lib/ffi-geos/wkb_writer.rb +4 -5
- data/lib/ffi-geos/wkt_reader.rb +1 -1
- data/lib/ffi-geos/wkt_writer.rb +7 -13
- data/lib/ffi-geos.rb +134 -48
- data/sonar-project.properties +16 -0
- data/test/coordinate_sequence_tests.rb +148 -126
- data/test/geometry_collection_tests.rb +41 -67
- data/test/geometry_tests.rb +341 -40
- data/test/interrupt_tests.rb +7 -7
- data/test/line_string_tests.rb +23 -15
- data/test/point_tests.rb +5 -5
- data/test/polygon_tests.rb +6 -7
- data/test/prepared_geometry_tests.rb +8 -8
- data/test/strtree_tests.rb +13 -12
- data/test/test_helper.rb +74 -56
- 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 +12 -10
- data/.travis.yml +0 -21
@@ -16,7 +16,7 @@ class GeometryCollectionTests < Minitest::Test
|
|
16
16
|
geom = read('GEOMETRYCOLLECTION(POINT(0 0))')
|
17
17
|
assert_kind_of(Enumerable, geom.each)
|
18
18
|
assert_kind_of(Enumerable, geom.to_enum)
|
19
|
-
assert_equal(geom, geom.each
|
19
|
+
assert_equal(geom, geom.each(&EMPTY_BLOCK))
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_geometry_collection_array
|
@@ -173,7 +173,8 @@ class GeometryCollectionTests < Minitest::Test
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def test_snap_to_grid
|
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),
|
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
|
+
'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))'
|
177
178
|
|
178
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))'
|
179
180
|
|
@@ -200,8 +201,8 @@ class GeometryCollectionTests < Minitest::Test
|
|
200
201
|
|
201
202
|
def test_snap_to_grid_with_illegal_result
|
202
203
|
assert_raises(Geos::InvalidGeometryError) do
|
203
|
-
read('GEOMETRYCOLLECTION (POINT (0 2), LINESTRING (0 1, 0 11), POLYGON ((0 1, 0 1, 0 6, 0 6, 0 1)))')
|
204
|
-
snap_to_grid(1)
|
204
|
+
read('GEOMETRYCOLLECTION (POINT (0 2), LINESTRING (0 1, 0 11), POLYGON ((0 1, 0 1, 0 6, 0 6, 0 1)))')
|
205
|
+
.snap_to_grid(1)
|
205
206
|
end
|
206
207
|
end
|
207
208
|
|
@@ -214,29 +215,25 @@ class GeometryCollectionTests < Minitest::Test
|
|
214
215
|
'GEOMETRYCOLLECTION (POINT (29 11), LINESTRING (30 10, 20 20), POLYGON ((30 10, 30 15, 25 15, 25 10, 30 10)))',
|
215
216
|
wkt,
|
216
217
|
Math::PI / 2,
|
217
|
-
[
|
218
|
-
)
|
218
|
+
[10.0, 20.0])
|
219
219
|
|
220
220
|
affine_tester(:rotate,
|
221
221
|
'GEOMETRYCOLLECTION (POINT (-2 0), LINESTRING (-3 1, 7 -9), POLYGON ((-3 1, -3 -4, 2 -4, 2 1, -3 1)))',
|
222
222
|
wkt,
|
223
223
|
-Math::PI / 2,
|
224
|
-
[
|
225
|
-
)
|
224
|
+
[-1.0, 2.0])
|
226
225
|
|
227
226
|
affine_tester(:rotate,
|
228
227
|
'GEOMETRYCOLLECTION (POINT (19 1), LINESTRING (20 0, 10 10), POLYGON ((20 0, 20 5, 15 5, 15 0, 20 0)))',
|
229
228
|
wkt,
|
230
229
|
Math::PI / 2,
|
231
|
-
read('POINT(10 10)')
|
232
|
-
)
|
230
|
+
read('POINT(10 10)'))
|
233
231
|
|
234
232
|
affine_tester(:rotate,
|
235
233
|
'GEOMETRYCOLLECTION (POINT (-0.5 0.5), LINESTRING (0.5 -0.5, -9.5 9.5), POLYGON ((0.5 -0.5, 0.5 4.5, -4.5 4.5, -4.5 -0.5, 0.5 -0.5)))',
|
236
234
|
wkt,
|
237
235
|
Math::PI / 2,
|
238
|
-
read('LINESTRING(0 0, 1 0)')
|
239
|
-
)
|
236
|
+
read('LINESTRING(0 0, 1 0)'))
|
240
237
|
end
|
241
238
|
|
242
239
|
def test_rotate_x
|
@@ -248,26 +245,22 @@ class GeometryCollectionTests < Minitest::Test
|
|
248
245
|
affine_tester(:rotate_x,
|
249
246
|
'GEOMETRYCOLLECTION Z (POINT Z (1 -1 -1), LINESTRING Z (1 -1 -1, 10 -10 -10), POLYGON Z ((0 0 0, 5 0 0, 5 -5 0, 0 -5 0, 0 0 0)))',
|
250
247
|
wkt,
|
251
|
-
Math::PI
|
252
|
-
)
|
248
|
+
Math::PI)
|
253
249
|
|
254
250
|
affine_tester(:rotate_x,
|
255
251
|
'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)))',
|
256
252
|
wkt,
|
257
|
-
Math::PI / 2
|
258
|
-
)
|
253
|
+
Math::PI / 2)
|
259
254
|
|
260
255
|
affine_tester(:rotate_x,
|
261
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)))',
|
262
257
|
wkt,
|
263
|
-
Math::PI + Math::PI / 2
|
264
|
-
)
|
258
|
+
Math::PI + (Math::PI / 2))
|
265
259
|
|
266
260
|
affine_tester(:rotate_x,
|
267
261
|
wkt,
|
268
262
|
wkt,
|
269
|
-
Math::PI * 2
|
270
|
-
)
|
263
|
+
Math::PI * 2)
|
271
264
|
end
|
272
265
|
|
273
266
|
def test_rotate_y
|
@@ -279,26 +272,22 @@ class GeometryCollectionTests < Minitest::Test
|
|
279
272
|
affine_tester(:rotate_y,
|
280
273
|
'GEOMETRYCOLLECTION Z (POINT Z (-1 1 -1), LINESTRING Z (-1 1 -1, -10 10 -10), POLYGON Z ((0 0 0, -5 0 0, -5 5 0, 0 5 0, 0 0 0)))',
|
281
274
|
wkt,
|
282
|
-
Math::PI
|
283
|
-
)
|
275
|
+
Math::PI)
|
284
276
|
|
285
277
|
affine_tester(:rotate_y,
|
286
278
|
'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)))',
|
287
279
|
wkt,
|
288
|
-
Math::PI / 2
|
289
|
-
)
|
280
|
+
Math::PI / 2)
|
290
281
|
|
291
282
|
affine_tester(:rotate_y,
|
292
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)))',
|
293
284
|
wkt,
|
294
|
-
Math::PI + Math::PI / 2
|
295
|
-
)
|
285
|
+
Math::PI + (Math::PI / 2))
|
296
286
|
|
297
287
|
affine_tester(:rotate_y,
|
298
288
|
wkt,
|
299
289
|
wkt,
|
300
|
-
Math::PI * 2
|
301
|
-
)
|
290
|
+
Math::PI * 2)
|
302
291
|
end
|
303
292
|
|
304
293
|
def test_rotate_z
|
@@ -309,26 +298,22 @@ class GeometryCollectionTests < Minitest::Test
|
|
309
298
|
affine_tester(:rotate_z,
|
310
299
|
'GEOMETRYCOLLECTION (POINT (-1 -1), LINESTRING (0 0, -10 -10), POLYGON ((0 0, -5 0, -5 -5, 0 -5, 0 0)))',
|
311
300
|
wkt,
|
312
|
-
Math::PI
|
313
|
-
)
|
301
|
+
Math::PI)
|
314
302
|
|
315
303
|
affine_tester(:rotate_z,
|
316
304
|
'GEOMETRYCOLLECTION (POINT (-1 1), LINESTRING (0 0, -10 10), POLYGON ((0 0, 0 5, -5 5, -5 0, 0 0)))',
|
317
305
|
wkt,
|
318
|
-
Math::PI / 2
|
319
|
-
)
|
306
|
+
Math::PI / 2)
|
320
307
|
|
321
308
|
affine_tester(:rotate_z,
|
322
309
|
'GEOMETRYCOLLECTION (POINT (1 -1), LINESTRING (0 0, 10 -10), POLYGON ((0 0, 0 -5, 5 -5, 5 0, 0 0)))',
|
323
310
|
wkt,
|
324
|
-
Math::PI + Math::PI / 2
|
325
|
-
)
|
311
|
+
Math::PI + (Math::PI / 2))
|
326
312
|
|
327
313
|
affine_tester(:rotate_z,
|
328
314
|
wkt,
|
329
315
|
wkt,
|
330
|
-
Math::PI * 2
|
331
|
-
)
|
316
|
+
Math::PI * 2)
|
332
317
|
end
|
333
318
|
|
334
319
|
def test_scale
|
@@ -336,15 +321,13 @@ class GeometryCollectionTests < Minitest::Test
|
|
336
321
|
'GEOMETRYCOLLECTION (POINT (5 5), LINESTRING (0 0, 50 50), POLYGON ((0 0, 25 0, 25 25, 0 25, 0 0)))',
|
337
322
|
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
338
323
|
5,
|
339
|
-
5
|
340
|
-
)
|
324
|
+
5)
|
341
325
|
|
342
326
|
affine_tester(:scale,
|
343
327
|
'GEOMETRYCOLLECTION (POINT (3 2), LINESTRING (0 0, 30 20), POLYGON ((0 0, 15 0, 15 10, 0 10, 0 0)))',
|
344
328
|
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
345
329
|
3,
|
346
|
-
2
|
347
|
-
)
|
330
|
+
2)
|
348
331
|
|
349
332
|
writer.output_dimensions = 3
|
350
333
|
affine_tester(:scale,
|
@@ -352,33 +335,29 @@ class GeometryCollectionTests < Minitest::Test
|
|
352
335
|
'GEOMETRYCOLLECTION Z (POINT Z (1 1 1), LINESTRING Z (1 1 1, 10 10 10), POLYGON Z ((0 0 0, 5 0 0, 5 5 0, 0 5 0, 0 0 0)))',
|
353
336
|
4,
|
354
337
|
2,
|
355
|
-
-8
|
356
|
-
)
|
338
|
+
-8)
|
357
339
|
end
|
358
340
|
|
359
341
|
def test_scale_hash
|
360
342
|
affine_tester(:scale,
|
361
343
|
'GEOMETRYCOLLECTION (POINT (5 5), LINESTRING (0 0, 50 50), POLYGON ((0 0, 25 0, 25 25, 0 25, 0 0)))',
|
362
344
|
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
363
|
-
:
|
364
|
-
:
|
365
|
-
)
|
345
|
+
x: 5,
|
346
|
+
y: 5)
|
366
347
|
|
367
348
|
affine_tester(:scale,
|
368
349
|
'GEOMETRYCOLLECTION (POINT (3 2), LINESTRING (0 0, 30 20), POLYGON ((0 0, 15 0, 15 10, 0 10, 0 0)))',
|
369
350
|
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
370
|
-
:
|
371
|
-
:
|
372
|
-
)
|
351
|
+
x: 3,
|
352
|
+
y: 2)
|
373
353
|
|
374
354
|
writer.output_dimensions = 3
|
375
355
|
affine_tester(:scale,
|
376
356
|
'GEOMETRYCOLLECTION Z (POINT Z (4 2 -8), LINESTRING Z (4 2 -8, 40 20 -80), POLYGON Z ((0 0 0, 20 0 0, 20 10 0, 0 10 0, 0 0 0)))',
|
377
357
|
'GEOMETRYCOLLECTION Z (POINT Z (1 1 1), LINESTRING Z (1 1 1, 10 10 10), POLYGON Z ((0 0 0, 5 0 0, 5 5 0, 0 5 0, 0 0 0)))',
|
378
|
-
:
|
379
|
-
:
|
380
|
-
:
|
381
|
-
)
|
358
|
+
x: 4,
|
359
|
+
y: 2,
|
360
|
+
z: -8)
|
382
361
|
end
|
383
362
|
|
384
363
|
def test_trans_scale
|
@@ -445,28 +424,26 @@ class GeometryCollectionTests < Minitest::Test
|
|
445
424
|
affine_tester(:trans_scale,
|
446
425
|
'GEOMETRYCOLLECTION (POINT (2 2), LINESTRING (1 1, 11 11), POLYGON ((1 1, 6 1, 6 6, 1 6, 1 1)))',
|
447
426
|
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
448
|
-
:
|
427
|
+
delta_x: 1, delta_y: 1, x_factor: 1, y_factor: 1)
|
449
428
|
|
450
429
|
writer.output_dimensions = 3
|
451
430
|
affine_tester(:trans_scale,
|
452
431
|
'GEOMETRYCOLLECTION Z (POINT Z (15 28 1), LINESTRING Z (15 28 1, 60 91 10), POLYGON Z ((10 21 0, 35 21 0, 35 56 0, 10 56 0, 10 21 0)))',
|
453
432
|
'GEOMETRYCOLLECTION Z (POINT Z (1 1 1), LINESTRING Z (1 1 1, 10 10 10), POLYGON Z ((0 0 0, 5 0 0, 5 5 0, 0 5 0, 0 0 0)))',
|
454
|
-
:
|
433
|
+
delta_x: 2, delta_y: 3, x_factor: 5, y_factor: 7)
|
455
434
|
|
456
435
|
affine_tester(:trans_scale,
|
457
436
|
'GEOMETRYCOLLECTION Z (POINT Z (3 1 1), LINESTRING Z (3 1 1, 12 10 10), POLYGON Z ((2 0 0, 7 0 0, 7 5 0, 2 5 0, 2 0 0)))',
|
458
437
|
'GEOMETRYCOLLECTION Z (POINT Z (1 1 1), LINESTRING Z (1 1 1, 10 10 10), POLYGON Z ((0 0 0, 5 0 0, 5 5 0, 0 5 0, 0 0 0)))',
|
459
|
-
:
|
438
|
+
delta_x: 2, z_factor: 2)
|
460
439
|
end
|
461
440
|
|
462
|
-
|
463
441
|
def test_translate
|
464
442
|
affine_tester(:translate,
|
465
443
|
'GEOMETRYCOLLECTION (POINT (6 13), LINESTRING (5 12, 15 22), POLYGON ((5 12, 10 12, 10 17, 5 17, 5 12)))',
|
466
444
|
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
467
445
|
5,
|
468
|
-
12
|
469
|
-
)
|
446
|
+
12)
|
470
447
|
|
471
448
|
writer.output_dimensions = 3
|
472
449
|
affine_tester(:translate,
|
@@ -474,25 +451,22 @@ class GeometryCollectionTests < Minitest::Test
|
|
474
451
|
'GEOMETRYCOLLECTION Z (POINT Z (1 1 1), LINESTRING Z (1 1 1, 10 10 10), POLYGON Z ((0 0 0, 5 0 0, 5 5 0, 0 5 0, 0 0 0)))',
|
475
452
|
-3,
|
476
453
|
-7,
|
477
|
-
3
|
478
|
-
)
|
454
|
+
3)
|
479
455
|
end
|
480
456
|
|
481
457
|
def test_translate_hash
|
482
458
|
affine_tester(:translate,
|
483
459
|
'GEOMETRYCOLLECTION (POINT (6 13), LINESTRING (5 12, 15 22), POLYGON ((5 12, 10 12, 10 17, 5 17, 5 12)))',
|
484
460
|
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
485
|
-
:
|
486
|
-
:
|
487
|
-
)
|
461
|
+
x: 5,
|
462
|
+
y: 12)
|
488
463
|
|
489
464
|
writer.output_dimensions = 3
|
490
465
|
affine_tester(:translate,
|
491
466
|
'GEOMETRYCOLLECTION Z (POINT Z (-2 -6 4), LINESTRING Z (-2 -6 4, 7 3 13), POLYGON Z ((-3 -7 3, 2 -7 3, 2 -2 3, -3 -2 3, -3 -7 3)))',
|
492
467
|
'GEOMETRYCOLLECTION Z (POINT Z (1 1 1), LINESTRING Z (1 1 1, 10 10 10), POLYGON Z ((0 0 0, 5 0 0, 5 5 0, 0 5 0, 0 0 0)))',
|
493
|
-
:
|
494
|
-
:
|
495
|
-
:
|
496
|
-
)
|
468
|
+
x: -3,
|
469
|
+
y: -7,
|
470
|
+
z: 3)
|
497
471
|
end
|
498
472
|
end
|