geos-extensions 1.0.0 → 2.0.0
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 +4 -4
- data/.travis.yml +17 -0
- data/MIT-LICENSE +1 -1
- data/Rakefile +2 -0
- data/lib/geos-extensions.rb +6 -0
- data/lib/geos/coordinate_sequence.rb +290 -12
- data/lib/geos/extensions/exceptions.rb +2 -0
- data/lib/geos/extensions/version.rb +3 -1
- data/lib/geos/geometry.rb +3 -1
- data/lib/geos/geometry_collection.rb +52 -0
- data/lib/geos/geos_helper.rb +2 -0
- data/lib/geos/google_maps.rb +2 -0
- data/lib/geos/google_maps/api_2.rb +2 -0
- data/lib/geos/google_maps/api_3.rb +2 -0
- data/lib/geos/google_maps/api_common.rb +2 -0
- data/lib/geos/google_maps/polyline_encoder.rb +2 -0
- data/lib/geos/line_string.rb +123 -0
- data/lib/geos/multi_line_string.rb +2 -0
- data/lib/geos/multi_point.rb +2 -0
- data/lib/geos/multi_polygon.rb +2 -0
- data/lib/geos/point.rb +59 -0
- data/lib/geos/polygon.rb +97 -0
- data/lib/geos/yaml.rb +1 -0
- data/lib/geos/yaml/psych.rb +1 -0
- data/lib/geos/yaml/syck.rb +1 -0
- data/lib/geos_extensions.rb +2 -0
- data/test/coordinate_sequence_tests.rb +256 -0
- data/test/geometry_collection_tests.rb +429 -0
- data/test/geometry_tests.rb +57 -0
- data/test/google_maps_api_2_tests.rb +2 -0
- data/test/google_maps_api_3_tests.rb +2 -0
- data/test/google_maps_api_common_tests.rb +2 -0
- data/test/google_maps_polyline_encoder_tests.rb +2 -0
- data/test/helper_tests.rb +2 -0
- data/test/line_string_tests.rb +211 -0
- data/test/misc_tests.rb +2 -0
- data/test/point_tests.rb +173 -0
- data/test/polygon_tests.rb +329 -0
- data/test/reader_tests.rb +2 -0
- data/test/test_helper.rb +73 -3
- data/test/writer_tests.rb +2 -0
- data/test/yaml_tests.rb +1 -0
- metadata +16 -3
@@ -0,0 +1,429 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__)
|
5
|
+
require 'test_helper'
|
6
|
+
|
7
|
+
class GeometryCollectionTests < Minitest::Test
|
8
|
+
include TestHelper
|
9
|
+
|
10
|
+
def test_x_max
|
11
|
+
geom = read('GEOMETRYCOLLECTION (
|
12
|
+
POLYGON ((0 0, 5 0, 8 9, -10 5, 0 0)),
|
13
|
+
LINESTRING (0 0, 5 0, 8 9, -10 5, 0 0),
|
14
|
+
POINT(3 12)
|
15
|
+
)')
|
16
|
+
|
17
|
+
assert_equal(8, geom.x_max)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_x_min
|
21
|
+
geom = read('GEOMETRYCOLLECTION (
|
22
|
+
POLYGON ((0 0, 5 0, 8 9, -10 5, 0 0)),
|
23
|
+
LINESTRING (0 0, 5 0, 8 9, -10 5, 0 0),
|
24
|
+
POINT(3 12)
|
25
|
+
)')
|
26
|
+
|
27
|
+
assert_equal(-10, geom.x_min)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_y_max
|
31
|
+
geom = read('GEOMETRYCOLLECTION (
|
32
|
+
POLYGON ((0 0, 5 0, 8 9, -10 5, 0 0)),
|
33
|
+
LINESTRING (0 0, 5 0, 8 9, -10 5, 0 0),
|
34
|
+
POINT(3 12)
|
35
|
+
)')
|
36
|
+
|
37
|
+
assert_equal(12, geom.y_max)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_y_min
|
41
|
+
geom = read('GEOMETRYCOLLECTION (
|
42
|
+
POLYGON ((0 0, 5 0, 8 9, -10 5, 0 0)),
|
43
|
+
LINESTRING (0 0, 5 0, 8 9, -10 5, 0 0),
|
44
|
+
POINT(3 12)
|
45
|
+
)')
|
46
|
+
|
47
|
+
assert_equal(0, geom.y_min)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_z_max
|
51
|
+
geom = read('GEOMETRYCOLLECTION (
|
52
|
+
POLYGON ((0 0, 5 0, 8 9, -10 5, 0 0)),
|
53
|
+
LINESTRING (0 0, 5 0, 8 9, -10 5, 0 0),
|
54
|
+
POINT(3 12)
|
55
|
+
)')
|
56
|
+
assert_equal(0, geom.z_max)
|
57
|
+
|
58
|
+
geom = read('GEOMETRYCOLLECTION Z (
|
59
|
+
POLYGON Z ((0 0 0, 5 0 3, 8 9 4, -10 5 3, 0 0 0)),
|
60
|
+
LINESTRING Z (0 0 0, 5 0 3, 8 9 4, -10 5 3, 0 0 0),
|
61
|
+
POINT Z (3 12 6)
|
62
|
+
)')
|
63
|
+
assert_equal(6, geom.z_max)
|
64
|
+
|
65
|
+
# GEOS lets you mix dimensionality, while PostGIS doesn't.
|
66
|
+
geom = read('GEOMETRYCOLLECTION (
|
67
|
+
POLYGON ((0 0, 5 0, 8 9, -10 5, 0 0)),
|
68
|
+
LINESTRING (0 0, 5 0, 8 9, -10 5, 0 0),
|
69
|
+
POINT(3 12 10)
|
70
|
+
)')
|
71
|
+
assert_equal(10, geom.z_max)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_z_min
|
75
|
+
geom = read('GEOMETRYCOLLECTION (
|
76
|
+
POLYGON ((0 0, 5 0, 8 9, -10 5, 0 0)),
|
77
|
+
LINESTRING (0 0, 5 0, 8 9, -10 5, 0 0),
|
78
|
+
POINT(3 12)
|
79
|
+
)')
|
80
|
+
assert_equal(0, geom.z_min)
|
81
|
+
|
82
|
+
geom = read('GEOMETRYCOLLECTION Z (
|
83
|
+
POLYGON Z ((0 0 0, 5 0 3, 8 9 4, -10 5 3, 0 0 0)),
|
84
|
+
LINESTRING Z (0 0 0, 5 0 3, 8 9 4, -10 5 3, 0 0 0),
|
85
|
+
POINT Z (3 12 6)
|
86
|
+
)')
|
87
|
+
assert_equal(0, geom.z_min)
|
88
|
+
|
89
|
+
# GEOS lets you mix dimensionality, while PostGIS doesn't.
|
90
|
+
geom = read('GEOMETRYCOLLECTION (
|
91
|
+
POLYGON ((0 0, 5 0, 8 9, -10 5, 0 0)),
|
92
|
+
LINESTRING (0 0, 5 0, 8 9, -10 5, 0 0),
|
93
|
+
POINT(3 12 -10)
|
94
|
+
)')
|
95
|
+
assert_equal(-10, geom.z_min)
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_snap_to_grid
|
99
|
+
writer.trim = true
|
100
|
+
|
101
|
+
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), 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))'
|
102
|
+
|
103
|
+
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))'
|
104
|
+
|
105
|
+
simple_bang_tester(:snap_to_grid, expected, wkt, 1)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_snap_to_grid_empty
|
109
|
+
writer.trim = true
|
110
|
+
|
111
|
+
assert(read('GEOMETRYCOLLECTION EMPTY').snap_to_grid!.empty?, " Expected an empty GeometryCollection")
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_snap_to_grid_with_srid
|
115
|
+
writer.trim = true
|
116
|
+
|
117
|
+
wkt = 'GEOMETRYCOLLECTION (
|
118
|
+
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),
|
119
|
+
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)),
|
120
|
+
POINT (10.12 10.12)
|
121
|
+
)'
|
122
|
+
|
123
|
+
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))'
|
124
|
+
|
125
|
+
srid_copy_tester(:snap_to_grid, expected, 0, :zero, wkt, 1)
|
126
|
+
srid_copy_tester(:snap_to_grid, expected, 4326, :lenient, wkt, 1)
|
127
|
+
srid_copy_tester(:snap_to_grid, expected, 4326, :strict, wkt, 1)
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_snap_to_grid_with_illegal_result
|
131
|
+
writer.trim = true
|
132
|
+
|
133
|
+
assert_raises(Geos::InvalidGeometryError) do
|
134
|
+
read('GEOMETRYCOLLECTION (POINT (0 2), LINESTRING (0 1, 0 11), POLYGON ((0 1, 0 1, 0 6, 0 6, 0 1)))').
|
135
|
+
snap_to_grid(1)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_rotate
|
140
|
+
writer.rounding_precision = 3
|
141
|
+
|
142
|
+
wkt = 'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))'
|
143
|
+
|
144
|
+
affine_tester(:rotate,
|
145
|
+
'GEOMETRYCOLLECTION (POINT (29 11), LINESTRING (30 10, 20 20), POLYGON ((30 10, 30 15, 25 15, 25 10, 30 10)))',
|
146
|
+
wkt,
|
147
|
+
Math::PI / 2,
|
148
|
+
[ 10.0, 20.0 ]
|
149
|
+
)
|
150
|
+
|
151
|
+
affine_tester(:rotate,
|
152
|
+
'GEOMETRYCOLLECTION (POINT (-2 0), LINESTRING (-3 1, 7 -9), POLYGON ((-3 1, -3 -4, 2 -4, 2 1, -3 1)))',
|
153
|
+
wkt,
|
154
|
+
-Math::PI / 2,
|
155
|
+
[ -1.0, 2.0 ]
|
156
|
+
)
|
157
|
+
|
158
|
+
affine_tester(:rotate,
|
159
|
+
'GEOMETRYCOLLECTION (POINT (19 1), LINESTRING (20 0, 10 10), POLYGON ((20 0, 20 5, 15 5, 15 0, 20 0)))',
|
160
|
+
wkt,
|
161
|
+
Math::PI / 2,
|
162
|
+
read('POINT(10 10)')
|
163
|
+
)
|
164
|
+
|
165
|
+
affine_tester(:rotate,
|
166
|
+
'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)))',
|
167
|
+
wkt,
|
168
|
+
Math::PI / 2,
|
169
|
+
read('LINESTRING(0 0, 1 0)')
|
170
|
+
)
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_rotate_x
|
174
|
+
writer.rounding_precision = 3
|
175
|
+
writer.output_dimensions = 3
|
176
|
+
|
177
|
+
wkt = '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)))'
|
178
|
+
|
179
|
+
affine_tester(:rotate_x,
|
180
|
+
'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)))',
|
181
|
+
wkt,
|
182
|
+
Math::PI
|
183
|
+
)
|
184
|
+
|
185
|
+
affine_tester(:rotate_x,
|
186
|
+
'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)))',
|
187
|
+
wkt,
|
188
|
+
Math::PI / 2
|
189
|
+
)
|
190
|
+
|
191
|
+
affine_tester(:rotate_x,
|
192
|
+
'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)))',
|
193
|
+
wkt,
|
194
|
+
Math::PI + Math::PI / 2
|
195
|
+
)
|
196
|
+
|
197
|
+
affine_tester(:rotate_x,
|
198
|
+
wkt,
|
199
|
+
wkt,
|
200
|
+
Math::PI * 2
|
201
|
+
)
|
202
|
+
end
|
203
|
+
|
204
|
+
def test_rotate_y
|
205
|
+
writer.rounding_precision = 6
|
206
|
+
writer.output_dimensions = 3
|
207
|
+
|
208
|
+
wkt = '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)))'
|
209
|
+
|
210
|
+
affine_tester(:rotate_y,
|
211
|
+
'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)))',
|
212
|
+
wkt,
|
213
|
+
Math::PI
|
214
|
+
)
|
215
|
+
|
216
|
+
affine_tester(:rotate_y,
|
217
|
+
'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)))',
|
218
|
+
wkt,
|
219
|
+
Math::PI / 2
|
220
|
+
)
|
221
|
+
|
222
|
+
affine_tester(:rotate_y,
|
223
|
+
'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)))',
|
224
|
+
wkt,
|
225
|
+
Math::PI + Math::PI / 2
|
226
|
+
)
|
227
|
+
|
228
|
+
affine_tester(:rotate_y,
|
229
|
+
wkt,
|
230
|
+
wkt,
|
231
|
+
Math::PI * 2
|
232
|
+
)
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_rotate_z
|
236
|
+
writer.rounding_precision = 3
|
237
|
+
|
238
|
+
wkt = 'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))'
|
239
|
+
|
240
|
+
affine_tester(:rotate_z,
|
241
|
+
'GEOMETRYCOLLECTION (POINT (-1 -1), LINESTRING (0 0, -10 -10), POLYGON ((0 0, -5 0, -5 -5, 0 -5, 0 0)))',
|
242
|
+
wkt,
|
243
|
+
Math::PI
|
244
|
+
)
|
245
|
+
|
246
|
+
affine_tester(:rotate_z,
|
247
|
+
'GEOMETRYCOLLECTION (POINT (-1 1), LINESTRING (0 0, -10 10), POLYGON ((0 0, 0 5, -5 5, -5 0, 0 0)))',
|
248
|
+
wkt,
|
249
|
+
Math::PI / 2
|
250
|
+
)
|
251
|
+
|
252
|
+
affine_tester(:rotate_z,
|
253
|
+
'GEOMETRYCOLLECTION (POINT (1 -1), LINESTRING (0 0, 10 -10), POLYGON ((0 0, 0 -5, 5 -5, 5 0, 0 0)))',
|
254
|
+
wkt,
|
255
|
+
Math::PI + Math::PI / 2
|
256
|
+
)
|
257
|
+
|
258
|
+
affine_tester(:rotate_z,
|
259
|
+
wkt,
|
260
|
+
wkt,
|
261
|
+
Math::PI * 2
|
262
|
+
)
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_scale
|
266
|
+
affine_tester(:scale,
|
267
|
+
'GEOMETRYCOLLECTION (POINT (5 5), LINESTRING (0 0, 50 50), POLYGON ((0 0, 25 0, 25 25, 0 25, 0 0)))',
|
268
|
+
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
269
|
+
5,
|
270
|
+
5
|
271
|
+
)
|
272
|
+
|
273
|
+
affine_tester(:scale,
|
274
|
+
'GEOMETRYCOLLECTION (POINT (3 2), LINESTRING (0 0, 30 20), POLYGON ((0 0, 15 0, 15 10, 0 10, 0 0)))',
|
275
|
+
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
276
|
+
3,
|
277
|
+
2
|
278
|
+
)
|
279
|
+
|
280
|
+
writer.output_dimensions = 3
|
281
|
+
affine_tester(:scale,
|
282
|
+
'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)))',
|
283
|
+
'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)))',
|
284
|
+
4,
|
285
|
+
2,
|
286
|
+
-8
|
287
|
+
)
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_scale_hash
|
291
|
+
affine_tester(:scale,
|
292
|
+
'GEOMETRYCOLLECTION (POINT (5 5), LINESTRING (0 0, 50 50), POLYGON ((0 0, 25 0, 25 25, 0 25, 0 0)))',
|
293
|
+
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
294
|
+
:x => 5,
|
295
|
+
:y => 5
|
296
|
+
)
|
297
|
+
|
298
|
+
affine_tester(:scale,
|
299
|
+
'GEOMETRYCOLLECTION (POINT (3 2), LINESTRING (0 0, 30 20), POLYGON ((0 0, 15 0, 15 10, 0 10, 0 0)))',
|
300
|
+
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
301
|
+
:x => 3,
|
302
|
+
:y => 2
|
303
|
+
)
|
304
|
+
|
305
|
+
writer.output_dimensions = 3
|
306
|
+
affine_tester(:scale,
|
307
|
+
'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)))',
|
308
|
+
'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)))',
|
309
|
+
:x => 4,
|
310
|
+
:y => 2,
|
311
|
+
:z => -8
|
312
|
+
)
|
313
|
+
end
|
314
|
+
|
315
|
+
def test_trans_scale
|
316
|
+
affine_tester(:trans_scale,
|
317
|
+
'GEOMETRYCOLLECTION (POINT (3 3), LINESTRING (2 2, 12 12), POLYGON ((2 2, 7 2, 7 7, 2 7, 2 2)))',
|
318
|
+
'GEOMETRYCOLLECTION (POINT (2 2), LINESTRING (1 1, 11 11), POLYGON ((1 1, 6 1, 6 6, 1 6, 1 1)))',
|
319
|
+
1, 1, 1, 1)
|
320
|
+
|
321
|
+
wkt = 'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))'
|
322
|
+
|
323
|
+
affine_tester(:trans_scale,
|
324
|
+
'GEOMETRYCOLLECTION (POINT (2 2), LINESTRING (1 1, 11 11), POLYGON ((1 1, 6 1, 6 6, 1 6, 1 1)))',
|
325
|
+
wkt,
|
326
|
+
1, 1, 1, 1)
|
327
|
+
|
328
|
+
affine_tester(:trans_scale,
|
329
|
+
'GEOMETRYCOLLECTION (POINT (0 0), LINESTRING (1 1, -9 -9), POLYGON ((1 1, -4 1, -4 -4, 1 -4, 1 1)))',
|
330
|
+
wkt,
|
331
|
+
-1, -1, -1, -1)
|
332
|
+
|
333
|
+
affine_tester(:trans_scale,
|
334
|
+
'GEOMETRYCOLLECTION (POINT (1 2), LINESTRING (0 1, 10 11), POLYGON ((0 1, 5 1, 5 6, 0 6, 0 1)))',
|
335
|
+
wkt,
|
336
|
+
0, 1, 1, 1)
|
337
|
+
|
338
|
+
affine_tester(:trans_scale,
|
339
|
+
'GEOMETRYCOLLECTION (POINT (2 1), LINESTRING (1 0, 11 10), POLYGON ((1 0, 6 0, 6 5, 1 5, 1 0)))',
|
340
|
+
wkt,
|
341
|
+
1, 0, 1, 1)
|
342
|
+
|
343
|
+
affine_tester(:trans_scale,
|
344
|
+
'GEOMETRYCOLLECTION (POINT (3 2), LINESTRING (2 1, 12 11), POLYGON ((2 1, 7 1, 7 6, 2 6, 2 1)))',
|
345
|
+
wkt,
|
346
|
+
2, 1, 1, 1)
|
347
|
+
|
348
|
+
affine_tester(:trans_scale,
|
349
|
+
'GEOMETRYCOLLECTION (POINT (2 3), LINESTRING (1 2, 11 12), POLYGON ((1 2, 6 2, 6 7, 1 7, 1 2)))',
|
350
|
+
wkt,
|
351
|
+
1, 2, 1, 1)
|
352
|
+
|
353
|
+
affine_tester(:trans_scale,
|
354
|
+
'GEOMETRYCOLLECTION (POINT (4 2), LINESTRING (2 1, 22 11), POLYGON ((2 1, 12 1, 12 6, 2 6, 2 1)))',
|
355
|
+
wkt,
|
356
|
+
1, 1, 2, 1)
|
357
|
+
|
358
|
+
affine_tester(:trans_scale,
|
359
|
+
'GEOMETRYCOLLECTION (POINT (2 4), LINESTRING (1 2, 11 22), POLYGON ((1 2, 6 2, 6 12, 1 12, 1 2)))',
|
360
|
+
wkt,
|
361
|
+
1, 1, 1, 2)
|
362
|
+
|
363
|
+
affine_tester(:trans_scale,
|
364
|
+
'GEOMETRYCOLLECTION (POINT (15 28), LINESTRING (10 21, 60 91), POLYGON ((10 21, 35 21, 35 56, 10 56, 10 21)))',
|
365
|
+
wkt,
|
366
|
+
2, 3, 5, 7)
|
367
|
+
|
368
|
+
writer.output_dimensions = 3
|
369
|
+
affine_tester(:trans_scale,
|
370
|
+
'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)))',
|
371
|
+
'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)))',
|
372
|
+
2, 3, 5, 7)
|
373
|
+
end
|
374
|
+
|
375
|
+
def test_trans_scale_hash
|
376
|
+
affine_tester(:trans_scale,
|
377
|
+
'GEOMETRYCOLLECTION (POINT (2 2), LINESTRING (1 1, 11 11), POLYGON ((1 1, 6 1, 6 6, 1 6, 1 1)))',
|
378
|
+
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
379
|
+
:delta_x => 1, :delta_y => 1, :x_factor => 1, :y_factor => 1)
|
380
|
+
|
381
|
+
writer.output_dimensions = 3
|
382
|
+
affine_tester(:trans_scale,
|
383
|
+
'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)))',
|
384
|
+
'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)))',
|
385
|
+
:delta_x => 2, :delta_y => 3, :x_factor => 5, :y_factor => 7)
|
386
|
+
|
387
|
+
affine_tester(:trans_scale,
|
388
|
+
'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)))',
|
389
|
+
'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)))',
|
390
|
+
:delta_x => 2, :z_factor => 2)
|
391
|
+
end
|
392
|
+
|
393
|
+
|
394
|
+
def test_translate
|
395
|
+
affine_tester(:translate,
|
396
|
+
'GEOMETRYCOLLECTION (POINT (6 13), LINESTRING (5 12, 15 22), POLYGON ((5 12, 10 12, 10 17, 5 17, 5 12)))',
|
397
|
+
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
398
|
+
5,
|
399
|
+
12
|
400
|
+
)
|
401
|
+
|
402
|
+
writer.output_dimensions = 3
|
403
|
+
affine_tester(:translate,
|
404
|
+
'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)))',
|
405
|
+
'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)))',
|
406
|
+
-3,
|
407
|
+
-7,
|
408
|
+
3
|
409
|
+
)
|
410
|
+
end
|
411
|
+
|
412
|
+
def test_translate_hash
|
413
|
+
affine_tester(:translate,
|
414
|
+
'GEOMETRYCOLLECTION (POINT (6 13), LINESTRING (5 12, 15 22), POLYGON ((5 12, 10 12, 10 17, 5 17, 5 12)))',
|
415
|
+
'GEOMETRYCOLLECTION (POINT (1 1), LINESTRING (0 0, 10 10), POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0)))',
|
416
|
+
:x => 5,
|
417
|
+
:y => 12
|
418
|
+
)
|
419
|
+
|
420
|
+
writer.output_dimensions = 3
|
421
|
+
affine_tester(:translate,
|
422
|
+
'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)))',
|
423
|
+
'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)))',
|
424
|
+
:x => -3,
|
425
|
+
:y => -7,
|
426
|
+
:z => 3
|
427
|
+
)
|
428
|
+
end
|
429
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__)
|
5
|
+
require 'test_helper'
|
6
|
+
|
7
|
+
class GeometryTests < Minitest::Test
|
8
|
+
include TestHelper
|
9
|
+
|
10
|
+
def test_dump_points
|
11
|
+
geom = Geos.read('GEOMETRYCOLLECTION(
|
12
|
+
MULTILINESTRING((0 0, 10 10, 20 20), (100 100, 200 200, 300 300)),
|
13
|
+
|
14
|
+
POINT(10 10),
|
15
|
+
|
16
|
+
POLYGON((0 0, 5 0, 5 5, 0 5, 0 0), (1 1, 4 1, 4 4, 1 4, 1 1))
|
17
|
+
)')
|
18
|
+
|
19
|
+
assert_equal([
|
20
|
+
[
|
21
|
+
[
|
22
|
+
Geos.create_point(0, 0),
|
23
|
+
Geos.create_point(10, 10),
|
24
|
+
Geos.create_point(20, 20)
|
25
|
+
],
|
26
|
+
|
27
|
+
[
|
28
|
+
Geos.create_point(100, 100),
|
29
|
+
Geos.create_point(200, 200),
|
30
|
+
Geos.create_point(300, 300)
|
31
|
+
]
|
32
|
+
],
|
33
|
+
|
34
|
+
[
|
35
|
+
Geos.create_point(10, 10)
|
36
|
+
],
|
37
|
+
|
38
|
+
[
|
39
|
+
[
|
40
|
+
Geos.create_point(0, 0),
|
41
|
+
Geos.create_point(5, 0),
|
42
|
+
Geos.create_point(5, 5),
|
43
|
+
Geos.create_point(0, 5),
|
44
|
+
Geos.create_point(0, 0)
|
45
|
+
],
|
46
|
+
|
47
|
+
[
|
48
|
+
Geos.create_point(1, 1),
|
49
|
+
Geos.create_point(4, 1),
|
50
|
+
Geos.create_point(4, 4),
|
51
|
+
Geos.create_point(1, 4),
|
52
|
+
Geos.create_point(1, 1)
|
53
|
+
]
|
54
|
+
]
|
55
|
+
], geom.dump_points)
|
56
|
+
end
|
57
|
+
end
|