rgeo 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/ext/geos_c_impl/extconf.rb +1 -0
  3. data/ext/geos_c_impl/factory.c +10 -1
  4. data/ext/geos_c_impl/geometry.c +25 -3
  5. data/ext/geos_c_impl/line_string.c +1 -12
  6. data/ext/geos_c_impl/polygon.c +0 -3
  7. data/ext/geos_c_impl/preface.h +3 -0
  8. data/lib/rgeo.rb +0 -1
  9. data/lib/rgeo/feature/geometry.rb +17 -0
  10. data/lib/rgeo/feature/types.rb +4 -4
  11. data/lib/rgeo/geographic/projected_feature_methods.rb +1 -22
  12. data/lib/rgeo/geos/ffi_feature_methods.rb +5 -0
  13. data/lib/rgeo/geos/utils.rb +2 -0
  14. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +1 -0
  15. data/lib/rgeo/version.rb +1 -1
  16. metadata +11 -171
  17. data/lib/rgeo/yaml.rb +0 -23
  18. data/test/cartesian_analysis_test.rb +0 -65
  19. data/test/cartesian_bbox_test.rb +0 -123
  20. data/test/common/factory_tests.rb +0 -78
  21. data/test/common/geometry_collection_tests.rb +0 -237
  22. data/test/common/line_string_tests.rb +0 -330
  23. data/test/common/multi_line_string_tests.rb +0 -182
  24. data/test/common/multi_point_tests.rb +0 -200
  25. data/test/common/multi_polygon_tests.rb +0 -191
  26. data/test/common/point_tests.rb +0 -370
  27. data/test/common/polygon_tests.rb +0 -228
  28. data/test/coord_sys/ogc_cs_test.rb +0 -342
  29. data/test/coord_sys/proj4_srs_data_test.rb +0 -41
  30. data/test/coord_sys/proj4_test.rb +0 -150
  31. data/test/coord_sys/sr_org_test.rb +0 -32
  32. data/test/coord_sys/url_reader_test.rb +0 -42
  33. data/test/geos_capi/factory_test.rb +0 -31
  34. data/test/geos_capi/geometry_collection_test.rb +0 -24
  35. data/test/geos_capi/line_string_test.rb +0 -24
  36. data/test/geos_capi/misc_test.rb +0 -116
  37. data/test/geos_capi/multi_line_string_test.rb +0 -24
  38. data/test/geos_capi/multi_point_test.rb +0 -24
  39. data/test/geos_capi/multi_polygon_test.rb +0 -39
  40. data/test/geos_capi/parsing_unparsing_test.rb +0 -40
  41. data/test/geos_capi/point_test.rb +0 -72
  42. data/test/geos_capi/polygon_test.rb +0 -154
  43. data/test/geos_capi/zmfactory_test.rb +0 -57
  44. data/test/geos_ffi/factory_test.rb +0 -31
  45. data/test/geos_ffi/geometry_collection_test.rb +0 -24
  46. data/test/geos_ffi/line_string_test.rb +0 -24
  47. data/test/geos_ffi/misc_test.rb +0 -63
  48. data/test/geos_ffi/multi_line_string_test.rb +0 -24
  49. data/test/geos_ffi/multi_point_test.rb +0 -24
  50. data/test/geos_ffi/multi_polygon_test.rb +0 -33
  51. data/test/geos_ffi/parsing_unparsing_test.rb +0 -41
  52. data/test/geos_ffi/point_test.rb +0 -77
  53. data/test/geos_ffi/polygon_test.rb +0 -46
  54. data/test/geos_ffi/zmfactory_test.rb +0 -58
  55. data/test/mixins_test.rb +0 -141
  56. data/test/oneoff_test.rb +0 -26
  57. data/test/projected_geographic/factory_test.rb +0 -25
  58. data/test/projected_geographic/geometry_collection_test.rb +0 -24
  59. data/test/projected_geographic/line_string_test.rb +0 -24
  60. data/test/projected_geographic/multi_line_string_test.rb +0 -26
  61. data/test/projected_geographic/multi_point_test.rb +0 -30
  62. data/test/projected_geographic/multi_polygon_test.rb +0 -25
  63. data/test/projected_geographic/point_test.rb +0 -51
  64. data/test/projected_geographic/polygon_test.rb +0 -24
  65. data/test/simple_cartesian/calculations_test.rb +0 -99
  66. data/test/simple_cartesian/factory_test.rb +0 -27
  67. data/test/simple_cartesian/geometry_collection_test.rb +0 -30
  68. data/test/simple_cartesian/line_string_test.rb +0 -31
  69. data/test/simple_cartesian/multi_line_string_test.rb +0 -28
  70. data/test/simple_cartesian/multi_point_test.rb +0 -31
  71. data/test/simple_cartesian/multi_polygon_test.rb +0 -31
  72. data/test/simple_cartesian/point_test.rb +0 -50
  73. data/test/simple_cartesian/polygon_test.rb +0 -28
  74. data/test/simple_mercator/factory_test.rb +0 -25
  75. data/test/simple_mercator/geometry_collection_test.rb +0 -24
  76. data/test/simple_mercator/line_string_test.rb +0 -24
  77. data/test/simple_mercator/multi_line_string_test.rb +0 -26
  78. data/test/simple_mercator/multi_point_test.rb +0 -29
  79. data/test/simple_mercator/multi_polygon_test.rb +0 -25
  80. data/test/simple_mercator/point_test.rb +0 -55
  81. data/test/simple_mercator/polygon_test.rb +0 -24
  82. data/test/simple_mercator/window_test.rb +0 -173
  83. data/test/spherical_geographic/calculations_test.rb +0 -167
  84. data/test/spherical_geographic/factory_test.rb +0 -27
  85. data/test/spherical_geographic/geometry_collection_test.rb +0 -31
  86. data/test/spherical_geographic/line_string_test.rb +0 -31
  87. data/test/spherical_geographic/multi_line_string_test.rb +0 -29
  88. data/test/spherical_geographic/multi_point_test.rb +0 -31
  89. data/test/spherical_geographic/multi_polygon_test.rb +0 -31
  90. data/test/spherical_geographic/point_test.rb +0 -78
  91. data/test/spherical_geographic/polygon_test.rb +0 -28
  92. data/test/types_test.rb +0 -42
  93. data/test/wkrep/wkb_generator_test.rb +0 -185
  94. data/test/wkrep/wkb_parser_test.rb +0 -293
  95. data/test/wkrep/wkt_generator_test.rb +0 -294
  96. data/test/wkrep/wkt_parser_test.rb +0 -412
@@ -1,330 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # Common tests for line string implementations
4
- #
5
- # -----------------------------------------------------------------------------
6
-
7
- require "rgeo"
8
-
9
- module RGeo
10
- module Tests # :nodoc:
11
- module Common # :nodoc:
12
- module LineStringTests # :nodoc:
13
- def test_creation_points2
14
- point1_ = @factory.point(0, 0)
15
- point2_ = @factory.point(0, 1)
16
- line1_ = @factory.line_string([point1_, point2_])
17
- assert_not_nil(line1_)
18
- assert_equal(::RGeo::Feature::LineString, line1_.geometry_type)
19
- assert_equal(2, line1_.num_points)
20
- assert_equal(point1_, line1_.point_n(0))
21
- assert_equal(point2_, line1_.point_n(1))
22
- assert_nil(line1_.point_n(-1))
23
- assert_nil(line1_.point_n(2))
24
- assert_equal(point1_, line1_.start_point)
25
- assert_equal(point2_, line1_.end_point)
26
- end
27
-
28
- def test_creation_points3
29
- point1_ = @factory.point(0, 0)
30
- point2_ = @factory.point(0, 1)
31
- point3_ = @factory.point(1, 0)
32
- line2_ = @factory.line_string([point1_, point2_, point3_])
33
- assert_not_nil(line2_)
34
- assert_equal(::RGeo::Feature::LineString, line2_.geometry_type)
35
- assert_equal(3, line2_.num_points)
36
- assert_equal(point1_, line2_.point_n(0))
37
- assert_equal(point2_, line2_.point_n(1))
38
- assert_equal(point3_, line2_.point_n(2))
39
- assert_nil(line2_.point_n(3))
40
- assert_equal(point1_, line2_.start_point)
41
- assert_equal(point3_, line2_.end_point)
42
- end
43
-
44
- def test_creation_points2_degenerate
45
- point1_ = @factory.point(0, 0)
46
- line3_ = @factory.line_string([point1_, point1_])
47
- assert_not_nil(line3_)
48
- assert_equal(::RGeo::Feature::LineString, line3_.geometry_type)
49
- assert_equal(2, line3_.num_points)
50
- assert_equal(point1_, line3_.point_n(0))
51
- assert_equal(point1_, line3_.point_n(1))
52
- assert_equal(point1_, line3_.start_point)
53
- assert_equal(point1_, line3_.end_point)
54
- end
55
-
56
- def test_creation_points_empty
57
- line4_ = @factory.line_string([])
58
- assert_not_nil(line4_)
59
- assert_equal(::RGeo::Feature::LineString, line4_.geometry_type)
60
- assert_equal(0, line4_.num_points)
61
- assert_nil(line4_.start_point)
62
- assert_nil(line4_.end_point)
63
- end
64
-
65
- def test_creation_line_string
66
- point1_ = @factory.point(0, 0)
67
- point2_ = @factory.point(0, 1)
68
- point3_ = @factory.point(1, 1)
69
- line1_ = @factory.line_string([point1_, point2_, point3_])
70
- assert_not_nil(line1_)
71
- assert(::RGeo::Feature::LineString === line1_)
72
- assert(!(::RGeo::Feature::LinearRing === line1_))
73
- assert(!(::RGeo::Feature::Line === line1_))
74
- assert_equal(::RGeo::Feature::LineString, line1_.geometry_type)
75
- end
76
-
77
- def test_creation_linear_ring
78
- point1_ = @factory.point(0, 0)
79
- point2_ = @factory.point(0, 1)
80
- point3_ = @factory.point(1, 0)
81
- line1_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
82
- assert_not_nil(line1_)
83
- assert(line1_.is_ring?)
84
- assert(::RGeo::Feature::LinearRing === line1_)
85
- assert_equal(::RGeo::Feature::LinearRing, line1_.geometry_type)
86
- line2_ = @factory.linear_ring([point1_, point2_, point3_])
87
- assert_not_nil(line2_)
88
- assert(line2_.is_ring?)
89
- assert(::RGeo::Feature::LinearRing === line2_)
90
- assert_equal(4, line2_.num_points)
91
- assert_equal(::RGeo::Feature::LinearRing, line2_.geometry_type)
92
- end
93
-
94
- def test_creation_line
95
- point1_ = @factory.point(0, 0)
96
- point2_ = @factory.point(0, 1)
97
- line1_ = @factory.line(point1_, point2_)
98
- assert_not_nil(line1_)
99
- assert(::RGeo::Feature::Line === line1_)
100
- assert_equal(::RGeo::Feature::Line, line1_.geometry_type)
101
- end
102
-
103
- def test_creation_errors
104
- point1_ = @factory.point(0, 0)
105
- collection_ = point1_.boundary
106
- line1_ = @factory.line_string([point1_])
107
- assert_nil(line1_)
108
- line2_ = @factory.line_string([point1_, collection_])
109
- assert_nil(line2_)
110
- end
111
-
112
- def test_required_equivalences
113
- point1_ = @factory.point(0, 0)
114
- point2_ = @factory.point(0, 1)
115
- point3_ = @factory.point(1, 0)
116
- line1_ = @factory.line_string([point1_, point2_, point3_])
117
- point4_ = @factory.point(0, 0)
118
- point5_ = @factory.point(0, 1)
119
- point6_ = @factory.point(1, 0)
120
- line2_ = @factory.line_string([point4_, point5_, point6_])
121
- assert(line1_.eql?(line2_))
122
- assert(line1_ == line2_)
123
- end
124
-
125
- def test_fully_equal
126
- point1_ = @factory.point(0, 0)
127
- point2_ = @factory.point(0, 1)
128
- point3_ = @factory.point(1, 0)
129
- line1_ = @factory.line_string([point1_, point2_, point3_])
130
- point4_ = @factory.point(0, 0)
131
- point5_ = @factory.point(0, 1)
132
- point6_ = @factory.point(1, 0)
133
- line2_ = @factory.line_string([point4_, point5_, point6_])
134
- assert(line1_.rep_equals?(line2_))
135
- assert(line1_.equals?(line2_))
136
- end
137
-
138
- def test_geometrically_equal_but_different_type
139
- point1_ = @factory.point(0, 0)
140
- point2_ = @factory.point(0, 1)
141
- line1_ = @factory.line_string([point1_, point2_])
142
- point4_ = @factory.point(0, 0)
143
- point5_ = @factory.point(0, 1)
144
- line2_ = @factory.line(point4_, point5_)
145
- assert(!line1_.rep_equals?(line2_))
146
- assert(line1_.equals?(line2_))
147
- end
148
-
149
- def test_geometrically_equal_but_different_type2
150
- point1_ = @factory.point(0, 0)
151
- point2_ = @factory.point(0, 1)
152
- point3_ = @factory.point(1, 0)
153
- line1_ = @factory.line_string([point1_, point2_, point3_, point1_])
154
- point4_ = @factory.point(0, 0)
155
- point5_ = @factory.point(0, 1)
156
- point6_ = @factory.point(1, 0)
157
- line2_ = @factory.linear_ring([point4_, point5_, point6_, point4_])
158
- assert(!line1_.rep_equals?(line2_))
159
- assert(line1_.equals?(line2_))
160
- end
161
-
162
- def test_geometrically_equal_but_different_overlap
163
- point1_ = @factory.point(0, 0)
164
- point2_ = @factory.point(0, 1)
165
- point3_ = @factory.point(1, 0)
166
- line1_ = @factory.line_string([point1_, point2_, point3_])
167
- point4_ = @factory.point(0, 0)
168
- point5_ = @factory.point(0, 1)
169
- point6_ = @factory.point(1, 0)
170
- line2_ = @factory.line_string([point4_, point5_, point6_, point5_])
171
- assert(!line1_.rep_equals?(line2_))
172
- assert(line1_.equals?(line2_))
173
- end
174
-
175
- def test_empty_equal
176
- line1_ = @factory.line_string([])
177
- line2_ = @factory.line_string([])
178
- assert(line1_.rep_equals?(line2_))
179
- assert(line1_.equals?(line2_))
180
- end
181
-
182
- def test_not_equal
183
- point1_ = @factory.point(0, 0)
184
- point2_ = @factory.point(0, 1)
185
- line1_ = @factory.line_string([point1_, point2_])
186
- point4_ = @factory.point(0, 0)
187
- point5_ = @factory.point(0, 1)
188
- point6_ = @factory.point(1, 0)
189
- line2_ = @factory.line_string([point4_, point5_, point6_])
190
- assert(!line1_.rep_equals?(line2_))
191
- assert(!line1_.equals?(line2_))
192
- end
193
-
194
- def test_hashes_equal_for_representationally_equivalent_objects
195
- point1_ = @factory.point(0, 0)
196
- point2_ = @factory.point(0, 1)
197
- point3_ = @factory.point(1, 0)
198
- line1_ = @factory.line_string([point1_, point2_, point3_])
199
- point4_ = @factory.point(0, 0)
200
- point5_ = @factory.point(0, 1)
201
- point6_ = @factory.point(1, 0)
202
- line2_ = @factory.line_string([point4_, point5_, point6_])
203
- assert_equal(line1_.hash, line2_.hash)
204
- end
205
-
206
- def test_out_of_order_is_not_equal
207
- point1_ = @factory.point(0, 0)
208
- point2_ = @factory.point(0, 1)
209
- line1_ = @factory.line_string([point1_, point2_])
210
- point4_ = @factory.point(0, 1)
211
- point5_ = @factory.point(0, 0)
212
- line2_ = @factory.line_string([point4_, point5_])
213
- assert(!line1_.rep_equals?(line2_))
214
- assert_not_equal(line1_.hash, line2_.hash)
215
- end
216
-
217
- def test_wkt_creation
218
- line1_ = @factory.parse_wkt("LINESTRING(21 22, 11 12)")
219
- assert_equal(@factory.point(21, 22), line1_.point_n(0))
220
- assert_equal(@factory.point(11, 12), line1_.point_n(1))
221
- assert_equal(2, line1_.num_points)
222
- line2_ = @factory.parse_wkt("LINESTRING(-1 -1, 21 22, 11 12, -1 -1)")
223
- assert_equal(@factory.point(-1, -1), line2_.point_n(0))
224
- assert_equal(@factory.point(21, 22), line2_.point_n(1))
225
- assert_equal(@factory.point(11, 12), line2_.point_n(2))
226
- assert_equal(@factory.point(-1, -1), line2_.point_n(3))
227
- assert_equal(4, line2_.num_points)
228
- end
229
-
230
- def test_clone
231
- point1_ = @factory.point(0, 0)
232
- point2_ = @factory.point(0, 1)
233
- line1_ = @factory.line_string([point1_, point2_])
234
- line2_ = line1_.clone
235
- assert(line1_.eql?(line2_))
236
- assert_equal(2, line2_.num_points)
237
- assert(point1_.eql?(line2_.point_n(0)))
238
- assert(point2_.eql?(line2_.point_n(1)))
239
- end
240
-
241
- def test_type_check
242
- point1_ = @factory.point(0, 0)
243
- point2_ = @factory.point(0, 1)
244
- line_ = @factory.line_string([point1_, point2_])
245
- assert(::RGeo::Feature::Geometry.check_type(line_))
246
- assert(!::RGeo::Feature::Point.check_type(line_))
247
- assert(!::RGeo::Feature::GeometryCollection.check_type(line_))
248
- assert(::RGeo::Feature::Curve.check_type(line_))
249
- assert(::RGeo::Feature::LineString.check_type(line_))
250
- assert(!::RGeo::Feature::LinearRing.check_type(line_))
251
- end
252
-
253
- def test_as_text_wkt_round_trip
254
- point1_ = @factory.point(0, 0)
255
- point2_ = @factory.point(0, 1)
256
- line1_ = @factory.line_string([point1_, point2_])
257
- text_ = line1_.as_text
258
- line2_ = @factory.parse_wkt(text_)
259
- assert(line2_.eql?(line1_))
260
- end
261
-
262
- def test_as_binary_wkb_round_trip
263
- point1_ = @factory.point(-42, 0)
264
- point2_ = @factory.point(0, 193)
265
- line1_ = @factory.line_string([point1_, point2_])
266
- binary_ = line1_.as_binary
267
- line2_ = @factory.parse_wkb(binary_)
268
- assert(line2_.eql?(line1_))
269
- end
270
-
271
- def test_empty_as_text_wkt_round_trip
272
- line1_ = @factory.line_string([])
273
- text_ = line1_.as_text
274
- line2_ = @factory.parse_wkt(text_)
275
- assert(line2_.is_empty?)
276
- end
277
-
278
- def test_empty_as_binary_wkb_round_trip
279
- line1_ = @factory.line_string([])
280
- binary_ = line1_.as_binary
281
- line2_ = @factory.parse_wkb(binary_)
282
- assert(line2_.is_empty?)
283
- end
284
-
285
- def test_dimension
286
- point1_ = @factory.point(-42, 0)
287
- point2_ = @factory.point(0, 193)
288
- line1_ = @factory.line_string([point1_, point2_])
289
- assert_equal(1, line1_.dimension)
290
- end
291
-
292
- def test_is_empty
293
- point1_ = @factory.point(-42, 0)
294
- point2_ = @factory.point(0, 193)
295
- line1_ = @factory.line_string([point1_, point2_])
296
- assert(!line1_.is_empty?)
297
- line2_ = @factory.line_string([])
298
- assert(line2_.is_empty?)
299
- end
300
-
301
- def test_marshal_roundtrip
302
- point1_ = @factory.point(0, 0)
303
- point2_ = @factory.point(0, 1)
304
- line1_ = @factory.line_string([point1_, point2_])
305
- data_ = ::Marshal.dump(line1_)
306
- line2_ = ::Marshal.load(data_)
307
- assert_equal(line1_, line2_)
308
- end
309
-
310
- def test_linestring_coordinates
311
- line = @factory.line_string([@factory.point(0.0, 1.0), @factory.point(2.0, 3.0)])
312
- assert_equal(line.coordinates, [[0.0, 1.0], [2.0, 3.0]])
313
- end
314
-
315
- if ::RGeo.yaml_supported?
316
-
317
- def test_psych_roundtrip
318
- point1_ = @factory.point(0, 0)
319
- point2_ = @factory.point(0, 1)
320
- line1_ = @factory.line_string([point1_, point2_])
321
- data_ = ::Psych.dump(line1_)
322
- line2_ = ::Psych.load(data_)
323
- assert_equal(line1_, line2_)
324
- end
325
-
326
- end
327
- end
328
- end
329
- end
330
- end
@@ -1,182 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # Common tests for multi line string implementations
4
- #
5
- # -----------------------------------------------------------------------------
6
-
7
- require "rgeo"
8
-
9
- module RGeo
10
- module Tests # :nodoc:
11
- module Common # :nodoc:
12
- module MultiLineStringTests # :nodoc:
13
- def setup
14
- @factory = create_factory
15
- point1_ = @factory.point(0, 0)
16
- point2_ = @factory.point(1, 0)
17
- point3_ = @factory.point(-4, 2) # (-4, 2)
18
- point4_ = @factory.point(-7, 6) # (-5, 3)
19
- point5_ = @factory.point(5, 11) # (-3, 5)
20
- @linestring1 = @factory.line_string([point1_, point2_])
21
- @linestring2 = @factory.line_string([point3_, point4_, point5_])
22
- @linearring1 = @factory.linear_ring([point5_, point3_, point4_, point5_])
23
- @line1 = @factory.line(point1_, point2_)
24
- end
25
-
26
- def test_creation_simple
27
- geom_ = @factory.multi_line_string([@linestring1, @linestring2])
28
- assert_not_nil(geom_)
29
- assert(::RGeo::Feature::MultiLineString === geom_)
30
- assert_equal(::RGeo::Feature::MultiLineString, geom_.geometry_type)
31
- assert_equal(2, geom_.num_geometries)
32
- assert(@linestring1.eql?(geom_[0]))
33
- assert(@linestring2.eql?(geom_[1]))
34
- end
35
-
36
- def test_creation_empty
37
- geom_ = @factory.multi_line_string([])
38
- assert_not_nil(geom_)
39
- assert(::RGeo::Feature::MultiLineString === geom_)
40
- assert_equal(::RGeo::Feature::MultiLineString, geom_.geometry_type)
41
- assert_equal(0, geom_.num_geometries)
42
- assert_equal([], geom_.to_a)
43
- end
44
-
45
- def test_creation_save_types
46
- geom_ = @factory.multi_line_string([@linestring1, @linearring1, @line1])
47
- assert_not_nil(geom_)
48
- assert(::RGeo::Feature::MultiLineString === geom_)
49
- assert_equal(::RGeo::Feature::MultiLineString, geom_.geometry_type)
50
- assert_equal(3, geom_.num_geometries)
51
- assert(geom_[1].eql?(@linearring1))
52
- assert(geom_[2].eql?(@line1))
53
- end
54
-
55
- def test_creation_casting
56
- mls1_ = @factory.collection([@line1])
57
- mls2_ = @factory.multi_line_string([@linearring1])
58
- geom_ = @factory.multi_line_string([@linestring1, @linestring2, mls1_, mls2_])
59
- assert_not_nil(geom_)
60
- assert_equal(::RGeo::Feature::MultiLineString, geom_.geometry_type)
61
- assert_equal(4, geom_.num_geometries)
62
- assert(@linestring1.eql?(geom_[0]))
63
- assert(@linestring2.eql?(geom_[1]))
64
- assert(@line1.eql?(geom_[2]))
65
- assert(@linearring1.eql?(geom_[3]))
66
- end
67
-
68
- def test_required_equivalences
69
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
70
- geom2_ = @factory.multi_line_string([@linestring1, @linestring2])
71
- assert(geom1_.eql?(geom2_))
72
- assert(geom1_ == geom2_)
73
- end
74
-
75
- def test_fully_equal
76
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
77
- geom2_ = @factory.multi_line_string([@linestring1, @linestring2])
78
- assert(geom1_.rep_equals?(geom2_))
79
- assert(geom1_.equals?(geom2_))
80
- end
81
-
82
- def test_geometrically_equal
83
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2, @linearring1])
84
- geom2_ = @factory.multi_line_string([@line1, @linearring1])
85
- assert(!geom1_.rep_equals?(geom2_))
86
- assert(geom1_.equals?(geom2_))
87
- end
88
-
89
- def test_not_equal
90
- geom1_ = @factory.multi_line_string([@linestring2])
91
- geom2_ = @factory.multi_line_string([@linearring1])
92
- assert(!geom1_.rep_equals?(geom2_))
93
- assert(!geom1_.equals?(geom2_))
94
- end
95
-
96
- def test_hashes_equal_for_representationally_equivalent_objects
97
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
98
- geom2_ = @factory.multi_line_string([@linestring1, @linestring2])
99
- assert_equal(geom1_.hash, geom2_.hash)
100
- end
101
-
102
- def test_wkt_creation_simple
103
- parsed_geom_ = @factory.parse_wkt("MULTILINESTRING((0 0, 1 0), (-4 2, -7 6, 5 11))")
104
- built_geom_ = @factory.multi_line_string([@linestring1, @linestring2])
105
- assert(built_geom_.eql?(parsed_geom_))
106
- end
107
-
108
- def test_wkt_creation_empty
109
- parsed_geom_ = @factory.parse_wkt("MULTILINESTRING EMPTY")
110
- assert_equal(::RGeo::Feature::MultiLineString, parsed_geom_.geometry_type)
111
- assert_equal(0, parsed_geom_.num_geometries)
112
- assert_equal([], parsed_geom_.to_a)
113
- end
114
-
115
- def test_clone
116
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
117
- geom2_ = geom1_.clone
118
- assert(geom1_.eql?(geom2_))
119
- assert_equal(::RGeo::Feature::MultiLineString, geom2_.geometry_type)
120
- assert_equal(2, geom2_.num_geometries)
121
- assert(@linestring1.eql?(geom2_[0]))
122
- assert(@linestring2.eql?(geom2_[1]))
123
- end
124
-
125
- def test_type_check
126
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
127
- assert(::RGeo::Feature::Geometry.check_type(geom1_))
128
- assert(!::RGeo::Feature::LineString.check_type(geom1_))
129
- assert(::RGeo::Feature::GeometryCollection.check_type(geom1_))
130
- assert(!::RGeo::Feature::MultiPoint.check_type(geom1_))
131
- assert(::RGeo::Feature::MultiLineString.check_type(geom1_))
132
- geom2_ = @factory.multi_line_string([])
133
- assert(::RGeo::Feature::Geometry.check_type(geom2_))
134
- assert(!::RGeo::Feature::LineString.check_type(geom2_))
135
- assert(::RGeo::Feature::GeometryCollection.check_type(geom2_))
136
- assert(!::RGeo::Feature::MultiPoint.check_type(geom2_))
137
- assert(::RGeo::Feature::MultiLineString.check_type(geom2_))
138
- end
139
-
140
- def test_as_text_wkt_round_trip
141
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
142
- text_ = geom1_.as_text
143
- geom2_ = @factory.parse_wkt(text_)
144
- assert(geom1_.eql?(geom2_))
145
- end
146
-
147
- def test_as_binary_wkb_round_trip
148
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
149
- binary_ = geom1_.as_binary
150
- geom2_ = @factory.parse_wkb(binary_)
151
- assert(geom1_.eql?(geom2_))
152
- end
153
-
154
- def test_dimension
155
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
156
- assert_equal(1, geom1_.dimension)
157
- geom2_ = @factory.multi_line_string([])
158
- assert_equal(-1, geom2_.dimension)
159
- end
160
-
161
- def test_is_empty
162
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
163
- assert(!geom1_.is_empty?)
164
- geom2_ = @factory.multi_line_string([])
165
- assert(geom2_.is_empty?)
166
- end
167
-
168
- def test_length
169
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
170
- assert_equal(19, geom1_.length)
171
- geom2_ = @factory.multi_line_string([])
172
- assert_equal(0, geom2_.length)
173
- end
174
-
175
- def test_coordinates
176
- ml = @factory.multi_line_string([@linestring1, @linestring2])
177
- assert_equal(ml.coordinates, [@linestring1, @linestring2].map(&:coordinates))
178
- end
179
- end
180
- end
181
- end
182
- end