rgeo 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +9 -7
- data/README.rdoc +7 -5
- data/Version +1 -1
- data/ext/geos_c_impl/factory.c +12 -19
- data/ext/geos_c_impl/factory.h +15 -21
- data/ext/geos_c_impl/geometry.c +19 -36
- data/ext/geos_c_impl/geometry.h +2 -12
- data/ext/geos_c_impl/geometry_collection.c +38 -157
- data/ext/geos_c_impl/geometry_collection.h +2 -12
- data/ext/geos_c_impl/line_string.c +83 -80
- data/ext/geos_c_impl/line_string.h +2 -12
- data/ext/geos_c_impl/main.c +5 -0
- data/ext/geos_c_impl/point.c +2 -12
- data/ext/geos_c_impl/point.h +2 -12
- data/ext/geos_c_impl/polygon.c +5 -14
- data/ext/geos_c_impl/polygon.h +2 -12
- data/ext/geos_c_impl/preface.h +8 -0
- data/lib/rgeo.rb +34 -16
- data/lib/rgeo/{geography/simple_spherical/geometry_collection_impl.rb → cartesian.rb} +19 -26
- data/lib/rgeo/cartesian/calculations.rb +129 -0
- data/lib/rgeo/cartesian/interface.rb +85 -0
- data/lib/rgeo/cartesian/simple_factory.rb +159 -0
- data/lib/rgeo/cartesian/simple_feature_classes.rb +187 -0
- data/lib/rgeo/cartesian/simple_feature_methods.rb +97 -0
- data/lib/rgeo/features.rb +1 -0
- data/lib/rgeo/features/curve.rb +3 -2
- data/lib/rgeo/features/factory.rb +62 -37
- data/lib/rgeo/features/geometry.rb +10 -32
- data/lib/rgeo/features/geometry_collection.rb +3 -2
- data/lib/rgeo/features/line.rb +3 -2
- data/lib/rgeo/features/line_string.rb +3 -2
- data/lib/rgeo/features/linear_ring.rb +3 -2
- data/lib/rgeo/features/multi_curve.rb +3 -2
- data/lib/rgeo/features/multi_line_string.rb +3 -2
- data/lib/rgeo/features/multi_point.rb +3 -2
- data/lib/rgeo/features/multi_polygon.rb +3 -2
- data/lib/rgeo/features/multi_surface.rb +3 -2
- data/lib/rgeo/features/point.rb +3 -2
- data/lib/rgeo/features/polygon.rb +3 -2
- data/lib/rgeo/features/surface.rb +3 -2
- data/lib/rgeo/features/types.rb +198 -0
- data/lib/rgeo/geography.rb +4 -14
- data/lib/rgeo/geography/factory.rb +7 -64
- data/lib/rgeo/geography/{simple_spherical/geometry_methods.rb → helper.rb} +4 -13
- data/lib/rgeo/geography/simple_mercator/feature_classes.rb +35 -89
- data/lib/rgeo/geography/simple_mercator/feature_methods.rb +22 -31
- data/lib/rgeo/geography/simple_mercator/projector.rb +4 -8
- data/lib/rgeo/geography/simple_spherical/calculations.rb +11 -9
- data/lib/rgeo/geography/simple_spherical/feature_classes.rb +189 -0
- data/lib/rgeo/geography/simple_spherical/{line_string_impl.rb → feature_methods.rb} +16 -64
- data/lib/rgeo/geos/factory.rb +26 -40
- data/lib/rgeo/geos/impl_additions.rb +3 -5
- data/lib/rgeo/{geography/simple_spherical/polygon_impl.rb → impl_helpers.rb} +16 -26
- data/lib/rgeo/impl_helpers/basic_geometry_collection_methods.rb +186 -0
- data/lib/rgeo/impl_helpers/basic_geometry_methods.rb +90 -0
- data/lib/rgeo/impl_helpers/basic_line_string_methods.rb +188 -0
- data/lib/rgeo/impl_helpers/basic_point_methods.rb +149 -0
- data/lib/rgeo/{geography/common/helper.rb → impl_helpers/basic_polygon_methods.rb} +62 -53
- data/lib/rgeo/{geography/common/polygon_methods.rb → impl_helpers/serialization.rb} +50 -42
- data/tests/common/geometry_collection_tests.rb +9 -7
- data/tests/common/multi_line_string_tests.rb +16 -13
- data/tests/common/multi_point_tests.rb +16 -13
- data/tests/common/multi_polygon_tests.rb +8 -6
- data/tests/common/point_tests.rb +1 -2
- data/tests/common/polygon_tests.rb +9 -9
- data/tests/geos/tc_multi_line_string.rb +2 -2
- data/tests/simple_cartesian/tc_calculations.rb +138 -0
- data/tests/simple_cartesian/tc_geometry_collection.rb +68 -0
- data/tests/simple_cartesian/tc_line_string.rb +70 -0
- data/{lib/rgeo/geography/simple_spherical/multi_line_string_impl.rb → tests/simple_cartesian/tc_multi_line_string.rb} +19 -19
- data/{lib/rgeo/geography/simple_spherical/multi_polygon_impl.rb → tests/simple_cartesian/tc_multi_point.rb} +19 -19
- data/{lib/rgeo/geography/common/geometry_methods.rb → tests/simple_cartesian/tc_multi_polygon.rb} +19 -41
- data/{lib/rgeo/geography/simple_spherical/point_impl.rb → tests/simple_cartesian/tc_point.rb} +33 -35
- data/tests/simple_cartesian/tc_polygon.rb +67 -0
- data/tests/simple_spherical/tc_geometry_collection.rb +68 -0
- data/tests/simple_spherical/tc_line_string.rb +10 -171
- data/tests/simple_spherical/tc_multi_line_string.rb +67 -0
- data/{lib/rgeo/geography/simple_spherical/multi_point_impl.rb → tests/simple_spherical/tc_multi_point.rb} +19 -19
- data/tests/simple_spherical/tc_multi_polygon.rb +70 -0
- data/tests/simple_spherical/tc_point.rb +17 -115
- data/tests/simple_spherical/tc_polygon.rb +67 -0
- metadata +46 -18
- data/ext/geos_c_impl/globals.h +0 -58
- data/lib/rgeo/geography/common/geometry_collection_methods.rb +0 -217
- data/lib/rgeo/geography/common/line_string_methods.rb +0 -201
- data/lib/rgeo/geography/common/point_methods.rb +0 -153
data/{lib/rgeo/geography/simple_spherical/point_impl.rb → tests/simple_cartesian/tc_point.rb}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
2
|
#
|
3
|
-
#
|
3
|
+
# Tests for the simple cartesian point implementation
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
# Copyright 2010 Daniel Azuma
|
@@ -34,58 +34,56 @@
|
|
34
34
|
;
|
35
35
|
|
36
36
|
|
37
|
+
require 'test/unit'
|
38
|
+
require 'rgeo'
|
39
|
+
|
40
|
+
require ::File.expand_path('../common/point_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
42
|
+
|
37
43
|
module RGeo
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
module SimpleSpherical
|
42
|
-
|
44
|
+
module Tests # :nodoc:
|
45
|
+
module SimpleCartesian # :nodoc:
|
43
46
|
|
44
|
-
class
|
47
|
+
class TestPoint < ::Test::Unit::TestCase # :nodoc:
|
45
48
|
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
include Common::PointMethods
|
50
|
+
def setup
|
51
|
+
@factory = ::RGeo::Cartesian.simple_factory(:srid => 1)
|
52
|
+
end
|
51
53
|
|
52
54
|
|
53
|
-
|
54
|
-
_set_factory(factory_)
|
55
|
-
_setup(x_, y_)
|
56
|
-
end
|
55
|
+
include ::RGeo::Tests::Common::PointTests
|
57
56
|
|
58
57
|
|
59
|
-
def
|
60
|
-
|
61
|
-
|
62
|
-
@y = 90.0 if @y > 90.0
|
63
|
-
@y = -90.0 if @y < -90.0
|
64
|
-
super
|
58
|
+
def test_srid
|
59
|
+
point_ = @factory.point(11, 12)
|
60
|
+
assert_equal(1, point_.srid)
|
65
61
|
end
|
66
62
|
|
67
63
|
|
68
|
-
def
|
69
|
-
|
64
|
+
def test_distance
|
65
|
+
point1_ = @factory.point(2, 2)
|
66
|
+
point2_ = @factory.point(7, 14)
|
67
|
+
assert_in_delta(13, point1_.distance(point2_), 0.0001)
|
70
68
|
end
|
71
69
|
|
72
70
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
71
|
+
undef_method :test_disjoint
|
72
|
+
undef_method :test_intersects
|
73
|
+
undef_method :test_touches
|
74
|
+
undef_method :test_crosses
|
75
|
+
undef_method :test_within
|
76
|
+
undef_method :test_contains
|
77
|
+
undef_method :test_overlaps
|
78
|
+
undef_method :test_convex_hull
|
79
|
+
undef_method :test_intersection
|
80
|
+
undef_method :test_union
|
81
|
+
undef_method :test_difference
|
82
|
+
undef_method :test_sym_difference
|
82
83
|
|
83
84
|
|
84
85
|
end
|
85
86
|
|
86
|
-
|
87
87
|
end
|
88
|
-
|
89
88
|
end
|
90
|
-
|
91
89
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple cartesian 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 SimpleCartesian # :nodoc:
|
46
|
+
|
47
|
+
class TestPolygon < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def setup
|
51
|
+
@factory = ::RGeo::Cartesian.simple_factory
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
include ::RGeo::Tests::Common::PolygonTests
|
56
|
+
|
57
|
+
|
58
|
+
undef_method :test_fully_equal
|
59
|
+
undef_method :test_geometrically_equal_but_ordered_different
|
60
|
+
undef_method :test_geometrically_equal_but_different_directions
|
61
|
+
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple spherical geometry collection 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/geometry_collection_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
42
|
+
|
43
|
+
module RGeo
|
44
|
+
module Tests # :nodoc:
|
45
|
+
module SimpleSpherical # :nodoc:
|
46
|
+
|
47
|
+
class TestGeometryCollection < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def create_factory
|
51
|
+
@factory = ::RGeo::Geography.simple_spherical
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
include ::RGeo::Tests::Common::GeometryCollectionTests
|
56
|
+
|
57
|
+
|
58
|
+
undef_method :test_fully_equal
|
59
|
+
undef_method :test_geometrically_equal
|
60
|
+
undef_method :test_empty_equal
|
61
|
+
undef_method :test_not_equal
|
62
|
+
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
2
|
#
|
3
|
-
# Tests for the simple spherical
|
3
|
+
# Tests for the simple spherical line string implementation
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
# Copyright 2010 Daniel Azuma
|
@@ -37,6 +37,8 @@
|
|
37
37
|
require 'test/unit'
|
38
38
|
require 'rgeo'
|
39
39
|
|
40
|
+
require ::File.expand_path('../common/line_string_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
40
42
|
|
41
43
|
module RGeo
|
42
44
|
module Tests # :nodoc:
|
@@ -50,178 +52,15 @@ module RGeo
|
|
50
52
|
end
|
51
53
|
|
52
54
|
|
53
|
-
|
54
|
-
point1_ = @factory.point(0, 0)
|
55
|
-
point2_ = @factory.point(0, 1)
|
56
|
-
point3_ = @factory.point(1, 0)
|
57
|
-
line1_ = @factory.line_string([point1_, point2_])
|
58
|
-
assert_not_nil(line1_)
|
59
|
-
assert_equal(::RGeo::Features::LineString, line1_.geometry_type)
|
60
|
-
assert_equal(2, line1_.num_points)
|
61
|
-
assert_equal(point1_, line1_.point_n(0))
|
62
|
-
assert_equal(point2_, line1_.point_n(1))
|
63
|
-
line2_ = @factory.line_string([point1_, point2_, point3_])
|
64
|
-
assert_not_nil(line2_)
|
65
|
-
assert_equal(::RGeo::Features::LineString, line2_.geometry_type)
|
66
|
-
assert_equal(3, line2_.num_points)
|
67
|
-
assert_equal(point1_, line2_.point_n(0))
|
68
|
-
assert_equal(point2_, line2_.point_n(1))
|
69
|
-
assert_equal(point3_, line2_.point_n(2))
|
70
|
-
line3_ = @factory.line_string([point1_, point1_])
|
71
|
-
assert_not_nil(line3_)
|
72
|
-
assert_equal(::RGeo::Features::LineString, line3_.geometry_type)
|
73
|
-
assert_equal(2, line3_.num_points)
|
74
|
-
assert_equal(point1_, line3_.point_n(0))
|
75
|
-
assert_equal(point1_, line3_.point_n(1))
|
76
|
-
line4_ = @factory.line_string([])
|
77
|
-
assert_not_nil(line4_)
|
78
|
-
assert_equal(::RGeo::Features::LineString, line4_.geometry_type)
|
79
|
-
assert_equal(0, line4_.num_points)
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
def _test_creation_line_string
|
84
|
-
point1_ = @factory.point(0, 0)
|
85
|
-
point2_ = @factory.point(0, 1)
|
86
|
-
point3_ = @factory.point(1, 1)
|
87
|
-
line1_ = @factory.line_string([point1_, point2_, point3_])
|
88
|
-
assert_not_nil(line1_)
|
89
|
-
assert(::RGeo::Features::LineString === line1_)
|
90
|
-
assert(!(::RGeo::Features::LinearRing === line1_))
|
91
|
-
assert(!(::RGeo::Features::Line === line1_))
|
92
|
-
assert_equal(::RGeo::Features::LineString, line1_.geometry_type)
|
93
|
-
end
|
94
|
-
|
95
|
-
|
96
|
-
def test_creation_linear_ring
|
97
|
-
point1_ = @factory.point(0, 0)
|
98
|
-
point2_ = @factory.point(0, 1)
|
99
|
-
point3_ = @factory.point(1, 0)
|
100
|
-
line1_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
|
101
|
-
assert_not_nil(line1_)
|
102
|
-
assert(line1_.is_ring?)
|
103
|
-
assert(::RGeo::Features::LinearRing === line1_)
|
104
|
-
assert_equal(::RGeo::Features::LinearRing, line1_.geometry_type)
|
105
|
-
line2_ = @factory.linear_ring([point1_, point2_, point3_])
|
106
|
-
assert_not_nil(line2_)
|
107
|
-
assert(line2_.is_ring?)
|
108
|
-
assert(::RGeo::Features::LinearRing === line2_)
|
109
|
-
assert_equal(4, line2_.num_points)
|
110
|
-
assert_equal(::RGeo::Features::LinearRing, line2_.geometry_type)
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
def _test_creation_line
|
115
|
-
point1_ = @factory.point(0, 0)
|
116
|
-
point2_ = @factory.point(0, 1)
|
117
|
-
line1_ = @factory.line(point1_, point2_)
|
118
|
-
assert_not_nil(line1_)
|
119
|
-
assert(::RGeo::Features::Line === line1_)
|
120
|
-
assert_equal(::RGeo::Features::Line, line1_.geometry_type)
|
121
|
-
end
|
122
|
-
|
123
|
-
|
124
|
-
def test_creation_errors
|
125
|
-
point1_ = @factory.point(0, 0)
|
126
|
-
collection_ = point1_.boundary
|
127
|
-
line1_ = @factory.line_string([point1_])
|
128
|
-
assert_nil(line1_)
|
129
|
-
line2_ = @factory.line_string([point1_, collection_])
|
130
|
-
assert_nil(line2_)
|
131
|
-
end
|
132
|
-
|
133
|
-
|
134
|
-
def test_wkt_creation
|
135
|
-
line1_ = @factory.parse_wkt('LINESTRING(21 22, 11 12)')
|
136
|
-
assert_equal(@factory.point(21, 22), line1_.point_n(0))
|
137
|
-
assert_equal(@factory.point(11, 12), line1_.point_n(1))
|
138
|
-
assert_equal(2, line1_.num_points)
|
139
|
-
line2_ = @factory.parse_wkt('LINESTRING(-1 -1, 21 22, 11 12, -1 -1)')
|
140
|
-
assert_equal(@factory.point(-1, -1), line2_.point_n(0))
|
141
|
-
assert_equal(@factory.point(21, 22), line2_.point_n(1))
|
142
|
-
assert_equal(@factory.point(11, 12), line2_.point_n(2))
|
143
|
-
assert_equal(@factory.point(-1, -1), line2_.point_n(3))
|
144
|
-
assert_equal(4, line2_.num_points)
|
145
|
-
end
|
146
|
-
|
147
|
-
|
148
|
-
def test_clone
|
149
|
-
point1_ = @factory.point(0, 0)
|
150
|
-
point2_ = @factory.point(0, 1)
|
151
|
-
line1_ = @factory.line_string([point1_, point2_])
|
152
|
-
line2_ = line1_.clone
|
153
|
-
assert(line1_.eql?(line2_))
|
154
|
-
assert_equal(2, line2_.num_points)
|
155
|
-
assert(point1_.eql?(line2_.point_n(0)))
|
156
|
-
assert(point2_.eql?(line2_.point_n(1)))
|
157
|
-
end
|
55
|
+
include ::RGeo::Tests::Common::LineStringTests
|
158
56
|
|
159
57
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
assert(!::RGeo::Features::GeometryCollection.check_type(line_))
|
167
|
-
assert(::RGeo::Features::Curve.check_type(line_))
|
168
|
-
assert(::RGeo::Features::LineString.check_type(line_))
|
169
|
-
assert(!::RGeo::Features::LinearRing.check_type(line_))
|
170
|
-
end
|
171
|
-
|
172
|
-
|
173
|
-
def test_as_text_wkt_round_trip
|
174
|
-
point1_ = @factory.point(0, 0)
|
175
|
-
point2_ = @factory.point(0, 1)
|
176
|
-
line1_ = @factory.line_string([point1_, point2_])
|
177
|
-
text_ = line1_.as_text
|
178
|
-
line2_ = @factory.parse_wkt(text_)
|
179
|
-
assert(line2_.eql?(line1_))
|
180
|
-
end
|
181
|
-
|
182
|
-
|
183
|
-
def test_as_binary_wkb_round_trip
|
184
|
-
point1_ = @factory.point(-42, 0)
|
185
|
-
point2_ = @factory.point(0, 193)
|
186
|
-
line1_ = @factory.line_string([point1_, point2_])
|
187
|
-
binary_ = line1_.as_binary
|
188
|
-
line2_ = @factory.parse_wkb(binary_)
|
189
|
-
assert(line2_.eql?(line1_))
|
190
|
-
end
|
191
|
-
|
192
|
-
|
193
|
-
def test_empty_as_text_wkt_round_trip
|
194
|
-
line1_ = @factory.line_string([])
|
195
|
-
text_ = line1_.as_text
|
196
|
-
line2_ = @factory.parse_wkt(text_)
|
197
|
-
assert(line2_.is_empty?)
|
198
|
-
end
|
199
|
-
|
200
|
-
|
201
|
-
def test_empty_as_binary_wkb_round_trip
|
202
|
-
line1_ = @factory.line_string([])
|
203
|
-
binary_ = line1_.as_binary
|
204
|
-
line2_ = @factory.parse_wkb(binary_)
|
205
|
-
assert(line2_.is_empty?)
|
206
|
-
end
|
207
|
-
|
208
|
-
|
209
|
-
def test_dimension
|
210
|
-
point1_ = @factory.point(-42, 0)
|
211
|
-
point2_ = @factory.point(0, 193)
|
212
|
-
line1_ = @factory.line_string([point1_, point2_])
|
213
|
-
assert_equal(1, line1_.dimension)
|
214
|
-
end
|
215
|
-
|
216
|
-
|
217
|
-
def test_is_empty
|
218
|
-
point1_ = @factory.point(-42, 0)
|
219
|
-
point2_ = @factory.point(0, 193)
|
220
|
-
line1_ = @factory.line_string([point1_, point2_])
|
221
|
-
assert(!line1_.is_empty?)
|
222
|
-
line2_ = @factory.line_string([])
|
223
|
-
assert(line2_.is_empty?)
|
224
|
-
end
|
58
|
+
undef_method :test_fully_equal
|
59
|
+
undef_method :test_geometrically_equal_but_different_type
|
60
|
+
undef_method :test_geometrically_equal_but_different_type2
|
61
|
+
undef_method :test_geometrically_equal_but_different_overlap
|
62
|
+
undef_method :test_empty_equal
|
63
|
+
undef_method :test_not_equal
|
225
64
|
|
226
65
|
|
227
66
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple spherical 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 SimpleSpherical # :nodoc:
|
46
|
+
|
47
|
+
class TestMultiLineString < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def create_factory
|
51
|
+
@factory = ::RGeo::Geography.simple_spherical
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
include ::RGeo::Tests::Common::MultiLineStringTests
|
56
|
+
|
57
|
+
|
58
|
+
undef_method :test_fully_equal
|
59
|
+
undef_method :test_geometrically_equal
|
60
|
+
undef_method :test_not_equal
|
61
|
+
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|