rgeo-shapefile 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -16
- data/lib/rgeo-shapefile.rb +1 -1
- data/lib/rgeo/shapefile.rb +3 -9
- data/lib/rgeo/shapefile/reader.rb +80 -127
- data/lib/rgeo/shapefile/version.rb +1 -5
- data/test/basic_test.rb +5 -18
- data/test/shapelib_cases_test.rb +446 -466
- metadata +5 -5
data/test/basic_test.rb
CHANGED
@@ -1,21 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "rgeo/shapefile"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
module Tests # :nodoc:
|
8
|
-
|
9
|
-
class BasicTest < ::Minitest::Test # :nodoc:
|
10
|
-
|
11
|
-
|
12
|
-
def test_has_version
|
13
|
-
refute_nil(::RGeo::Shapefile::VERSION)
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
4
|
+
class BasicTest < Minitest::Test
|
5
|
+
def test_has_version
|
6
|
+
assert RGeo::Shapefile::VERSION.is_a?(String)
|
20
7
|
end
|
21
8
|
end
|
data/test/shapelib_cases_test.rb
CHANGED
@@ -1,492 +1,472 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "rgeo/shapefile"
|
3
3
|
|
4
|
+
class ShapelibCasesTest < Minitest::Test
|
5
|
+
def test_open_with_block_returns_value_of_block
|
6
|
+
result = _open_shapefile("test") do |file_|
|
7
|
+
file_.num_records
|
8
|
+
end
|
9
|
+
assert_equal(3, result)
|
10
|
+
end
|
4
11
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
rec_ = file_.next
|
20
|
-
assert_equal(0, rec_.index)
|
21
|
-
assert_equal(1, rec_.geometry[0].num_interior_rings)
|
22
|
-
assert_equal(1, file_.cur_index)
|
23
|
-
file_.rewind
|
24
|
-
assert_equal(0, file_.cur_index)
|
25
|
-
rec_ = file_.next
|
26
|
-
assert_equal(0, rec_.index)
|
27
|
-
assert_equal(1, rec_.geometry[0].num_interior_rings)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
def test_seek
|
33
|
-
_open_shapefile('test') do |file_|
|
34
|
-
assert_equal(0, file_.cur_index)
|
35
|
-
assert_equal(false, file_.seek_index(4))
|
36
|
-
assert_equal(0, file_.cur_index)
|
37
|
-
file_.seek_index(3)
|
38
|
-
assert_equal(3, file_.cur_index)
|
39
|
-
assert_nil(file_.next)
|
40
|
-
file_.seek_index(2)
|
41
|
-
assert_equal(2, file_.cur_index)
|
42
|
-
rec_ = file_.next
|
43
|
-
assert_equal(2, rec_.index)
|
44
|
-
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
45
|
-
assert_equal('', rec_['Descriptio'])
|
46
|
-
file_.seek_index(0)
|
47
|
-
assert_equal(0, file_.cur_index)
|
48
|
-
rec_ = file_.next
|
49
|
-
assert_equal(0, rec_.index)
|
50
|
-
assert_equal(1, rec_.geometry[0].num_interior_rings)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
def test_attributes
|
56
|
-
_open_shapefile('test') do |file_|
|
57
|
-
rec_ = file_.next
|
58
|
-
assert_equal('Square with triangle missing', rec_['Descriptio'])
|
59
|
-
assert_equal('Square with triangle missing', rec_.attributes['Descriptio'])
|
60
|
-
assert_equal(1, rec_['TestInt'])
|
61
|
-
assert_equal(2.5, rec_['TestDouble'])
|
62
|
-
assert_nil(rec_['NotAKey'])
|
63
|
-
rec_ = file_.next
|
64
|
-
assert_equal('Smaller triangle', rec_['Descriptio'])
|
65
|
-
assert_equal(100, rec_['TestInt'])
|
66
|
-
assert_equal(1000.25, rec_['TestDouble'])
|
67
|
-
rec_ = file_.next
|
68
|
-
assert_equal('', rec_['Descriptio'])
|
69
|
-
assert_equal(0, rec_['TestInt'])
|
70
|
-
assert_equal(0, rec_['TestDouble'])
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
def test_test0
|
76
|
-
_open_shapefile('test0') do |file_|
|
77
|
-
assert_equal(0, file_.shape_type_code)
|
78
|
-
assert_equal(2, file_.num_records)
|
79
|
-
rec_ = file_.next
|
80
|
-
assert_equal(0, rec_.index)
|
81
|
-
assert_nil(rec_.geometry)
|
82
|
-
rec_ = file_.next
|
83
|
-
assert_equal(1, rec_.index)
|
84
|
-
assert_nil(rec_.geometry)
|
85
|
-
assert_nil(file_.next)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
def _test_point_shapefile(filename_, has_z_, has_m_)
|
91
|
-
_open_shapefile(filename_) do |file_|
|
92
|
-
assert_equal(has_z_ ? 11 : has_m_ ? 21 : 1, file_.shape_type_code)
|
93
|
-
assert_equal(2, file_.num_records)
|
94
|
-
assert_equal(has_z_, file_.factory.property(:has_z_coordinate))
|
95
|
-
assert_equal(has_m_, file_.factory.property(:has_m_coordinate))
|
96
|
-
rec_ = file_.next
|
97
|
-
assert_equal(0, rec_.index)
|
98
|
-
assert_equal(::RGeo::Feature::Point, rec_.geometry.geometry_type)
|
99
|
-
assert_equal(1, rec_.geometry.x)
|
100
|
-
assert_equal(2, rec_.geometry.y)
|
101
|
-
assert_equal(3, rec_.geometry.z) if has_z_
|
102
|
-
assert_equal(4, rec_.geometry.m) if has_m_
|
103
|
-
rec_ = file_.next
|
104
|
-
assert_equal(1, rec_.index)
|
105
|
-
assert_equal(::RGeo::Feature::Point, rec_.geometry.geometry_type)
|
106
|
-
assert_equal(10, rec_.geometry.x)
|
107
|
-
assert_equal(20, rec_.geometry.y)
|
108
|
-
assert_equal(30, rec_.geometry.z) if has_z_
|
109
|
-
assert_equal(40, rec_.geometry.m) if has_m_
|
110
|
-
assert_nil(file_.next)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
|
115
|
-
def test_test1
|
116
|
-
_test_point_shapefile('test1', false, false)
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
|
-
def test_test2
|
121
|
-
_test_point_shapefile('test2', true, true)
|
122
|
-
end
|
123
|
-
|
124
|
-
|
125
|
-
def test_test3
|
126
|
-
_test_point_shapefile('test3', false, true)
|
127
|
-
end
|
128
|
-
|
129
|
-
|
130
|
-
def _test_multipoint_shapefile(filename_, has_z_, has_m_)
|
131
|
-
_open_shapefile(filename_) do |file_|
|
132
|
-
assert_equal(has_z_ ? 18 : has_m_ ? 28 : 8, file_.shape_type_code)
|
133
|
-
assert_equal(3, file_.num_records)
|
134
|
-
assert_equal(has_z_, file_.factory.property(:has_z_coordinate))
|
135
|
-
assert_equal(has_m_, file_.factory.property(:has_m_coordinate))
|
136
|
-
rec_ = file_.next
|
137
|
-
assert_equal(::RGeo::Feature::MultiPoint, rec_.geometry.geometry_type)
|
138
|
-
assert_equal(4, rec_.geometry.num_geometries)
|
139
|
-
assert_equal(1.15, rec_.geometry[0].x)
|
140
|
-
assert_equal(2.25, rec_.geometry[0].y)
|
141
|
-
assert_equal(3.35, rec_.geometry[0].z) if has_z_
|
142
|
-
assert_equal(4.45, rec_.geometry[0].m) if has_m_
|
143
|
-
assert_equal(4.15, rec_.geometry[3].x)
|
144
|
-
assert_equal(5.25, rec_.geometry[3].y)
|
145
|
-
assert_equal(6.35, rec_.geometry[3].z) if has_z_
|
146
|
-
assert_equal(7.45, rec_.geometry[3].m) if has_m_
|
147
|
-
rec_ = file_.next
|
148
|
-
assert_equal(::RGeo::Feature::MultiPoint, rec_.geometry.geometry_type)
|
149
|
-
assert_equal(4, rec_.geometry.num_geometries)
|
150
|
-
rec_ = file_.next
|
151
|
-
assert_equal(::RGeo::Feature::MultiPoint, rec_.geometry.geometry_type)
|
152
|
-
assert_equal(4, rec_.geometry.num_geometries)
|
153
|
-
assert_equal(21.15, rec_.geometry[0].x)
|
154
|
-
assert_equal(22.25, rec_.geometry[0].y)
|
155
|
-
assert_equal(23.35, rec_.geometry[0].z) if has_z_
|
156
|
-
assert_equal(24.45, rec_.geometry[0].m) if has_m_
|
157
|
-
assert_equal(24.15, rec_.geometry[3].x)
|
158
|
-
assert_equal(25.25, rec_.geometry[3].y)
|
159
|
-
assert_equal(26.35, rec_.geometry[3].z) if has_z_
|
160
|
-
assert_equal(27.45, rec_.geometry[3].m) if has_m_
|
161
|
-
assert_nil(file_.next)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
|
166
|
-
def test_test4
|
167
|
-
_test_multipoint_shapefile('test4', false, false)
|
168
|
-
end
|
169
|
-
|
170
|
-
|
171
|
-
def test_test5
|
172
|
-
_test_multipoint_shapefile('test5', true, true)
|
173
|
-
end
|
174
|
-
|
12
|
+
def test_rewind
|
13
|
+
_open_shapefile("test") do |file_|
|
14
|
+
assert_equal(0, file_.cur_index)
|
15
|
+
rec_ = file_.next
|
16
|
+
assert_equal(0, rec_.index)
|
17
|
+
assert_equal(1, rec_.geometry[0].num_interior_rings)
|
18
|
+
assert_equal(1, file_.cur_index)
|
19
|
+
file_.rewind
|
20
|
+
assert_equal(0, file_.cur_index)
|
21
|
+
rec_ = file_.next
|
22
|
+
assert_equal(0, rec_.index)
|
23
|
+
assert_equal(1, rec_.geometry[0].num_interior_rings)
|
24
|
+
end
|
25
|
+
end
|
175
26
|
|
176
|
-
|
177
|
-
|
178
|
-
|
27
|
+
def test_seek
|
28
|
+
_open_shapefile("test") do |file_|
|
29
|
+
assert_equal(0, file_.cur_index)
|
30
|
+
assert_equal(false, file_.seek_index(4))
|
31
|
+
assert_equal(0, file_.cur_index)
|
32
|
+
file_.seek_index(3)
|
33
|
+
assert_equal(3, file_.cur_index)
|
34
|
+
assert_nil(file_.next)
|
35
|
+
file_.seek_index(2)
|
36
|
+
assert_equal(2, file_.cur_index)
|
37
|
+
rec_ = file_.next
|
38
|
+
assert_equal(2, rec_.index)
|
39
|
+
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
40
|
+
assert_equal("", rec_["Descriptio"])
|
41
|
+
file_.seek_index(0)
|
42
|
+
assert_equal(0, file_.cur_index)
|
43
|
+
rec_ = file_.next
|
44
|
+
assert_equal(0, rec_.index)
|
45
|
+
assert_equal(1, rec_.geometry[0].num_interior_rings)
|
46
|
+
end
|
47
|
+
end
|
179
48
|
|
49
|
+
def test_attributes
|
50
|
+
_open_shapefile("test") do |file_|
|
51
|
+
rec_ = file_.next
|
52
|
+
assert_equal("Square with triangle missing", rec_["Descriptio"])
|
53
|
+
assert_equal("Square with triangle missing", rec_.attributes["Descriptio"])
|
54
|
+
assert_equal(1, rec_["TestInt"])
|
55
|
+
assert_equal(2.5, rec_["TestDouble"])
|
56
|
+
assert_nil(rec_["NotAKey"])
|
57
|
+
rec_ = file_.next
|
58
|
+
assert_equal("Smaller triangle", rec_["Descriptio"])
|
59
|
+
assert_equal(100, rec_["TestInt"])
|
60
|
+
assert_equal(1000.25, rec_["TestDouble"])
|
61
|
+
rec_ = file_.next
|
62
|
+
assert_equal("", rec_["Descriptio"])
|
63
|
+
assert_equal(0, rec_["TestInt"])
|
64
|
+
assert_equal(0, rec_["TestDouble"])
|
65
|
+
end
|
66
|
+
end
|
180
67
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
assert_equal(4.45, rec_.geometry[0].point_n(0).m) if has_m_
|
195
|
-
assert_equal(2, rec_.geometry[0].point_n(1).x)
|
196
|
-
assert_equal(1, rec_.geometry[0].point_n(1).y)
|
197
|
-
assert_equal(4.35, rec_.geometry[0].point_n(1).z) if has_z_
|
198
|
-
assert_equal(5.45, rec_.geometry[0].point_n(1).m) if has_m_
|
199
|
-
assert_equal(2, rec_.geometry[0].point_n(2).x)
|
200
|
-
assert_equal(2, rec_.geometry[0].point_n(2).y)
|
201
|
-
assert_equal(5.35, rec_.geometry[0].point_n(2).z) if has_z_
|
202
|
-
assert_equal(6.45, rec_.geometry[0].point_n(2).m) if has_m_
|
203
|
-
assert_equal(1, rec_.geometry[0].point_n(4).x)
|
204
|
-
assert_equal(1, rec_.geometry[0].point_n(4).y)
|
205
|
-
assert_equal(7.35, rec_.geometry[0].point_n(4).z) if has_z_
|
206
|
-
assert_equal(8.45, rec_.geometry[0].point_n(4).m) if has_m_
|
207
|
-
rec_ = file_.next
|
208
|
-
assert_equal(::RGeo::Feature::MultiLineString, rec_.geometry.geometry_type)
|
209
|
-
assert_equal(1, rec_.geometry.num_geometries)
|
210
|
-
rec_ = file_.next
|
211
|
-
assert_equal(::RGeo::Feature::MultiLineString, rec_.geometry.geometry_type)
|
212
|
-
assert_equal(1, rec_.geometry.num_geometries)
|
213
|
-
assert_equal(5, rec_.geometry[0].num_points)
|
214
|
-
assert_equal(1, rec_.geometry[0].point_n(0).x)
|
215
|
-
assert_equal(7, rec_.geometry[0].point_n(0).y)
|
216
|
-
assert_equal(23.35, rec_.geometry[0].point_n(0).z) if has_z_
|
217
|
-
assert_equal(24.45, rec_.geometry[0].point_n(0).m) if has_m_
|
218
|
-
assert_equal(2, rec_.geometry[0].point_n(1).x)
|
219
|
-
assert_equal(7, rec_.geometry[0].point_n(1).y)
|
220
|
-
assert_equal(24.35, rec_.geometry[0].point_n(1).z) if has_z_
|
221
|
-
assert_equal(25.45, rec_.geometry[0].point_n(1).m) if has_m_
|
222
|
-
assert_equal(2, rec_.geometry[0].point_n(2).x)
|
223
|
-
assert_equal(8, rec_.geometry[0].point_n(2).y)
|
224
|
-
assert_equal(25.35, rec_.geometry[0].point_n(2).z) if has_z_
|
225
|
-
assert_equal(26.45, rec_.geometry[0].point_n(2).m) if has_m_
|
226
|
-
assert_equal(1, rec_.geometry[0].point_n(4).x)
|
227
|
-
assert_equal(7, rec_.geometry[0].point_n(4).y)
|
228
|
-
assert_equal(27.35, rec_.geometry[0].point_n(4).z) if has_z_
|
229
|
-
assert_equal(28.45, rec_.geometry[0].point_n(4).m) if has_m_
|
230
|
-
rec_ = file_.next
|
231
|
-
assert_equal(::RGeo::Feature::MultiLineString, rec_.geometry.geometry_type)
|
232
|
-
assert_equal(3, rec_.geometry.num_geometries)
|
233
|
-
assert_equal(5, rec_.geometry[0].num_points)
|
234
|
-
assert_equal(0, rec_.geometry[0].point_n(0).x)
|
235
|
-
assert_equal(0, rec_.geometry[0].point_n(0).y)
|
236
|
-
assert_equal(0, rec_.geometry[0].point_n(0).z) if has_z_
|
237
|
-
assert_equal(0, rec_.geometry[0].point_n(0).m) if has_m_
|
238
|
-
assert_equal(0, rec_.geometry[0].point_n(1).x)
|
239
|
-
assert_equal(100, rec_.geometry[0].point_n(1).y)
|
240
|
-
assert_equal(1, rec_.geometry[0].point_n(1).z) if has_z_
|
241
|
-
assert_equal(2, rec_.geometry[0].point_n(1).m) if has_m_
|
242
|
-
assert_equal(0, rec_.geometry[0].point_n(4).x)
|
243
|
-
assert_equal(0, rec_.geometry[0].point_n(4).y)
|
244
|
-
assert_equal(4, rec_.geometry[0].point_n(4).z) if has_z_
|
245
|
-
assert_equal(8, rec_.geometry[0].point_n(4).m) if has_m_
|
246
|
-
assert_equal(5, rec_.geometry[1].num_points)
|
247
|
-
assert_equal(10, rec_.geometry[1].point_n(0).x)
|
248
|
-
assert_equal(20, rec_.geometry[1].point_n(0).y)
|
249
|
-
assert_equal(5, rec_.geometry[1].point_n(0).z) if has_z_
|
250
|
-
assert_equal(10, rec_.geometry[1].point_n(0).m) if has_m_
|
251
|
-
assert_equal(30, rec_.geometry[1].point_n(1).x)
|
252
|
-
assert_equal(20, rec_.geometry[1].point_n(1).y)
|
253
|
-
assert_equal(6, rec_.geometry[1].point_n(1).z) if has_z_
|
254
|
-
assert_equal(12, rec_.geometry[1].point_n(1).m) if has_m_
|
255
|
-
assert_equal(30, rec_.geometry[1].point_n(2).x)
|
256
|
-
assert_equal(40, rec_.geometry[1].point_n(2).y)
|
257
|
-
assert_equal(7, rec_.geometry[1].point_n(2).z) if has_z_
|
258
|
-
assert_equal(14, rec_.geometry[1].point_n(2).m) if has_m_
|
259
|
-
assert_equal(5, rec_.geometry[2].num_points)
|
260
|
-
assert_equal(60, rec_.geometry[2].point_n(0).x)
|
261
|
-
assert_equal(20, rec_.geometry[2].point_n(0).y)
|
262
|
-
assert_equal(10, rec_.geometry[2].point_n(0).z) if has_z_
|
263
|
-
assert_equal(20, rec_.geometry[2].point_n(0).m) if has_m_
|
264
|
-
assert_equal(90, rec_.geometry[2].point_n(1).x)
|
265
|
-
assert_equal(20, rec_.geometry[2].point_n(1).y)
|
266
|
-
assert_equal(11, rec_.geometry[2].point_n(1).z) if has_z_
|
267
|
-
assert_equal(22, rec_.geometry[2].point_n(1).m) if has_m_
|
268
|
-
assert_equal(60, rec_.geometry[2].point_n(4).x)
|
269
|
-
assert_equal(20, rec_.geometry[2].point_n(4).y)
|
270
|
-
assert_equal(14, rec_.geometry[2].point_n(4).z) if has_z_
|
271
|
-
assert_equal(28, rec_.geometry[2].point_n(4).m) if has_m_
|
272
|
-
end
|
273
|
-
end
|
68
|
+
def test_test0
|
69
|
+
_open_shapefile("test0") do |file_|
|
70
|
+
assert_equal(0, file_.shape_type_code)
|
71
|
+
assert_equal(2, file_.num_records)
|
72
|
+
rec_ = file_.next
|
73
|
+
assert_equal(0, rec_.index)
|
74
|
+
assert_nil(rec_.geometry)
|
75
|
+
rec_ = file_.next
|
76
|
+
assert_equal(1, rec_.index)
|
77
|
+
assert_nil(rec_.geometry)
|
78
|
+
assert_nil(file_.next)
|
79
|
+
end
|
80
|
+
end
|
274
81
|
|
82
|
+
def _test_point_shapefile(filename_, has_z_, has_m_)
|
83
|
+
_open_shapefile(filename_) do |file_|
|
84
|
+
assert_equal(has_z_ ? 11 : has_m_ ? 21 : 1, file_.shape_type_code)
|
85
|
+
assert_equal(2, file_.num_records)
|
86
|
+
assert_equal(has_z_, file_.factory.property(:has_z_coordinate))
|
87
|
+
assert_equal(has_m_, file_.factory.property(:has_m_coordinate))
|
88
|
+
rec_ = file_.next
|
89
|
+
assert_equal(0, rec_.index)
|
90
|
+
assert_equal(RGeo::Feature::Point, rec_.geometry.geometry_type)
|
91
|
+
assert_equal(1, rec_.geometry.x)
|
92
|
+
assert_equal(2, rec_.geometry.y)
|
93
|
+
assert_equal(3, rec_.geometry.z) if has_z_
|
94
|
+
assert_equal(4, rec_.geometry.m) if has_m_
|
95
|
+
rec_ = file_.next
|
96
|
+
assert_equal(1, rec_.index)
|
97
|
+
assert_equal(RGeo::Feature::Point, rec_.geometry.geometry_type)
|
98
|
+
assert_equal(10, rec_.geometry.x)
|
99
|
+
assert_equal(20, rec_.geometry.y)
|
100
|
+
assert_equal(30, rec_.geometry.z) if has_z_
|
101
|
+
assert_equal(40, rec_.geometry.m) if has_m_
|
102
|
+
assert_nil(file_.next)
|
103
|
+
end
|
104
|
+
end
|
275
105
|
|
276
|
-
|
277
|
-
|
278
|
-
|
106
|
+
def test_test1
|
107
|
+
_test_point_shapefile("test1", false, false)
|
108
|
+
end
|
279
109
|
|
110
|
+
def test_test2
|
111
|
+
_test_point_shapefile("test2", true, true)
|
112
|
+
end
|
280
113
|
|
281
|
-
|
282
|
-
|
283
|
-
|
114
|
+
def test_test3
|
115
|
+
_test_point_shapefile("test3", false, true)
|
116
|
+
end
|
284
117
|
|
118
|
+
def _test_multipoint_shapefile(filename_, has_z_, has_m_)
|
119
|
+
_open_shapefile(filename_) do |file_|
|
120
|
+
assert_equal(has_z_ ? 18 : has_m_ ? 28 : 8, file_.shape_type_code)
|
121
|
+
assert_equal(3, file_.num_records)
|
122
|
+
assert_equal(has_z_, file_.factory.property(:has_z_coordinate))
|
123
|
+
assert_equal(has_m_, file_.factory.property(:has_m_coordinate))
|
124
|
+
rec_ = file_.next
|
125
|
+
assert_equal(RGeo::Feature::MultiPoint, rec_.geometry.geometry_type)
|
126
|
+
assert_equal(4, rec_.geometry.num_geometries)
|
127
|
+
assert_equal(1.15, rec_.geometry[0].x)
|
128
|
+
assert_equal(2.25, rec_.geometry[0].y)
|
129
|
+
assert_equal(3.35, rec_.geometry[0].z) if has_z_
|
130
|
+
assert_equal(4.45, rec_.geometry[0].m) if has_m_
|
131
|
+
assert_equal(4.15, rec_.geometry[3].x)
|
132
|
+
assert_equal(5.25, rec_.geometry[3].y)
|
133
|
+
assert_equal(6.35, rec_.geometry[3].z) if has_z_
|
134
|
+
assert_equal(7.45, rec_.geometry[3].m) if has_m_
|
135
|
+
rec_ = file_.next
|
136
|
+
assert_equal(RGeo::Feature::MultiPoint, rec_.geometry.geometry_type)
|
137
|
+
assert_equal(4, rec_.geometry.num_geometries)
|
138
|
+
rec_ = file_.next
|
139
|
+
assert_equal(RGeo::Feature::MultiPoint, rec_.geometry.geometry_type)
|
140
|
+
assert_equal(4, rec_.geometry.num_geometries)
|
141
|
+
assert_equal(21.15, rec_.geometry[0].x)
|
142
|
+
assert_equal(22.25, rec_.geometry[0].y)
|
143
|
+
assert_equal(23.35, rec_.geometry[0].z) if has_z_
|
144
|
+
assert_equal(24.45, rec_.geometry[0].m) if has_m_
|
145
|
+
assert_equal(24.15, rec_.geometry[3].x)
|
146
|
+
assert_equal(25.25, rec_.geometry[3].y)
|
147
|
+
assert_equal(26.35, rec_.geometry[3].z) if has_z_
|
148
|
+
assert_equal(27.45, rec_.geometry[3].m) if has_m_
|
149
|
+
assert_nil(file_.next)
|
150
|
+
end
|
151
|
+
end
|
285
152
|
|
286
|
-
|
287
|
-
|
288
|
-
|
153
|
+
def test_test4
|
154
|
+
_test_multipoint_shapefile("test4", false, false)
|
155
|
+
end
|
289
156
|
|
157
|
+
def test_test5
|
158
|
+
_test_multipoint_shapefile("test5", true, true)
|
159
|
+
end
|
290
160
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
assert_equal(4, file_.num_records)
|
295
|
-
assert_equal(has_z_, file_.factory.property(:has_z_coordinate))
|
296
|
-
assert_equal(has_m_, file_.factory.property(:has_m_coordinate))
|
297
|
-
rec_ = file_.next
|
298
|
-
assert_equal(::RGeo::Feature::MultiPolygon, rec_.geometry.geometry_type)
|
299
|
-
assert_equal(1, rec_.geometry.num_geometries)
|
300
|
-
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
301
|
-
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
302
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).x)
|
303
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).y)
|
304
|
-
assert_equal(3.35, rec_.geometry[0].exterior_ring.point_n(0).z) if has_z_
|
305
|
-
assert_equal(4.45, rec_.geometry[0].exterior_ring.point_n(0).m) if has_m_
|
306
|
-
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).x)
|
307
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(1).y)
|
308
|
-
assert_equal(4.35, rec_.geometry[0].exterior_ring.point_n(1).z) if has_z_
|
309
|
-
assert_equal(5.45, rec_.geometry[0].exterior_ring.point_n(1).m) if has_m_
|
310
|
-
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).x)
|
311
|
-
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).y)
|
312
|
-
assert_equal(5.35, rec_.geometry[0].exterior_ring.point_n(2).z) if has_z_
|
313
|
-
assert_equal(6.45, rec_.geometry[0].exterior_ring.point_n(2).m) if has_m_
|
314
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).x)
|
315
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).y)
|
316
|
-
assert_equal(7.35, rec_.geometry[0].exterior_ring.point_n(4).z) if has_z_
|
317
|
-
assert_equal(8.45, rec_.geometry[0].exterior_ring.point_n(4).m) if has_m_
|
318
|
-
rec_ = file_.next
|
319
|
-
assert_equal(::RGeo::Feature::MultiPolygon, rec_.geometry.geometry_type)
|
320
|
-
assert_equal(1, rec_.geometry.num_geometries)
|
321
|
-
rec_ = file_.next
|
322
|
-
assert_equal(::RGeo::Feature::MultiPolygon, rec_.geometry.geometry_type)
|
323
|
-
assert_equal(1, rec_.geometry.num_geometries)
|
324
|
-
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
325
|
-
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
326
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).x)
|
327
|
-
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(0).y)
|
328
|
-
assert_equal(23.35, rec_.geometry[0].exterior_ring.point_n(0).z) if has_z_
|
329
|
-
assert_equal(24.45, rec_.geometry[0].exterior_ring.point_n(0).m) if has_m_
|
330
|
-
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).x)
|
331
|
-
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(1).y)
|
332
|
-
assert_equal(24.35, rec_.geometry[0].exterior_ring.point_n(1).z) if has_z_
|
333
|
-
assert_equal(25.45, rec_.geometry[0].exterior_ring.point_n(1).m) if has_m_
|
334
|
-
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).x)
|
335
|
-
assert_equal(8, rec_.geometry[0].exterior_ring.point_n(2).y)
|
336
|
-
assert_equal(25.35, rec_.geometry[0].exterior_ring.point_n(2).z) if has_z_
|
337
|
-
assert_equal(26.45, rec_.geometry[0].exterior_ring.point_n(2).m) if has_m_
|
338
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).x)
|
339
|
-
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(4).y)
|
340
|
-
assert_equal(27.35, rec_.geometry[0].exterior_ring.point_n(4).z) if has_z_
|
341
|
-
assert_equal(28.45, rec_.geometry[0].exterior_ring.point_n(4).m) if has_m_
|
342
|
-
rec_ = file_.next
|
343
|
-
assert_equal(::RGeo::Feature::MultiPolygon, rec_.geometry.geometry_type)
|
344
|
-
assert_equal(1, rec_.geometry.num_geometries)
|
345
|
-
assert_equal(2, rec_.geometry[0].num_interior_rings)
|
346
|
-
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
347
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).x)
|
348
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).y)
|
349
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).z) if has_z_
|
350
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).m) if has_m_
|
351
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(1).x)
|
352
|
-
assert_equal(100, rec_.geometry[0].exterior_ring.point_n(1).y)
|
353
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(1).z) if has_z_
|
354
|
-
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).m) if has_m_
|
355
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(4).x)
|
356
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(4).y)
|
357
|
-
assert_equal(4, rec_.geometry[0].exterior_ring.point_n(4).z) if has_z_
|
358
|
-
assert_equal(8, rec_.geometry[0].exterior_ring.point_n(4).m) if has_m_
|
359
|
-
assert_equal(5, rec_.geometry[0].interior_ring_n(0).num_points)
|
360
|
-
assert_equal(10, rec_.geometry[0].interior_ring_n(0).point_n(0).x)
|
361
|
-
assert_equal(20, rec_.geometry[0].interior_ring_n(0).point_n(0).y)
|
362
|
-
assert_equal(5, rec_.geometry[0].interior_ring_n(0).point_n(0).z) if has_z_
|
363
|
-
assert_equal(10, rec_.geometry[0].interior_ring_n(0).point_n(0).m) if has_m_
|
364
|
-
assert_equal(30, rec_.geometry[0].interior_ring_n(0).point_n(1).x)
|
365
|
-
assert_equal(20, rec_.geometry[0].interior_ring_n(0).point_n(1).y)
|
366
|
-
assert_equal(6, rec_.geometry[0].interior_ring_n(0).point_n(1).z) if has_z_
|
367
|
-
assert_equal(12, rec_.geometry[0].interior_ring_n(0).point_n(1).m) if has_m_
|
368
|
-
assert_equal(30, rec_.geometry[0].interior_ring_n(0).point_n(2).x)
|
369
|
-
assert_equal(40, rec_.geometry[0].interior_ring_n(0).point_n(2).y)
|
370
|
-
assert_equal(7, rec_.geometry[0].interior_ring_n(0).point_n(2).z) if has_z_
|
371
|
-
assert_equal(14, rec_.geometry[0].interior_ring_n(0).point_n(2).m) if has_m_
|
372
|
-
assert_equal(5, rec_.geometry[0].interior_ring_n(1).num_points)
|
373
|
-
assert_equal(60, rec_.geometry[0].interior_ring_n(1).point_n(0).x)
|
374
|
-
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(0).y)
|
375
|
-
assert_equal(10, rec_.geometry[0].interior_ring_n(1).point_n(0).z) if has_z_
|
376
|
-
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(0).m) if has_m_
|
377
|
-
assert_equal(90, rec_.geometry[0].interior_ring_n(1).point_n(1).x)
|
378
|
-
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(1).y)
|
379
|
-
assert_equal(11, rec_.geometry[0].interior_ring_n(1).point_n(1).z) if has_z_
|
380
|
-
assert_equal(22, rec_.geometry[0].interior_ring_n(1).point_n(1).m) if has_m_
|
381
|
-
assert_equal(60, rec_.geometry[0].interior_ring_n(1).point_n(4).x)
|
382
|
-
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(4).y)
|
383
|
-
assert_equal(14, rec_.geometry[0].interior_ring_n(1).point_n(4).z) if has_z_
|
384
|
-
assert_equal(28, rec_.geometry[0].interior_ring_n(1).point_n(4).m) if has_m_
|
385
|
-
end
|
386
|
-
end
|
161
|
+
def test_test6
|
162
|
+
_test_multipoint_shapefile("test6", false, true)
|
163
|
+
end
|
387
164
|
|
165
|
+
def _test_polyline_shapefile(filename_, has_z_, has_m_)
|
166
|
+
_open_shapefile(filename_) do |file_|
|
167
|
+
assert_equal(has_z_ ? 13 : has_m_ ? 23 : 3, file_.shape_type_code)
|
168
|
+
assert_equal(4, file_.num_records)
|
169
|
+
assert_equal(has_z_, file_.factory.property(:has_z_coordinate))
|
170
|
+
assert_equal(has_m_, file_.factory.property(:has_m_coordinate))
|
171
|
+
rec_ = file_.next
|
172
|
+
assert_equal(RGeo::Feature::MultiLineString, rec_.geometry.geometry_type)
|
173
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
174
|
+
assert_equal(5, rec_.geometry[0].num_points)
|
175
|
+
assert_equal(1, rec_.geometry[0].point_n(0).x)
|
176
|
+
assert_equal(1, rec_.geometry[0].point_n(0).y)
|
177
|
+
assert_equal(3.35, rec_.geometry[0].point_n(0).z) if has_z_
|
178
|
+
assert_equal(4.45, rec_.geometry[0].point_n(0).m) if has_m_
|
179
|
+
assert_equal(2, rec_.geometry[0].point_n(1).x)
|
180
|
+
assert_equal(1, rec_.geometry[0].point_n(1).y)
|
181
|
+
assert_equal(4.35, rec_.geometry[0].point_n(1).z) if has_z_
|
182
|
+
assert_equal(5.45, rec_.geometry[0].point_n(1).m) if has_m_
|
183
|
+
assert_equal(2, rec_.geometry[0].point_n(2).x)
|
184
|
+
assert_equal(2, rec_.geometry[0].point_n(2).y)
|
185
|
+
assert_equal(5.35, rec_.geometry[0].point_n(2).z) if has_z_
|
186
|
+
assert_equal(6.45, rec_.geometry[0].point_n(2).m) if has_m_
|
187
|
+
assert_equal(1, rec_.geometry[0].point_n(4).x)
|
188
|
+
assert_equal(1, rec_.geometry[0].point_n(4).y)
|
189
|
+
assert_equal(7.35, rec_.geometry[0].point_n(4).z) if has_z_
|
190
|
+
assert_equal(8.45, rec_.geometry[0].point_n(4).m) if has_m_
|
191
|
+
rec_ = file_.next
|
192
|
+
assert_equal(RGeo::Feature::MultiLineString, rec_.geometry.geometry_type)
|
193
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
194
|
+
rec_ = file_.next
|
195
|
+
assert_equal(RGeo::Feature::MultiLineString, rec_.geometry.geometry_type)
|
196
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
197
|
+
assert_equal(5, rec_.geometry[0].num_points)
|
198
|
+
assert_equal(1, rec_.geometry[0].point_n(0).x)
|
199
|
+
assert_equal(7, rec_.geometry[0].point_n(0).y)
|
200
|
+
assert_equal(23.35, rec_.geometry[0].point_n(0).z) if has_z_
|
201
|
+
assert_equal(24.45, rec_.geometry[0].point_n(0).m) if has_m_
|
202
|
+
assert_equal(2, rec_.geometry[0].point_n(1).x)
|
203
|
+
assert_equal(7, rec_.geometry[0].point_n(1).y)
|
204
|
+
assert_equal(24.35, rec_.geometry[0].point_n(1).z) if has_z_
|
205
|
+
assert_equal(25.45, rec_.geometry[0].point_n(1).m) if has_m_
|
206
|
+
assert_equal(2, rec_.geometry[0].point_n(2).x)
|
207
|
+
assert_equal(8, rec_.geometry[0].point_n(2).y)
|
208
|
+
assert_equal(25.35, rec_.geometry[0].point_n(2).z) if has_z_
|
209
|
+
assert_equal(26.45, rec_.geometry[0].point_n(2).m) if has_m_
|
210
|
+
assert_equal(1, rec_.geometry[0].point_n(4).x)
|
211
|
+
assert_equal(7, rec_.geometry[0].point_n(4).y)
|
212
|
+
assert_equal(27.35, rec_.geometry[0].point_n(4).z) if has_z_
|
213
|
+
assert_equal(28.45, rec_.geometry[0].point_n(4).m) if has_m_
|
214
|
+
rec_ = file_.next
|
215
|
+
assert_equal(RGeo::Feature::MultiLineString, rec_.geometry.geometry_type)
|
216
|
+
assert_equal(3, rec_.geometry.num_geometries)
|
217
|
+
assert_equal(5, rec_.geometry[0].num_points)
|
218
|
+
assert_equal(0, rec_.geometry[0].point_n(0).x)
|
219
|
+
assert_equal(0, rec_.geometry[0].point_n(0).y)
|
220
|
+
assert_equal(0, rec_.geometry[0].point_n(0).z) if has_z_
|
221
|
+
assert_equal(0, rec_.geometry[0].point_n(0).m) if has_m_
|
222
|
+
assert_equal(0, rec_.geometry[0].point_n(1).x)
|
223
|
+
assert_equal(100, rec_.geometry[0].point_n(1).y)
|
224
|
+
assert_equal(1, rec_.geometry[0].point_n(1).z) if has_z_
|
225
|
+
assert_equal(2, rec_.geometry[0].point_n(1).m) if has_m_
|
226
|
+
assert_equal(0, rec_.geometry[0].point_n(4).x)
|
227
|
+
assert_equal(0, rec_.geometry[0].point_n(4).y)
|
228
|
+
assert_equal(4, rec_.geometry[0].point_n(4).z) if has_z_
|
229
|
+
assert_equal(8, rec_.geometry[0].point_n(4).m) if has_m_
|
230
|
+
assert_equal(5, rec_.geometry[1].num_points)
|
231
|
+
assert_equal(10, rec_.geometry[1].point_n(0).x)
|
232
|
+
assert_equal(20, rec_.geometry[1].point_n(0).y)
|
233
|
+
assert_equal(5, rec_.geometry[1].point_n(0).z) if has_z_
|
234
|
+
assert_equal(10, rec_.geometry[1].point_n(0).m) if has_m_
|
235
|
+
assert_equal(30, rec_.geometry[1].point_n(1).x)
|
236
|
+
assert_equal(20, rec_.geometry[1].point_n(1).y)
|
237
|
+
assert_equal(6, rec_.geometry[1].point_n(1).z) if has_z_
|
238
|
+
assert_equal(12, rec_.geometry[1].point_n(1).m) if has_m_
|
239
|
+
assert_equal(30, rec_.geometry[1].point_n(2).x)
|
240
|
+
assert_equal(40, rec_.geometry[1].point_n(2).y)
|
241
|
+
assert_equal(7, rec_.geometry[1].point_n(2).z) if has_z_
|
242
|
+
assert_equal(14, rec_.geometry[1].point_n(2).m) if has_m_
|
243
|
+
assert_equal(5, rec_.geometry[2].num_points)
|
244
|
+
assert_equal(60, rec_.geometry[2].point_n(0).x)
|
245
|
+
assert_equal(20, rec_.geometry[2].point_n(0).y)
|
246
|
+
assert_equal(10, rec_.geometry[2].point_n(0).z) if has_z_
|
247
|
+
assert_equal(20, rec_.geometry[2].point_n(0).m) if has_m_
|
248
|
+
assert_equal(90, rec_.geometry[2].point_n(1).x)
|
249
|
+
assert_equal(20, rec_.geometry[2].point_n(1).y)
|
250
|
+
assert_equal(11, rec_.geometry[2].point_n(1).z) if has_z_
|
251
|
+
assert_equal(22, rec_.geometry[2].point_n(1).m) if has_m_
|
252
|
+
assert_equal(60, rec_.geometry[2].point_n(4).x)
|
253
|
+
assert_equal(20, rec_.geometry[2].point_n(4).y)
|
254
|
+
assert_equal(14, rec_.geometry[2].point_n(4).z) if has_z_
|
255
|
+
assert_equal(28, rec_.geometry[2].point_n(4).m) if has_m_
|
256
|
+
end
|
257
|
+
end
|
388
258
|
|
389
|
-
|
390
|
-
|
391
|
-
|
259
|
+
def test_test7
|
260
|
+
_test_polyline_shapefile("test7", false, false)
|
261
|
+
end
|
392
262
|
|
263
|
+
def test_test8
|
264
|
+
_test_polyline_shapefile("test8", true, true)
|
265
|
+
end
|
393
266
|
|
394
|
-
|
395
|
-
|
396
|
-
|
267
|
+
def test_test9
|
268
|
+
_test_polyline_shapefile("test9", false, true)
|
269
|
+
end
|
397
270
|
|
271
|
+
def _test_polygon_shapefile(filename_, has_z_, has_m_)
|
272
|
+
_open_shapefile(filename_) do |file_|
|
273
|
+
assert_equal(has_z_ ? 15 : has_m_ ? 25 : 5, file_.shape_type_code)
|
274
|
+
assert_equal(4, file_.num_records)
|
275
|
+
assert_equal(has_z_, file_.factory.property(:has_z_coordinate))
|
276
|
+
assert_equal(has_m_, file_.factory.property(:has_m_coordinate))
|
277
|
+
rec_ = file_.next
|
278
|
+
assert_equal(RGeo::Feature::MultiPolygon, rec_.geometry.geometry_type)
|
279
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
280
|
+
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
281
|
+
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
282
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).x)
|
283
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).y)
|
284
|
+
assert_equal(3.35, rec_.geometry[0].exterior_ring.point_n(0).z) if has_z_
|
285
|
+
assert_equal(4.45, rec_.geometry[0].exterior_ring.point_n(0).m) if has_m_
|
286
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).x)
|
287
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(1).y)
|
288
|
+
assert_equal(4.35, rec_.geometry[0].exterior_ring.point_n(1).z) if has_z_
|
289
|
+
assert_equal(5.45, rec_.geometry[0].exterior_ring.point_n(1).m) if has_m_
|
290
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).x)
|
291
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).y)
|
292
|
+
assert_equal(5.35, rec_.geometry[0].exterior_ring.point_n(2).z) if has_z_
|
293
|
+
assert_equal(6.45, rec_.geometry[0].exterior_ring.point_n(2).m) if has_m_
|
294
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).x)
|
295
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).y)
|
296
|
+
assert_equal(7.35, rec_.geometry[0].exterior_ring.point_n(4).z) if has_z_
|
297
|
+
assert_equal(8.45, rec_.geometry[0].exterior_ring.point_n(4).m) if has_m_
|
298
|
+
rec_ = file_.next
|
299
|
+
assert_equal(RGeo::Feature::MultiPolygon, rec_.geometry.geometry_type)
|
300
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
301
|
+
rec_ = file_.next
|
302
|
+
assert_equal(RGeo::Feature::MultiPolygon, rec_.geometry.geometry_type)
|
303
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
304
|
+
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
305
|
+
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
306
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).x)
|
307
|
+
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(0).y)
|
308
|
+
assert_equal(23.35, rec_.geometry[0].exterior_ring.point_n(0).z) if has_z_
|
309
|
+
assert_equal(24.45, rec_.geometry[0].exterior_ring.point_n(0).m) if has_m_
|
310
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).x)
|
311
|
+
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(1).y)
|
312
|
+
assert_equal(24.35, rec_.geometry[0].exterior_ring.point_n(1).z) if has_z_
|
313
|
+
assert_equal(25.45, rec_.geometry[0].exterior_ring.point_n(1).m) if has_m_
|
314
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).x)
|
315
|
+
assert_equal(8, rec_.geometry[0].exterior_ring.point_n(2).y)
|
316
|
+
assert_equal(25.35, rec_.geometry[0].exterior_ring.point_n(2).z) if has_z_
|
317
|
+
assert_equal(26.45, rec_.geometry[0].exterior_ring.point_n(2).m) if has_m_
|
318
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).x)
|
319
|
+
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(4).y)
|
320
|
+
assert_equal(27.35, rec_.geometry[0].exterior_ring.point_n(4).z) if has_z_
|
321
|
+
assert_equal(28.45, rec_.geometry[0].exterior_ring.point_n(4).m) if has_m_
|
322
|
+
rec_ = file_.next
|
323
|
+
assert_equal(RGeo::Feature::MultiPolygon, rec_.geometry.geometry_type)
|
324
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
325
|
+
assert_equal(2, rec_.geometry[0].num_interior_rings)
|
326
|
+
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
327
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).x)
|
328
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).y)
|
329
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).z) if has_z_
|
330
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).m) if has_m_
|
331
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(1).x)
|
332
|
+
assert_equal(100, rec_.geometry[0].exterior_ring.point_n(1).y)
|
333
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(1).z) if has_z_
|
334
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).m) if has_m_
|
335
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(4).x)
|
336
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(4).y)
|
337
|
+
assert_equal(4, rec_.geometry[0].exterior_ring.point_n(4).z) if has_z_
|
338
|
+
assert_equal(8, rec_.geometry[0].exterior_ring.point_n(4).m) if has_m_
|
339
|
+
assert_equal(5, rec_.geometry[0].interior_ring_n(0).num_points)
|
340
|
+
assert_equal(10, rec_.geometry[0].interior_ring_n(0).point_n(0).x)
|
341
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(0).point_n(0).y)
|
342
|
+
assert_equal(5, rec_.geometry[0].interior_ring_n(0).point_n(0).z) if has_z_
|
343
|
+
assert_equal(10, rec_.geometry[0].interior_ring_n(0).point_n(0).m) if has_m_
|
344
|
+
assert_equal(30, rec_.geometry[0].interior_ring_n(0).point_n(1).x)
|
345
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(0).point_n(1).y)
|
346
|
+
assert_equal(6, rec_.geometry[0].interior_ring_n(0).point_n(1).z) if has_z_
|
347
|
+
assert_equal(12, rec_.geometry[0].interior_ring_n(0).point_n(1).m) if has_m_
|
348
|
+
assert_equal(30, rec_.geometry[0].interior_ring_n(0).point_n(2).x)
|
349
|
+
assert_equal(40, rec_.geometry[0].interior_ring_n(0).point_n(2).y)
|
350
|
+
assert_equal(7, rec_.geometry[0].interior_ring_n(0).point_n(2).z) if has_z_
|
351
|
+
assert_equal(14, rec_.geometry[0].interior_ring_n(0).point_n(2).m) if has_m_
|
352
|
+
assert_equal(5, rec_.geometry[0].interior_ring_n(1).num_points)
|
353
|
+
assert_equal(60, rec_.geometry[0].interior_ring_n(1).point_n(0).x)
|
354
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(0).y)
|
355
|
+
assert_equal(10, rec_.geometry[0].interior_ring_n(1).point_n(0).z) if has_z_
|
356
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(0).m) if has_m_
|
357
|
+
assert_equal(90, rec_.geometry[0].interior_ring_n(1).point_n(1).x)
|
358
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(1).y)
|
359
|
+
assert_equal(11, rec_.geometry[0].interior_ring_n(1).point_n(1).z) if has_z_
|
360
|
+
assert_equal(22, rec_.geometry[0].interior_ring_n(1).point_n(1).m) if has_m_
|
361
|
+
assert_equal(60, rec_.geometry[0].interior_ring_n(1).point_n(4).x)
|
362
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(4).y)
|
363
|
+
assert_equal(14, rec_.geometry[0].interior_ring_n(1).point_n(4).z) if has_z_
|
364
|
+
assert_equal(28, rec_.geometry[0].interior_ring_n(1).point_n(4).m) if has_m_
|
365
|
+
end
|
366
|
+
end
|
398
367
|
|
399
|
-
|
400
|
-
|
401
|
-
|
368
|
+
def test_test10
|
369
|
+
_test_polygon_shapefile("test10", false, false)
|
370
|
+
end
|
402
371
|
|
372
|
+
def test_test11
|
373
|
+
_test_polygon_shapefile("test11", true, true)
|
374
|
+
end
|
403
375
|
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
assert_equal(4, file_.num_records)
|
408
|
-
assert_equal(true, file_.factory.property(:has_z_coordinate))
|
409
|
-
# I believe shapefile's test13 incorrectly includes bounding
|
410
|
-
# box data for m, since there is no actual m data. So I
|
411
|
-
# disabled this test:
|
412
|
-
# assert_equal(false, file_.factory.property(:has_m_coordinate))
|
413
|
-
rec_ = file_.next
|
414
|
-
assert_equal(::RGeo::Feature::GeometryCollection, rec_.geometry.geometry_type)
|
415
|
-
assert_equal(1, rec_.geometry.num_geometries)
|
416
|
-
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
417
|
-
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
418
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).x)
|
419
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).y)
|
420
|
-
assert_equal(3.35, rec_.geometry[0].exterior_ring.point_n(0).z)
|
421
|
-
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).x)
|
422
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(1).y)
|
423
|
-
assert_equal(4.35, rec_.geometry[0].exterior_ring.point_n(1).z)
|
424
|
-
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).x)
|
425
|
-
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).y)
|
426
|
-
assert_equal(5.35, rec_.geometry[0].exterior_ring.point_n(2).z)
|
427
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).x)
|
428
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).y)
|
429
|
-
assert_equal(7.35, rec_.geometry[0].exterior_ring.point_n(4).z)
|
430
|
-
rec_ = file_.next
|
431
|
-
assert_equal(::RGeo::Feature::GeometryCollection, rec_.geometry.geometry_type)
|
432
|
-
assert_equal(1, rec_.geometry.num_geometries)
|
433
|
-
rec_ = file_.next
|
434
|
-
assert_equal(::RGeo::Feature::GeometryCollection, rec_.geometry.geometry_type)
|
435
|
-
assert_equal(1, rec_.geometry.num_geometries)
|
436
|
-
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
437
|
-
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
438
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).x)
|
439
|
-
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(0).y)
|
440
|
-
assert_equal(23.35, rec_.geometry[0].exterior_ring.point_n(0).z)
|
441
|
-
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).x)
|
442
|
-
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(1).y)
|
443
|
-
assert_equal(24.35, rec_.geometry[0].exterior_ring.point_n(1).z)
|
444
|
-
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).x)
|
445
|
-
assert_equal(8, rec_.geometry[0].exterior_ring.point_n(2).y)
|
446
|
-
assert_equal(25.35, rec_.geometry[0].exterior_ring.point_n(2).z)
|
447
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).x)
|
448
|
-
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(4).y)
|
449
|
-
assert_equal(27.35, rec_.geometry[0].exterior_ring.point_n(4).z)
|
450
|
-
rec_ = file_.next
|
451
|
-
assert_equal(::RGeo::Feature::GeometryCollection, rec_.geometry.geometry_type)
|
452
|
-
assert_equal(1, rec_.geometry.num_geometries)
|
453
|
-
assert_equal(2, rec_.geometry[0].num_interior_rings)
|
454
|
-
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
455
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).x)
|
456
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).y)
|
457
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).z)
|
458
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(1).x)
|
459
|
-
assert_equal(100, rec_.geometry[0].exterior_ring.point_n(1).y)
|
460
|
-
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(1).z)
|
461
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(4).x)
|
462
|
-
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(4).y)
|
463
|
-
assert_equal(4, rec_.geometry[0].exterior_ring.point_n(4).z)
|
464
|
-
assert_equal(5, rec_.geometry[0].interior_ring_n(0).num_points)
|
465
|
-
assert_equal(10, rec_.geometry[0].interior_ring_n(0).point_n(0).x)
|
466
|
-
assert_equal(20, rec_.geometry[0].interior_ring_n(0).point_n(0).y)
|
467
|
-
assert_equal(5, rec_.geometry[0].interior_ring_n(0).point_n(0).z)
|
468
|
-
assert_equal(30, rec_.geometry[0].interior_ring_n(0).point_n(1).x)
|
469
|
-
assert_equal(20, rec_.geometry[0].interior_ring_n(0).point_n(1).y)
|
470
|
-
assert_equal(6, rec_.geometry[0].interior_ring_n(0).point_n(1).z)
|
471
|
-
assert_equal(30, rec_.geometry[0].interior_ring_n(0).point_n(2).x)
|
472
|
-
assert_equal(40, rec_.geometry[0].interior_ring_n(0).point_n(2).y)
|
473
|
-
assert_equal(7, rec_.geometry[0].interior_ring_n(0).point_n(2).z)
|
474
|
-
assert_equal(5, rec_.geometry[0].interior_ring_n(1).num_points)
|
475
|
-
assert_equal(60, rec_.geometry[0].interior_ring_n(1).point_n(0).x)
|
476
|
-
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(0).y)
|
477
|
-
assert_equal(10, rec_.geometry[0].interior_ring_n(1).point_n(0).z)
|
478
|
-
assert_equal(90, rec_.geometry[0].interior_ring_n(1).point_n(1).x)
|
479
|
-
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(1).y)
|
480
|
-
assert_equal(11, rec_.geometry[0].interior_ring_n(1).point_n(1).z)
|
481
|
-
assert_equal(60, rec_.geometry[0].interior_ring_n(1).point_n(4).x)
|
482
|
-
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(4).y)
|
483
|
-
assert_equal(14, rec_.geometry[0].interior_ring_n(1).point_n(4).z)
|
484
|
-
end
|
485
|
-
end
|
376
|
+
def test_test12
|
377
|
+
_test_polygon_shapefile("test12", false, true)
|
378
|
+
end
|
486
379
|
|
380
|
+
def test_test13
|
381
|
+
_open_shapefile("test13") do |file_|
|
382
|
+
assert_equal(31, file_.shape_type_code)
|
383
|
+
assert_equal(4, file_.num_records)
|
384
|
+
assert_equal(true, file_.factory.property(:has_z_coordinate))
|
385
|
+
# I believe shapefile's test13 incorrectly includes bounding
|
386
|
+
# box data for m, since there is no actual m data. So I
|
387
|
+
# disabled this test:
|
388
|
+
# assert_equal(false, file_.factory.property(:has_m_coordinate))
|
389
|
+
rec_ = file_.next
|
390
|
+
assert_equal(RGeo::Feature::GeometryCollection, rec_.geometry.geometry_type)
|
391
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
392
|
+
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
393
|
+
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
394
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).x)
|
395
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).y)
|
396
|
+
assert_equal(3.35, rec_.geometry[0].exterior_ring.point_n(0).z)
|
397
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).x)
|
398
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(1).y)
|
399
|
+
assert_equal(4.35, rec_.geometry[0].exterior_ring.point_n(1).z)
|
400
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).x)
|
401
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).y)
|
402
|
+
assert_equal(5.35, rec_.geometry[0].exterior_ring.point_n(2).z)
|
403
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).x)
|
404
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).y)
|
405
|
+
assert_equal(7.35, rec_.geometry[0].exterior_ring.point_n(4).z)
|
406
|
+
rec_ = file_.next
|
407
|
+
assert_equal(RGeo::Feature::GeometryCollection, rec_.geometry.geometry_type)
|
408
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
409
|
+
rec_ = file_.next
|
410
|
+
assert_equal(RGeo::Feature::GeometryCollection, rec_.geometry.geometry_type)
|
411
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
412
|
+
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
413
|
+
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
414
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).x)
|
415
|
+
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(0).y)
|
416
|
+
assert_equal(23.35, rec_.geometry[0].exterior_ring.point_n(0).z)
|
417
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).x)
|
418
|
+
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(1).y)
|
419
|
+
assert_equal(24.35, rec_.geometry[0].exterior_ring.point_n(1).z)
|
420
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).x)
|
421
|
+
assert_equal(8, rec_.geometry[0].exterior_ring.point_n(2).y)
|
422
|
+
assert_equal(25.35, rec_.geometry[0].exterior_ring.point_n(2).z)
|
423
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).x)
|
424
|
+
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(4).y)
|
425
|
+
assert_equal(27.35, rec_.geometry[0].exterior_ring.point_n(4).z)
|
426
|
+
rec_ = file_.next
|
427
|
+
assert_equal(RGeo::Feature::GeometryCollection, rec_.geometry.geometry_type)
|
428
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
429
|
+
assert_equal(2, rec_.geometry[0].num_interior_rings)
|
430
|
+
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
431
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).x)
|
432
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).y)
|
433
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).z)
|
434
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(1).x)
|
435
|
+
assert_equal(100, rec_.geometry[0].exterior_ring.point_n(1).y)
|
436
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(1).z)
|
437
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(4).x)
|
438
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(4).y)
|
439
|
+
assert_equal(4, rec_.geometry[0].exterior_ring.point_n(4).z)
|
440
|
+
assert_equal(5, rec_.geometry[0].interior_ring_n(0).num_points)
|
441
|
+
assert_equal(10, rec_.geometry[0].interior_ring_n(0).point_n(0).x)
|
442
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(0).point_n(0).y)
|
443
|
+
assert_equal(5, rec_.geometry[0].interior_ring_n(0).point_n(0).z)
|
444
|
+
assert_equal(30, rec_.geometry[0].interior_ring_n(0).point_n(1).x)
|
445
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(0).point_n(1).y)
|
446
|
+
assert_equal(6, rec_.geometry[0].interior_ring_n(0).point_n(1).z)
|
447
|
+
assert_equal(30, rec_.geometry[0].interior_ring_n(0).point_n(2).x)
|
448
|
+
assert_equal(40, rec_.geometry[0].interior_ring_n(0).point_n(2).y)
|
449
|
+
assert_equal(7, rec_.geometry[0].interior_ring_n(0).point_n(2).z)
|
450
|
+
assert_equal(5, rec_.geometry[0].interior_ring_n(1).num_points)
|
451
|
+
assert_equal(60, rec_.geometry[0].interior_ring_n(1).point_n(0).x)
|
452
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(0).y)
|
453
|
+
assert_equal(10, rec_.geometry[0].interior_ring_n(1).point_n(0).z)
|
454
|
+
assert_equal(90, rec_.geometry[0].interior_ring_n(1).point_n(1).x)
|
455
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(1).y)
|
456
|
+
assert_equal(11, rec_.geometry[0].interior_ring_n(1).point_n(1).z)
|
457
|
+
assert_equal(60, rec_.geometry[0].interior_ring_n(1).point_n(4).x)
|
458
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(4).y)
|
459
|
+
assert_equal(14, rec_.geometry[0].interior_ring_n(1).point_n(4).z)
|
460
|
+
end
|
461
|
+
end
|
487
462
|
|
488
|
-
|
463
|
+
private
|
489
464
|
|
490
|
-
|
465
|
+
def _open_shapefile(name_, &block_)
|
466
|
+
RGeo::Shapefile::Reader.open(
|
467
|
+
File.expand_path("shapelib_testcases/#{name_}",
|
468
|
+
File.dirname(__FILE__)),
|
469
|
+
&block_
|
470
|
+
)
|
491
471
|
end
|
492
472
|
end
|