rgeo 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/rgeo/yaml.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# RGeo yaml support
|
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,19 +41,19 @@ end
|
|
41
41
|
|
42
42
|
|
43
43
|
module RGeo
|
44
|
-
|
45
|
-
|
44
|
+
|
45
|
+
|
46
46
|
# :stopdoc:
|
47
47
|
PSYCH_AVAILABLE = defined?(::Psych)
|
48
48
|
# :startdoc:
|
49
|
-
|
50
|
-
|
49
|
+
|
50
|
+
|
51
51
|
# Returns true if YAML serialization and deserialization is supported.
|
52
52
|
# YAML support requires the Psych library/gem.
|
53
|
-
|
53
|
+
|
54
54
|
def self.yaml_supported?
|
55
55
|
PSYCH_AVAILABLE
|
56
56
|
end
|
57
|
-
|
58
|
-
|
57
|
+
|
58
|
+
|
59
59
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Common tests for geometry collection implementations
|
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
|
@@ -40,10 +40,10 @@ require 'rgeo'
|
|
40
40
|
module RGeo
|
41
41
|
module Tests # :nodoc:
|
42
42
|
module Common # :nodoc:
|
43
|
-
|
43
|
+
|
44
44
|
module GeometryCollectionTests # :nodoc:
|
45
|
-
|
46
|
-
|
45
|
+
|
46
|
+
|
47
47
|
def setup
|
48
48
|
@factory = create_factory
|
49
49
|
@point1 = @factory.point(0, 0)
|
@@ -54,8 +54,8 @@ module RGeo
|
|
54
54
|
@line2 = @factory.line_string([@point3, @point4, @point1])
|
55
55
|
@line3 = @factory.line(@point3, @point4)
|
56
56
|
end
|
57
|
-
|
58
|
-
|
57
|
+
|
58
|
+
|
59
59
|
def test_creation_simple
|
60
60
|
geom_ = @factory.collection([@point1, @line1])
|
61
61
|
assert_not_nil(geom_)
|
@@ -65,8 +65,8 @@ module RGeo
|
|
65
65
|
assert(@point1.eql?(geom_[0]))
|
66
66
|
assert(@line1.eql?(geom_[1]))
|
67
67
|
end
|
68
|
-
|
69
|
-
|
68
|
+
|
69
|
+
|
70
70
|
def test_creation_empty
|
71
71
|
geom_ = @factory.collection([])
|
72
72
|
assert_not_nil(geom_)
|
@@ -75,16 +75,16 @@ module RGeo
|
|
75
75
|
assert_equal(0, geom_.num_geometries)
|
76
76
|
assert_equal([], geom_.to_a)
|
77
77
|
end
|
78
|
-
|
79
|
-
|
78
|
+
|
79
|
+
|
80
80
|
def test_bounds_check
|
81
81
|
geom_ = @factory.collection([@point1, @line1])
|
82
82
|
assert_nil(geom_.geometry_n(200))
|
83
83
|
assert_nil(geom_.geometry_n(-1))
|
84
84
|
assert(@line1.eql?(geom_[-1]))
|
85
85
|
end
|
86
|
-
|
87
|
-
|
86
|
+
|
87
|
+
|
88
88
|
def test_creation_save_klass
|
89
89
|
geom_ = @factory.collection([@point1, @line3])
|
90
90
|
assert_not_nil(geom_)
|
@@ -93,8 +93,8 @@ module RGeo
|
|
93
93
|
assert_equal(2, geom_.num_geometries)
|
94
94
|
assert(geom_[1].eql?(@line3))
|
95
95
|
end
|
96
|
-
|
97
|
-
|
96
|
+
|
97
|
+
|
98
98
|
def test_creation_compound
|
99
99
|
geom1_ = @factory.collection([@point1, @line1])
|
100
100
|
geom2_ = @factory.collection([@point2, geom1_])
|
@@ -104,8 +104,8 @@ module RGeo
|
|
104
104
|
assert_equal(2, geom2_.num_geometries)
|
105
105
|
assert(geom2_[1].eql?(geom1_))
|
106
106
|
end
|
107
|
-
|
108
|
-
|
107
|
+
|
108
|
+
|
109
109
|
def test_creation_compound_save_klass
|
110
110
|
geom1_ = @factory.collection([@point1, @line3])
|
111
111
|
geom2_ = @factory.collection([@point2, geom1_])
|
@@ -116,54 +116,54 @@ module RGeo
|
|
116
116
|
assert_equal(2, geom2_.num_geometries)
|
117
117
|
assert_equal(::RGeo::Feature::Line, geom2_[1][1].geometry_type)
|
118
118
|
end
|
119
|
-
|
120
|
-
|
119
|
+
|
120
|
+
|
121
121
|
def test_fully_equal
|
122
122
|
geom1_ = @factory.collection([@point1, @line1])
|
123
123
|
geom2_ = @factory.collection([@point1, @line1])
|
124
124
|
assert(geom1_.eql?(geom2_))
|
125
125
|
assert(geom1_.equals?(geom2_))
|
126
126
|
end
|
127
|
-
|
128
|
-
|
127
|
+
|
128
|
+
|
129
129
|
def test_geometrically_equal
|
130
130
|
geom1_ = @factory.collection([@point2, @line2])
|
131
131
|
geom2_ = @factory.collection([@point2, @line1, @line2])
|
132
132
|
assert(!geom1_.eql?(geom2_))
|
133
133
|
assert(geom1_.equals?(geom2_))
|
134
134
|
end
|
135
|
-
|
136
|
-
|
135
|
+
|
136
|
+
|
137
137
|
def test_empty_equal
|
138
138
|
geom1_ = @factory.collection([])
|
139
139
|
geom2_ = @factory.collection([])
|
140
140
|
assert(geom1_.eql?(geom2_))
|
141
141
|
assert(geom1_.equals?(geom2_))
|
142
142
|
end
|
143
|
-
|
144
|
-
|
143
|
+
|
144
|
+
|
145
145
|
def test_not_equal
|
146
146
|
geom1_ = @factory.collection([@point1, @line1])
|
147
147
|
geom2_ = @factory.collection([@point2, @line1])
|
148
148
|
assert(!geom1_.eql?(geom2_))
|
149
149
|
assert(!geom1_.equals?(geom2_))
|
150
150
|
end
|
151
|
-
|
152
|
-
|
151
|
+
|
152
|
+
|
153
153
|
def test_wkt_creation_simple
|
154
154
|
parsed_geom_ = @factory.parse_wkt('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-4 2, -5 3))')
|
155
155
|
built_geom_ = @factory.collection([@point1, @line1])
|
156
156
|
assert(built_geom_.eql?(parsed_geom_))
|
157
157
|
end
|
158
|
-
|
159
|
-
|
158
|
+
|
159
|
+
|
160
160
|
def test_wkt_creation_empty
|
161
161
|
parsed_geom_ = @factory.parse_wkt('GEOMETRYCOLLECTION EMPTY')
|
162
162
|
assert_equal(0, parsed_geom_.num_geometries)
|
163
163
|
assert_equal([], parsed_geom_.to_a)
|
164
164
|
end
|
165
|
-
|
166
|
-
|
165
|
+
|
166
|
+
|
167
167
|
def test_clone
|
168
168
|
geom1_ = @factory.collection([@point1, @line1])
|
169
169
|
geom2_ = geom1_.clone
|
@@ -173,8 +173,8 @@ module RGeo
|
|
173
173
|
assert(@point1.eql?(geom2_[0]))
|
174
174
|
assert(@line1.eql?(geom2_[1]))
|
175
175
|
end
|
176
|
-
|
177
|
-
|
176
|
+
|
177
|
+
|
178
178
|
def test_type_check
|
179
179
|
geom1_ = @factory.collection([@point1, @line1])
|
180
180
|
assert(::RGeo::Feature::Geometry.check_type(geom1_))
|
@@ -187,24 +187,24 @@ module RGeo
|
|
187
187
|
assert(::RGeo::Feature::GeometryCollection.check_type(geom2_))
|
188
188
|
assert(!::RGeo::Feature::MultiPoint.check_type(geom2_))
|
189
189
|
end
|
190
|
-
|
191
|
-
|
190
|
+
|
191
|
+
|
192
192
|
def test_as_text_wkt_round_trip
|
193
193
|
geom1_ = @factory.collection([@point1, @line1])
|
194
194
|
text_ = geom1_.as_text
|
195
195
|
geom2_ = @factory.parse_wkt(text_)
|
196
196
|
assert(geom1_.eql?(geom2_))
|
197
197
|
end
|
198
|
-
|
199
|
-
|
198
|
+
|
199
|
+
|
200
200
|
def test_as_binary_wkb_round_trip
|
201
201
|
geom1_ = @factory.collection([@point1, @line1])
|
202
202
|
binary_ = geom1_.as_binary
|
203
203
|
geom2_ = @factory.parse_wkb(binary_)
|
204
204
|
assert(geom1_.eql?(geom2_))
|
205
205
|
end
|
206
|
-
|
207
|
-
|
206
|
+
|
207
|
+
|
208
208
|
def test_dimension
|
209
209
|
geom1_ = @factory.collection([@point1, @line1])
|
210
210
|
assert_equal(1, geom1_.dimension)
|
@@ -213,32 +213,32 @@ module RGeo
|
|
213
213
|
geom3_ = @factory.collection([])
|
214
214
|
assert_equal(-1, geom3_.dimension)
|
215
215
|
end
|
216
|
-
|
217
|
-
|
216
|
+
|
217
|
+
|
218
218
|
def test_is_empty
|
219
219
|
geom1_ = @factory.collection([@point1, @line1])
|
220
220
|
assert(!geom1_.is_empty?)
|
221
221
|
geom2_ = @factory.collection([])
|
222
222
|
assert(geom2_.is_empty?)
|
223
223
|
end
|
224
|
-
|
225
|
-
|
224
|
+
|
225
|
+
|
226
226
|
def test_empty_collection_envelope
|
227
227
|
empty_ = @factory.collection([])
|
228
228
|
envelope_ = empty_.envelope
|
229
229
|
assert_equal(Feature::GeometryCollection, envelope_.geometry_type)
|
230
230
|
assert_equal(0, envelope_.num_geometries)
|
231
231
|
end
|
232
|
-
|
233
|
-
|
232
|
+
|
233
|
+
|
234
234
|
def test_empty_collection_boundary
|
235
235
|
empty_ = @factory.collection([])
|
236
236
|
assert_nil(empty_.boundary)
|
237
237
|
end
|
238
|
-
|
239
|
-
|
238
|
+
|
239
|
+
|
240
240
|
end
|
241
|
-
|
241
|
+
|
242
242
|
end
|
243
243
|
end
|
244
244
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Common tests for line string implementations
|
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
|
@@ -40,10 +40,10 @@ require 'rgeo'
|
|
40
40
|
module RGeo
|
41
41
|
module Tests # :nodoc:
|
42
42
|
module Common # :nodoc:
|
43
|
-
|
43
|
+
|
44
44
|
module LineStringTests # :nodoc:
|
45
|
-
|
46
|
-
|
45
|
+
|
46
|
+
|
47
47
|
def test_creation_points2
|
48
48
|
point1_ = @factory.point(0, 0)
|
49
49
|
point2_ = @factory.point(0, 1)
|
@@ -58,8 +58,8 @@ module RGeo
|
|
58
58
|
assert_equal(point1_, line1_.start_point)
|
59
59
|
assert_equal(point2_, line1_.end_point)
|
60
60
|
end
|
61
|
-
|
62
|
-
|
61
|
+
|
62
|
+
|
63
63
|
def test_creation_points3
|
64
64
|
point1_ = @factory.point(0, 0)
|
65
65
|
point2_ = @factory.point(0, 1)
|
@@ -75,8 +75,8 @@ module RGeo
|
|
75
75
|
assert_equal(point1_, line2_.start_point)
|
76
76
|
assert_equal(point3_, line2_.end_point)
|
77
77
|
end
|
78
|
-
|
79
|
-
|
78
|
+
|
79
|
+
|
80
80
|
def test_creation_points2_degenerate
|
81
81
|
point1_ = @factory.point(0, 0)
|
82
82
|
line3_ = @factory.line_string([point1_, point1_])
|
@@ -88,8 +88,8 @@ module RGeo
|
|
88
88
|
assert_equal(point1_, line3_.start_point)
|
89
89
|
assert_equal(point1_, line3_.end_point)
|
90
90
|
end
|
91
|
-
|
92
|
-
|
91
|
+
|
92
|
+
|
93
93
|
def test_creation_points_empty
|
94
94
|
line4_ = @factory.line_string([])
|
95
95
|
assert_not_nil(line4_)
|
@@ -98,8 +98,8 @@ module RGeo
|
|
98
98
|
assert_nil(line4_.start_point)
|
99
99
|
assert_nil(line4_.end_point)
|
100
100
|
end
|
101
|
-
|
102
|
-
|
101
|
+
|
102
|
+
|
103
103
|
def test_creation_line_string
|
104
104
|
point1_ = @factory.point(0, 0)
|
105
105
|
point2_ = @factory.point(0, 1)
|
@@ -111,8 +111,8 @@ module RGeo
|
|
111
111
|
assert(!(::RGeo::Feature::Line === line1_))
|
112
112
|
assert_equal(::RGeo::Feature::LineString, line1_.geometry_type)
|
113
113
|
end
|
114
|
-
|
115
|
-
|
114
|
+
|
115
|
+
|
116
116
|
def test_creation_linear_ring
|
117
117
|
point1_ = @factory.point(0, 0)
|
118
118
|
point2_ = @factory.point(0, 1)
|
@@ -129,8 +129,8 @@ module RGeo
|
|
129
129
|
assert_equal(4, line2_.num_points)
|
130
130
|
assert_equal(::RGeo::Feature::LinearRing, line2_.geometry_type)
|
131
131
|
end
|
132
|
-
|
133
|
-
|
132
|
+
|
133
|
+
|
134
134
|
def test_creation_line
|
135
135
|
point1_ = @factory.point(0, 0)
|
136
136
|
point2_ = @factory.point(0, 1)
|
@@ -139,8 +139,8 @@ module RGeo
|
|
139
139
|
assert(::RGeo::Feature::Line === line1_)
|
140
140
|
assert_equal(::RGeo::Feature::Line, line1_.geometry_type)
|
141
141
|
end
|
142
|
-
|
143
|
-
|
142
|
+
|
143
|
+
|
144
144
|
def test_creation_errors
|
145
145
|
point1_ = @factory.point(0, 0)
|
146
146
|
collection_ = point1_.boundary
|
@@ -149,8 +149,8 @@ module RGeo
|
|
149
149
|
line2_ = @factory.line_string([point1_, collection_])
|
150
150
|
assert_nil(line2_)
|
151
151
|
end
|
152
|
-
|
153
|
-
|
152
|
+
|
153
|
+
|
154
154
|
def test_fully_equal
|
155
155
|
point1_ = @factory.point(0, 0)
|
156
156
|
point2_ = @factory.point(0, 1)
|
@@ -163,8 +163,8 @@ module RGeo
|
|
163
163
|
assert(line1_.eql?(line2_))
|
164
164
|
assert(line1_.equals?(line2_))
|
165
165
|
end
|
166
|
-
|
167
|
-
|
166
|
+
|
167
|
+
|
168
168
|
def test_geometrically_equal_but_different_type
|
169
169
|
point1_ = @factory.point(0, 0)
|
170
170
|
point2_ = @factory.point(0, 1)
|
@@ -175,8 +175,8 @@ module RGeo
|
|
175
175
|
assert(!line1_.eql?(line2_))
|
176
176
|
assert(line1_.equals?(line2_))
|
177
177
|
end
|
178
|
-
|
179
|
-
|
178
|
+
|
179
|
+
|
180
180
|
def test_geometrically_equal_but_different_type2
|
181
181
|
point1_ = @factory.point(0, 0)
|
182
182
|
point2_ = @factory.point(0, 1)
|
@@ -189,8 +189,8 @@ module RGeo
|
|
189
189
|
assert(!line1_.eql?(line2_))
|
190
190
|
assert(line1_.equals?(line2_))
|
191
191
|
end
|
192
|
-
|
193
|
-
|
192
|
+
|
193
|
+
|
194
194
|
def test_geometrically_equal_but_different_overlap
|
195
195
|
point1_ = @factory.point(0, 0)
|
196
196
|
point2_ = @factory.point(0, 1)
|
@@ -203,16 +203,16 @@ module RGeo
|
|
203
203
|
assert(!line1_.eql?(line2_))
|
204
204
|
assert(line1_.equals?(line2_))
|
205
205
|
end
|
206
|
-
|
207
|
-
|
206
|
+
|
207
|
+
|
208
208
|
def test_empty_equal
|
209
209
|
line1_ = @factory.line_string([])
|
210
210
|
line2_ = @factory.line_string([])
|
211
211
|
assert(line1_.eql?(line2_))
|
212
212
|
assert(line1_.equals?(line2_))
|
213
213
|
end
|
214
|
-
|
215
|
-
|
214
|
+
|
215
|
+
|
216
216
|
def test_not_equal
|
217
217
|
point1_ = @factory.point(0, 0)
|
218
218
|
point2_ = @factory.point(0, 1)
|
@@ -224,8 +224,8 @@ module RGeo
|
|
224
224
|
assert(!line1_.eql?(line2_))
|
225
225
|
assert(!line1_.equals?(line2_))
|
226
226
|
end
|
227
|
-
|
228
|
-
|
227
|
+
|
228
|
+
|
229
229
|
def test_wkt_creation
|
230
230
|
line1_ = @factory.parse_wkt('LINESTRING(21 22, 11 12)')
|
231
231
|
assert_equal(@factory.point(21, 22), line1_.point_n(0))
|
@@ -238,8 +238,8 @@ module RGeo
|
|
238
238
|
assert_equal(@factory.point(-1, -1), line2_.point_n(3))
|
239
239
|
assert_equal(4, line2_.num_points)
|
240
240
|
end
|
241
|
-
|
242
|
-
|
241
|
+
|
242
|
+
|
243
243
|
def test_clone
|
244
244
|
point1_ = @factory.point(0, 0)
|
245
245
|
point2_ = @factory.point(0, 1)
|
@@ -250,8 +250,8 @@ module RGeo
|
|
250
250
|
assert(point1_.eql?(line2_.point_n(0)))
|
251
251
|
assert(point2_.eql?(line2_.point_n(1)))
|
252
252
|
end
|
253
|
-
|
254
|
-
|
253
|
+
|
254
|
+
|
255
255
|
def test_type_check
|
256
256
|
point1_ = @factory.point(0, 0)
|
257
257
|
point2_ = @factory.point(0, 1)
|
@@ -263,8 +263,8 @@ module RGeo
|
|
263
263
|
assert(::RGeo::Feature::LineString.check_type(line_))
|
264
264
|
assert(!::RGeo::Feature::LinearRing.check_type(line_))
|
265
265
|
end
|
266
|
-
|
267
|
-
|
266
|
+
|
267
|
+
|
268
268
|
def test_as_text_wkt_round_trip
|
269
269
|
point1_ = @factory.point(0, 0)
|
270
270
|
point2_ = @factory.point(0, 1)
|
@@ -273,8 +273,8 @@ module RGeo
|
|
273
273
|
line2_ = @factory.parse_wkt(text_)
|
274
274
|
assert(line2_.eql?(line1_))
|
275
275
|
end
|
276
|
-
|
277
|
-
|
276
|
+
|
277
|
+
|
278
278
|
def test_as_binary_wkb_round_trip
|
279
279
|
point1_ = @factory.point(-42, 0)
|
280
280
|
point2_ = @factory.point(0, 193)
|
@@ -283,32 +283,32 @@ module RGeo
|
|
283
283
|
line2_ = @factory.parse_wkb(binary_)
|
284
284
|
assert(line2_.eql?(line1_))
|
285
285
|
end
|
286
|
-
|
287
|
-
|
286
|
+
|
287
|
+
|
288
288
|
def test_empty_as_text_wkt_round_trip
|
289
289
|
line1_ = @factory.line_string([])
|
290
290
|
text_ = line1_.as_text
|
291
291
|
line2_ = @factory.parse_wkt(text_)
|
292
292
|
assert(line2_.is_empty?)
|
293
293
|
end
|
294
|
-
|
295
|
-
|
294
|
+
|
295
|
+
|
296
296
|
def test_empty_as_binary_wkb_round_trip
|
297
297
|
line1_ = @factory.line_string([])
|
298
298
|
binary_ = line1_.as_binary
|
299
299
|
line2_ = @factory.parse_wkb(binary_)
|
300
300
|
assert(line2_.is_empty?)
|
301
301
|
end
|
302
|
-
|
303
|
-
|
302
|
+
|
303
|
+
|
304
304
|
def test_dimension
|
305
305
|
point1_ = @factory.point(-42, 0)
|
306
306
|
point2_ = @factory.point(0, 193)
|
307
307
|
line1_ = @factory.line_string([point1_, point2_])
|
308
308
|
assert_equal(1, line1_.dimension)
|
309
309
|
end
|
310
|
-
|
311
|
-
|
310
|
+
|
311
|
+
|
312
312
|
def test_is_empty
|
313
313
|
point1_ = @factory.point(-42, 0)
|
314
314
|
point2_ = @factory.point(0, 193)
|
@@ -317,10 +317,10 @@ module RGeo
|
|
317
317
|
line2_ = @factory.line_string([])
|
318
318
|
assert(line2_.is_empty?)
|
319
319
|
end
|
320
|
-
|
321
|
-
|
320
|
+
|
321
|
+
|
322
322
|
end
|
323
|
-
|
323
|
+
|
324
324
|
end
|
325
325
|
end
|
326
326
|
end
|