rgeo 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/History.rdoc +22 -0
  2. data/README.rdoc +124 -0
  3. data/Version +1 -0
  4. data/ext/geos_c_impl/extconf.rb +72 -0
  5. data/ext/geos_c_impl/factory.c +468 -0
  6. data/ext/geos_c_impl/factory.h +217 -0
  7. data/ext/geos_c_impl/geometry.c +644 -0
  8. data/ext/geos_c_impl/geometry.h +65 -0
  9. data/ext/geos_c_impl/geometry_collection.c +580 -0
  10. data/ext/geos_c_impl/geometry_collection.h +79 -0
  11. data/ext/geos_c_impl/globals.h +58 -0
  12. data/ext/geos_c_impl/line_string.c +468 -0
  13. data/ext/geos_c_impl/line_string.h +74 -0
  14. data/ext/geos_c_impl/main.c +65 -0
  15. data/ext/geos_c_impl/point.c +201 -0
  16. data/ext/geos_c_impl/point.h +77 -0
  17. data/ext/geos_c_impl/polygon.c +259 -0
  18. data/ext/geos_c_impl/polygon.h +76 -0
  19. data/ext/geos_c_impl/preface.h +42 -0
  20. data/lib/rgeo.rb +68 -0
  21. data/lib/rgeo/errors.rb +59 -0
  22. data/lib/rgeo/features.rb +89 -0
  23. data/lib/rgeo/features/curve.rb +155 -0
  24. data/lib/rgeo/features/factory.rb +191 -0
  25. data/lib/rgeo/features/geometry.rb +560 -0
  26. data/lib/rgeo/features/geometry_collection.rb +118 -0
  27. data/lib/rgeo/features/line.rb +65 -0
  28. data/lib/rgeo/features/line_string.rb +101 -0
  29. data/lib/rgeo/features/linear_ring.rb +65 -0
  30. data/lib/rgeo/features/multi_curve.rb +112 -0
  31. data/lib/rgeo/features/multi_line_string.rb +65 -0
  32. data/lib/rgeo/features/multi_point.rb +72 -0
  33. data/lib/rgeo/features/multi_polygon.rb +96 -0
  34. data/lib/rgeo/features/multi_surface.rb +115 -0
  35. data/lib/rgeo/features/point.rb +97 -0
  36. data/lib/rgeo/features/polygon.rb +141 -0
  37. data/lib/rgeo/features/surface.rb +121 -0
  38. data/lib/rgeo/geo_json.rb +58 -0
  39. data/lib/rgeo/geo_json/coder.rb +305 -0
  40. data/lib/rgeo/geo_json/entities.rb +284 -0
  41. data/lib/rgeo/geo_json/interface.rb +95 -0
  42. data/lib/rgeo/geography.rb +75 -0
  43. data/lib/rgeo/geography/common/geometry_collection_methods.rb +206 -0
  44. data/lib/rgeo/geography/common/geometry_methods.rb +92 -0
  45. data/lib/rgeo/geography/common/helper.rb +102 -0
  46. data/lib/rgeo/geography/common/line_string_methods.rb +187 -0
  47. data/lib/rgeo/geography/common/point_methods.rb +149 -0
  48. data/lib/rgeo/geography/common/polygon_methods.rb +122 -0
  49. data/lib/rgeo/geography/factories.rb +136 -0
  50. data/lib/rgeo/geography/factory.rb +246 -0
  51. data/lib/rgeo/geography/projected_window.rb +467 -0
  52. data/lib/rgeo/geography/simple_mercator/feature_classes.rb +320 -0
  53. data/lib/rgeo/geography/simple_mercator/feature_methods.rb +291 -0
  54. data/lib/rgeo/geography/simple_mercator/projector.rb +116 -0
  55. data/lib/rgeo/geography/simple_spherical/calculations.rb +70 -0
  56. data/lib/rgeo/geography/simple_spherical/geometry_collection_impl.rb +66 -0
  57. data/lib/rgeo/geography/simple_spherical/geometry_methods.rb +59 -0
  58. data/lib/rgeo/geography/simple_spherical/line_string_impl.rb +104 -0
  59. data/lib/rgeo/geography/simple_spherical/multi_line_string_impl.rb +67 -0
  60. data/lib/rgeo/geography/simple_spherical/multi_point_impl.rb +67 -0
  61. data/lib/rgeo/geography/simple_spherical/multi_polygon_impl.rb +67 -0
  62. data/lib/rgeo/geography/simple_spherical/point_impl.rb +85 -0
  63. data/lib/rgeo/geography/simple_spherical/polygon_impl.rb +66 -0
  64. data/lib/rgeo/geos.rb +72 -0
  65. data/lib/rgeo/geos/factory.rb +260 -0
  66. data/lib/rgeo/geos/impl_additions.rb +57 -0
  67. data/lib/rgeo/geos/interface.rb +74 -0
  68. data/lib/rgeo/version.rb +52 -0
  69. data/tests/geos/tc_factory.rb +91 -0
  70. data/tests/geos/tc_geometry_collection.rb +226 -0
  71. data/tests/geos/tc_line_string.rb +310 -0
  72. data/tests/geos/tc_misc.rb +72 -0
  73. data/tests/geos/tc_multi_line_string.rb +211 -0
  74. data/tests/geos/tc_multi_point.rb +202 -0
  75. data/tests/geos/tc_multi_polygon.rb +210 -0
  76. data/tests/geos/tc_point.rb +305 -0
  77. data/tests/geos/tc_polygon.rb +240 -0
  78. data/tests/simple_mercator/tc_point.rb +303 -0
  79. data/tests/simple_mercator/tc_window.rb +219 -0
  80. data/tests/tc_geojson.rb +230 -0
  81. data/tests/tc_oneoff.rb +61 -0
  82. metadata +162 -0
@@ -0,0 +1,240 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for the GEOS polygon implementation
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ require 'test/unit'
38
+ require 'rgeo'
39
+
40
+
41
+ module RGeo
42
+ module Tests # :nodoc:
43
+ module Geos
44
+
45
+ class TestPolygon < ::Test::Unit::TestCase # :nodoc:
46
+
47
+
48
+ def setup
49
+ @factory = ::RGeo::Geos.factory
50
+ end
51
+
52
+
53
+ def test_creation_simple
54
+ point1_ = @factory.point(0, 0)
55
+ point2_ = @factory.point(0, 1)
56
+ point3_ = @factory.point(1, 0)
57
+ exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
58
+ polygon_ = @factory.polygon(exterior_)
59
+ assert_not_nil(polygon_)
60
+ assert_kind_of(::RGeo::Geos::PolygonImpl, polygon_)
61
+ assert(::RGeo::Features::Polygon === polygon_)
62
+ assert_equal(::RGeo::Features::Polygon, polygon_.geometry_type)
63
+ assert_equal(exterior_, polygon_.exterior_ring)
64
+ assert_equal(0, polygon_.num_interior_rings)
65
+ end
66
+
67
+
68
+ def test_creation_one_hole
69
+ point1_ = @factory.point(0, 0)
70
+ point2_ = @factory.point(0, 10)
71
+ point3_ = @factory.point(10, 10)
72
+ point4_ = @factory.point(10, 0)
73
+ point5_ = @factory.point(4, 4)
74
+ point6_ = @factory.point(5, 6)
75
+ point7_ = @factory.point(6, 4)
76
+ exterior_ = @factory.linear_ring([point1_, point2_, point3_, point4_, point1_])
77
+ interior_ = @factory.linear_ring([point5_, point6_, point7_, point5_])
78
+ polygon_ = @factory.polygon(exterior_, [interior_])
79
+ assert_not_nil(polygon_)
80
+ assert_kind_of(::RGeo::Geos::PolygonImpl, polygon_)
81
+ assert(::RGeo::Features::Polygon === polygon_)
82
+ assert_equal(::RGeo::Features::Polygon, polygon_.geometry_type)
83
+ assert_equal(exterior_, polygon_.exterior_ring)
84
+ assert_equal(1, polygon_.num_interior_rings)
85
+ assert_equal([interior_], polygon_.interior_rings)
86
+ end
87
+
88
+
89
+ def test_fully_equal
90
+ point1_ = @factory.point(0, 0)
91
+ point2_ = @factory.point(0, 1)
92
+ point3_ = @factory.point(1, 0)
93
+ exterior1_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
94
+ poly1_ = @factory.polygon(exterior1_)
95
+ point4_ = @factory.point(0, 0)
96
+ point5_ = @factory.point(0, 1)
97
+ point6_ = @factory.point(1, 0)
98
+ exterior2_ = @factory.linear_ring([point4_, point5_, point6_, point4_])
99
+ poly2_ = @factory.polygon(exterior2_)
100
+ assert(poly1_.eql?(poly2_))
101
+ assert(poly1_.equals?(poly2_))
102
+ end
103
+
104
+
105
+ def test_geometrically_equal_but_ordered_different
106
+ point1_ = @factory.point(0, 0)
107
+ point2_ = @factory.point(0, 1)
108
+ point3_ = @factory.point(1, 0)
109
+ exterior1_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
110
+ poly1_ = @factory.polygon(exterior1_)
111
+ exterior2_ = @factory.linear_ring([point2_, point3_, point1_, point2_])
112
+ poly2_ = @factory.polygon(exterior2_)
113
+ assert(!poly1_.eql?(poly2_))
114
+ assert(poly1_.equals?(poly2_))
115
+ end
116
+
117
+
118
+ def test_geometrically_equal_but_different_directions
119
+ point1_ = @factory.point(0, 0)
120
+ point2_ = @factory.point(0, 1)
121
+ point3_ = @factory.point(1, 0)
122
+ exterior1_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
123
+ poly1_ = @factory.polygon(exterior1_)
124
+ exterior2_ = @factory.linear_ring([point1_, point3_, point2_, point1_])
125
+ poly2_ = @factory.polygon(exterior2_)
126
+ assert(!poly1_.eql?(poly2_))
127
+ assert(poly1_.equals?(poly2_))
128
+ end
129
+
130
+
131
+ def test_wkt_creation_simple
132
+ parsed_poly_ = @factory.parse_wkt('POLYGON((0 0, 0 1, 1 0, 0 0))')
133
+ point1_ = @factory.point(0, 0)
134
+ point2_ = @factory.point(0, 1)
135
+ point3_ = @factory.point(1, 0)
136
+ exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
137
+ built_poly_ = @factory.polygon(exterior_)
138
+ assert_equal(built_poly_, parsed_poly_)
139
+ end
140
+
141
+
142
+ def test_wkt_creation_one_hole
143
+ parsed_poly_ = @factory.parse_wkt('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0), (4 4, 5 6, 6 4, 4 4))')
144
+ point1_ = @factory.point(0, 0)
145
+ point2_ = @factory.point(0, 10)
146
+ point3_ = @factory.point(10, 10)
147
+ point4_ = @factory.point(10, 0)
148
+ point5_ = @factory.point(4, 4)
149
+ point6_ = @factory.point(5, 6)
150
+ point7_ = @factory.point(6, 4)
151
+ exterior_ = @factory.linear_ring([point1_, point2_, point3_, point4_, point1_])
152
+ interior_ = @factory.linear_ring([point5_, point6_, point7_, point5_])
153
+ built_poly_ = @factory.polygon(exterior_, [interior_])
154
+ assert_equal(built_poly_, parsed_poly_)
155
+ end
156
+
157
+
158
+ def test_clone
159
+ point1_ = @factory.point(0, 0)
160
+ point2_ = @factory.point(0, 1)
161
+ point3_ = @factory.point(1, 0)
162
+ exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
163
+ poly1_ = @factory.polygon(exterior_)
164
+ poly2_ = poly1_.clone
165
+ assert_equal(poly1_, poly2_)
166
+ assert_equal(exterior_, poly2_.exterior_ring)
167
+ assert_equal(0, poly2_.num_interior_rings)
168
+ end
169
+
170
+
171
+ def test_type_check
172
+ point1_ = @factory.point(0, 0)
173
+ point2_ = @factory.point(0, 1)
174
+ point3_ = @factory.point(1, 0)
175
+ exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
176
+ poly_ = @factory.polygon(exterior_)
177
+ assert(::RGeo::Features::Geometry.check_type(poly_))
178
+ assert(!::RGeo::Features::Point.check_type(poly_))
179
+ assert(!::RGeo::Features::GeometryCollection.check_type(poly_))
180
+ assert(::RGeo::Features::Surface.check_type(poly_))
181
+ assert(::RGeo::Features::Polygon.check_type(poly_))
182
+ end
183
+
184
+
185
+ def test_as_text_wkt_round_trip
186
+ point1_ = @factory.point(0, 0)
187
+ point2_ = @factory.point(0, 1)
188
+ point3_ = @factory.point(1, 0)
189
+ exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
190
+ poly1_ = @factory.polygon(exterior_)
191
+ text_ = poly1_.as_text
192
+ poly2_ = @factory.parse_wkt(text_)
193
+ assert_equal(poly1_, poly2_)
194
+ end
195
+
196
+
197
+ def test_as_binary_wkb_round_trip
198
+ point1_ = @factory.point(0, 0)
199
+ point2_ = @factory.point(0, 1)
200
+ point3_ = @factory.point(1, 0)
201
+ exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
202
+ poly1_ = @factory.polygon(exterior_)
203
+ binary_ = poly1_.as_binary
204
+ poly2_ = @factory.parse_wkb(binary_)
205
+ assert_equal(poly1_, poly2_)
206
+ end
207
+
208
+
209
+ def test_dimension
210
+ point1_ = @factory.point(0, 0)
211
+ point2_ = @factory.point(0, 10)
212
+ point3_ = @factory.point(10, 10)
213
+ point4_ = @factory.point(10, 0)
214
+ point5_ = @factory.point(4, 4)
215
+ point6_ = @factory.point(5, 6)
216
+ point7_ = @factory.point(6, 4)
217
+ exterior_ = @factory.linear_ring([point1_, point2_, point3_, point4_, point1_])
218
+ interior_ = @factory.linear_ring([point5_, point6_, point7_, point5_])
219
+ poly_ = @factory.polygon(exterior_, [interior_])
220
+ assert_equal(2, poly_.dimension)
221
+ end
222
+
223
+
224
+ def test_is_empty
225
+ point1_ = @factory.point(0, 0)
226
+ point2_ = @factory.point(0, 1)
227
+ point3_ = @factory.point(1, 0)
228
+ exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
229
+ poly1_ = @factory.polygon(exterior_)
230
+ assert(!poly1_.is_empty?)
231
+ poly2_ = @factory.polygon(@factory.linear_ring([]))
232
+ assert(poly2_.is_empty?)
233
+ end
234
+
235
+
236
+ end
237
+
238
+ end
239
+ end
240
+ end
@@ -0,0 +1,303 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Tests for the simple mercator point implementation
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ require 'test/unit'
38
+ require 'rgeo'
39
+
40
+
41
+ module RGeo
42
+ module Tests # :nodoc:
43
+ module SimpleMercator
44
+
45
+ class TestPoint < ::Test::Unit::TestCase # :nodoc:
46
+
47
+
48
+ def setup
49
+ @factory = ::RGeo::Geography.simple_mercator
50
+ end
51
+
52
+
53
+ def assert_close_enough(p1_, p2_)
54
+ assert((p1_.x - p2_.x).abs < 0.00000001 && (p1_.y - p2_.y).abs < 0.00000001)
55
+ end
56
+
57
+
58
+ def assert_contains_approx(p_, mp_)
59
+ assert(mp_.any?{ |q_| (p_.x - q_.x).abs < 0.00000001 && (p_.y - q_.y).abs < 0.00000001 })
60
+ end
61
+
62
+
63
+ def test_creation
64
+ point_ = @factory.point(21, -22)
65
+ assert_equal(21, point_.x)
66
+ assert_equal(-22, point_.y)
67
+ assert_equal(21, point_.longitude)
68
+ assert_equal(-22, point_.latitude)
69
+ end
70
+
71
+
72
+ def test_wkt_creation
73
+ point1_ = @factory.parse_wkt('POINT(21 -22)')
74
+ assert_equal(21, point1_.x)
75
+ assert_equal(-22, point1_.y)
76
+ assert_equal(21, point1_.longitude)
77
+ assert_equal(-22, point1_.latitude)
78
+ end
79
+
80
+
81
+ def test_clone
82
+ point1_ = @factory.point(11, 12)
83
+ point2_ = point1_.clone
84
+ assert_equal(point1_, point2_)
85
+ point3_ = @factory.point(13, 12)
86
+ point4_ = point3_.dup
87
+ assert_equal(point3_, point4_)
88
+ assert_not_equal(point2_, point4_)
89
+ end
90
+
91
+
92
+ def test_type_check
93
+ point_ = @factory.point(21, 22)
94
+ assert(::RGeo::Features::Geometry.check_type(point_))
95
+ assert(::RGeo::Features::Point.check_type(point_))
96
+ assert(!::RGeo::Features::GeometryCollection.check_type(point_))
97
+ assert(!::RGeo::Features::Curve.check_type(point_))
98
+ end
99
+
100
+
101
+ def test_geometry_type
102
+ point_ = @factory.point(11, 12)
103
+ assert_equal(::RGeo::Features::Point, point_.geometry_type)
104
+ end
105
+
106
+
107
+ def test_dimension
108
+ point_ = @factory.point(11, 12)
109
+ assert_equal(0, point_.dimension)
110
+ end
111
+
112
+
113
+ def test_srid
114
+ point_ = @factory.point(11, 12)
115
+ assert_equal(4326, point_.srid)
116
+ end
117
+
118
+
119
+ def test_envelope
120
+ point_ = @factory.point(11, 12)
121
+ assert_close_enough(point_, point_.envelope)
122
+ end
123
+
124
+
125
+ def test_as_text_wkt_round_trip
126
+ point1_ = @factory.point(11, 12)
127
+ text_ = point1_.as_text
128
+ point2_ = @factory.parse_wkt(text_)
129
+ assert_equal(point2_, point1_)
130
+ end
131
+
132
+
133
+ def test_as_binary_wkb_round_trip
134
+ point1_ = @factory.point(211, 12)
135
+ binary_ = point1_.as_binary
136
+ point2_ = @factory.parse_wkb(binary_)
137
+ assert_equal(point2_, point1_)
138
+ end
139
+
140
+
141
+ def test_is_empty
142
+ point1_ = @factory.point(0, 0)
143
+ assert(!point1_.is_empty?)
144
+ end
145
+
146
+
147
+ def test_is_simple
148
+ point1_ = @factory.point(0, 0)
149
+ assert(point1_.is_simple?)
150
+ end
151
+
152
+
153
+ def test_boundary
154
+ point_ = @factory.point(11, 12)
155
+ boundary_ = point_.boundary
156
+ assert_equal(::RGeo::Features::GeometryCollection, boundary_.geometry_type)
157
+ assert(boundary_.is_empty?)
158
+ end
159
+
160
+
161
+ def test_equals
162
+ point1_ = @factory.point(11, 12)
163
+ point2_ = @factory.point(11, 12)
164
+ point3_ = @factory.point(13, 12)
165
+ assert_equal(point1_, point2_)
166
+ assert_not_equal(point1_, point3_)
167
+ end
168
+
169
+
170
+ def test_disjoint
171
+ point1_ = @factory.point(11, 12)
172
+ point2_ = @factory.point(11, 12)
173
+ point3_ = @factory.point(12, 12)
174
+ assert(!point1_.disjoint?(point2_))
175
+ assert(point1_.disjoint?(point3_))
176
+ end
177
+
178
+
179
+ def test_intersects
180
+ point1_ = @factory.point(11, 12)
181
+ point2_ = @factory.point(11, 12)
182
+ point3_ = @factory.point(12, 12)
183
+ assert(point1_.intersects?(point2_))
184
+ assert(!point1_.intersects?(point3_))
185
+ end
186
+
187
+
188
+ def test_touches
189
+ point1_ = @factory.point(11, 12)
190
+ point2_ = @factory.point(11, 12)
191
+ point3_ = @factory.point(12, 12)
192
+ assert(!point1_.touches?(point2_))
193
+ assert(!point1_.touches?(point3_))
194
+ end
195
+
196
+
197
+ def test_crosses
198
+ point1_ = @factory.point(11, 12)
199
+ point2_ = @factory.point(11, 12)
200
+ point3_ = @factory.point(12, 12)
201
+ assert(!point1_.crosses?(point2_))
202
+ assert(!point1_.crosses?(point3_))
203
+ end
204
+
205
+
206
+ def test_within
207
+ point1_ = @factory.point(11, 12)
208
+ point2_ = @factory.point(11, 12)
209
+ point3_ = @factory.point(12, 12)
210
+ assert(point1_.within?(point2_))
211
+ assert(!point1_.within?(point3_))
212
+ end
213
+
214
+
215
+ def test_contains
216
+ point1_ = @factory.point(11, 12)
217
+ point2_ = @factory.point(11, 12)
218
+ point3_ = @factory.point(12, 12)
219
+ assert(point1_.contains?(point2_))
220
+ assert(!point1_.contains?(point3_))
221
+ end
222
+
223
+
224
+ def test_overlaps
225
+ point1_ = @factory.point(11, 12)
226
+ point2_ = @factory.point(11, 12)
227
+ point3_ = @factory.point(12, 12)
228
+ assert(!point1_.overlaps?(point2_))
229
+ assert(!point1_.overlaps?(point3_))
230
+ end
231
+
232
+
233
+ def test_distance
234
+ point1_ = @factory.point(11, 12)
235
+ point2_ = @factory.point(11, 12)
236
+ point3_ = @factory.point(13, 12)
237
+ assert_in_delta(0, point1_.distance(point2_), 0.0001)
238
+ assert_in_delta(217773, point1_.distance(point3_), 1)
239
+ end
240
+
241
+
242
+ def test_convex_hull
243
+ point_ = @factory.point(11, 12)
244
+ hull_ = point_.convex_hull
245
+ assert_close_enough(point_, hull_)
246
+ end
247
+
248
+
249
+ def test_intersection
250
+ point1_ = @factory.point(11, 12)
251
+ point2_ = @factory.point(11, 12)
252
+ point3_ = @factory.point(12, 12)
253
+ assert_close_enough(point1_, point1_.intersection(point2_))
254
+ int13_ = point1_.intersection(point3_)
255
+ assert_equal(::RGeo::Features::GeometryCollection, int13_.geometry_type)
256
+ assert(int13_.is_empty?)
257
+ end
258
+
259
+
260
+ def test_union
261
+ point1_ = @factory.point(11, 12)
262
+ point2_ = @factory.point(11, 12)
263
+ point3_ = @factory.point(12, 12)
264
+ union12_ = point1_.union(point2_)
265
+ union13_ = point1_.union(point3_)
266
+ assert_close_enough(point1_, union12_)
267
+ assert_equal(::RGeo::Features::MultiPoint, union13_.geometry_type)
268
+ assert_contains_approx(point1_, union13_)
269
+ assert_contains_approx(point3_, union13_)
270
+ end
271
+
272
+
273
+ def test_difference
274
+ point1_ = @factory.point(11, 12)
275
+ point2_ = @factory.point(11, 12)
276
+ point3_ = @factory.point(12, 12)
277
+ diff12_ = point1_.difference(point2_)
278
+ diff13_ = point1_.difference(point3_)
279
+ assert_equal(::RGeo::Features::GeometryCollection, diff12_.geometry_type)
280
+ assert(diff12_.is_empty?)
281
+ assert_close_enough(point1_, diff13_)
282
+ end
283
+
284
+
285
+ def test_sym_difference
286
+ point1_ = @factory.point(11, 12)
287
+ point2_ = @factory.point(11, 12)
288
+ point3_ = @factory.point(12, 12)
289
+ diff12_ = point1_.sym_difference(point2_)
290
+ diff13_ = point1_.sym_difference(point3_)
291
+ assert_equal(::RGeo::Features::GeometryCollection, diff12_.geometry_type)
292
+ assert(diff12_.is_empty?)
293
+ assert_equal(::RGeo::Features::MultiPoint, diff13_.geometry_type)
294
+ assert_contains_approx(point1_, diff13_)
295
+ assert_contains_approx(point3_, diff13_)
296
+ end
297
+
298
+
299
+ end
300
+
301
+ end
302
+ end
303
+ end