rgeo 0.1.10 → 0.1.11

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.
Files changed (43) hide show
  1. data/History.rdoc +13 -0
  2. data/README.rdoc +6 -0
  3. data/Version +1 -1
  4. data/ext/geos_c_impl/factory.c +2 -2
  5. data/lib/rgeo/features/factory.rb +2 -2
  6. data/lib/rgeo/features/geometry.rb +26 -4
  7. data/lib/rgeo/features/geometry_collection.rb +12 -2
  8. data/lib/rgeo/geography/common/geometry_collection_methods.rb +12 -1
  9. data/lib/rgeo/geography/common/helper.rb +4 -4
  10. data/lib/rgeo/geography/common/line_string_methods.rb +1 -1
  11. data/lib/rgeo/geography/common/point_methods.rb +1 -1
  12. data/lib/rgeo/geography/common/polygon_methods.rb +1 -1
  13. data/lib/rgeo/geography/factories.rb +19 -6
  14. data/lib/rgeo/geography/factory.rb +31 -10
  15. data/lib/rgeo/geography/simple_mercator/feature_classes.rb +26 -26
  16. data/lib/rgeo/geography/simple_mercator/feature_methods.rb +14 -14
  17. data/lib/rgeo/geography/simple_mercator/projector.rb +1 -1
  18. data/lib/rgeo/geography/simple_spherical/calculations.rb +61 -0
  19. data/lib/rgeo/geography/simple_spherical/point_impl.rb +5 -0
  20. data/lib/rgeo/geos/factory.rb +12 -11
  21. data/tests/common/geometry_collection_tests.rb +220 -0
  22. data/tests/common/line_string_tests.rb +300 -0
  23. data/tests/common/multi_line_string_tests.rb +206 -0
  24. data/tests/common/multi_point_tests.rb +198 -0
  25. data/tests/common/multi_polygon_tests.rb +206 -0
  26. data/tests/common/point_tests.rb +281 -0
  27. data/tests/common/polygon_tests.rb +232 -0
  28. data/tests/geos/tc_geometry_collection.rb +5 -169
  29. data/tests/geos/tc_line_string.rb +4 -252
  30. data/tests/geos/tc_multi_line_string.rb +5 -154
  31. data/tests/geos/tc_multi_point.rb +5 -145
  32. data/tests/geos/tc_multi_polygon.rb +4 -151
  33. data/tests/geos/tc_point.rb +11 -213
  34. data/tests/geos/tc_polygon.rb +4 -182
  35. data/tests/simple_mercator/tc_geometry_collection.rb +62 -0
  36. data/tests/simple_mercator/tc_line_string.rb +62 -0
  37. data/tests/simple_mercator/tc_multi_line_string.rb +62 -0
  38. data/tests/simple_mercator/tc_multi_point.rb +62 -0
  39. data/tests/simple_mercator/tc_multi_polygon.rb +63 -0
  40. data/tests/simple_mercator/tc_point.rb +7 -220
  41. data/tests/simple_mercator/tc_polygon.rb +62 -0
  42. data/tests/simple_spherical/tc_point.rb +165 -0
  43. metadata +48 -9
@@ -37,10 +37,12 @@
37
37
  require 'test/unit'
38
38
  require 'rgeo'
39
39
 
40
+ require ::File.expand_path('../common/line_string_tests.rb', ::File.dirname(__FILE__))
41
+
40
42
 
41
43
  module RGeo
42
44
  module Tests # :nodoc:
43
- module Geos
45
+ module Geos # :nodoc:
44
46
 
45
47
  class TestLineString < ::Test::Unit::TestCase # :nodoc:
46
48
 
@@ -50,257 +52,7 @@ module RGeo
50
52
  end
51
53
 
52
54
 
53
- def test_creation_success
54
- point1_ = @factory.point(0, 0)
55
- point2_ = @factory.point(0, 1)
56
- point3_ = @factory.point(1, 0)
57
- line1_ = @factory.line_string([point1_, point2_])
58
- assert_not_nil(line1_)
59
- assert_kind_of(::RGeo::Geos::LineStringImpl, line1_)
60
- assert_equal(2, line1_.num_points)
61
- assert_equal(point1_, line1_.point_n(0))
62
- assert_equal(point2_, line1_.point_n(1))
63
- line2_ = @factory.line_string([point1_, point2_, point3_])
64
- assert_not_nil(line2_)
65
- assert_kind_of(::RGeo::Geos::LineStringImpl, line2_)
66
- assert_equal(3, line2_.num_points)
67
- assert_equal(point1_, line2_.point_n(0))
68
- assert_equal(point2_, line2_.point_n(1))
69
- assert_equal(point3_, line2_.point_n(2))
70
- line3_ = @factory.line_string([point1_, point1_])
71
- assert_not_nil(line3_)
72
- assert_kind_of(::RGeo::Geos::LineStringImpl, line3_)
73
- assert_equal(2, line3_.num_points)
74
- assert_equal(point1_, line3_.point_n(0))
75
- assert_equal(point1_, line3_.point_n(1))
76
- line4_ = @factory.line_string([])
77
- assert_not_nil(line4_)
78
- assert_kind_of(::RGeo::Geos::LineStringImpl, line4_)
79
- assert_equal(0, line4_.num_points)
80
- end
81
-
82
-
83
- def test_creation_line_string
84
- point1_ = @factory.point(0, 0)
85
- point2_ = @factory.point(0, 1)
86
- point3_ = @factory.point(1, 1)
87
- line1_ = @factory.line_string([point1_, point2_, point3_])
88
- assert_not_nil(line1_)
89
- assert_kind_of(::RGeo::Geos::LineStringImpl, line1_)
90
- assert(::RGeo::Features::LineString === line1_)
91
- assert(!(::RGeo::Features::LinearRing === line1_))
92
- assert(!(::RGeo::Features::Line === line1_))
93
- assert_equal(::RGeo::Features::LineString, line1_.geometry_type)
94
- end
95
-
96
-
97
- def test_creation_linear_ring
98
- point1_ = @factory.point(0, 0)
99
- point2_ = @factory.point(0, 1)
100
- point3_ = @factory.point(1, 0)
101
- line1_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
102
- assert_not_nil(line1_)
103
- assert_kind_of(::RGeo::Geos::LinearRingImpl, line1_)
104
- assert(line1_.is_ring?)
105
- assert(::RGeo::Features::LinearRing === line1_)
106
- assert_equal(::RGeo::Features::LinearRing, line1_.geometry_type)
107
- line2_ = @factory.linear_ring([point1_, point2_, point3_])
108
- assert_not_nil(line2_)
109
- assert_kind_of(::RGeo::Geos::LinearRingImpl, line2_)
110
- assert(line2_.is_ring?)
111
- assert(::RGeo::Features::LinearRing === line2_)
112
- assert_equal(4, line2_.num_points)
113
- assert_equal(::RGeo::Features::LinearRing, line2_.geometry_type)
114
- end
115
-
116
-
117
- def test_creation_line
118
- point1_ = @factory.point(0, 0)
119
- point2_ = @factory.point(0, 1)
120
- line1_ = @factory.line(point1_, point2_)
121
- assert_not_nil(line1_)
122
- assert_kind_of(::RGeo::Geos::LineImpl, line1_)
123
- assert(::RGeo::Features::Line === line1_)
124
- assert_equal(::RGeo::Features::Line, line1_.geometry_type)
125
- end
126
-
127
-
128
- def test_creation_errors
129
- point1_ = @factory.point(0, 0)
130
- collection_ = point1_.boundary
131
- line1_ = @factory.line_string([point1_])
132
- assert_nil(line1_)
133
- line2_ = @factory.line_string([point1_, collection_])
134
- assert_nil(line2_)
135
- end
136
-
137
-
138
- def test_fully_equal
139
- point1_ = @factory.point(0, 0)
140
- point2_ = @factory.point(0, 1)
141
- point3_ = @factory.point(1, 0)
142
- line1_ = @factory.line_string([point1_, point2_, point3_])
143
- point4_ = @factory.point(0, 0)
144
- point5_ = @factory.point(0, 1)
145
- point6_ = @factory.point(1, 0)
146
- line2_ = @factory.line_string([point4_, point5_, point6_])
147
- assert(line1_.eql?(line2_))
148
- assert(line1_.equals?(line2_))
149
- end
150
-
151
-
152
- def test_geometrically_equal_but_different_type
153
- point1_ = @factory.point(0, 0)
154
- point2_ = @factory.point(0, 1)
155
- line1_ = @factory.line_string([point1_, point2_])
156
- point4_ = @factory.point(0, 0)
157
- point5_ = @factory.point(0, 1)
158
- line2_ = @factory.line(point4_, point5_)
159
- assert(!line1_.eql?(line2_))
160
- assert(line1_.equals?(line2_))
161
- end
162
-
163
-
164
- def test_geometrically_equal_but_different_type2
165
- point1_ = @factory.point(0, 0)
166
- point2_ = @factory.point(0, 1)
167
- point3_ = @factory.point(1, 0)
168
- line1_ = @factory.line_string([point1_, point2_, point3_, point1_])
169
- point4_ = @factory.point(0, 0)
170
- point5_ = @factory.point(0, 1)
171
- point6_ = @factory.point(1, 0)
172
- line2_ = @factory.linear_ring([point4_, point5_, point6_, point4_])
173
- assert(!line1_.eql?(line2_))
174
- assert(line1_.equals?(line2_))
175
- end
176
-
177
-
178
- def test_geometrically_equal_but_different_overlap
179
- point1_ = @factory.point(0, 0)
180
- point2_ = @factory.point(0, 1)
181
- point3_ = @factory.point(1, 0)
182
- line1_ = @factory.line_string([point1_, point2_, point3_])
183
- point4_ = @factory.point(0, 0)
184
- point5_ = @factory.point(0, 1)
185
- point6_ = @factory.point(1, 0)
186
- line2_ = @factory.line_string([point4_, point5_, point6_, point5_])
187
- assert(!line1_.eql?(line2_))
188
- assert(line1_.equals?(line2_))
189
- end
190
-
191
-
192
- def test_empty_equal
193
- line1_ = @factory.line_string([])
194
- line2_ = @factory.line_string([])
195
- assert(line1_.eql?(line2_))
196
- assert(line1_.equals?(line2_))
197
- end
198
-
199
-
200
- def test_not_equal
201
- point1_ = @factory.point(0, 0)
202
- point2_ = @factory.point(0, 1)
203
- line1_ = @factory.line_string([point1_, point2_])
204
- point4_ = @factory.point(0, 0)
205
- point5_ = @factory.point(0, 1)
206
- point6_ = @factory.point(1, 0)
207
- line2_ = @factory.line_string([point4_, point5_, point6_])
208
- assert(!line1_.eql?(line2_))
209
- assert(!line1_.equals?(line2_))
210
- end
211
-
212
-
213
- def test_wkt_creation
214
- line1_ = @factory.parse_wkt('LINESTRING(21 22, 11 12)')
215
- assert_equal(@factory.point(21, 22), line1_.point_n(0))
216
- assert_equal(@factory.point(11, 12), line1_.point_n(1))
217
- assert_equal(2, line1_.num_points)
218
- line2_ = @factory.parse_wkt('LINESTRING(-1 -1, 21 22, 11 12, -1 -1)')
219
- assert_equal(@factory.point(-1, -1), line2_.point_n(0))
220
- assert_equal(@factory.point(21, 22), line2_.point_n(1))
221
- assert_equal(@factory.point(11, 12), line2_.point_n(2))
222
- assert_equal(@factory.point(-1, -1), line2_.point_n(3))
223
- assert_equal(4, line2_.num_points)
224
- end
225
-
226
-
227
- def test_clone
228
- point1_ = @factory.point(0, 0)
229
- point2_ = @factory.point(0, 1)
230
- line1_ = @factory.line_string([point1_, point2_])
231
- line2_ = line1_.clone
232
- assert_equal(line1_, line2_)
233
- assert_equal(2, line2_.num_points)
234
- assert_equal(point1_, line2_.point_n(0))
235
- assert_equal(point2_, line2_.point_n(1))
236
- end
237
-
238
-
239
- def test_type_check
240
- point1_ = @factory.point(0, 0)
241
- point2_ = @factory.point(0, 1)
242
- line_ = @factory.line_string([point1_, point2_])
243
- assert(::RGeo::Features::Geometry.check_type(line_))
244
- assert(!::RGeo::Features::Point.check_type(line_))
245
- assert(!::RGeo::Features::GeometryCollection.check_type(line_))
246
- assert(::RGeo::Features::Curve.check_type(line_))
247
- assert(::RGeo::Features::LineString.check_type(line_))
248
- assert(!::RGeo::Features::LinearRing.check_type(line_))
249
- end
250
-
251
-
252
- def test_as_text_wkt_round_trip
253
- point1_ = @factory.point(0, 0)
254
- point2_ = @factory.point(0, 1)
255
- line1_ = @factory.line_string([point1_, point2_])
256
- text_ = line1_.as_text
257
- line2_ = @factory.parse_wkt(text_)
258
- assert_equal(line2_, line1_)
259
- end
260
-
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_equal(line2_, line1_)
269
- end
270
-
271
-
272
- def test_empty_as_text_wkt_round_trip
273
- line1_ = @factory.line_string([])
274
- text_ = line1_.as_text
275
- line2_ = @factory.parse_wkt(text_)
276
- assert(line2_.is_empty?)
277
- end
278
-
279
-
280
- def test_empty_as_binary_wkb_round_trip
281
- line1_ = @factory.line_string([])
282
- binary_ = line1_.as_binary
283
- line2_ = @factory.parse_wkb(binary_)
284
- assert(line2_.is_empty?)
285
- end
286
-
287
-
288
- def test_dimension
289
- point1_ = @factory.point(-42, 0)
290
- point2_ = @factory.point(0, 193)
291
- line1_ = @factory.line_string([point1_, point2_])
292
- assert_equal(1, line1_.dimension)
293
- end
294
-
295
-
296
- def test_is_empty
297
- point1_ = @factory.point(-42, 0)
298
- point2_ = @factory.point(0, 193)
299
- line1_ = @factory.line_string([point1_, point2_])
300
- assert(!line1_.is_empty?)
301
- line2_ = @factory.line_string([])
302
- assert(line2_.is_empty?)
303
- end
55
+ include ::RGeo::Tests::Common::LineStringTests
304
56
 
305
57
 
306
58
  end
@@ -37,6 +37,8 @@
37
37
  require 'test/unit'
38
38
  require 'rgeo'
39
39
 
40
+ require ::File.expand_path('../common/multi_point_tests.rb', ::File.dirname(__FILE__))
41
+
40
42
 
41
43
  module RGeo
42
44
  module Tests # :nodoc:
@@ -45,163 +47,12 @@ module RGeo
45
47
  class TestMultiLineString < ::Test::Unit::TestCase # :nodoc:
46
48
 
47
49
 
48
- def setup
49
- @factory = ::RGeo::Geos.factory
50
- point1_ = @factory.point(0, 0)
51
- point2_ = @factory.point(1, 0)
52
- point3_ = @factory.point(-4, 2)
53
- point4_ = @factory.point(-5, 3)
54
- point5_ = @factory.point(-3, 5)
55
- @linestring1 = @factory.line_string([point1_, point2_])
56
- @linestring2 = @factory.line_string([point3_, point4_, point5_])
57
- @linearring1 = @factory.linear_ring([point5_, point3_, point4_, point5_])
58
- @line1 = @factory.line(point1_, point2_)
59
- end
60
-
61
-
62
- def test_creation_simple
63
- geom_ = @factory.multi_line_string([@linestring1, @linestring2])
64
- assert_not_nil(geom_)
65
- assert_kind_of(::RGeo::Geos::MultiLineStringImpl, geom_)
66
- assert(::RGeo::Features::MultiLineString === geom_)
67
- assert_equal(::RGeo::Features::MultiLineString, geom_.geometry_type)
68
- assert_equal(2, geom_.num_geometries)
69
- assert_equal([@linestring1, @linestring2], geom_.to_a)
70
- end
71
-
72
-
73
- def test_creation_empty
74
- geom_ = @factory.multi_line_string([])
75
- assert_not_nil(geom_)
76
- assert_kind_of(::RGeo::Geos::MultiLineStringImpl, geom_)
77
- assert(::RGeo::Features::MultiLineString === geom_)
78
- assert_equal(::RGeo::Features::MultiLineString, geom_.geometry_type)
79
- assert_equal(0, geom_.num_geometries)
80
- assert_equal([], geom_.to_a)
81
- end
82
-
83
-
84
- def test_creation_save_types
85
- geom_ = @factory.multi_line_string([@linestring1, @linearring1, @line1])
86
- assert_not_nil(geom_)
87
- assert_kind_of(::RGeo::Geos::MultiLineStringImpl, geom_)
88
- assert(::RGeo::Features::MultiLineString === geom_)
89
- assert_equal(::RGeo::Features::MultiLineString, geom_.geometry_type)
90
- assert_equal(3, geom_.num_geometries)
91
- assert(geom_[1].eql?(@linearring1))
92
- assert(geom_[2].eql?(@line1))
93
- end
94
-
95
-
96
- def test_creation_compound
97
- mls1_ = @factory.multi_line_string([@linestring1, @linestring2])
98
- mls2_ = @factory.collection([@line1])
99
- mls3_ = @factory.collection([mls1_])
100
- geom_ = @factory.multi_line_string([mls3_, mls2_, @linearring1])
101
- assert_not_nil(geom_)
102
- assert_kind_of(::RGeo::Geos::MultiLineStringImpl, geom_)
103
- assert(::RGeo::Features::MultiLineString === geom_)
104
- assert_equal(::RGeo::Features::MultiLineString, geom_.geometry_type)
105
- assert_equal(4, geom_.num_geometries)
106
- assert(geom_.to_a.eql?([@linestring1, @linestring2, @line1, @linearring1]))
107
- end
108
-
109
-
110
- def test_fully_equal
111
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
112
- geom2_ = @factory.multi_line_string([@linestring1, @linestring2])
113
- assert(geom1_.eql?(geom2_))
114
- assert(geom1_.equals?(geom2_))
115
- end
116
-
117
-
118
- def test_geometrically_equal
119
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2, @linearring1])
120
- geom2_ = @factory.multi_line_string([@line1, @linearring1])
121
- assert(!geom1_.eql?(geom2_))
122
- assert(geom1_.equals?(geom2_))
123
- end
124
-
125
-
126
- def test_not_equal
127
- geom1_ = @factory.multi_line_string([@linestring2])
128
- geom2_ = @factory.multi_line_string([@linearring1])
129
- assert(!geom1_.eql?(geom2_))
130
- assert(!geom1_.equals?(geom2_))
50
+ def create_factory
51
+ ::RGeo::Geos.factory
131
52
  end
132
53
 
133
54
 
134
- def test_wkt_creation_simple
135
- parsed_geom_ = @factory.parse_wkt('MULTILINESTRING((0 0, 1 0), (-4 2, -5 3, -3 5))')
136
- built_geom_ = @factory.multi_line_string([@linestring1, @linestring2])
137
- assert_equal(built_geom_, parsed_geom_)
138
- end
139
-
140
-
141
- def test_wkt_creation_empty
142
- parsed_geom_ = @factory.parse_wkt('MULTILINESTRING EMPTY')
143
- assert_equal(::RGeo::Features::MultiLineString, parsed_geom_.geometry_type)
144
- assert_equal(0, parsed_geom_.num_geometries)
145
- assert_equal([], parsed_geom_.to_a)
146
- end
147
-
148
-
149
- def test_clone
150
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
151
- geom2_ = geom1_.clone
152
- assert_equal(geom1_, geom2_)
153
- assert_equal(::RGeo::Features::MultiLineString, geom2_.geometry_type)
154
- assert_equal(2, geom2_.num_geometries)
155
- assert_equal([@linestring1, @linestring2], geom2_.to_a)
156
- end
157
-
158
-
159
- def test_type_check
160
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
161
- assert(::RGeo::Features::Geometry.check_type(geom1_))
162
- assert(!::RGeo::Features::LineString.check_type(geom1_))
163
- assert(::RGeo::Features::GeometryCollection.check_type(geom1_))
164
- assert(!::RGeo::Features::MultiPoint.check_type(geom1_))
165
- assert(::RGeo::Features::MultiLineString.check_type(geom1_))
166
- geom2_ = @factory.multi_line_string([])
167
- assert(::RGeo::Features::Geometry.check_type(geom2_))
168
- assert(!::RGeo::Features::LineString.check_type(geom2_))
169
- assert(::RGeo::Features::GeometryCollection.check_type(geom2_))
170
- assert(!::RGeo::Features::MultiPoint.check_type(geom2_))
171
- assert(::RGeo::Features::MultiLineString.check_type(geom2_))
172
- end
173
-
174
-
175
- def test_as_text_wkt_round_trip
176
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
177
- text_ = geom1_.as_text
178
- geom2_ = @factory.parse_wkt(text_)
179
- assert_equal(geom1_, geom2_)
180
- end
181
-
182
-
183
- def test_as_binary_wkb_round_trip
184
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
185
- binary_ = geom1_.as_binary
186
- geom2_ = @factory.parse_wkb(binary_)
187
- assert_equal(geom1_, geom2_)
188
- end
189
-
190
-
191
- def test_dimension
192
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
193
- assert_equal(1, geom1_.dimension)
194
- geom2_ = @factory.multi_line_string([])
195
- assert_equal(-1, geom2_.dimension)
196
- end
197
-
198
-
199
- def test_is_empty
200
- geom1_ = @factory.multi_line_string([@linestring1, @linestring2])
201
- assert(!geom1_.is_empty?)
202
- geom2_ = @factory.multi_line_string([])
203
- assert(geom2_.is_empty?)
204
- end
55
+ include ::RGeo::Tests::Common::MultiPointTests
205
56
 
206
57
 
207
58
  end
@@ -37,6 +37,8 @@
37
37
  require 'test/unit'
38
38
  require 'rgeo'
39
39
 
40
+ require ::File.expand_path('../common/multi_point_tests.rb', ::File.dirname(__FILE__))
41
+
40
42
 
41
43
  module RGeo
42
44
  module Tests # :nodoc:
@@ -45,154 +47,12 @@ module RGeo
45
47
  class TestMultiPoint < ::Test::Unit::TestCase # :nodoc:
46
48
 
47
49
 
48
- def setup
49
- @factory = ::RGeo::Geos.factory
50
- @point1 = @factory.point(0, 0)
51
- @point2 = @factory.point(1, 0)
52
- @point3 = @factory.point(-4, 2)
53
- @point4 = @factory.point(-5, 3)
54
- @point5 = @factory.point(-5, 3)
55
- end
56
-
57
-
58
- def test_creation_simple
59
- geom_ = @factory.multi_point([@point1, @point2])
60
- assert_not_nil(geom_)
61
- assert_kind_of(::RGeo::Geos::MultiPointImpl, geom_)
62
- assert(::RGeo::Features::MultiPoint === geom_)
63
- assert_equal(::RGeo::Features::MultiPoint, geom_.geometry_type)
64
- assert_equal(2, geom_.num_geometries)
65
- assert_equal([@point1, @point2], geom_.to_a)
66
- end
67
-
68
-
69
- def test_creation_empty
70
- geom_ = @factory.multi_point([])
71
- assert_not_nil(geom_)
72
- assert_kind_of(::RGeo::Geos::MultiPointImpl, geom_)
73
- assert(::RGeo::Features::MultiPoint === geom_)
74
- assert_equal(::RGeo::Features::MultiPoint, geom_.geometry_type)
75
- assert_equal(0, geom_.num_geometries)
76
- assert_equal([], geom_.to_a)
77
- end
78
-
79
-
80
- def test_creation_compound
81
- mp1_ = @factory.multi_point([@point1, @point2])
82
- mp2_ = @factory.collection([@point3])
83
- mp3_ = @factory.collection([mp1_])
84
- geom_ = @factory.multi_point([mp3_, mp2_, @point4])
85
- assert_not_nil(geom_)
86
- assert_kind_of(::RGeo::Geos::MultiPointImpl, geom_)
87
- assert(::RGeo::Features::MultiPoint === geom_)
88
- assert_equal(::RGeo::Features::MultiPoint, geom_.geometry_type)
89
- assert_equal(4, geom_.num_geometries)
90
- assert_equal([@point1, @point2, @point3, @point4], geom_.to_a)
91
- end
92
-
93
-
94
- def test_creation_wrong_type
95
- line_ = @factory.line_string([@point1, @point2])
96
- geom_ = @factory.multi_point([@point3, line_])
97
- assert_nil(geom_)
98
- end
99
-
100
-
101
- def test_fully_equal
102
- geom1_ = @factory.multi_point([@point1, @point2])
103
- geom2_ = @factory.multi_point([@point1, @point2])
104
- assert(geom1_.eql?(geom2_))
105
- assert(geom1_.equals?(geom2_))
106
- end
107
-
108
-
109
- def test_geometrically_equal
110
- geom1_ = @factory.multi_point([@point1, @point4])
111
- geom2_ = @factory.multi_point([@point1, @point4, @point5])
112
- assert(!geom1_.eql?(geom2_))
113
- assert(geom1_.equals?(geom2_))
114
- end
115
-
116
-
117
- def test_not_equal
118
- geom1_ = @factory.multi_point([@point1, @point2])
119
- geom2_ = @factory.multi_point([@point1])
120
- assert(!geom1_.eql?(geom2_))
121
- assert(!geom1_.equals?(geom2_))
50
+ def create_factory
51
+ ::RGeo::Geos.factory
122
52
  end
123
53
 
124
54
 
125
- def test_wkt_creation_simple
126
- parsed_geom_ = @factory.parse_wkt('MULTIPOINT((0 0), (-4 2), (-5 3))')
127
- built_geom_ = @factory.multi_point([@point1, @point3, @point4])
128
- assert_equal(built_geom_, parsed_geom_)
129
- end
130
-
131
-
132
- def test_wkt_creation_empty
133
- parsed_geom_ = @factory.parse_wkt('MULTIPOINT EMPTY')
134
- assert(::RGeo::Features::MultiPoint === parsed_geom_)
135
- assert_equal(0, parsed_geom_.num_geometries)
136
- assert_equal([], parsed_geom_.to_a)
137
- end
138
-
139
-
140
- def test_clone
141
- geom1_ = @factory.multi_point([@point1, @point2])
142
- geom2_ = geom1_.clone
143
- assert_equal(geom1_, geom2_)
144
- assert_equal(::RGeo::Features::MultiPoint, geom2_.geometry_type)
145
- assert_equal(2, geom2_.num_geometries)
146
- assert_equal([@point1, @point2], geom2_.to_a)
147
- end
148
-
149
-
150
- def test_type_check
151
- geom1_ = @factory.multi_point([@point1, @point2])
152
- assert(::RGeo::Features::Geometry.check_type(geom1_))
153
- assert(!::RGeo::Features::Point.check_type(geom1_))
154
- assert(::RGeo::Features::GeometryCollection.check_type(geom1_))
155
- assert(::RGeo::Features::MultiPoint.check_type(geom1_))
156
- assert(!::RGeo::Features::MultiLineString.check_type(geom1_))
157
- geom2_ = @factory.multi_point([])
158
- assert(::RGeo::Features::Geometry.check_type(geom2_))
159
- assert(!::RGeo::Features::Point.check_type(geom2_))
160
- assert(::RGeo::Features::GeometryCollection.check_type(geom2_))
161
- assert(::RGeo::Features::MultiPoint.check_type(geom2_))
162
- assert(!::RGeo::Features::MultiLineString.check_type(geom2_))
163
- end
164
-
165
-
166
- def test_as_text_wkt_round_trip
167
- geom1_ = @factory.multi_point([@point1, @point2])
168
- text_ = geom1_.as_text
169
- geom2_ = @factory.parse_wkt(text_)
170
- assert_equal(geom1_, geom2_)
171
- end
172
-
173
-
174
- def test_as_binary_wkb_round_trip
175
- geom1_ = @factory.multi_point([@point1, @point2])
176
- binary_ = geom1_.as_binary
177
- geom2_ = @factory.parse_wkb(binary_)
178
- assert_equal(geom1_, geom2_)
179
- end
180
-
181
-
182
- def test_dimension
183
- geom1_ = @factory.multi_point([@point1, @point2])
184
- assert_equal(0, geom1_.dimension)
185
- geom2_ = @factory.multi_point([])
186
- assert_equal(-1, geom2_.dimension)
187
- end
188
-
189
-
190
- def test_is_empty
191
- geom1_ = @factory.multi_point([@point1, @point2])
192
- assert(!geom1_.is_empty?)
193
- geom2_ = @factory.multi_point([])
194
- assert(geom2_.is_empty?)
195
- end
55
+ include ::RGeo::Tests::Common::MultiPointTests
196
56
 
197
57
 
198
58
  end