rgeo 0.1.21 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +11 -0
- data/README.rdoc +1 -1
- data/Spatial_Programming_With_RGeo.rdoc +382 -0
- data/Version +1 -1
- data/lib/active_record/connection_adapters/postgis_adapter.rb +1 -1
- data/lib/rgeo.rb +4 -4
- data/lib/rgeo/active_record/base_modifications.rb +1 -1
- data/lib/rgeo/all.rb +1 -1
- data/lib/rgeo/cartesian/bounding_box.rb +2 -2
- data/lib/rgeo/cartesian/factory.rb +18 -11
- data/lib/rgeo/cartesian/interface.rb +4 -4
- data/lib/rgeo/coord_sys.rb +8 -1
- data/lib/rgeo/coord_sys/proj4.rb +4 -4
- data/lib/rgeo/feature/factory.rb +68 -49
- data/lib/rgeo/feature/factory_generator.rb +2 -2
- data/lib/rgeo/feature/types.rb +4 -4
- data/lib/rgeo/geo_json/coder.rb +5 -5
- data/lib/rgeo/{geography.rb → geographic.rb} +15 -15
- data/lib/rgeo/{geography → geographic}/factory.rb +27 -20
- data/lib/rgeo/{geography → geographic}/interface.rb +43 -29
- data/lib/rgeo/{geography → geographic}/proj4_projector.rb +2 -2
- data/lib/rgeo/{geography → geographic}/projected_feature_classes.rb +2 -2
- data/lib/rgeo/{geography → geographic}/projected_feature_methods.rb +2 -2
- data/lib/rgeo/{geography → geographic}/projected_window.rb +5 -5
- data/lib/rgeo/{geography → geographic}/simple_mercator_projector.rb +2 -2
- data/lib/rgeo/{geography → geographic}/spherical_feature_classes.rb +2 -2
- data/lib/rgeo/{geography → geographic}/spherical_feature_methods.rb +2 -2
- data/lib/rgeo/{geography → geographic}/spherical_math.rb +1 -1
- data/lib/rgeo/geos/factory.rb +22 -15
- data/lib/rgeo/geos/interface.rb +3 -3
- data/lib/rgeo/geos/zm_factory.rb +20 -6
- data/lib/rgeo/impl_helper/basic_point_methods.rb +2 -2
- data/lib/rgeo/shapefile/reader.rb +5 -5
- data/lib/rgeo/wkrep/wkb_generator.rb +2 -2
- data/lib/rgeo/wkrep/wkb_parser.rb +4 -4
- data/lib/rgeo/wkrep/wkt_generator.rb +2 -2
- data/lib/rgeo/wkrep/wkt_parser.rb +7 -7
- data/test/active_record/common_setup_methods.rb +1 -1
- data/test/geos/tc_point.rb +3 -3
- data/test/geos/tc_zmfactory.rb +7 -7
- data/test/{projected_geography → projected_geographic}/tc_geometry_collection.rb +2 -2
- data/test/{projected_geography → projected_geographic}/tc_line_string.rb +2 -2
- data/test/{projected_geography → projected_geographic}/tc_multi_line_string.rb +2 -2
- data/test/{projected_geography → projected_geographic}/tc_multi_point.rb +2 -2
- data/test/{projected_geography → projected_geographic}/tc_multi_polygon.rb +3 -3
- data/test/{projected_geography → projected_geographic}/tc_point.rb +5 -5
- data/test/{projected_geography → projected_geographic}/tc_polygon.rb +2 -2
- data/test/shapefile/tc_shapelib_tests.rb +10 -10
- data/test/simple_cartesian/tc_point.rb +3 -3
- data/test/simple_mercator/tc_geometry_collection.rb +1 -1
- data/test/simple_mercator/tc_line_string.rb +1 -1
- data/test/simple_mercator/tc_multi_line_string.rb +1 -1
- data/test/simple_mercator/tc_multi_point.rb +1 -1
- data/test/simple_mercator/tc_multi_polygon.rb +2 -2
- data/test/simple_mercator/tc_point.rb +4 -4
- data/test/simple_mercator/tc_polygon.rb +1 -1
- data/test/simple_mercator/tc_window.rb +39 -39
- data/test/spherical_geographic/tc_calculations.rb +203 -0
- data/test/{spherical_geography → spherical_geographic}/tc_geometry_collection.rb +2 -2
- data/test/{spherical_geography → spherical_geographic}/tc_line_string.rb +2 -2
- data/test/{spherical_geography → spherical_geographic}/tc_multi_line_string.rb +2 -2
- data/test/{spherical_geography → spherical_geographic}/tc_multi_point.rb +2 -2
- data/test/{spherical_geography → spherical_geographic}/tc_multi_polygon.rb +3 -3
- data/test/{spherical_geography → spherical_geographic}/tc_point.rb +6 -6
- data/test/{spherical_geography → spherical_geographic}/tc_polygon.rb +2 -2
- data/test/tc_geojson.rb +3 -3
- data/test/tc_oneoff.rb +5 -5
- data/test/wkrep/tc_wkb_generator.rb +3 -3
- data/test/wkrep/tc_wkb_parser.rb +16 -16
- data/test/wkrep/tc_wkt_generator.rb +3 -3
- data/test/wkrep/tc_wkt_parser.rb +21 -21
- metadata +46 -44
- data/test/spherical_geography/tc_calculations.rb +0 -203
@@ -48,8 +48,8 @@ module RGeo
|
|
48
48
|
|
49
49
|
|
50
50
|
def create_factories
|
51
|
-
@factory = ::RGeo::
|
52
|
-
@lenient_factory = ::RGeo::
|
51
|
+
@factory = ::RGeo::Geographic.simple_mercator_factory
|
52
|
+
@lenient_factory = ::RGeo::Geographic.simple_mercator_factory(:lenient_multi_polygon_assertions => true)
|
53
53
|
end
|
54
54
|
|
55
55
|
|
@@ -48,10 +48,10 @@ module RGeo
|
|
48
48
|
|
49
49
|
|
50
50
|
def setup
|
51
|
-
@factory = ::RGeo::
|
52
|
-
@zfactory = ::RGeo::
|
53
|
-
@mfactory = ::RGeo::
|
54
|
-
@zmfactory = ::RGeo::
|
51
|
+
@factory = ::RGeo::Geographic.simple_mercator_factory
|
52
|
+
@zfactory = ::RGeo::Geographic.simple_mercator_factory(:has_z_coordinate => true)
|
53
|
+
@mfactory = ::RGeo::Geographic.simple_mercator_factory(:has_m_coordinate => true)
|
54
|
+
@zmfactory = ::RGeo::Geographic.simple_mercator_factory(:has_z_coordinate => true, :has_m_coordinate => true)
|
55
55
|
end
|
56
56
|
|
57
57
|
|
@@ -46,7 +46,7 @@ module RGeo
|
|
46
46
|
|
47
47
|
|
48
48
|
def setup
|
49
|
-
@factory = ::RGeo::
|
49
|
+
@factory = ::RGeo::Geographic.simple_mercator_factory
|
50
50
|
end
|
51
51
|
|
52
52
|
|
@@ -80,34 +80,34 @@ module RGeo
|
|
80
80
|
|
81
81
|
|
82
82
|
def test_center_point
|
83
|
-
window1_ =
|
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
|
-
window2_ =
|
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
88
|
|
89
89
|
|
90
90
|
def test_crosses_seam
|
91
|
-
window1_ =
|
91
|
+
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(-170, 30), @factory.point(170, 40))
|
92
92
|
assert(!window1_.crosses_seam?)
|
93
|
-
window2_ =
|
93
|
+
window2_ = Geographic::ProjectedWindow.for_corners(@factory.point(170, 30), @factory.point(-170, 40))
|
94
94
|
assert(window2_.crosses_seam?)
|
95
95
|
end
|
96
96
|
|
97
97
|
|
98
98
|
def test_degenerate
|
99
|
-
window1_ =
|
99
|
+
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(-20, 30), @factory.point(-10, 40))
|
100
100
|
assert(!window1_.degenerate?)
|
101
|
-
window2_ =
|
101
|
+
window2_ = Geographic::ProjectedWindow.for_corners(@factory.point(-20, 30), @factory.point(-20, 40))
|
102
102
|
assert(window2_.degenerate?)
|
103
|
-
window3_ =
|
103
|
+
window3_ = Geographic::ProjectedWindow.for_corners(@factory.point(-20, 30), @factory.point(-10, 30))
|
104
104
|
assert(window3_.degenerate?)
|
105
105
|
end
|
106
106
|
|
107
107
|
|
108
108
|
def test_contains_point
|
109
|
-
window1_ =
|
110
|
-
window2_ =
|
109
|
+
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(-170, 30), @factory.point(-160, 40))
|
110
|
+
window2_ = Geographic::ProjectedWindow.for_corners(@factory.point(170, 30), @factory.point(-170, 40))
|
111
111
|
point1_ = @factory.point(-169, 32)
|
112
112
|
point2_ = @factory.point(-171, 32)
|
113
113
|
point3_ = @factory.point(-169, 29)
|
@@ -124,43 +124,43 @@ module RGeo
|
|
124
124
|
|
125
125
|
|
126
126
|
def test_noseam_contains_window
|
127
|
-
window1_ =
|
128
|
-
assert(window1_.contains_window?(
|
127
|
+
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(10, 10), @factory.point(30, 30))
|
128
|
+
assert(window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 15), @factory.point(25, 25))))
|
129
129
|
|
130
|
-
assert(!window1_.contains_window?(
|
131
|
-
assert(!window1_.contains_window?(
|
132
|
-
assert(!window1_.contains_window?(
|
133
|
-
assert(!window1_.contains_window?(
|
134
|
-
assert(!window1_.contains_window?(
|
130
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(5, 15), @factory.point(25, 25))))
|
131
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 15), @factory.point(35, 25))))
|
132
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(0, 15), @factory.point(5, 25))))
|
133
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(35, 15), @factory.point(40, 25))))
|
134
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(5, 15), @factory.point(35, 25))))
|
135
135
|
|
136
|
-
assert(!window1_.contains_window?(
|
137
|
-
assert(!window1_.contains_window?(
|
138
|
-
assert(!window1_.contains_window?(
|
139
|
-
assert(!window1_.contains_window?(
|
140
|
-
assert(!window1_.contains_window?(
|
136
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 5), @factory.point(25, 25))))
|
137
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 15), @factory.point(25, 35))))
|
138
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 0), @factory.point(25, 5))))
|
139
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 35), @factory.point(25, 40))))
|
140
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(15, 5), @factory.point(25, 35))))
|
141
141
|
|
142
|
-
assert(!window1_.contains_window?(
|
142
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(170, 35), @factory.point(-170, 40))))
|
143
143
|
end
|
144
144
|
|
145
145
|
|
146
146
|
def test_seam_contains_window
|
147
|
-
window1_ =
|
148
|
-
assert(window1_.contains_window?(
|
149
|
-
assert(window1_.contains_window?(
|
150
|
-
assert(window1_.contains_window?(
|
147
|
+
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(160, 10), @factory.point(-160, 30))
|
148
|
+
assert(window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(175, 15), @factory.point(-175, 25))))
|
149
|
+
assert(window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(170, 15), @factory.point(175, 25))))
|
150
|
+
assert(window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(-175, 15), @factory.point(-170, 25))))
|
151
151
|
|
152
|
-
assert(!window1_.contains_window?(
|
153
|
-
assert(!window1_.contains_window?(
|
154
|
-
assert(!window1_.contains_window?(
|
155
|
-
assert(!window1_.contains_window?(
|
152
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(150, 15), @factory.point(170, 25))))
|
153
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(150, 15), @factory.point(-170, 25))))
|
154
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(-170, 15), @factory.point(-150, 25))))
|
155
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(170, 15), @factory.point(-150, 25))))
|
156
156
|
|
157
|
-
assert(!window1_.contains_window?(
|
158
|
-
assert(!window1_.contains_window?(
|
157
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(-150, 15), @factory.point(150, 25))))
|
158
|
+
assert(!window1_.contains_window?(Geographic::ProjectedWindow.for_corners(@factory.point(150, 15), @factory.point(-150, 25))))
|
159
159
|
end
|
160
160
|
|
161
161
|
|
162
162
|
def test_scaled_by
|
163
|
-
window1_ =
|
163
|
+
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(20, -20), @factory.point(50, 40))
|
164
164
|
window1s_ = window1_.scaled_by(2, 1.5)
|
165
165
|
assert(window1s_.contains_point?(@factory.point(10, -25)))
|
166
166
|
assert(window1s_.contains_point?(@factory.point(60, 45)))
|
@@ -170,7 +170,7 @@ module RGeo
|
|
170
170
|
|
171
171
|
|
172
172
|
def test_scaled_by_across_seam
|
173
|
-
window1_ =
|
173
|
+
window1_ = Geographic::ProjectedWindow.for_corners(@factory.point(170, -20), @factory.point(-160, 40))
|
174
174
|
window1s_ = window1_.scaled_by(2, 1.5)
|
175
175
|
assert(window1s_.contains_point?(@factory.point(160, -25)))
|
176
176
|
assert(window1s_.contains_point?(@factory.point(-150, 45)))
|
@@ -180,7 +180,7 @@ module RGeo
|
|
180
180
|
|
181
181
|
|
182
182
|
def test_surrounding_point
|
183
|
-
window1_ =
|
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)))
|
@@ -188,7 +188,7 @@ module RGeo
|
|
188
188
|
|
189
189
|
|
190
190
|
def test_bounding_1_point
|
191
|
-
window1_ =
|
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)))
|
@@ -196,7 +196,7 @@ module RGeo
|
|
196
196
|
|
197
197
|
|
198
198
|
def test_bounding_2_points
|
199
|
-
window1_ =
|
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)))
|
@@ -204,7 +204,7 @@ module RGeo
|
|
204
204
|
|
205
205
|
|
206
206
|
def test_bounding_2_points_across_seam
|
207
|
-
window1_ =
|
207
|
+
window1_ = Geographic::ProjectedWindow.bounding_points([@factory.point(-170, 10), @factory.point(170, 30)])
|
208
208
|
assert(window1_.contains_point?(@factory.point(-174, 20)))
|
209
209
|
assert(!window1_.contains_point?(@factory.point(-160, 20)))
|
210
210
|
assert(!window1_.contains_point?(@factory.point(160, 20)))
|
@@ -0,0 +1,203 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the internal calculations for simple spherical
|
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 SphericalGeographic # :nodoc:
|
44
|
+
|
45
|
+
class TestCalculations < ::Test::Unit::TestCase # :nodoc:
|
46
|
+
|
47
|
+
|
48
|
+
def assert_close_enough(v1_, v2_)
|
49
|
+
diff_ = (v1_ - v2_).abs
|
50
|
+
# denom_ = (v1_ + v2_).abs
|
51
|
+
# diff_ /= denom_ if denom_ > 0.01
|
52
|
+
assert(diff_ < 0.00000001, "#{v1_} is not close to #{v2_}")
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def test_point_eql
|
57
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
58
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
59
|
+
assert_equal(point1_, point2_)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def test_point_from_latlng
|
64
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.from_latlon(45, -45)
|
65
|
+
assert_close_enough(0.5, point1_.x)
|
66
|
+
assert_close_enough(-0.5, point1_.y)
|
67
|
+
assert_close_enough(::Math.sqrt(2) * 0.5, point1_.z)
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
def test_point_dot_one
|
72
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 1, 1)
|
73
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 1, 1)
|
74
|
+
assert_close_enough(1.0, point1_ * point2_)
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def test_point_dot_minusone
|
79
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 1, 1)
|
80
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(-1, -1, -1)
|
81
|
+
assert_close_enough(-1.0, point1_ * point2_)
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def test_point_dot_zero
|
86
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 1, 0)
|
87
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, -1, 0)
|
88
|
+
assert_close_enough(0.0, point1_ * point2_)
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
def test_point_cross
|
93
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 1, 0)
|
94
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, -1, 0)
|
95
|
+
assert_close_enough(-1.0, (point1_ % point2_).z)
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
def test_point_cross_coincident
|
100
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
101
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
102
|
+
assert_nil(point1_ % point2_)
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
def test_point_cross_opposite
|
107
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
108
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(-1, 0, 0)
|
109
|
+
assert_nil(point1_ % point2_)
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
def test_arc_axis
|
114
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 1, 0)
|
115
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, -1, 0)
|
116
|
+
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
117
|
+
assert_close_enough(-1.0, arc1_.axis.z)
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
def test_arc_axis2
|
122
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
123
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0.000001, 0)
|
124
|
+
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
125
|
+
assert_close_enough(1.0, arc1_.axis.z)
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
def test_arc_intersects_point_off
|
130
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
131
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0.000002, 0)
|
132
|
+
point3_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0.000001, 0.1)
|
133
|
+
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
134
|
+
assert_equal(false, arc1_.contains_point?(point3_))
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
def test_arc_intersects_point_between
|
139
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
140
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0.000002, 0)
|
141
|
+
point3_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0.000001, 0)
|
142
|
+
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
143
|
+
assert_equal(true, arc1_.contains_point?(point3_))
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
def test_arc_intersects_point_endpoint
|
148
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0, 0)
|
149
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(1, 0.000002, 0)
|
150
|
+
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
151
|
+
assert_equal(true, arc1_.contains_point?(point1_))
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
def test_arc_intersects_arc_true
|
156
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, 0.1, 1)
|
157
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, -0.1, 1)
|
158
|
+
point3_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(-0.1, 0, 1)
|
159
|
+
point4_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0.1, 0, 1)
|
160
|
+
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
161
|
+
arc2_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point3_, point4_)
|
162
|
+
assert_equal(true, arc1_.intersects_arc?(arc2_))
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
def test_arc_intersects_arc_parallel
|
167
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, 0.1, 1)
|
168
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, -0.1, 1)
|
169
|
+
point3_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0.1, 0.1, 1)
|
170
|
+
point4_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0.1, -0.1, 1)
|
171
|
+
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
172
|
+
arc2_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point3_, point4_)
|
173
|
+
assert_equal(false, arc1_.intersects_arc?(arc2_))
|
174
|
+
end
|
175
|
+
|
176
|
+
|
177
|
+
def test_arc_intersects_arc_separated_tee
|
178
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, 0.1, 1)
|
179
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, -0.1, 1)
|
180
|
+
point3_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0.1, 0, 1)
|
181
|
+
point4_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0.2, 0, 1)
|
182
|
+
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
183
|
+
arc2_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point3_, point4_)
|
184
|
+
assert_equal(false, arc1_.intersects_arc?(arc2_))
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
def test_arc_intersects_arc_connected_tee
|
189
|
+
point1_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, 0.1, 1)
|
190
|
+
point2_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, -0.1, 1)
|
191
|
+
point3_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0, 0, 1)
|
192
|
+
point4_ = ::RGeo::Geographic::SphericalMath::PointXYZ.new(0.1, 0, 1)
|
193
|
+
arc1_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point1_, point2_)
|
194
|
+
arc2_ = ::RGeo::Geographic::SphericalMath::ArcXYZ.new(point3_, point4_)
|
195
|
+
assert_equal(true, arc1_.intersects_arc?(arc2_))
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
end
|
200
|
+
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
@@ -42,13 +42,13 @@ require ::File.expand_path('../common/geometry_collection_tests.rb', ::File.dirn
|
|
42
42
|
|
43
43
|
module RGeo
|
44
44
|
module Tests # :nodoc:
|
45
|
-
module
|
45
|
+
module SphericalGeographic # :nodoc:
|
46
46
|
|
47
47
|
class TestGeometryCollection < ::Test::Unit::TestCase # :nodoc:
|
48
48
|
|
49
49
|
|
50
50
|
def create_factory
|
51
|
-
@factory = ::RGeo::
|
51
|
+
@factory = ::RGeo::Geographic.spherical_factory
|
52
52
|
end
|
53
53
|
|
54
54
|
|