rgeo 0.3.3 → 0.3.4
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.
- data/History.rdoc +6 -0
- data/README.rdoc +1 -1
- data/Version +1 -1
- data/ext/geos_c_impl/extconf.rb +13 -13
- data/ext/geos_c_impl/factory.c +30 -18
- data/ext/geos_c_impl/factory.h +18 -12
- data/ext/geos_c_impl/geometry.c +11 -11
- data/ext/geos_c_impl/geometry.h +7 -7
- data/ext/geos_c_impl/geometry_collection.c +15 -15
- data/ext/geos_c_impl/geometry_collection.h +8 -8
- data/ext/geos_c_impl/line_string.c +14 -14
- data/ext/geos_c_impl/line_string.h +7 -7
- data/ext/geos_c_impl/main.c +7 -7
- data/ext/geos_c_impl/point.c +9 -9
- data/ext/geos_c_impl/point.h +7 -7
- data/ext/geos_c_impl/polygon.c +9 -9
- data/ext/geos_c_impl/polygon.h +7 -7
- data/ext/geos_c_impl/preface.h +7 -7
- data/ext/proj4_c_impl/extconf.rb +13 -13
- data/ext/proj4_c_impl/main.c +12 -12
- data/lib/rgeo.rb +26 -26
- data/lib/rgeo/cartesian.rb +12 -12
- data/lib/rgeo/cartesian/analysis.rb +26 -26
- data/lib/rgeo/cartesian/bounding_box.rb +83 -83
- data/lib/rgeo/cartesian/calculations.rb +36 -36
- data/lib/rgeo/cartesian/factory.rb +78 -78
- data/lib/rgeo/cartesian/feature_classes.rb +74 -74
- data/lib/rgeo/cartesian/feature_methods.rb +34 -34
- data/lib/rgeo/cartesian/interface.rb +33 -33
- data/lib/rgeo/coord_sys.rb +15 -15
- data/lib/rgeo/coord_sys/cs/entities.rb +533 -534
- data/lib/rgeo/coord_sys/cs/factories.rb +69 -69
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +44 -44
- data/lib/rgeo/coord_sys/proj4.rb +85 -85
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/interface.rb +44 -44
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +29 -29
- data/lib/rgeo/error.rb +17 -17
- data/lib/rgeo/feature.rb +15 -15
- data/lib/rgeo/feature/curve.rb +58 -58
- data/lib/rgeo/feature/factory.rb +84 -84
- data/lib/rgeo/feature/factory_generator.rb +32 -32
- data/lib/rgeo/feature/geometry.rb +215 -215
- data/lib/rgeo/feature/geometry_collection.rb +46 -46
- data/lib/rgeo/feature/line.rb +21 -21
- data/lib/rgeo/feature/line_string.rb +35 -35
- data/lib/rgeo/feature/linear_ring.rb +20 -20
- data/lib/rgeo/feature/mixins.rb +61 -61
- data/lib/rgeo/feature/multi_curve.rb +37 -37
- data/lib/rgeo/feature/multi_line_string.rb +20 -20
- data/lib/rgeo/feature/multi_point.rb +22 -22
- data/lib/rgeo/feature/multi_polygon.rb +28 -28
- data/lib/rgeo/feature/multi_surface.rb +39 -39
- data/lib/rgeo/feature/point.rb +42 -42
- data/lib/rgeo/feature/polygon.rb +50 -50
- data/lib/rgeo/feature/surface.rb +42 -42
- data/lib/rgeo/feature/types.rb +58 -58
- data/lib/rgeo/geographic.rb +14 -14
- data/lib/rgeo/geographic/factory.rb +87 -87
- data/lib/rgeo/geographic/interface.rb +55 -55
- data/lib/rgeo/geographic/proj4_projector.rb +35 -35
- data/lib/rgeo/geographic/projected_feature_classes.rb +95 -95
- data/lib/rgeo/geographic/projected_feature_methods.rb +81 -81
- data/lib/rgeo/geographic/projected_window.rb +103 -103
- data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -32
- data/lib/rgeo/geographic/spherical_feature_classes.rb +93 -93
- data/lib/rgeo/geographic/spherical_feature_methods.rb +25 -25
- data/lib/rgeo/geographic/spherical_math.rb +58 -58
- data/lib/rgeo/geos.rb +22 -17
- data/lib/rgeo/geos/factory.rb +93 -93
- data/lib/rgeo/geos/ffi_classes.rb +306 -231
- data/lib/rgeo/geos/ffi_factory.rb +100 -96
- data/lib/rgeo/geos/impl_additions.rb +22 -22
- data/lib/rgeo/geos/interface.rb +45 -45
- data/lib/rgeo/geos/zm_factory.rb +90 -90
- data/lib/rgeo/geos/zm_impl.rb +167 -167
- data/lib/rgeo/impl_helper.rb +11 -11
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +71 -71
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +29 -29
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +61 -61
- data/lib/rgeo/impl_helper/basic_point_methods.rb +43 -43
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +35 -35
- data/lib/rgeo/impl_helper/math.rb +13 -13
- data/lib/rgeo/version.rb +10 -10
- data/lib/rgeo/wkrep.rb +16 -16
- data/lib/rgeo/wkrep/wkb_generator.rb +51 -51
- data/lib/rgeo/wkrep/wkb_parser.rb +52 -52
- data/lib/rgeo/wkrep/wkt_generator.rb +51 -51
- data/lib/rgeo/wkrep/wkt_parser.rb +66 -66
- data/lib/rgeo/yaml.rb +14 -14
- data/test/common/geometry_collection_tests.rb +53 -53
- data/test/common/line_string_tests.rb +57 -57
- data/test/common/multi_line_string_tests.rb +43 -43
- data/test/common/multi_point_tests.rb +43 -43
- data/test/common/multi_polygon_tests.rb +43 -43
- data/test/common/point_tests.rb +75 -75
- data/test/common/polygon_tests.rb +37 -37
- data/test/coord_sys/tc_active_record_table.rb +25 -25
- data/test/coord_sys/tc_ogc_cs.rb +72 -72
- data/test/coord_sys/tc_proj4.rb +51 -51
- data/test/coord_sys/tc_proj4_srs_data.rb +17 -17
- data/test/coord_sys/tc_sr_org.rb +15 -15
- data/test/coord_sys/tc_url_reader.rb +19 -19
- data/test/geos_capi/tc_factory.rb +21 -21
- data/test/geos_capi/tc_geometry_collection.rb +15 -15
- data/test/geos_capi/tc_line_string.rb +15 -15
- data/test/geos_capi/tc_misc.rb +33 -22
- data/test/geos_capi/tc_multi_line_string.rb +15 -15
- data/test/geos_capi/tc_multi_point.rb +15 -15
- data/test/geos_capi/tc_multi_polygon.rb +15 -15
- data/test/geos_capi/tc_parsing_unparsing.rb +19 -19
- data/test/geos_capi/tc_point.rb +21 -21
- data/test/geos_capi/tc_polygon.rb +19 -19
- data/test/geos_capi/tc_zmfactory.rb +17 -17
- data/test/geos_ffi/tc_factory.rb +21 -21
- data/test/geos_ffi/tc_geometry_collection.rb +15 -15
- data/test/geos_ffi/tc_line_string.rb +15 -15
- data/test/geos_ffi/tc_misc.rb +49 -15
- data/test/geos_ffi/tc_multi_line_string.rb +15 -15
- data/test/geos_ffi/tc_multi_point.rb +15 -15
- data/test/geos_ffi/tc_multi_polygon.rb +15 -15
- data/test/geos_ffi/tc_parsing_unparsing.rb +19 -19
- data/test/geos_ffi/tc_point.rb +21 -21
- data/test/geos_ffi/tc_polygon.rb +19 -19
- data/test/geos_ffi/tc_zmfactory.rb +17 -17
- data/test/projected_geographic/tc_geometry_collection.rb +15 -15
- data/test/projected_geographic/tc_line_string.rb +15 -15
- data/test/projected_geographic/tc_multi_line_string.rb +15 -15
- data/test/projected_geographic/tc_multi_point.rb +15 -15
- data/test/projected_geographic/tc_multi_polygon.rb +15 -15
- data/test/projected_geographic/tc_point.rb +23 -23
- data/test/projected_geographic/tc_polygon.rb +15 -15
- data/test/simple_cartesian/tc_calculations.rb +31 -31
- data/test/simple_cartesian/tc_geometry_collection.rb +17 -17
- data/test/simple_cartesian/tc_line_string.rb +17 -17
- data/test/simple_cartesian/tc_multi_line_string.rb +17 -17
- data/test/simple_cartesian/tc_multi_point.rb +17 -17
- data/test/simple_cartesian/tc_multi_polygon.rb +17 -17
- data/test/simple_cartesian/tc_point.rb +21 -21
- data/test/simple_cartesian/tc_polygon.rb +17 -17
- data/test/simple_mercator/tc_geometry_collection.rb +15 -15
- data/test/simple_mercator/tc_line_string.rb +15 -15
- data/test/simple_mercator/tc_multi_line_string.rb +15 -15
- data/test/simple_mercator/tc_multi_point.rb +15 -15
- data/test/simple_mercator/tc_multi_polygon.rb +15 -15
- data/test/simple_mercator/tc_point.rb +23 -23
- data/test/simple_mercator/tc_polygon.rb +15 -15
- data/test/simple_mercator/tc_window.rb +50 -50
- data/test/spherical_geographic/tc_calculations.rb +47 -47
- data/test/spherical_geographic/tc_geometry_collection.rb +17 -17
- data/test/spherical_geographic/tc_line_string.rb +17 -17
- data/test/spherical_geographic/tc_multi_line_string.rb +17 -17
- data/test/spherical_geographic/tc_multi_point.rb +17 -17
- data/test/spherical_geographic/tc_multi_polygon.rb +17 -17
- data/test/spherical_geographic/tc_point.rb +23 -23
- data/test/spherical_geographic/tc_polygon.rb +17 -17
- data/test/tc_cartesian_analysis.rb +23 -23
- data/test/tc_mixins.rb +39 -39
- data/test/tc_oneoff.rb +15 -15
- data/test/tc_types.rb +17 -17
- data/test/wkrep/tc_wkb_generator.rb +67 -67
- data/test/wkrep/tc_wkb_parser.rb +73 -73
- data/test/wkrep/tc_wkt_generator.rb +75 -75
- data/test/wkrep/tc_wkt_parser.rb +97 -97
- metadata +3 -3
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Tests for the simple mercator window implementation
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -41,25 +41,25 @@ require 'rgeo'
|
|
41
41
|
module RGeo
|
42
42
|
module Tests # :nodoc:
|
43
43
|
module SimpleMercator # :nodoc:
|
44
|
-
|
44
|
+
|
45
45
|
class TestWindow < ::Test::Unit::TestCase # :nodoc:
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
def setup
|
49
49
|
@factory = ::RGeo::Geographic.simple_mercator_factory
|
50
50
|
end
|
51
|
-
|
52
|
-
|
51
|
+
|
52
|
+
|
53
53
|
def assert_close_enough(p1_, p2_)
|
54
54
|
assert((p1_.x - p2_.x).abs < 0.00001 && (p1_.y - p2_.y).abs < 0.00001)
|
55
55
|
end
|
56
|
-
|
57
|
-
|
56
|
+
|
57
|
+
|
58
58
|
def assert_contains_approx(p_, mp_)
|
59
59
|
assert(mp_.any?{ |q_| (p_.x - q_.x).abs < 0.00001 && (p_.y - q_.y).abs < 0.00001 })
|
60
60
|
end
|
61
|
-
|
62
|
-
|
61
|
+
|
62
|
+
|
63
63
|
def test_limits
|
64
64
|
limits_ = @factory.projection_limits_window
|
65
65
|
assert_in_delta(-20037508, limits_.x_min, 1)
|
@@ -67,8 +67,8 @@ module RGeo
|
|
67
67
|
assert_in_delta(20037508, limits_.x_max, 1)
|
68
68
|
assert_in_delta(20037508, limits_.y_max, 1)
|
69
69
|
end
|
70
|
-
|
71
|
-
|
70
|
+
|
71
|
+
|
72
72
|
def test_limits_unprojected
|
73
73
|
limits_ = @factory.projection_limits_window
|
74
74
|
assert_close_enough(@factory.point(-180, -85.051129), limits_.sw_point)
|
@@ -77,24 +77,24 @@ module RGeo
|
|
77
77
|
assert_close_enough(@factory.point(180, 85.051129), limits_.ne_point)
|
78
78
|
assert_close_enough(@factory.point(0, 0), limits_.center_point)
|
79
79
|
end
|
80
|
-
|
81
|
-
|
80
|
+
|
81
|
+
|
82
82
|
def test_center_point
|
83
83
|
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(-160, -30), @factory.point(170, 30))
|
84
84
|
assert_close_enough(@factory.point(5, 0), window1_.center_point)
|
85
85
|
window2_ = Geographic::ProjectedWindow.for_corners(@factory.point(160, -30), @factory.point(-170, 30))
|
86
86
|
assert_close_enough(@factory.point(175, 0), window2_.center_point)
|
87
87
|
end
|
88
|
-
|
89
|
-
|
88
|
+
|
89
|
+
|
90
90
|
def test_crosses_seam
|
91
91
|
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(-170, 30), @factory.point(170, 40))
|
92
92
|
assert(!window1_.crosses_seam?)
|
93
93
|
window2_ = Geographic::ProjectedWindow.for_corners(@factory.point(170, 30), @factory.point(-170, 40))
|
94
94
|
assert(window2_.crosses_seam?)
|
95
95
|
end
|
96
|
-
|
97
|
-
|
96
|
+
|
97
|
+
|
98
98
|
def test_degenerate
|
99
99
|
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(-20, 30), @factory.point(-10, 40))
|
100
100
|
assert(!window1_.degenerate?)
|
@@ -103,8 +103,8 @@ module RGeo
|
|
103
103
|
window3_ = Geographic::ProjectedWindow.for_corners(@factory.point(-20, 30), @factory.point(-10, 30))
|
104
104
|
assert(window3_.degenerate?)
|
105
105
|
end
|
106
|
-
|
107
|
-
|
106
|
+
|
107
|
+
|
108
108
|
def test_contains_point
|
109
109
|
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(-170, 30), @factory.point(-160, 40))
|
110
110
|
window2_ = Geographic::ProjectedWindow.for_corners(@factory.point(170, 30), @factory.point(-170, 40))
|
@@ -121,44 +121,44 @@ module RGeo
|
|
121
121
|
assert(window2_.contains_point?(point4_))
|
122
122
|
assert(!window2_.contains_point?(point5_))
|
123
123
|
end
|
124
|
-
|
125
|
-
|
124
|
+
|
125
|
+
|
126
126
|
def test_noseam_contains_window
|
127
127
|
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(10, 10), @factory.point(30, 30))
|
128
128
|
assert(window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 15), @factory.point(25, 25))))
|
129
|
-
|
129
|
+
|
130
130
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(5, 15), @factory.point(25, 25))))
|
131
131
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 15), @factory.point(35, 25))))
|
132
132
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(0, 15), @factory.point(5, 25))))
|
133
133
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(35, 15), @factory.point(40, 25))))
|
134
134
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(5, 15), @factory.point(35, 25))))
|
135
|
-
|
135
|
+
|
136
136
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 5), @factory.point(25, 25))))
|
137
137
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 15), @factory.point(25, 35))))
|
138
138
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 0), @factory.point(25, 5))))
|
139
139
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 35), @factory.point(25, 40))))
|
140
140
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 5), @factory.point(25, 35))))
|
141
|
-
|
141
|
+
|
142
142
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(170, 35), @factory.point(-170, 40))))
|
143
143
|
end
|
144
|
-
|
145
|
-
|
144
|
+
|
145
|
+
|
146
146
|
def test_seam_contains_window
|
147
147
|
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(160, 10), @factory.point(-160, 30))
|
148
148
|
assert(window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(175, 15), @factory.point(-175, 25))))
|
149
149
|
assert(window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(170, 15), @factory.point(175, 25))))
|
150
150
|
assert(window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(-175, 15), @factory.point(-170, 25))))
|
151
|
-
|
151
|
+
|
152
152
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(150, 15), @factory.point(170, 25))))
|
153
153
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(150, 15), @factory.point(-170, 25))))
|
154
154
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(-170, 15), @factory.point(-150, 25))))
|
155
155
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(170, 15), @factory.point(-150, 25))))
|
156
|
-
|
156
|
+
|
157
157
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(-150, 15), @factory.point(150, 25))))
|
158
158
|
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(150, 15), @factory.point(-150, 25))))
|
159
159
|
end
|
160
|
-
|
161
|
-
|
160
|
+
|
161
|
+
|
162
162
|
def test_scaled_by
|
163
163
|
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(20, -20), @factory.point(50, 40))
|
164
164
|
window1s_ = window1_.scaled_by(2, 1.5)
|
@@ -167,8 +167,8 @@ module RGeo
|
|
167
167
|
assert(!window1s_.contains_point?(@factory.point(0, -25)))
|
168
168
|
assert(!window1s_.contains_point?(@factory.point(10, -35)))
|
169
169
|
end
|
170
|
-
|
171
|
-
|
170
|
+
|
171
|
+
|
172
172
|
def test_scaled_by_across_seam
|
173
173
|
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(170, -20), @factory.point(-160, 40))
|
174
174
|
window1s_ = window1_.scaled_by(2, 1.5)
|
@@ -177,32 +177,32 @@ module RGeo
|
|
177
177
|
assert(!window1s_.contains_point?(@factory.point(150, -25)))
|
178
178
|
assert(!window1s_.contains_point?(@factory.point(-140, 45)))
|
179
179
|
end
|
180
|
-
|
181
|
-
|
180
|
+
|
181
|
+
|
182
182
|
def test_surrounding_point
|
183
183
|
window1_ = Geographic::ProjectedWindow.surrounding_point(@factory.point(20, -20), 1)
|
184
184
|
assert(window1_.contains_point?(@factory.point(20, -20)))
|
185
185
|
assert(!window1_.contains_point?(@factory.point(20, -21)))
|
186
186
|
assert(!window1_.contains_point?(@factory.point(19, -20)))
|
187
187
|
end
|
188
|
-
|
189
|
-
|
188
|
+
|
189
|
+
|
190
190
|
def test_bounding_1_point
|
191
191
|
window1_ = Geographic::ProjectedWindow.bounding_points([@factory.point(20, -20)]).with_margin(1)
|
192
192
|
assert(window1_.contains_point?(@factory.point(20, -20)))
|
193
193
|
assert(!window1_.contains_point?(@factory.point(20, -21)))
|
194
194
|
assert(!window1_.contains_point?(@factory.point(19, -20)))
|
195
195
|
end
|
196
|
-
|
197
|
-
|
196
|
+
|
197
|
+
|
198
198
|
def test_bounding_2_points
|
199
199
|
window1_ = Geographic::ProjectedWindow.bounding_points([@factory.point(10, 10), @factory.point(30, 30)])
|
200
200
|
assert(window1_.contains_point?(@factory.point(20, 20)))
|
201
201
|
assert(!window1_.contains_point?(@factory.point(5, 20)))
|
202
202
|
assert(!window1_.contains_point?(@factory.point(20, 35)))
|
203
203
|
end
|
204
|
-
|
205
|
-
|
204
|
+
|
205
|
+
|
206
206
|
def test_bounding_2_points_across_seam
|
207
207
|
window1_ = Geographic::ProjectedWindow.bounding_points([@factory.point(-170, 10), @factory.point(170, 30)])
|
208
208
|
assert(window1_.contains_point?(@factory.point(-174, 20)))
|
@@ -210,10 +210,10 @@ module RGeo
|
|
210
210
|
assert(!window1_.contains_point?(@factory.point(160, 20)))
|
211
211
|
assert(!window1_.contains_point?(@factory.point(-174, 35)))
|
212
212
|
end
|
213
|
-
|
214
|
-
|
213
|
+
|
214
|
+
|
215
215
|
end
|
216
|
-
|
216
|
+
|
217
217
|
end
|
218
218
|
end
|
219
219
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Tests for the internal calculations for simple spherical
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -41,91 +41,91 @@ require 'rgeo'
|
|
41
41
|
module RGeo
|
42
42
|
module Tests # :nodoc:
|
43
43
|
module SphericalGeographic # :nodoc:
|
44
|
-
|
44
|
+
|
45
45
|
class TestCalculations < ::Test::Unit::TestCase # :nodoc:
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
def assert_close_enough(v1_, v2_)
|
49
49
|
diff_ = (v1_ - v2_).abs
|
50
50
|
# denom_ = (v1_ + v2_).abs
|
51
51
|
# diff_ /= denom_ if denom_ > 0.01
|
52
52
|
assert(diff_ < 0.00000001, "#{v1_} is not close to #{v2_}")
|
53
53
|
end
|
54
|
-
|
55
|
-
|
54
|
+
|
55
|
+
|
56
56
|
def test_point_eql
|
57
57
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
58
58
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
59
59
|
assert_equal(point1_, point2_)
|
60
60
|
end
|
61
|
-
|
62
|
-
|
61
|
+
|
62
|
+
|
63
63
|
def test_point_from_latlng
|
64
64
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.from_latlon(45, -45)
|
65
65
|
assert_close_enough(0.5, point1_.x)
|
66
66
|
assert_close_enough(-0.5, point1_.y)
|
67
67
|
assert_close_enough(::Math.sqrt(2) * 0.5, point1_.z)
|
68
68
|
end
|
69
|
-
|
70
|
-
|
69
|
+
|
70
|
+
|
71
71
|
def test_point_dot_one
|
72
72
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 1, 1)
|
73
73
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 1, 1)
|
74
74
|
assert_close_enough(1.0, point1_ * point2_)
|
75
75
|
end
|
76
|
-
|
77
|
-
|
76
|
+
|
77
|
+
|
78
78
|
def test_point_dot_minusone
|
79
79
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 1, 1)
|
80
80
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(-1, -1, -1)
|
81
81
|
assert_close_enough(-1.0, point1_ * point2_)
|
82
82
|
end
|
83
|
-
|
84
|
-
|
83
|
+
|
84
|
+
|
85
85
|
def test_point_dot_zero
|
86
86
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 1, 0)
|
87
87
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, -1, 0)
|
88
88
|
assert_close_enough(0.0, point1_ * point2_)
|
89
89
|
end
|
90
|
-
|
91
|
-
|
90
|
+
|
91
|
+
|
92
92
|
def test_point_cross
|
93
93
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 1, 0)
|
94
94
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, -1, 0)
|
95
95
|
assert_close_enough(-1.0, (point1_ % point2_).z)
|
96
96
|
end
|
97
|
-
|
98
|
-
|
97
|
+
|
98
|
+
|
99
99
|
def test_point_cross_coincident
|
100
100
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
101
101
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
102
102
|
assert_nil(point1_ % point2_)
|
103
103
|
end
|
104
|
-
|
105
|
-
|
104
|
+
|
105
|
+
|
106
106
|
def test_point_cross_opposite
|
107
107
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
108
108
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(-1, 0, 0)
|
109
109
|
assert_nil(point1_ % point2_)
|
110
110
|
end
|
111
|
-
|
112
|
-
|
111
|
+
|
112
|
+
|
113
113
|
def test_arc_axis
|
114
114
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 1, 0)
|
115
115
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, -1, 0)
|
116
116
|
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
117
117
|
assert_close_enough(-1.0, arc1_.axis.z)
|
118
118
|
end
|
119
|
-
|
120
|
-
|
119
|
+
|
120
|
+
|
121
121
|
def test_arc_axis2
|
122
122
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
123
123
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0.000001, 0)
|
124
124
|
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
125
125
|
assert_close_enough(1.0, arc1_.axis.z)
|
126
126
|
end
|
127
|
-
|
128
|
-
|
127
|
+
|
128
|
+
|
129
129
|
def test_arc_intersects_point_off
|
130
130
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
131
131
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0.000002, 0)
|
@@ -133,8 +133,8 @@ module RGeo
|
|
133
133
|
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
134
134
|
assert_equal(false, arc1_.contains_point?(point3_))
|
135
135
|
end
|
136
|
-
|
137
|
-
|
136
|
+
|
137
|
+
|
138
138
|
def test_arc_intersects_point_between
|
139
139
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
140
140
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0.000002, 0)
|
@@ -142,16 +142,16 @@ module RGeo
|
|
142
142
|
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
143
143
|
assert_equal(true, arc1_.contains_point?(point3_))
|
144
144
|
end
|
145
|
-
|
146
|
-
|
145
|
+
|
146
|
+
|
147
147
|
def test_arc_intersects_point_endpoint
|
148
148
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
149
149
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0.000002, 0)
|
150
150
|
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
151
151
|
assert_equal(true, arc1_.contains_point?(point1_))
|
152
152
|
end
|
153
|
-
|
154
|
-
|
153
|
+
|
154
|
+
|
155
155
|
def test_arc_intersects_arc_true
|
156
156
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, 0.1, 1)
|
157
157
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, -0.1, 1)
|
@@ -161,8 +161,8 @@ module RGeo
|
|
161
161
|
arc2_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point3_, point4_)
|
162
162
|
assert_equal(true, arc1_.intersects_arc?(arc2_))
|
163
163
|
end
|
164
|
-
|
165
|
-
|
164
|
+
|
165
|
+
|
166
166
|
def test_arc_intersects_arc_parallel
|
167
167
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, 0.1, 1)
|
168
168
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, -0.1, 1)
|
@@ -172,8 +172,8 @@ module RGeo
|
|
172
172
|
arc2_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point3_, point4_)
|
173
173
|
assert_equal(false, arc1_.intersects_arc?(arc2_))
|
174
174
|
end
|
175
|
-
|
176
|
-
|
175
|
+
|
176
|
+
|
177
177
|
def test_arc_intersects_arc_separated_tee
|
178
178
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, 0.1, 1)
|
179
179
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, -0.1, 1)
|
@@ -183,8 +183,8 @@ module RGeo
|
|
183
183
|
arc2_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point3_, point4_)
|
184
184
|
assert_equal(false, arc1_.intersects_arc?(arc2_))
|
185
185
|
end
|
186
|
-
|
187
|
-
|
186
|
+
|
187
|
+
|
188
188
|
def test_arc_intersects_arc_connected_tee
|
189
189
|
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, 0.1, 1)
|
190
190
|
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, -0.1, 1)
|
@@ -194,10 +194,10 @@ module RGeo
|
|
194
194
|
arc2_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point3_, point4_)
|
195
195
|
assert_equal(true, arc1_.intersects_arc?(arc2_))
|
196
196
|
end
|
197
|
-
|
198
|
-
|
197
|
+
|
198
|
+
|
199
199
|
end
|
200
|
-
|
200
|
+
|
201
201
|
end
|
202
202
|
end
|
203
203
|
end
|