rgeo 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +29 -0
- data/ext/geos_c_impl/Makefile_2.2.3 +260 -0
- data/ext/geos_c_impl/coordinates.c +65 -0
- data/ext/geos_c_impl/coordinates.h +2 -0
- data/ext/geos_c_impl/extconf.rb +19 -43
- data/ext/geos_c_impl/geometry.c +24 -0
- data/ext/geos_c_impl/geometry_collection.c +99 -1
- data/ext/geos_c_impl/geos_c_impl_2.2.3.bundle +0 -0
- data/ext/geos_c_impl/line_string.c +38 -0
- data/ext/geos_c_impl/mkmf.log +123 -0
- data/ext/geos_c_impl/point.c +27 -0
- data/ext/geos_c_impl/polygon.c +26 -0
- data/ext/proj4_c_impl/Makefile_2.2.3 +260 -0
- data/ext/proj4_c_impl/extconf.rb +32 -32
- data/ext/proj4_c_impl/mkmf.log +47 -0
- data/ext/proj4_c_impl/proj4_c_impl_2.2.3.bundle +0 -0
- data/lib/rgeo.rb +10 -11
- data/lib/rgeo/cartesian.rb +7 -12
- data/lib/rgeo/cartesian/analysis.rb +13 -26
- data/lib/rgeo/cartesian/bounding_box.rb +45 -114
- data/lib/rgeo/cartesian/calculations.rb +3 -21
- data/lib/rgeo/cartesian/factory.rb +101 -122
- data/lib/rgeo/cartesian/feature_classes.rb +9 -59
- data/lib/rgeo/cartesian/feature_methods.rb +15 -45
- data/lib/rgeo/cartesian/interface.rb +6 -17
- data/lib/rgeo/coord_sys.rb +9 -15
- data/lib/rgeo/coord_sys/cs/entities.rb +84 -330
- data/lib/rgeo/coord_sys/cs/factories.rb +2 -32
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +52 -80
- data/lib/rgeo/coord_sys/proj4.rb +28 -67
- data/lib/rgeo/coord_sys/proj4_c_impl.bundle +0 -0
- data/lib/rgeo/coord_sys/srs_database/interface.rb +4 -24
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +20 -38
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +6 -22
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +6 -21
- data/lib/rgeo/error.rb +0 -6
- data/lib/rgeo/feature.rb +18 -23
- data/lib/rgeo/feature/curve.rb +0 -14
- data/lib/rgeo/feature/factory.rb +13 -38
- data/lib/rgeo/feature/factory_generator.rb +4 -16
- data/lib/rgeo/feature/geometry.rb +18 -60
- data/lib/rgeo/feature/geometry_collection.rb +3 -17
- data/lib/rgeo/feature/line.rb +0 -10
- data/lib/rgeo/feature/line_string.rb +1 -13
- data/lib/rgeo/feature/linear_ring.rb +0 -9
- data/lib/rgeo/feature/mixins.rb +11 -36
- data/lib/rgeo/feature/multi_curve.rb +0 -11
- data/lib/rgeo/feature/multi_line_string.rb +0 -9
- data/lib/rgeo/feature/multi_point.rb +0 -9
- data/lib/rgeo/feature/multi_polygon.rb +0 -9
- data/lib/rgeo/feature/multi_surface.rb +0 -12
- data/lib/rgeo/feature/point.rb +0 -13
- data/lib/rgeo/feature/polygon.rb +1 -14
- data/lib/rgeo/feature/surface.rb +0 -12
- data/lib/rgeo/feature/types.rb +19 -61
- data/lib/rgeo/geographic.rb +10 -15
- data/lib/rgeo/geographic/factory.rb +126 -147
- data/lib/rgeo/geographic/interface.rb +67 -81
- data/lib/rgeo/geographic/proj4_projector.rb +13 -37
- data/lib/rgeo/geographic/projected_feature_classes.rb +7 -66
- data/lib/rgeo/geographic/projected_feature_methods.rb +15 -80
- data/lib/rgeo/geographic/projected_window.rb +15 -67
- data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -56
- data/lib/rgeo/geographic/spherical_feature_classes.rb +9 -68
- data/lib/rgeo/geographic/spherical_feature_methods.rb +18 -51
- data/lib/rgeo/geographic/spherical_math.rb +26 -51
- data/lib/rgeo/geos.rb +23 -20
- data/lib/rgeo/geos/capi_factory.rb +125 -131
- data/lib/rgeo/geos/capi_feature_classes.rb +21 -88
- data/lib/rgeo/geos/ffi_factory.rb +90 -143
- data/lib/rgeo/geos/ffi_feature_classes.rb +8 -63
- data/lib/rgeo/geos/ffi_feature_methods.rb +46 -162
- data/lib/rgeo/geos/geos_c_impl.bundle +0 -0
- data/lib/rgeo/geos/interface.rb +4 -23
- data/lib/rgeo/geos/utils.rb +4 -19
- data/lib/rgeo/geos/zm_factory.rb +82 -131
- data/lib/rgeo/geos/zm_feature_classes.rb +8 -63
- data/lib/rgeo/geos/zm_feature_methods.rb +34 -107
- data/lib/rgeo/impl_helper.rb +8 -13
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +27 -71
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +10 -28
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +21 -57
- data/lib/rgeo/impl_helper/basic_point_methods.rb +12 -30
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +9 -28
- data/lib/rgeo/impl_helper/math.rb +4 -10
- data/lib/rgeo/impl_helper/utils.rb +2 -10
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep.rb +4 -9
- data/lib/rgeo/wkrep/wkb_generator.rb +22 -46
- data/lib/rgeo/wkrep/wkb_parser.rb +25 -52
- data/lib/rgeo/wkrep/wkt_generator.rb +39 -69
- data/lib/rgeo/wkrep/wkt_parser.rb +52 -89
- data/lib/rgeo/yaml.rb +1 -7
- data/test/common/factory_tests.rb +4 -19
- data/test/common/geometry_collection_tests.rb +6 -39
- data/test/common/line_string_tests.rb +10 -39
- data/test/common/multi_line_string_tests.rb +10 -30
- data/test/common/multi_point_tests.rb +15 -34
- data/test/common/multi_polygon_tests.rb +26 -28
- data/test/common/point_tests.rb +37 -59
- data/test/common/polygon_tests.rb +16 -25
- data/test/coord_sys/tc_ogc_cs.rb +151 -186
- data/test/coord_sys/tc_proj4.rb +35 -60
- data/test/coord_sys/tc_proj4_srs_data.rb +15 -24
- data/test/coord_sys/tc_sr_org.rb +11 -19
- data/test/coord_sys/tc_url_reader.rb +13 -23
- data/test/geos_capi/tc_factory.rb +7 -16
- data/test/geos_capi/tc_geometry_collection.rb +6 -14
- data/test/geos_capi/tc_line_string.rb +7 -15
- data/test/geos_capi/tc_misc.rb +26 -41
- data/test/geos_capi/tc_multi_line_string.rb +6 -14
- data/test/geos_capi/tc_multi_point.rb +7 -15
- data/test/geos_capi/tc_multi_polygon.rb +8 -18
- data/test/geos_capi/tc_parsing_unparsing.rb +11 -21
- data/test/geos_capi/tc_point.rb +12 -26
- data/test/geos_capi/tc_polygon.rb +52 -17
- data/test/geos_capi/tc_zmfactory.rb +7 -18
- data/test/geos_ffi/tc_factory.rb +7 -16
- data/test/geos_ffi/tc_geometry_collection.rb +7 -15
- data/test/geos_ffi/tc_line_string.rb +7 -15
- data/test/geos_ffi/tc_misc.rb +8 -18
- data/test/geos_ffi/tc_multi_line_string.rb +7 -15
- data/test/geos_ffi/tc_multi_point.rb +8 -16
- data/test/geos_ffi/tc_multi_polygon.rb +9 -18
- data/test/geos_ffi/tc_parsing_unparsing.rb +14 -24
- data/test/geos_ffi/tc_point.rb +13 -28
- data/test/geos_ffi/tc_polygon.rb +7 -17
- data/test/geos_ffi/tc_zmfactory.rb +8 -19
- data/test/projected_geographic/tc_factory.rb +7 -15
- data/test/projected_geographic/tc_geometry_collection.rb +7 -15
- data/test/projected_geographic/tc_line_string.rb +7 -15
- data/test/projected_geographic/tc_multi_line_string.rb +7 -16
- data/test/projected_geographic/tc_multi_point.rb +8 -17
- data/test/projected_geographic/tc_multi_polygon.rb +8 -16
- data/test/projected_geographic/tc_point.rb +11 -23
- data/test/projected_geographic/tc_polygon.rb +7 -15
- data/test/simple_cartesian/tc_calculations.rb +6 -22
- data/test/simple_cartesian/tc_factory.rb +7 -16
- data/test/simple_cartesian/tc_geometry_collection.rb +6 -15
- data/test/simple_cartesian/tc_line_string.rb +6 -15
- data/test/simple_cartesian/tc_multi_line_string.rb +6 -15
- data/test/simple_cartesian/tc_multi_point.rb +7 -16
- data/test/simple_cartesian/tc_multi_polygon.rb +7 -16
- data/test/simple_cartesian/tc_point.rb +10 -21
- data/test/simple_cartesian/tc_polygon.rb +6 -15
- data/test/simple_mercator/tc_factory.rb +6 -14
- data/test/simple_mercator/tc_geometry_collection.rb +6 -14
- data/test/simple_mercator/tc_line_string.rb +6 -14
- data/test/simple_mercator/tc_multi_line_string.rb +6 -15
- data/test/simple_mercator/tc_multi_point.rb +7 -16
- data/test/simple_mercator/tc_multi_polygon.rb +7 -15
- data/test/simple_mercator/tc_point.rb +11 -24
- data/test/simple_mercator/tc_polygon.rb +6 -14
- data/test/simple_mercator/tc_window.rb +10 -34
- data/test/spherical_geographic/tc_calculations.rb +5 -32
- data/test/spherical_geographic/tc_factory.rb +6 -15
- data/test/spherical_geographic/tc_geometry_collection.rb +6 -15
- data/test/spherical_geographic/tc_line_string.rb +6 -15
- data/test/spherical_geographic/tc_multi_line_string.rb +6 -15
- data/test/spherical_geographic/tc_multi_point.rb +7 -16
- data/test/spherical_geographic/tc_multi_polygon.rb +7 -16
- data/test/spherical_geographic/tc_point.rb +10 -22
- data/test/spherical_geographic/tc_polygon.rb +6 -15
- data/test/tc_cartesian_analysis.rb +4 -16
- data/test/tc_cartesian_bbox.rb +7 -21
- data/test/tc_mixins.rb +8 -25
- data/test/tc_oneoff.rb +5 -13
- data/test/tc_types.rb +7 -16
- data/test/wkrep/tc_wkb_generator.rb +63 -97
- data/test/wkrep/tc_wkb_parser.rb +63 -100
- data/test/wkrep/tc_wkt_generator.rb +54 -92
- data/test/wkrep/tc_wkt_parser.rb +84 -133
- metadata +39 -9
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +0 -166
- data/test/coord_sys/tc_active_record_table.rb +0 -79
data/test/common/point_tests.rb
CHANGED
@@ -4,40 +4,32 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
|
7
|
+
require "rgeo"
|
9
8
|
|
10
9
|
module RGeo
|
11
|
-
module Tests
|
12
|
-
module Common
|
13
|
-
|
14
|
-
module PointTests # :nodoc:
|
15
|
-
|
16
|
-
|
10
|
+
module Tests # :nodoc:
|
11
|
+
module Common # :nodoc:
|
12
|
+
module PointTests # :nodoc:
|
17
13
|
def assert_close_enough(p1_, p2_)
|
18
14
|
assert((p1_.x - p2_.x).abs < 0.00000001 && (p1_.y - p2_.y).abs < 0.00000001)
|
19
15
|
end
|
20
16
|
|
21
|
-
|
22
17
|
def assert_contains_approx(p_, mp_)
|
23
|
-
assert(mp_.any?{ |q_| (p_.x - q_.x).abs < 0.00000001 && (p_.y - q_.y).abs < 0.00000001 })
|
18
|
+
assert(mp_.any? { |q_| (p_.x - q_.x).abs < 0.00000001 && (p_.y - q_.y).abs < 0.00000001 })
|
24
19
|
end
|
25
20
|
|
26
|
-
|
27
21
|
def test_creation
|
28
22
|
point_ = @factory.point(21, -22)
|
29
23
|
assert_equal(21, point_.x)
|
30
24
|
assert_equal(-22, point_.y)
|
31
25
|
end
|
32
26
|
|
33
|
-
|
34
27
|
def test_wkt_creation
|
35
|
-
point1_ = @factory.parse_wkt(
|
28
|
+
point1_ = @factory.parse_wkt("Point (21 -22)")
|
36
29
|
assert_equal(21, point1_.x)
|
37
30
|
assert_equal(-22, point1_.y)
|
38
31
|
end
|
39
32
|
|
40
|
-
|
41
33
|
def test_clone
|
42
34
|
point1_ = @factory.point(11, 12)
|
43
35
|
point2_ = point1_.clone
|
@@ -48,7 +40,6 @@ module RGeo
|
|
48
40
|
assert_not_equal(point2_, point4_)
|
49
41
|
end
|
50
42
|
|
51
|
-
|
52
43
|
def test_type_check
|
53
44
|
point_ = @factory.point(21, 22)
|
54
45
|
assert(::RGeo::Feature::Geometry.check_type(point_))
|
@@ -57,31 +48,26 @@ module RGeo
|
|
57
48
|
assert(!::RGeo::Feature::Curve.check_type(point_))
|
58
49
|
end
|
59
50
|
|
60
|
-
|
61
51
|
def test_geometry_type
|
62
52
|
point_ = @factory.point(11, 12)
|
63
53
|
assert_equal(::RGeo::Feature::Point, point_.geometry_type)
|
64
54
|
end
|
65
55
|
|
66
|
-
|
67
56
|
def test_dimension
|
68
57
|
point_ = @factory.point(11, 12)
|
69
58
|
assert_equal(0, point_.dimension)
|
70
59
|
end
|
71
60
|
|
72
|
-
|
73
61
|
def test_envelope
|
74
62
|
point_ = @factory.point(11, 12)
|
75
63
|
assert_close_enough(point_, point_.envelope)
|
76
64
|
end
|
77
65
|
|
78
|
-
|
79
66
|
def test_as_text
|
80
67
|
point_ = @factory.point(11, 12)
|
81
|
-
assert_equal(
|
68
|
+
assert_equal("POINT (11.0 12.0)", point_.as_text)
|
82
69
|
end
|
83
70
|
|
84
|
-
|
85
71
|
def test_as_text_wkt_round_trip
|
86
72
|
point1_ = @factory.point(11, 12)
|
87
73
|
text_ = point1_.as_text
|
@@ -89,7 +75,6 @@ module RGeo
|
|
89
75
|
assert_equal(point2_, point1_)
|
90
76
|
end
|
91
77
|
|
92
|
-
|
93
78
|
def test_as_binary_wkb_round_trip
|
94
79
|
point1_ = @factory.point(211, 12)
|
95
80
|
binary_ = point1_.as_binary
|
@@ -97,26 +82,22 @@ module RGeo
|
|
97
82
|
assert_equal(point2_, point1_)
|
98
83
|
end
|
99
84
|
|
100
|
-
|
101
85
|
def test_is_empty
|
102
86
|
point1_ = @factory.point(0, 0)
|
103
87
|
assert(!point1_.is_empty?)
|
104
88
|
end
|
105
89
|
|
106
|
-
|
107
90
|
def test_is_simple
|
108
91
|
point1_ = @factory.point(0, 0)
|
109
92
|
assert(point1_.is_simple?)
|
110
93
|
end
|
111
94
|
|
112
|
-
|
113
95
|
def test_boundary
|
114
96
|
point_ = @factory.point(11, 12)
|
115
97
|
boundary_ = point_.boundary
|
116
98
|
assert(boundary_.is_empty?)
|
117
99
|
end
|
118
100
|
|
119
|
-
|
120
101
|
def test_equals
|
121
102
|
point1_ = @factory.point(11, 12)
|
122
103
|
point2_ = @factory.point(11, 12)
|
@@ -129,11 +110,10 @@ module RGeo
|
|
129
110
|
assert(point1_ != point3_)
|
130
111
|
assert(!point1_.rep_equals?(point3_))
|
131
112
|
assert(!point1_.eql?(point3_))
|
132
|
-
assert(point1_ !=
|
133
|
-
assert(!point1_.eql?(
|
113
|
+
assert(point1_ != "hello")
|
114
|
+
assert(!point1_.eql?("hello"))
|
134
115
|
end
|
135
116
|
|
136
|
-
|
137
117
|
def test_out_of_order_is_not_equal
|
138
118
|
point1_ = @factory.point(11, 12)
|
139
119
|
point2_ = @factory.point(12, 11)
|
@@ -141,20 +121,17 @@ module RGeo
|
|
141
121
|
assert_not_equal(point1_.hash, point2_.hash)
|
142
122
|
end
|
143
123
|
|
144
|
-
|
145
124
|
def test_hashes_equal_for_representationally_equivalent_objects
|
146
125
|
point1_ = @factory.point(11, 12)
|
147
126
|
point2_ = @factory.point(11, 12)
|
148
127
|
assert_equal(point1_.hash, point2_.hash)
|
149
128
|
end
|
150
129
|
|
151
|
-
|
152
130
|
def test_point_as_hash_key
|
153
|
-
hash_ = {@factory.point(11, 12) => :hello}
|
131
|
+
hash_ = { @factory.point(11, 12) => :hello }
|
154
132
|
assert_equal(:hello, hash_[@factory.point(11, 12)])
|
155
133
|
end
|
156
134
|
|
157
|
-
|
158
135
|
def test_disjoint
|
159
136
|
point1_ = @factory.point(11, 12)
|
160
137
|
point2_ = @factory.point(11, 12)
|
@@ -163,7 +140,6 @@ module RGeo
|
|
163
140
|
assert(point1_.disjoint?(point3_))
|
164
141
|
end
|
165
142
|
|
166
|
-
|
167
143
|
def test_intersects
|
168
144
|
point1_ = @factory.point(11, 12)
|
169
145
|
point2_ = @factory.point(11, 12)
|
@@ -172,7 +148,6 @@ module RGeo
|
|
172
148
|
assert(!point1_.intersects?(point3_))
|
173
149
|
end
|
174
150
|
|
175
|
-
|
176
151
|
def test_touches
|
177
152
|
point1_ = @factory.point(11, 12)
|
178
153
|
point2_ = @factory.point(11, 12)
|
@@ -181,7 +156,6 @@ module RGeo
|
|
181
156
|
assert(!point1_.touches?(point3_))
|
182
157
|
end
|
183
158
|
|
184
|
-
|
185
159
|
def test_crosses
|
186
160
|
point1_ = @factory.point(11, 12)
|
187
161
|
point2_ = @factory.point(11, 12)
|
@@ -190,7 +164,6 @@ module RGeo
|
|
190
164
|
assert(!point1_.crosses?(point3_))
|
191
165
|
end
|
192
166
|
|
193
|
-
|
194
167
|
def test_within
|
195
168
|
point1_ = @factory.point(11, 12)
|
196
169
|
point2_ = @factory.point(11, 12)
|
@@ -199,7 +172,6 @@ module RGeo
|
|
199
172
|
assert(!point1_.within?(point3_))
|
200
173
|
end
|
201
174
|
|
202
|
-
|
203
175
|
def test_contains
|
204
176
|
point1_ = @factory.point(11, 12)
|
205
177
|
point2_ = @factory.point(11, 12)
|
@@ -208,7 +180,6 @@ module RGeo
|
|
208
180
|
assert(!point1_.contains?(point3_))
|
209
181
|
end
|
210
182
|
|
211
|
-
|
212
183
|
def test_overlaps
|
213
184
|
point1_ = @factory.point(11, 12)
|
214
185
|
point2_ = @factory.point(11, 12)
|
@@ -217,13 +188,11 @@ module RGeo
|
|
217
188
|
assert(!point1_.overlaps?(point3_))
|
218
189
|
end
|
219
190
|
|
220
|
-
|
221
191
|
def test_convex_hull
|
222
192
|
point_ = @factory.point(11, 12)
|
223
193
|
assert_close_enough(point_, point_.convex_hull)
|
224
194
|
end
|
225
195
|
|
226
|
-
|
227
196
|
def test_intersection
|
228
197
|
point1_ = @factory.point(11, 12)
|
229
198
|
point2_ = @factory.point(11, 12)
|
@@ -233,7 +202,6 @@ module RGeo
|
|
233
202
|
assert(int13_.is_empty?)
|
234
203
|
end
|
235
204
|
|
236
|
-
|
237
205
|
def test_union
|
238
206
|
point1_ = @factory.point(11, 12)
|
239
207
|
point2_ = @factory.point(11, 12)
|
@@ -246,7 +214,6 @@ module RGeo
|
|
246
214
|
assert_contains_approx(point3_, union13_)
|
247
215
|
end
|
248
216
|
|
249
|
-
|
250
217
|
def test_difference
|
251
218
|
point1_ = @factory.point(11, 12)
|
252
219
|
point2_ = @factory.point(11, 12)
|
@@ -258,7 +225,6 @@ module RGeo
|
|
258
225
|
assert_close_enough(point1_, diff13_)
|
259
226
|
end
|
260
227
|
|
261
|
-
|
262
228
|
def test_sym_difference
|
263
229
|
point1_ = @factory.point(11, 12)
|
264
230
|
point2_ = @factory.point(11, 12)
|
@@ -272,7 +238,6 @@ module RGeo
|
|
272
238
|
assert_contains_approx(point3_, diff13_)
|
273
239
|
end
|
274
240
|
|
275
|
-
|
276
241
|
def test_buffer
|
277
242
|
point_ = @factory.point(11, 12)
|
278
243
|
buffer_ = point_.buffer(4)
|
@@ -280,7 +245,6 @@ module RGeo
|
|
280
245
|
assert_equal(33, buffer_.exterior_ring.num_points)
|
281
246
|
end
|
282
247
|
|
283
|
-
|
284
248
|
def test_3dz_creation
|
285
249
|
point_ = @zfactory.point(11, 12, 13)
|
286
250
|
assert_equal(11, point_.x)
|
@@ -292,7 +256,6 @@ module RGeo
|
|
292
256
|
assert_equal(0, point2_.z)
|
293
257
|
end
|
294
258
|
|
295
|
-
|
296
259
|
def test_3dm_creation
|
297
260
|
point_ = @mfactory.point(11, 12, 13)
|
298
261
|
assert_equal(11, point_.x)
|
@@ -304,7 +267,6 @@ module RGeo
|
|
304
267
|
assert_equal(0, point2_.m)
|
305
268
|
end
|
306
269
|
|
307
|
-
|
308
270
|
def test_4d_creation
|
309
271
|
point_ = @zmfactory.point(11, 12, 13, 14)
|
310
272
|
assert_equal(11, point_.x)
|
@@ -318,13 +280,12 @@ module RGeo
|
|
318
280
|
assert_equal(0, point2_.m)
|
319
281
|
end
|
320
282
|
|
321
|
-
|
322
283
|
def test_wkt_creation_3d
|
323
|
-
point2_ = @zfactory.parse_wkt(
|
284
|
+
point2_ = @zfactory.parse_wkt("POINT(11 12 13)")
|
324
285
|
assert_equal(11, point2_.x)
|
325
286
|
assert_equal(12, point2_.y)
|
326
287
|
assert_equal(13, point2_.z)
|
327
|
-
point1_ = @zfactory.parse_wkt(
|
288
|
+
point1_ = @zfactory.parse_wkt("POINT(21 22)")
|
328
289
|
assert_equal(21, point1_.x)
|
329
290
|
assert_equal(22, point1_.y)
|
330
291
|
# Z is undefined in this case.
|
@@ -332,7 +293,6 @@ module RGeo
|
|
332
293
|
# parser doesn't behave that way.
|
333
294
|
end
|
334
295
|
|
335
|
-
|
336
296
|
def test_marshal_roundtrip
|
337
297
|
point_ = @factory.point(11, 12)
|
338
298
|
data_ = ::Marshal.dump(point_)
|
@@ -340,7 +300,6 @@ module RGeo
|
|
340
300
|
assert_equal(point_, point2_)
|
341
301
|
end
|
342
302
|
|
343
|
-
|
344
303
|
def test_marshal_roundtrip_3d
|
345
304
|
point_ = @zfactory.point(11, 12, 13)
|
346
305
|
data_ = ::Marshal.dump(point_)
|
@@ -348,7 +307,6 @@ module RGeo
|
|
348
307
|
assert_equal(point_, point2_)
|
349
308
|
end
|
350
309
|
|
351
|
-
|
352
310
|
def test_marshal_roundtrip_4d
|
353
311
|
point_ = @zmfactory.point(11, 12, 13, 14)
|
354
312
|
data_ = ::Marshal.dump(point_)
|
@@ -356,6 +314,31 @@ module RGeo
|
|
356
314
|
assert_equal(point_, point2_)
|
357
315
|
end
|
358
316
|
|
317
|
+
def test_coordinates
|
318
|
+
point_ = @factory.point(11.0, 12.0)
|
319
|
+
assert_equal([11.0, 12.0], point_.coordinates)
|
320
|
+
end
|
321
|
+
|
322
|
+
def test_coordinates_3dz
|
323
|
+
point_ = @zfactory.point(11, 12, 13)
|
324
|
+
assert_equal([11.0, 12.0, 13.0], point_.coordinates)
|
325
|
+
point2_ = @zfactory.point(21, 22)
|
326
|
+
assert_equal([21.0, 22.0, 0.0], point2_.coordinates)
|
327
|
+
end
|
328
|
+
|
329
|
+
def test_coordinates_3dm
|
330
|
+
point_ = @mfactory.point(11, 12, 13)
|
331
|
+
assert_equal([11.0, 12.0, 13.0], point_.coordinates)
|
332
|
+
point2_ = @mfactory.point(21, 22)
|
333
|
+
assert_equal([21.0, 22.0, 0.0], point2_.coordinates)
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_coordinates_4d
|
337
|
+
point_ = @zmfactory.point(11, 12, 13, 14)
|
338
|
+
assert_equal([11.0, 12.0, 13.0, 14.0], point_.coordinates)
|
339
|
+
point2_ = @zmfactory.point(21, 22)
|
340
|
+
assert_equal([21.0, 22.0, 0.0, 0.0], point2_.coordinates)
|
341
|
+
end
|
359
342
|
|
360
343
|
if ::RGeo.yaml_supported?
|
361
344
|
|
@@ -366,7 +349,6 @@ module RGeo
|
|
366
349
|
assert_equal(point_, point2_)
|
367
350
|
end
|
368
351
|
|
369
|
-
|
370
352
|
def test_psych_roundtrip_3d
|
371
353
|
point_ = @zfactory.point(11, 12, 13)
|
372
354
|
data_ = ::Psych.dump(point_)
|
@@ -374,7 +356,6 @@ module RGeo
|
|
374
356
|
assert_equal(point_, point2_)
|
375
357
|
end
|
376
358
|
|
377
|
-
|
378
359
|
def test_psych_roundtrip_4d
|
379
360
|
point_ = @zmfactory.point(11, 12, 13, 14)
|
380
361
|
data_ = ::Psych.dump(point_)
|
@@ -383,10 +364,7 @@ module RGeo
|
|
383
364
|
end
|
384
365
|
|
385
366
|
end
|
386
|
-
|
387
|
-
|
388
367
|
end
|
389
|
-
|
390
368
|
end
|
391
369
|
end
|
392
370
|
end
|
@@ -4,16 +4,12 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
|
7
|
+
require "rgeo"
|
9
8
|
|
10
9
|
module RGeo
|
11
|
-
module Tests
|
12
|
-
module Common
|
13
|
-
|
14
|
-
module PolygonTests # :nodoc:
|
15
|
-
|
16
|
-
|
10
|
+
module Tests # :nodoc:
|
11
|
+
module Common # :nodoc:
|
12
|
+
module PolygonTests # :nodoc:
|
17
13
|
def test_creation_simple
|
18
14
|
point1_ = @factory.point(0, 0)
|
19
15
|
point2_ = @factory.point(0, 1)
|
@@ -29,7 +25,6 @@ module RGeo
|
|
29
25
|
assert_nil(polygon_.interior_ring_n(-1))
|
30
26
|
end
|
31
27
|
|
32
|
-
|
33
28
|
def test_creation_one_hole
|
34
29
|
point1_ = @factory.point(0, 0)
|
35
30
|
point2_ = @factory.point(0, 10)
|
@@ -51,7 +46,6 @@ module RGeo
|
|
51
46
|
assert_nil(polygon_.interior_ring_n(-1))
|
52
47
|
end
|
53
48
|
|
54
|
-
|
55
49
|
def test_required_equivalences
|
56
50
|
point1_ = @factory.point(0, 0)
|
57
51
|
point2_ = @factory.point(0, 1)
|
@@ -67,7 +61,6 @@ module RGeo
|
|
67
61
|
assert(poly1_ == poly2_)
|
68
62
|
end
|
69
63
|
|
70
|
-
|
71
64
|
def test_fully_equal
|
72
65
|
point1_ = @factory.point(0, 0)
|
73
66
|
point2_ = @factory.point(0, 1)
|
@@ -83,7 +76,6 @@ module RGeo
|
|
83
76
|
assert(poly1_.equals?(poly2_))
|
84
77
|
end
|
85
78
|
|
86
|
-
|
87
79
|
def test_geometrically_equal_but_ordered_different
|
88
80
|
point1_ = @factory.point(0, 0)
|
89
81
|
point2_ = @factory.point(0, 1)
|
@@ -96,7 +88,6 @@ module RGeo
|
|
96
88
|
assert(poly1_.equals?(poly2_))
|
97
89
|
end
|
98
90
|
|
99
|
-
|
100
91
|
def test_geometrically_equal_but_different_directions
|
101
92
|
point1_ = @factory.point(0, 0)
|
102
93
|
point2_ = @factory.point(0, 1)
|
@@ -109,7 +100,6 @@ module RGeo
|
|
109
100
|
assert(poly1_.equals?(poly2_))
|
110
101
|
end
|
111
102
|
|
112
|
-
|
113
103
|
def test_hashes_equal_for_representationally_equivalent_objects
|
114
104
|
point1_ = @factory.point(0, 0)
|
115
105
|
point2_ = @factory.point(0, 1)
|
@@ -124,9 +114,8 @@ module RGeo
|
|
124
114
|
assert_equal(poly1_.hash, poly2_.hash)
|
125
115
|
end
|
126
116
|
|
127
|
-
|
128
117
|
def test_wkt_creation_simple
|
129
|
-
parsed_poly_ = @factory.parse_wkt(
|
118
|
+
parsed_poly_ = @factory.parse_wkt("POLYGON((0 0, 0 1, 1 0, 0 0))")
|
130
119
|
point1_ = @factory.point(0, 0)
|
131
120
|
point2_ = @factory.point(0, 1)
|
132
121
|
point3_ = @factory.point(1, 0)
|
@@ -135,9 +124,8 @@ module RGeo
|
|
135
124
|
assert(built_poly_.eql?(parsed_poly_))
|
136
125
|
end
|
137
126
|
|
138
|
-
|
139
127
|
def test_wkt_creation_one_hole
|
140
|
-
parsed_poly_ = @factory.parse_wkt(
|
128
|
+
parsed_poly_ = @factory.parse_wkt("POLYGON((0 0, 0 10, 10 10, 10 0, 0 0), (4 4, 5 6, 6 4, 4 4))")
|
141
129
|
point1_ = @factory.point(0, 0)
|
142
130
|
point2_ = @factory.point(0, 10)
|
143
131
|
point3_ = @factory.point(10, 10)
|
@@ -151,7 +139,6 @@ module RGeo
|
|
151
139
|
assert(built_poly_.eql?(parsed_poly_))
|
152
140
|
end
|
153
141
|
|
154
|
-
|
155
142
|
def test_clone
|
156
143
|
point1_ = @factory.point(0, 0)
|
157
144
|
point2_ = @factory.point(0, 1)
|
@@ -164,7 +151,6 @@ module RGeo
|
|
164
151
|
assert_equal(0, poly2_.num_interior_rings)
|
165
152
|
end
|
166
153
|
|
167
|
-
|
168
154
|
def test_type_check
|
169
155
|
point1_ = @factory.point(0, 0)
|
170
156
|
point2_ = @factory.point(0, 1)
|
@@ -178,7 +164,6 @@ module RGeo
|
|
178
164
|
assert(::RGeo::Feature::Polygon.check_type(poly_))
|
179
165
|
end
|
180
166
|
|
181
|
-
|
182
167
|
def test_as_text_wkt_round_trip
|
183
168
|
point1_ = @factory.point(0, 0)
|
184
169
|
point2_ = @factory.point(0, 1)
|
@@ -190,7 +175,6 @@ module RGeo
|
|
190
175
|
assert(poly1_.eql?(poly2_))
|
191
176
|
end
|
192
177
|
|
193
|
-
|
194
178
|
def test_as_binary_wkb_round_trip
|
195
179
|
point1_ = @factory.point(0, 0)
|
196
180
|
point2_ = @factory.point(0, 1)
|
@@ -202,7 +186,6 @@ module RGeo
|
|
202
186
|
assert(poly1_.eql?(poly2_))
|
203
187
|
end
|
204
188
|
|
205
|
-
|
206
189
|
def test_dimension
|
207
190
|
point1_ = @factory.point(0, 0)
|
208
191
|
point2_ = @factory.point(0, 10)
|
@@ -217,7 +200,6 @@ module RGeo
|
|
217
200
|
assert_equal(2, poly_.dimension)
|
218
201
|
end
|
219
202
|
|
220
|
-
|
221
203
|
def test_is_empty
|
222
204
|
point1_ = @factory.point(0, 0)
|
223
205
|
point2_ = @factory.point(0, 1)
|
@@ -229,9 +211,18 @@ module RGeo
|
|
229
211
|
assert(poly2_.is_empty?)
|
230
212
|
end
|
231
213
|
|
214
|
+
def test_polygon_coordinates
|
215
|
+
coordinates = [
|
216
|
+
[[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0], [0.0, 0.0]],
|
217
|
+
[[0.25, 0.25], [0.75, 0.25], [0.75, 0.75], [0.25, 0.75], [0.25, 0.25]]
|
218
|
+
]
|
232
219
|
|
220
|
+
ring = @factory.line_string(coordinates.first.map { |(x, y)| @factory.point x, y })
|
221
|
+
inner_ring = @factory.line_string(coordinates.last.map { |(x, y)| @factory.point x, y })
|
222
|
+
polygon = @factory.polygon ring, [inner_ring]
|
223
|
+
assert_equal(polygon.coordinates, coordinates)
|
224
|
+
end
|
233
225
|
end
|
234
|
-
|
235
226
|
end
|
236
227
|
end
|
237
228
|
end
|