rgeo 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.rdoc +13 -0
- data/README.rdoc +6 -0
- data/Version +1 -1
- data/ext/geos_c_impl/factory.c +2 -2
- data/lib/rgeo/features/factory.rb +2 -2
- data/lib/rgeo/features/geometry.rb +26 -4
- data/lib/rgeo/features/geometry_collection.rb +12 -2
- data/lib/rgeo/geography/common/geometry_collection_methods.rb +12 -1
- data/lib/rgeo/geography/common/helper.rb +4 -4
- data/lib/rgeo/geography/common/line_string_methods.rb +1 -1
- data/lib/rgeo/geography/common/point_methods.rb +1 -1
- data/lib/rgeo/geography/common/polygon_methods.rb +1 -1
- data/lib/rgeo/geography/factories.rb +19 -6
- data/lib/rgeo/geography/factory.rb +31 -10
- data/lib/rgeo/geography/simple_mercator/feature_classes.rb +26 -26
- data/lib/rgeo/geography/simple_mercator/feature_methods.rb +14 -14
- data/lib/rgeo/geography/simple_mercator/projector.rb +1 -1
- data/lib/rgeo/geography/simple_spherical/calculations.rb +61 -0
- data/lib/rgeo/geography/simple_spherical/point_impl.rb +5 -0
- data/lib/rgeo/geos/factory.rb +12 -11
- data/tests/common/geometry_collection_tests.rb +220 -0
- data/tests/common/line_string_tests.rb +300 -0
- data/tests/common/multi_line_string_tests.rb +206 -0
- data/tests/common/multi_point_tests.rb +198 -0
- data/tests/common/multi_polygon_tests.rb +206 -0
- data/tests/common/point_tests.rb +281 -0
- data/tests/common/polygon_tests.rb +232 -0
- data/tests/geos/tc_geometry_collection.rb +5 -169
- data/tests/geos/tc_line_string.rb +4 -252
- data/tests/geos/tc_multi_line_string.rb +5 -154
- data/tests/geos/tc_multi_point.rb +5 -145
- data/tests/geos/tc_multi_polygon.rb +4 -151
- data/tests/geos/tc_point.rb +11 -213
- data/tests/geos/tc_polygon.rb +4 -182
- data/tests/simple_mercator/tc_geometry_collection.rb +62 -0
- data/tests/simple_mercator/tc_line_string.rb +62 -0
- data/tests/simple_mercator/tc_multi_line_string.rb +62 -0
- data/tests/simple_mercator/tc_multi_point.rb +62 -0
- data/tests/simple_mercator/tc_multi_polygon.rb +63 -0
- data/tests/simple_mercator/tc_point.rb +7 -220
- data/tests/simple_mercator/tc_polygon.rb +62 -0
- data/tests/simple_spherical/tc_point.rb +165 -0
- metadata +48 -9
@@ -0,0 +1,62 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple mercator line string 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
|
+
require ::File.expand_path('../common/line_string_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
42
|
+
|
43
|
+
module RGeo
|
44
|
+
module Tests # :nodoc:
|
45
|
+
module SimpleMercator # :nodoc:
|
46
|
+
|
47
|
+
class TestLineString < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def setup
|
51
|
+
@factory = ::RGeo::Geography.simple_mercator
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
include ::RGeo::Tests::Common::LineStringTests
|
56
|
+
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple mercator multi line string 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
|
+
require ::File.expand_path('../common/multi_line_string_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
42
|
+
|
43
|
+
module RGeo
|
44
|
+
module Tests # :nodoc:
|
45
|
+
module SimpleMercator
|
46
|
+
|
47
|
+
class TestMultiLineString < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def create_factory
|
51
|
+
::RGeo::Geography.simple_mercator
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
include ::RGeo::Tests::Common::MultiLineStringTests
|
56
|
+
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple mercator multi 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
|
+
require ::File.expand_path('../common/multi_point_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
42
|
+
|
43
|
+
module RGeo
|
44
|
+
module Tests # :nodoc:
|
45
|
+
module SimpleMercator
|
46
|
+
|
47
|
+
class TestMultiPoint < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def create_factory
|
51
|
+
::RGeo::Geography.simple_mercator
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
include ::RGeo::Tests::Common::MultiPointTests
|
56
|
+
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple mercator multi 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
|
+
require ::File.expand_path('../common/multi_polygon_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
42
|
+
|
43
|
+
module RGeo
|
44
|
+
module Tests # :nodoc:
|
45
|
+
module SimpleMercator
|
46
|
+
|
47
|
+
class TestMultiPolygon < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def create_factories
|
51
|
+
@factory = ::RGeo::Geography.simple_mercator
|
52
|
+
@lenient_factory = ::RGeo::Geography.simple_mercator(:lenient_multi_polygon_assertions => true)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
include ::RGeo::Tests::Common::MultiPolygonTests
|
57
|
+
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -37,6 +37,8 @@
|
|
37
37
|
require 'test/unit'
|
38
38
|
require 'rgeo'
|
39
39
|
|
40
|
+
require ::File.expand_path('../common/point_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
40
42
|
|
41
43
|
module RGeo
|
42
44
|
module Tests # :nodoc:
|
@@ -50,186 +52,28 @@ module RGeo
|
|
50
52
|
end
|
51
53
|
|
52
54
|
|
53
|
-
|
54
|
-
assert((p1_.x - p2_.x).abs < 0.00000001 && (p1_.y - p2_.y).abs < 0.00000001)
|
55
|
-
end
|
55
|
+
include ::RGeo::Tests::Common::PointTests
|
56
56
|
|
57
57
|
|
58
|
-
def
|
59
|
-
|
58
|
+
def test_has_projection
|
59
|
+
point_ = @factory.point(21, -22)
|
60
|
+
assert(point_.respond_to?(:projection))
|
60
61
|
end
|
61
62
|
|
62
63
|
|
63
|
-
def
|
64
|
+
def test_latlon
|
64
65
|
point_ = @factory.point(21, -22)
|
65
|
-
assert_equal(21, point_.x)
|
66
|
-
assert_equal(-22, point_.y)
|
67
66
|
assert_equal(21, point_.longitude)
|
68
67
|
assert_equal(-22, point_.latitude)
|
69
68
|
end
|
70
69
|
|
71
70
|
|
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
71
|
def test_srid
|
114
72
|
point_ = @factory.point(11, 12)
|
115
73
|
assert_equal(4326, point_.srid)
|
116
74
|
end
|
117
75
|
|
118
76
|
|
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
77
|
def test_distance
|
234
78
|
point1_ = @factory.point(11, 12)
|
235
79
|
point2_ = @factory.point(11, 12)
|
@@ -239,63 +83,6 @@ module RGeo
|
|
239
83
|
end
|
240
84
|
|
241
85
|
|
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
86
|
end
|
300
87
|
|
301
88
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple mercator 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
|
+
require ::File.expand_path('../common/polygon_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
42
|
+
|
43
|
+
module RGeo
|
44
|
+
module Tests # :nodoc:
|
45
|
+
module SimpleMercator # :nodoc:
|
46
|
+
|
47
|
+
class TestPolygon < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def setup
|
51
|
+
@factory = ::RGeo::Geography.simple_mercator
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
include ::RGeo::Tests::Common::PolygonTests
|
56
|
+
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|