rgeo 0.1.17 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +8 -0
- data/README.rdoc +40 -21
- data/Version +1 -1
- data/lib/rgeo.rb +1 -0
- data/lib/rgeo/cartesian.rb +1 -0
- data/lib/rgeo/cartesian/analysis.rb +115 -0
- data/lib/rgeo/cartesian/feature_classes.rb +0 -14
- data/lib/rgeo/features/factory.rb +5 -5
- data/lib/rgeo/features/factory_generator.rb +10 -0
- data/lib/rgeo/geo_json/coder.rb +49 -14
- data/lib/rgeo/geo_json/interface.rb +6 -6
- data/lib/rgeo/shapefile.rb +60 -0
- data/lib/rgeo/shapefile/reader.rb +898 -0
- data/tests/shapefile/shapelib_testcases/readme.txt +11 -0
- data/tests/shapefile/shapelib_testcases/test.dbf +0 -0
- data/tests/shapefile/shapelib_testcases/test.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test0.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test0.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test1.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test1.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test10.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test10.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test11.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test11.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test12.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test12.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test13.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test13.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test2.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test2.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test3.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test3.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test4.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test4.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test5.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test5.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test6.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test6.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test7.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test7.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test8.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test8.shx +0 -0
- data/tests/shapefile/shapelib_testcases/test9.shp +0 -0
- data/tests/shapefile/shapelib_testcases/test9.shx +0 -0
- data/tests/shapefile/tc_shapelib_tests.rb +527 -0
- data/tests/tc_cartesian_analysis.rb +107 -0
- data/tests/tc_oneoff.rb +1 -0
- metadata +118 -12
@@ -0,0 +1,11 @@
|
|
1
|
+
The shapefiles in this directory are a test suite used by shapelib.
|
2
|
+
They don't cover every case, but seemed a good starting point.
|
3
|
+
Shapelib can be found at http://shapelib.maptools.org/
|
4
|
+
|
5
|
+
The numbered test files are generated by the shptest tool. The
|
6
|
+
non-numbered case (including a dbf file) is generated by the
|
7
|
+
makeshape.sh script. Both were run from shapelib release 1.3.0b2.
|
8
|
+
|
9
|
+
Since we're embedding the test cases themselves here in this
|
10
|
+
directory, we note that they are Copyright 1999 Frank Warmerdam,
|
11
|
+
and are distrubted under an MIT style license.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,527 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# A container file for one-off tests
|
4
|
+
#
|
5
|
+
# -----------------------------------------------------------------------------
|
6
|
+
# Copyright 2010 Daniel Azuma
|
7
|
+
#
|
8
|
+
# All rights reserved.
|
9
|
+
#
|
10
|
+
# Redistribution and use in source and binary forms, with or without
|
11
|
+
# modification, are permitted provided that the following conditions are met:
|
12
|
+
#
|
13
|
+
# * Redistributions of source code must retain the above copyright notice,
|
14
|
+
# this list of conditions and the following disclaimer.
|
15
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
16
|
+
# this list of conditions and the following disclaimer in the documentation
|
17
|
+
# and/or other materials provided with the distribution.
|
18
|
+
# * Neither the name of the copyright holder, nor the names of any other
|
19
|
+
# contributors to this software, may be used to endorse or promote products
|
20
|
+
# derived from this software without specific prior written permission.
|
21
|
+
#
|
22
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
26
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
27
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
# -----------------------------------------------------------------------------
|
34
|
+
;
|
35
|
+
|
36
|
+
|
37
|
+
require 'test/unit'
|
38
|
+
require 'rgeo'
|
39
|
+
|
40
|
+
|
41
|
+
module RGeo
|
42
|
+
module Tests # :nodoc:
|
43
|
+
module Shapefile
|
44
|
+
|
45
|
+
class TestShapelibTests < ::Test::Unit::TestCase # :nodoc:
|
46
|
+
|
47
|
+
def _open_shapefile(name_, &block_)
|
48
|
+
RGeo::Shapefile::Reader.open(::File.expand_path("shapelib_testcases/#{name_}", ::File.dirname(__FILE__)), :factory_generator => ::RGeo::Cartesian.method(:simple_factory), &block_)
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def test_rewind
|
53
|
+
_open_shapefile('test') do |file_|
|
54
|
+
assert_equal(0, file_.cur_index)
|
55
|
+
rec_ = file_.next
|
56
|
+
assert_equal(0, rec_.index)
|
57
|
+
assert_equal(1, rec_.geometry[0].num_interior_rings)
|
58
|
+
assert_equal(1, file_.cur_index)
|
59
|
+
file_.rewind
|
60
|
+
assert_equal(0, file_.cur_index)
|
61
|
+
rec_ = file_.next
|
62
|
+
assert_equal(0, rec_.index)
|
63
|
+
assert_equal(1, rec_.geometry[0].num_interior_rings)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def test_seek
|
69
|
+
_open_shapefile('test') do |file_|
|
70
|
+
assert_equal(0, file_.cur_index)
|
71
|
+
assert_equal(false, file_.seek_index(4))
|
72
|
+
assert_equal(0, file_.cur_index)
|
73
|
+
file_.seek_index(3)
|
74
|
+
assert_equal(3, file_.cur_index)
|
75
|
+
assert_nil(file_.next)
|
76
|
+
file_.seek_index(2)
|
77
|
+
assert_equal(2, file_.cur_index)
|
78
|
+
rec_ = file_.next
|
79
|
+
assert_equal(2, rec_.index)
|
80
|
+
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
81
|
+
assert_equal('', rec_['Descriptio'])
|
82
|
+
file_.seek_index(0)
|
83
|
+
assert_equal(0, file_.cur_index)
|
84
|
+
rec_ = file_.next
|
85
|
+
assert_equal(0, rec_.index)
|
86
|
+
assert_equal(1, rec_.geometry[0].num_interior_rings)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
def test_attributes
|
92
|
+
_open_shapefile('test') do |file_|
|
93
|
+
rec_ = file_.next
|
94
|
+
assert_equal('Square with triangle missing', rec_['Descriptio'])
|
95
|
+
assert_equal(1, rec_['TestInt'])
|
96
|
+
assert_equal(2.5, rec_['TestDouble'])
|
97
|
+
assert_nil(rec_['NotAKey'])
|
98
|
+
rec_ = file_.next
|
99
|
+
assert_equal('Smaller triangle', rec_['Descriptio'])
|
100
|
+
assert_equal(100, rec_['TestInt'])
|
101
|
+
assert_equal(1000.25, rec_['TestDouble'])
|
102
|
+
rec_ = file_.next
|
103
|
+
assert_equal('', rec_['Descriptio'])
|
104
|
+
assert_equal(0, rec_['TestInt'])
|
105
|
+
assert_equal(0, rec_['TestDouble'])
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
def test_test0
|
111
|
+
_open_shapefile('test0') do |file_|
|
112
|
+
assert_equal(0, file_.shape_type_code)
|
113
|
+
assert_equal(2, file_.num_records)
|
114
|
+
rec_ = file_.next
|
115
|
+
assert_equal(0, rec_.index)
|
116
|
+
assert_nil(rec_.geometry)
|
117
|
+
rec_ = file_.next
|
118
|
+
assert_equal(1, rec_.index)
|
119
|
+
assert_nil(rec_.geometry)
|
120
|
+
assert_nil(file_.next)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
def _test_point_shapefile(filename_, has_z_, has_m_)
|
126
|
+
_open_shapefile(filename_) do |file_|
|
127
|
+
assert_equal(has_z_ ? 11 : has_m_ ? 21 : 1, file_.shape_type_code)
|
128
|
+
assert_equal(2, file_.num_records)
|
129
|
+
assert_equal(has_z_, file_.factory.has_capability?(:z_coordinate))
|
130
|
+
assert_equal(has_m_, file_.factory.has_capability?(:m_coordinate))
|
131
|
+
rec_ = file_.next
|
132
|
+
assert_equal(0, rec_.index)
|
133
|
+
assert_equal(::RGeo::Features::Point, rec_.geometry.geometry_type)
|
134
|
+
assert_equal(1, rec_.geometry.x)
|
135
|
+
assert_equal(2, rec_.geometry.y)
|
136
|
+
assert_equal(3, rec_.geometry.z) if has_z_
|
137
|
+
assert_equal(4, rec_.geometry.m) if has_m_
|
138
|
+
rec_ = file_.next
|
139
|
+
assert_equal(1, rec_.index)
|
140
|
+
assert_equal(::RGeo::Features::Point, rec_.geometry.geometry_type)
|
141
|
+
assert_equal(10, rec_.geometry.x)
|
142
|
+
assert_equal(20, rec_.geometry.y)
|
143
|
+
assert_equal(30, rec_.geometry.z) if has_z_
|
144
|
+
assert_equal(40, rec_.geometry.m) if has_m_
|
145
|
+
assert_nil(file_.next)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
def test_test1
|
151
|
+
_test_point_shapefile('test1', false, false)
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
def test_test2
|
156
|
+
_test_point_shapefile('test2', true, true)
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
def test_test3
|
161
|
+
_test_point_shapefile('test3', false, true)
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
def _test_multipoint_shapefile(filename_, has_z_, has_m_)
|
166
|
+
_open_shapefile(filename_) do |file_|
|
167
|
+
assert_equal(has_z_ ? 18 : has_m_ ? 28 : 8, file_.shape_type_code)
|
168
|
+
assert_equal(3, file_.num_records)
|
169
|
+
assert_equal(has_z_, file_.factory.has_capability?(:z_coordinate))
|
170
|
+
assert_equal(has_m_, file_.factory.has_capability?(:m_coordinate))
|
171
|
+
rec_ = file_.next
|
172
|
+
assert_equal(::RGeo::Features::MultiPoint, rec_.geometry.geometry_type)
|
173
|
+
assert_equal(4, rec_.geometry.num_geometries)
|
174
|
+
assert_equal(1.15, rec_.geometry[0].x)
|
175
|
+
assert_equal(2.25, rec_.geometry[0].y)
|
176
|
+
assert_equal(3.35, rec_.geometry[0].z) if has_z_
|
177
|
+
assert_equal(4.45, rec_.geometry[0].m) if has_m_
|
178
|
+
assert_equal(4.15, rec_.geometry[3].x)
|
179
|
+
assert_equal(5.25, rec_.geometry[3].y)
|
180
|
+
assert_equal(6.35, rec_.geometry[3].z) if has_z_
|
181
|
+
assert_equal(7.45, rec_.geometry[3].m) if has_m_
|
182
|
+
rec_ = file_.next
|
183
|
+
assert_equal(::RGeo::Features::MultiPoint, rec_.geometry.geometry_type)
|
184
|
+
assert_equal(4, rec_.geometry.num_geometries)
|
185
|
+
rec_ = file_.next
|
186
|
+
assert_equal(::RGeo::Features::MultiPoint, rec_.geometry.geometry_type)
|
187
|
+
assert_equal(4, rec_.geometry.num_geometries)
|
188
|
+
assert_equal(21.15, rec_.geometry[0].x)
|
189
|
+
assert_equal(22.25, rec_.geometry[0].y)
|
190
|
+
assert_equal(23.35, rec_.geometry[0].z) if has_z_
|
191
|
+
assert_equal(24.45, rec_.geometry[0].m) if has_m_
|
192
|
+
assert_equal(24.15, rec_.geometry[3].x)
|
193
|
+
assert_equal(25.25, rec_.geometry[3].y)
|
194
|
+
assert_equal(26.35, rec_.geometry[3].z) if has_z_
|
195
|
+
assert_equal(27.45, rec_.geometry[3].m) if has_m_
|
196
|
+
assert_nil(file_.next)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
|
201
|
+
def test_test4
|
202
|
+
_test_multipoint_shapefile('test4', false, false)
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
def test_test5
|
207
|
+
_test_multipoint_shapefile('test5', true, true)
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
def test_test6
|
212
|
+
_test_multipoint_shapefile('test6', false, true)
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
def _test_polyline_shapefile(filename_, has_z_, has_m_)
|
217
|
+
_open_shapefile(filename_) do |file_|
|
218
|
+
assert_equal(has_z_ ? 13 : has_m_ ? 23 : 3, file_.shape_type_code)
|
219
|
+
assert_equal(4, file_.num_records)
|
220
|
+
assert_equal(has_z_, file_.factory.has_capability?(:z_coordinate))
|
221
|
+
assert_equal(has_m_, file_.factory.has_capability?(:m_coordinate))
|
222
|
+
rec_ = file_.next
|
223
|
+
assert_equal(::RGeo::Features::MultiLineString, rec_.geometry.geometry_type)
|
224
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
225
|
+
assert_equal(5, rec_.geometry[0].num_points)
|
226
|
+
assert_equal(1, rec_.geometry[0].point_n(0).x)
|
227
|
+
assert_equal(1, rec_.geometry[0].point_n(0).y)
|
228
|
+
assert_equal(3.35, rec_.geometry[0].point_n(0).z) if has_z_
|
229
|
+
assert_equal(4.45, rec_.geometry[0].point_n(0).m) if has_m_
|
230
|
+
assert_equal(2, rec_.geometry[0].point_n(1).x)
|
231
|
+
assert_equal(1, rec_.geometry[0].point_n(1).y)
|
232
|
+
assert_equal(4.35, rec_.geometry[0].point_n(1).z) if has_z_
|
233
|
+
assert_equal(5.45, rec_.geometry[0].point_n(1).m) if has_m_
|
234
|
+
assert_equal(2, rec_.geometry[0].point_n(2).x)
|
235
|
+
assert_equal(2, rec_.geometry[0].point_n(2).y)
|
236
|
+
assert_equal(5.35, rec_.geometry[0].point_n(2).z) if has_z_
|
237
|
+
assert_equal(6.45, rec_.geometry[0].point_n(2).m) if has_m_
|
238
|
+
assert_equal(1, rec_.geometry[0].point_n(4).x)
|
239
|
+
assert_equal(1, rec_.geometry[0].point_n(4).y)
|
240
|
+
assert_equal(7.35, rec_.geometry[0].point_n(4).z) if has_z_
|
241
|
+
assert_equal(8.45, rec_.geometry[0].point_n(4).m) if has_m_
|
242
|
+
rec_ = file_.next
|
243
|
+
assert_equal(::RGeo::Features::MultiLineString, rec_.geometry.geometry_type)
|
244
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
245
|
+
rec_ = file_.next
|
246
|
+
assert_equal(::RGeo::Features::MultiLineString, rec_.geometry.geometry_type)
|
247
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
248
|
+
assert_equal(5, rec_.geometry[0].num_points)
|
249
|
+
assert_equal(1, rec_.geometry[0].point_n(0).x)
|
250
|
+
assert_equal(7, rec_.geometry[0].point_n(0).y)
|
251
|
+
assert_equal(23.35, rec_.geometry[0].point_n(0).z) if has_z_
|
252
|
+
assert_equal(24.45, rec_.geometry[0].point_n(0).m) if has_m_
|
253
|
+
assert_equal(2, rec_.geometry[0].point_n(1).x)
|
254
|
+
assert_equal(7, rec_.geometry[0].point_n(1).y)
|
255
|
+
assert_equal(24.35, rec_.geometry[0].point_n(1).z) if has_z_
|
256
|
+
assert_equal(25.45, rec_.geometry[0].point_n(1).m) if has_m_
|
257
|
+
assert_equal(2, rec_.geometry[0].point_n(2).x)
|
258
|
+
assert_equal(8, rec_.geometry[0].point_n(2).y)
|
259
|
+
assert_equal(25.35, rec_.geometry[0].point_n(2).z) if has_z_
|
260
|
+
assert_equal(26.45, rec_.geometry[0].point_n(2).m) if has_m_
|
261
|
+
assert_equal(1, rec_.geometry[0].point_n(4).x)
|
262
|
+
assert_equal(7, rec_.geometry[0].point_n(4).y)
|
263
|
+
assert_equal(27.35, rec_.geometry[0].point_n(4).z) if has_z_
|
264
|
+
assert_equal(28.45, rec_.geometry[0].point_n(4).m) if has_m_
|
265
|
+
rec_ = file_.next
|
266
|
+
assert_equal(::RGeo::Features::MultiLineString, rec_.geometry.geometry_type)
|
267
|
+
assert_equal(3, rec_.geometry.num_geometries)
|
268
|
+
assert_equal(5, rec_.geometry[0].num_points)
|
269
|
+
assert_equal(0, rec_.geometry[0].point_n(0).x)
|
270
|
+
assert_equal(0, rec_.geometry[0].point_n(0).y)
|
271
|
+
assert_equal(0, rec_.geometry[0].point_n(0).z) if has_z_
|
272
|
+
assert_equal(0, rec_.geometry[0].point_n(0).m) if has_m_
|
273
|
+
assert_equal(0, rec_.geometry[0].point_n(1).x)
|
274
|
+
assert_equal(100, rec_.geometry[0].point_n(1).y)
|
275
|
+
assert_equal(1, rec_.geometry[0].point_n(1).z) if has_z_
|
276
|
+
assert_equal(2, rec_.geometry[0].point_n(1).m) if has_m_
|
277
|
+
assert_equal(0, rec_.geometry[0].point_n(4).x)
|
278
|
+
assert_equal(0, rec_.geometry[0].point_n(4).y)
|
279
|
+
assert_equal(4, rec_.geometry[0].point_n(4).z) if has_z_
|
280
|
+
assert_equal(8, rec_.geometry[0].point_n(4).m) if has_m_
|
281
|
+
assert_equal(5, rec_.geometry[1].num_points)
|
282
|
+
assert_equal(10, rec_.geometry[1].point_n(0).x)
|
283
|
+
assert_equal(20, rec_.geometry[1].point_n(0).y)
|
284
|
+
assert_equal(5, rec_.geometry[1].point_n(0).z) if has_z_
|
285
|
+
assert_equal(10, rec_.geometry[1].point_n(0).m) if has_m_
|
286
|
+
assert_equal(30, rec_.geometry[1].point_n(1).x)
|
287
|
+
assert_equal(20, rec_.geometry[1].point_n(1).y)
|
288
|
+
assert_equal(6, rec_.geometry[1].point_n(1).z) if has_z_
|
289
|
+
assert_equal(12, rec_.geometry[1].point_n(1).m) if has_m_
|
290
|
+
assert_equal(30, rec_.geometry[1].point_n(2).x)
|
291
|
+
assert_equal(40, rec_.geometry[1].point_n(2).y)
|
292
|
+
assert_equal(7, rec_.geometry[1].point_n(2).z) if has_z_
|
293
|
+
assert_equal(14, rec_.geometry[1].point_n(2).m) if has_m_
|
294
|
+
assert_equal(5, rec_.geometry[2].num_points)
|
295
|
+
assert_equal(60, rec_.geometry[2].point_n(0).x)
|
296
|
+
assert_equal(20, rec_.geometry[2].point_n(0).y)
|
297
|
+
assert_equal(10, rec_.geometry[2].point_n(0).z) if has_z_
|
298
|
+
assert_equal(20, rec_.geometry[2].point_n(0).m) if has_m_
|
299
|
+
assert_equal(90, rec_.geometry[2].point_n(1).x)
|
300
|
+
assert_equal(20, rec_.geometry[2].point_n(1).y)
|
301
|
+
assert_equal(11, rec_.geometry[2].point_n(1).z) if has_z_
|
302
|
+
assert_equal(22, rec_.geometry[2].point_n(1).m) if has_m_
|
303
|
+
assert_equal(60, rec_.geometry[2].point_n(4).x)
|
304
|
+
assert_equal(20, rec_.geometry[2].point_n(4).y)
|
305
|
+
assert_equal(14, rec_.geometry[2].point_n(4).z) if has_z_
|
306
|
+
assert_equal(28, rec_.geometry[2].point_n(4).m) if has_m_
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
|
311
|
+
def test_test7
|
312
|
+
_test_polyline_shapefile('test7', false, false)
|
313
|
+
end
|
314
|
+
|
315
|
+
|
316
|
+
def test_test8
|
317
|
+
_test_polyline_shapefile('test8', true, true)
|
318
|
+
end
|
319
|
+
|
320
|
+
|
321
|
+
def test_test9
|
322
|
+
_test_polyline_shapefile('test9', false, true)
|
323
|
+
end
|
324
|
+
|
325
|
+
|
326
|
+
def _test_polygon_shapefile(filename_, has_z_, has_m_)
|
327
|
+
_open_shapefile(filename_) do |file_|
|
328
|
+
assert_equal(has_z_ ? 15 : has_m_ ? 25 : 5, file_.shape_type_code)
|
329
|
+
assert_equal(4, file_.num_records)
|
330
|
+
assert_equal(has_z_, file_.factory.has_capability?(:z_coordinate))
|
331
|
+
assert_equal(has_m_, file_.factory.has_capability?(:m_coordinate))
|
332
|
+
rec_ = file_.next
|
333
|
+
assert_equal(::RGeo::Features::MultiPolygon, rec_.geometry.geometry_type)
|
334
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
335
|
+
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
336
|
+
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
337
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).x)
|
338
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).y)
|
339
|
+
assert_equal(3.35, rec_.geometry[0].exterior_ring.point_n(0).z) if has_z_
|
340
|
+
assert_equal(4.45, rec_.geometry[0].exterior_ring.point_n(0).m) if has_m_
|
341
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).x)
|
342
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(1).y)
|
343
|
+
assert_equal(4.35, rec_.geometry[0].exterior_ring.point_n(1).z) if has_z_
|
344
|
+
assert_equal(5.45, rec_.geometry[0].exterior_ring.point_n(1).m) if has_m_
|
345
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).x)
|
346
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).y)
|
347
|
+
assert_equal(5.35, rec_.geometry[0].exterior_ring.point_n(2).z) if has_z_
|
348
|
+
assert_equal(6.45, rec_.geometry[0].exterior_ring.point_n(2).m) if has_m_
|
349
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).x)
|
350
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).y)
|
351
|
+
assert_equal(7.35, rec_.geometry[0].exterior_ring.point_n(4).z) if has_z_
|
352
|
+
assert_equal(8.45, rec_.geometry[0].exterior_ring.point_n(4).m) if has_m_
|
353
|
+
rec_ = file_.next
|
354
|
+
assert_equal(::RGeo::Features::MultiPolygon, rec_.geometry.geometry_type)
|
355
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
356
|
+
rec_ = file_.next
|
357
|
+
assert_equal(::RGeo::Features::MultiPolygon, rec_.geometry.geometry_type)
|
358
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
359
|
+
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
360
|
+
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
361
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).x)
|
362
|
+
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(0).y)
|
363
|
+
assert_equal(23.35, rec_.geometry[0].exterior_ring.point_n(0).z) if has_z_
|
364
|
+
assert_equal(24.45, rec_.geometry[0].exterior_ring.point_n(0).m) if has_m_
|
365
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).x)
|
366
|
+
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(1).y)
|
367
|
+
assert_equal(24.35, rec_.geometry[0].exterior_ring.point_n(1).z) if has_z_
|
368
|
+
assert_equal(25.45, rec_.geometry[0].exterior_ring.point_n(1).m) if has_m_
|
369
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).x)
|
370
|
+
assert_equal(8, rec_.geometry[0].exterior_ring.point_n(2).y)
|
371
|
+
assert_equal(25.35, rec_.geometry[0].exterior_ring.point_n(2).z) if has_z_
|
372
|
+
assert_equal(26.45, rec_.geometry[0].exterior_ring.point_n(2).m) if has_m_
|
373
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).x)
|
374
|
+
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(4).y)
|
375
|
+
assert_equal(27.35, rec_.geometry[0].exterior_ring.point_n(4).z) if has_z_
|
376
|
+
assert_equal(28.45, rec_.geometry[0].exterior_ring.point_n(4).m) if has_m_
|
377
|
+
rec_ = file_.next
|
378
|
+
assert_equal(::RGeo::Features::MultiPolygon, rec_.geometry.geometry_type)
|
379
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
380
|
+
assert_equal(2, rec_.geometry[0].num_interior_rings)
|
381
|
+
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
382
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).x)
|
383
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).y)
|
384
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).z) if has_z_
|
385
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).m) if has_m_
|
386
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(1).x)
|
387
|
+
assert_equal(100, rec_.geometry[0].exterior_ring.point_n(1).y)
|
388
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(1).z) if has_z_
|
389
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).m) if has_m_
|
390
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(4).x)
|
391
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(4).y)
|
392
|
+
assert_equal(4, rec_.geometry[0].exterior_ring.point_n(4).z) if has_z_
|
393
|
+
assert_equal(8, rec_.geometry[0].exterior_ring.point_n(4).m) if has_m_
|
394
|
+
assert_equal(5, rec_.geometry[0].interior_ring_n(0).num_points)
|
395
|
+
assert_equal(10, rec_.geometry[0].interior_ring_n(0).point_n(0).x)
|
396
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(0).point_n(0).y)
|
397
|
+
assert_equal(5, rec_.geometry[0].interior_ring_n(0).point_n(0).z) if has_z_
|
398
|
+
assert_equal(10, rec_.geometry[0].interior_ring_n(0).point_n(0).m) if has_m_
|
399
|
+
assert_equal(30, rec_.geometry[0].interior_ring_n(0).point_n(1).x)
|
400
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(0).point_n(1).y)
|
401
|
+
assert_equal(6, rec_.geometry[0].interior_ring_n(0).point_n(1).z) if has_z_
|
402
|
+
assert_equal(12, rec_.geometry[0].interior_ring_n(0).point_n(1).m) if has_m_
|
403
|
+
assert_equal(30, rec_.geometry[0].interior_ring_n(0).point_n(2).x)
|
404
|
+
assert_equal(40, rec_.geometry[0].interior_ring_n(0).point_n(2).y)
|
405
|
+
assert_equal(7, rec_.geometry[0].interior_ring_n(0).point_n(2).z) if has_z_
|
406
|
+
assert_equal(14, rec_.geometry[0].interior_ring_n(0).point_n(2).m) if has_m_
|
407
|
+
assert_equal(5, rec_.geometry[0].interior_ring_n(1).num_points)
|
408
|
+
assert_equal(60, rec_.geometry[0].interior_ring_n(1).point_n(0).x)
|
409
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(0).y)
|
410
|
+
assert_equal(10, rec_.geometry[0].interior_ring_n(1).point_n(0).z) if has_z_
|
411
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(0).m) if has_m_
|
412
|
+
assert_equal(90, rec_.geometry[0].interior_ring_n(1).point_n(1).x)
|
413
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(1).y)
|
414
|
+
assert_equal(11, rec_.geometry[0].interior_ring_n(1).point_n(1).z) if has_z_
|
415
|
+
assert_equal(22, rec_.geometry[0].interior_ring_n(1).point_n(1).m) if has_m_
|
416
|
+
assert_equal(60, rec_.geometry[0].interior_ring_n(1).point_n(4).x)
|
417
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(4).y)
|
418
|
+
assert_equal(14, rec_.geometry[0].interior_ring_n(1).point_n(4).z) if has_z_
|
419
|
+
assert_equal(28, rec_.geometry[0].interior_ring_n(1).point_n(4).m) if has_m_
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
|
424
|
+
def test_test10
|
425
|
+
_test_polygon_shapefile('test10', false, false)
|
426
|
+
end
|
427
|
+
|
428
|
+
|
429
|
+
def test_test11
|
430
|
+
_test_polygon_shapefile('test11', true, true)
|
431
|
+
end
|
432
|
+
|
433
|
+
|
434
|
+
def test_test12
|
435
|
+
_test_polygon_shapefile('test12', false, true)
|
436
|
+
end
|
437
|
+
|
438
|
+
|
439
|
+
def test_test13
|
440
|
+
_open_shapefile('test13') do |file_|
|
441
|
+
assert_equal(31, file_.shape_type_code)
|
442
|
+
assert_equal(4, file_.num_records)
|
443
|
+
assert_equal(true, file_.factory.has_capability?(:z_coordinate))
|
444
|
+
# I believe shapefile's test13 incorrectly includes bounding
|
445
|
+
# box data for m, since there is no actual m data. So I
|
446
|
+
# disabled this test:
|
447
|
+
# assert_equal(false, file_.factory.has_capability?(:m_coordinate))
|
448
|
+
rec_ = file_.next
|
449
|
+
assert_equal(::RGeo::Features::GeometryCollection, rec_.geometry.geometry_type)
|
450
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
451
|
+
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
452
|
+
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
453
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).x)
|
454
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).y)
|
455
|
+
assert_equal(3.35, rec_.geometry[0].exterior_ring.point_n(0).z)
|
456
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).x)
|
457
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(1).y)
|
458
|
+
assert_equal(4.35, rec_.geometry[0].exterior_ring.point_n(1).z)
|
459
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).x)
|
460
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).y)
|
461
|
+
assert_equal(5.35, rec_.geometry[0].exterior_ring.point_n(2).z)
|
462
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).x)
|
463
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).y)
|
464
|
+
assert_equal(7.35, rec_.geometry[0].exterior_ring.point_n(4).z)
|
465
|
+
rec_ = file_.next
|
466
|
+
assert_equal(::RGeo::Features::GeometryCollection, rec_.geometry.geometry_type)
|
467
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
468
|
+
rec_ = file_.next
|
469
|
+
assert_equal(::RGeo::Features::GeometryCollection, rec_.geometry.geometry_type)
|
470
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
471
|
+
assert_equal(0, rec_.geometry[0].num_interior_rings)
|
472
|
+
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
473
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(0).x)
|
474
|
+
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(0).y)
|
475
|
+
assert_equal(23.35, rec_.geometry[0].exterior_ring.point_n(0).z)
|
476
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(1).x)
|
477
|
+
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(1).y)
|
478
|
+
assert_equal(24.35, rec_.geometry[0].exterior_ring.point_n(1).z)
|
479
|
+
assert_equal(2, rec_.geometry[0].exterior_ring.point_n(2).x)
|
480
|
+
assert_equal(8, rec_.geometry[0].exterior_ring.point_n(2).y)
|
481
|
+
assert_equal(25.35, rec_.geometry[0].exterior_ring.point_n(2).z)
|
482
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(4).x)
|
483
|
+
assert_equal(7, rec_.geometry[0].exterior_ring.point_n(4).y)
|
484
|
+
assert_equal(27.35, rec_.geometry[0].exterior_ring.point_n(4).z)
|
485
|
+
rec_ = file_.next
|
486
|
+
assert_equal(::RGeo::Features::GeometryCollection, rec_.geometry.geometry_type)
|
487
|
+
assert_equal(1, rec_.geometry.num_geometries)
|
488
|
+
assert_equal(2, rec_.geometry[0].num_interior_rings)
|
489
|
+
assert_equal(5, rec_.geometry[0].exterior_ring.num_points)
|
490
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).x)
|
491
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).y)
|
492
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(0).z)
|
493
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(1).x)
|
494
|
+
assert_equal(100, rec_.geometry[0].exterior_ring.point_n(1).y)
|
495
|
+
assert_equal(1, rec_.geometry[0].exterior_ring.point_n(1).z)
|
496
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(4).x)
|
497
|
+
assert_equal(0, rec_.geometry[0].exterior_ring.point_n(4).y)
|
498
|
+
assert_equal(4, rec_.geometry[0].exterior_ring.point_n(4).z)
|
499
|
+
assert_equal(5, rec_.geometry[0].interior_ring_n(0).num_points)
|
500
|
+
assert_equal(10, rec_.geometry[0].interior_ring_n(0).point_n(0).x)
|
501
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(0).point_n(0).y)
|
502
|
+
assert_equal(5, rec_.geometry[0].interior_ring_n(0).point_n(0).z)
|
503
|
+
assert_equal(30, rec_.geometry[0].interior_ring_n(0).point_n(1).x)
|
504
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(0).point_n(1).y)
|
505
|
+
assert_equal(6, rec_.geometry[0].interior_ring_n(0).point_n(1).z)
|
506
|
+
assert_equal(30, rec_.geometry[0].interior_ring_n(0).point_n(2).x)
|
507
|
+
assert_equal(40, rec_.geometry[0].interior_ring_n(0).point_n(2).y)
|
508
|
+
assert_equal(7, rec_.geometry[0].interior_ring_n(0).point_n(2).z)
|
509
|
+
assert_equal(5, rec_.geometry[0].interior_ring_n(1).num_points)
|
510
|
+
assert_equal(60, rec_.geometry[0].interior_ring_n(1).point_n(0).x)
|
511
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(0).y)
|
512
|
+
assert_equal(10, rec_.geometry[0].interior_ring_n(1).point_n(0).z)
|
513
|
+
assert_equal(90, rec_.geometry[0].interior_ring_n(1).point_n(1).x)
|
514
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(1).y)
|
515
|
+
assert_equal(11, rec_.geometry[0].interior_ring_n(1).point_n(1).z)
|
516
|
+
assert_equal(60, rec_.geometry[0].interior_ring_n(1).point_n(4).x)
|
517
|
+
assert_equal(20, rec_.geometry[0].interior_ring_n(1).point_n(4).y)
|
518
|
+
assert_equal(14, rec_.geometry[0].interior_ring_n(1).point_n(4).z)
|
519
|
+
end
|
520
|
+
end
|
521
|
+
|
522
|
+
|
523
|
+
end
|
524
|
+
|
525
|
+
end
|
526
|
+
end
|
527
|
+
end
|