ffi-geos 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- 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/tools_tests.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'test_helper'
|
@@ -24,7 +23,7 @@ class ToolsTests < Minitest::Test
|
|
24
23
|
def test_bool_to_int
|
25
24
|
assert_equal(1, Geos::Tools.bool_to_int(1))
|
26
25
|
assert_equal(1, Geos::Tools.bool_to_int(true))
|
27
|
-
assert_equal(1, Geos::Tools.bool_to_int(
|
26
|
+
assert_equal(1, Geos::Tools.bool_to_int(''))
|
28
27
|
assert_equal(1, Geos::Tools.bool_to_int(0))
|
29
28
|
assert_equal(0, Geos::Tools.bool_to_int(false))
|
30
29
|
assert_equal(0, Geos::Tools.bool_to_int(nil))
|
@@ -91,4 +90,3 @@ class ToolsTests < Minitest::Test
|
|
91
90
|
assert_equal(:round, Geos::Tools.symbol_for_enum(Geos::BufferCapStyles, 1))
|
92
91
|
end
|
93
92
|
end
|
94
|
-
|
data/test/utils_tests.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'test_helper'
|
@@ -14,17 +13,17 @@ class UtilsTests < Minitest::Test
|
|
14
13
|
def test_orientation_index
|
15
14
|
skip unless ENV['FORCE_TESTS'] || (defined?(Geos::Utils) && Geos::Utils.respond_to?(:orientation_index))
|
16
15
|
|
17
|
-
assert_equal(0,
|
18
|
-
assert_equal(0,
|
19
|
-
assert_equal(0,
|
20
|
-
assert_equal(0,
|
21
|
-
assert_equal(0,
|
22
|
-
assert_equal(1,
|
23
|
-
assert_equal(1,
|
24
|
-
assert_equal(-1,
|
25
|
-
assert_equal(-1,
|
26
|
-
assert_equal(1,
|
27
|
-
assert_equal(-1,
|
16
|
+
assert_equal(0, Geos::Utils.orientation_index(0, 0, 10, 0, 5, 0))
|
17
|
+
assert_equal(0, Geos::Utils.orientation_index(0, 0, 10, 0, 10, 0))
|
18
|
+
assert_equal(0, Geos::Utils.orientation_index(0, 0, 10, 0, 0, 0))
|
19
|
+
assert_equal(0, Geos::Utils.orientation_index(0, 0, 10, 0, -5, 0))
|
20
|
+
assert_equal(0, Geos::Utils.orientation_index(0, 0, 10, 0, 20, 0))
|
21
|
+
assert_equal(1, Geos::Utils.orientation_index(0, 0, 10, 10, 5, 6))
|
22
|
+
assert_equal(1, Geos::Utils.orientation_index(0, 0, 10, 10, 5, 20))
|
23
|
+
assert_equal(-1, Geos::Utils.orientation_index(0, 0, 10, 10, 5, 3))
|
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, 1000000, 1000001))
|
26
|
+
assert_equal(-1, Geos::Utils.orientation_index(0, 0, 10, 10, 1000000, 999999))
|
28
27
|
end
|
29
28
|
|
30
29
|
def test_relate_match
|
@@ -58,7 +57,7 @@ class UtilsTests < Minitest::Test
|
|
58
57
|
end
|
59
58
|
|
60
59
|
def test_create_point_with_x_y_and_z_arguments
|
61
|
-
assert_equal('POINT Z (10 20 30)', write(Geos.create_point(10, 20, 30), :
|
60
|
+
assert_equal('POINT Z (10 20 30)', write(Geos.create_point(10, 20, 30), output_dimensions: 3))
|
62
61
|
end
|
63
62
|
|
64
63
|
def test_create_point_with_too_many_arguments
|
@@ -76,8 +75,8 @@ class UtilsTests < Minitest::Test
|
|
76
75
|
|
77
76
|
def test_create_line_string
|
78
77
|
cs = Geos::CoordinateSequence.new([
|
79
|
-
|
80
|
-
|
78
|
+
[ 10, 20, 30 ],
|
79
|
+
[ 30, 20, 10 ]
|
81
80
|
])
|
82
81
|
|
83
82
|
writer.output_dimensions = 3
|
@@ -120,7 +119,7 @@ class UtilsTests < Minitest::Test
|
|
120
119
|
def test_create_bad_line_string
|
121
120
|
cs = Geos::CoordinateSequence.new(1, 0)
|
122
121
|
assert_raises(ArgumentError) do
|
123
|
-
Geos
|
122
|
+
Geos.create_line_string(cs)
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
@@ -173,7 +172,7 @@ class UtilsTests < Minitest::Test
|
|
173
172
|
cs = Geos::CoordinateSequence.new(1, 0)
|
174
173
|
|
175
174
|
assert_raises(ArgumentError) do
|
176
|
-
Geos
|
175
|
+
Geos.create_linear_ring(cs)
|
177
176
|
end
|
178
177
|
end
|
179
178
|
|
@@ -186,9 +185,9 @@ class UtilsTests < Minitest::Test
|
|
186
185
|
[ 0, 0 ]
|
187
186
|
])
|
188
187
|
|
189
|
-
exterior_ring = Geos
|
188
|
+
exterior_ring = Geos.create_linear_ring(cs)
|
190
189
|
|
191
|
-
geom = Geos
|
190
|
+
geom = Geos.create_polygon(exterior_ring)
|
192
191
|
assert_instance_of(Geos::Polygon, geom)
|
193
192
|
assert_equal('Polygon', geom.geom_type)
|
194
193
|
assert_equal(Geos::GEOS_POLYGON, geom.type_id)
|
@@ -212,7 +211,7 @@ class UtilsTests < Minitest::Test
|
|
212
211
|
[ 2, 2 ]
|
213
212
|
)
|
214
213
|
|
215
|
-
geom = Geos
|
214
|
+
geom = Geos.create_polygon(outer, inner)
|
216
215
|
assert_instance_of(Geos::Polygon, geom)
|
217
216
|
assert_equal('Polygon', geom.geom_type)
|
218
217
|
assert_equal(Geos::GEOS_POLYGON, geom.type_id)
|
@@ -244,7 +243,7 @@ class UtilsTests < Minitest::Test
|
|
244
243
|
[ 6, 6 ]
|
245
244
|
)
|
246
245
|
|
247
|
-
geom = Geos
|
246
|
+
geom = Geos.create_polygon(exterior_ring, [ hole_1, hole_2 ])
|
248
247
|
assert_instance_of(Geos::Polygon, geom)
|
249
248
|
assert_equal('Polygon', geom.geom_type)
|
250
249
|
assert_equal(Geos::GEOS_POLYGON, geom.type_id)
|
@@ -340,6 +339,7 @@ class UtilsTests < Minitest::Test
|
|
340
339
|
assert_kind_of(Geos::MultiLineString, Geos.create_collection(:multi_line_string))
|
341
340
|
end
|
342
341
|
|
342
|
+
|
343
343
|
def test_create_bad_geometry_collection
|
344
344
|
skip unless ENV['FORCE_TESTS'] || Geos.respond_to?(:create_geometry_collection)
|
345
345
|
|
@@ -355,7 +355,7 @@ class UtilsTests < Minitest::Test
|
|
355
355
|
def test_create_geometry_collection_with_options
|
356
356
|
skip unless ENV['FORCE_TESTS'] || Geos.respond_to?(:create_geometry_collection)
|
357
357
|
|
358
|
-
geom = Geos.create_collection(:multi_line_string, :
|
358
|
+
geom = Geos.create_collection(:multi_line_string, srid: 4326)
|
359
359
|
|
360
360
|
assert_kind_of(Geos::MultiLineString, geom)
|
361
361
|
assert_equal(4326, geom.srid)
|
data/test/wkb_reader_tests.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'test_helper'
|
@@ -192,9 +191,10 @@ class WkbReaderTests < Minitest::Test
|
|
192
191
|
@wkb_reader.read("\x01\x01\x00\x00\x20\x2B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x40\x00\x00\x00\x00\x00\x00\x1C\x40").srid)
|
193
192
|
|
194
193
|
assert_equal(4326,
|
195
|
-
@wkb_reader.read(
|
196
|
-
|
197
|
-
|
194
|
+
@wkb_reader.read(
|
195
|
+
"\x01\x01\x00\x00\x20\x2B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x40\x00\x00\x00\x00\x00\x00\x1C\x40",
|
196
|
+
srid: 4326
|
197
|
+
).srid)
|
198
198
|
end
|
199
199
|
|
200
200
|
def test_read_hex_srid
|
@@ -202,20 +202,21 @@ class WkbReaderTests < Minitest::Test
|
|
202
202
|
@wkb_reader.read_hex('01010000202B00000000000000000018400000000000001C40').srid)
|
203
203
|
|
204
204
|
assert_equal(4326,
|
205
|
-
@wkb_reader.read_hex(
|
206
|
-
|
207
|
-
|
205
|
+
@wkb_reader.read_hex(
|
206
|
+
'01010000202B00000000000000000018400000000000001C40',
|
207
|
+
srid: 4326
|
208
|
+
).srid)
|
208
209
|
end
|
209
210
|
|
210
211
|
def test_read_parse_error
|
211
212
|
assert_raises(Geos::WkbReader::ParseError) do
|
212
|
-
@wkb_reader.read(
|
213
|
+
@wkb_reader.read('FOO')
|
213
214
|
end
|
214
215
|
end
|
215
216
|
|
216
217
|
def test_read_hex_parse_error
|
217
218
|
assert_raises(Geos::WkbReader::ParseError) do
|
218
|
-
@wkb_reader.read_hex(
|
219
|
+
@wkb_reader.read_hex('FOO')
|
219
220
|
end
|
220
221
|
end
|
221
222
|
end
|
data/test/wkb_writer_tests.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'test_helper'
|
@@ -121,8 +120,6 @@ class WkbWriterTests < Minitest::Test
|
|
121
120
|
)
|
122
121
|
end
|
123
122
|
|
124
|
-
|
125
|
-
|
126
123
|
def test_2d_little_endian_with_3d_input
|
127
124
|
wkb_tester(
|
128
125
|
'010100000000000000000018400000000000001C40',
|
@@ -145,8 +142,6 @@ class WkbWriterTests < Minitest::Test
|
|
145
142
|
)
|
146
143
|
end
|
147
144
|
|
148
|
-
|
149
|
-
|
150
145
|
def test_2d_big_endian_with_3d_input
|
151
146
|
wkb_tester(
|
152
147
|
'00000000014018000000000000401C000000000000',
|
@@ -314,8 +309,6 @@ class WkbWriterTests < Minitest::Test
|
|
314
309
|
)
|
315
310
|
end
|
316
311
|
|
317
|
-
|
318
|
-
|
319
312
|
def test_2d_little_endian_with_3d_input_binary
|
320
313
|
wkb_tester(
|
321
314
|
'010100000000000000000018400000000000001C40',
|
@@ -440,9 +433,8 @@ class WkbWriterTests < Minitest::Test
|
|
440
433
|
}
|
441
434
|
|
442
435
|
tester[
|
443
|
-
"\x01\x01\x00\x00\x20\xE6\x10\x00\x00\x00\x00\x00\x00\x00\x00\xF0\x3F\x00\x00\x00\x00\x00\x00\x00\x40",
|
444
|
-
|
445
|
-
}
|
436
|
+
"\x01\x01\x00\x00\x20\xE6\x10\x00\x00\x00\x00\x00\x00\x00\x00\xF0\x3F\x00\x00\x00\x00\x00\x00\x00\x40",
|
437
|
+
include_srid: true
|
446
438
|
]
|
447
439
|
|
448
440
|
tester[
|
@@ -456,9 +448,9 @@ class WkbWriterTests < Minitest::Test
|
|
456
448
|
geom = read('POINT(1 2 3)')
|
457
449
|
geom.srid = 4326
|
458
450
|
|
459
|
-
assert_equal('0101000020E6100000000000000000F03F0000000000000040', @wkb_writer.write_hex(geom,
|
460
|
-
:
|
461
|
-
|
451
|
+
assert_equal('0101000020E6100000000000000000F03F0000000000000040', @wkb_writer.write_hex(geom,
|
452
|
+
include_srid: true
|
453
|
+
))
|
462
454
|
|
463
455
|
assert_equal('0101000000000000000000F03F0000000000000040', @wkb_writer.write_hex(geom))
|
464
456
|
end
|
data/test/wkt_reader_tests.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'test_helper'
|
@@ -121,6 +120,6 @@ class WktReaderTests < Minitest::Test
|
|
121
120
|
|
122
121
|
def test_read_with_srid
|
123
122
|
assert_equal(0, read('POINT (0 0)').srid)
|
124
|
-
assert_equal(4326, read('POINT (0 0)', :
|
123
|
+
assert_equal(4326, read('POINT (0 0)', srid: 4326).srid)
|
125
124
|
end
|
126
125
|
end
|
data/test/wkt_writer_tests.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require 'test_helper'
|
@@ -11,7 +10,7 @@ class WktWriterTests < Minitest::Test
|
|
11
10
|
wkt = write(geom)
|
12
11
|
|
13
12
|
x, y = if wkt =~ /^POINT\s\((\d+\.\d+)\s*(\d+\.\d+)\)$/
|
14
|
-
[
|
13
|
+
[ Regexp.last_match[1].to_f, Regexp.last_match[2].to_f ]
|
15
14
|
end
|
16
15
|
|
17
16
|
assert_in_delta(12.3456789, x, TOLERANCE)
|
@@ -117,18 +116,14 @@ class WktWriterTests < Minitest::Test
|
|
117
116
|
@writer.rounding_precision = 2
|
118
117
|
|
119
118
|
geom = read('POINT(1 2 3)')
|
120
|
-
assert_equal('POINT (1 2)', write(geom,
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
assert_equal('POINT (1
|
125
|
-
:
|
126
|
-
|
127
|
-
|
128
|
-
assert_equal('POINT Z (1 2 3)', write(geom, {
|
129
|
-
:output_dimensions => 3,
|
130
|
-
:trim => true
|
131
|
-
}))
|
119
|
+
assert_equal('POINT (1 2)', write(geom, trim: true))
|
120
|
+
|
121
|
+
assert_equal('POINT (1.0000 2.0000)', write(geom, rounding_precision: 4))
|
122
|
+
|
123
|
+
assert_equal('POINT Z (1 2 3)', write(geom,
|
124
|
+
output_dimensions: 3,
|
125
|
+
trim: true
|
126
|
+
))
|
132
127
|
|
133
128
|
assert_equal('POINT (1.00 2.00)', write(geom))
|
134
129
|
end
|
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: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- J Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -32,6 +32,7 @@ extra_rdoc_files:
|
|
32
32
|
- README.rdoc
|
33
33
|
files:
|
34
34
|
- ".gitignore"
|
35
|
+
- ".rubocop.yml"
|
35
36
|
- ".travis.yml"
|
36
37
|
- Gemfile
|
37
38
|
- Guardfile
|
@@ -61,6 +62,7 @@ files:
|
|
61
62
|
- lib/ffi-geos/wkb_writer.rb
|
62
63
|
- lib/ffi-geos/wkt_reader.rb
|
63
64
|
- lib/ffi-geos/wkt_writer.rb
|
65
|
+
- test/.rubocop.yml
|
64
66
|
- test/coordinate_sequence_tests.rb
|
65
67
|
- test/geometry_collection_tests.rb
|
66
68
|
- test/geometry_tests.rb
|
@@ -100,11 +102,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
102
|
version: '0'
|
101
103
|
requirements: []
|
102
104
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.6
|
105
|
+
rubygems_version: 2.7.6
|
104
106
|
signing_key:
|
105
107
|
specification_version: 4
|
106
108
|
summary: An ffi wrapper for GEOS, a C++ port of the Java Topology Suite (JTS).
|
107
109
|
test_files:
|
110
|
+
- test/.rubocop.yml
|
108
111
|
- test/coordinate_sequence_tests.rb
|
109
112
|
- test/geometry_collection_tests.rb
|
110
113
|
- test/geometry_tests.rb
|