rgeo 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/geos_c_impl/extconf.rb +1 -0
- data/ext/geos_c_impl/factory.c +10 -1
- data/ext/geos_c_impl/geometry.c +25 -3
- data/ext/geos_c_impl/line_string.c +1 -12
- data/ext/geos_c_impl/polygon.c +0 -3
- data/ext/geos_c_impl/preface.h +3 -0
- data/lib/rgeo.rb +0 -1
- data/lib/rgeo/feature/geometry.rb +17 -0
- data/lib/rgeo/feature/types.rb +4 -4
- data/lib/rgeo/geographic/projected_feature_methods.rb +1 -22
- data/lib/rgeo/geos/ffi_feature_methods.rb +5 -0
- data/lib/rgeo/geos/utils.rb +2 -0
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +1 -0
- data/lib/rgeo/version.rb +1 -1
- metadata +11 -171
- data/lib/rgeo/yaml.rb +0 -23
- data/test/cartesian_analysis_test.rb +0 -65
- data/test/cartesian_bbox_test.rb +0 -123
- data/test/common/factory_tests.rb +0 -78
- data/test/common/geometry_collection_tests.rb +0 -237
- data/test/common/line_string_tests.rb +0 -330
- data/test/common/multi_line_string_tests.rb +0 -182
- data/test/common/multi_point_tests.rb +0 -200
- data/test/common/multi_polygon_tests.rb +0 -191
- data/test/common/point_tests.rb +0 -370
- data/test/common/polygon_tests.rb +0 -228
- data/test/coord_sys/ogc_cs_test.rb +0 -342
- data/test/coord_sys/proj4_srs_data_test.rb +0 -41
- data/test/coord_sys/proj4_test.rb +0 -150
- data/test/coord_sys/sr_org_test.rb +0 -32
- data/test/coord_sys/url_reader_test.rb +0 -42
- data/test/geos_capi/factory_test.rb +0 -31
- data/test/geos_capi/geometry_collection_test.rb +0 -24
- data/test/geos_capi/line_string_test.rb +0 -24
- data/test/geos_capi/misc_test.rb +0 -116
- data/test/geos_capi/multi_line_string_test.rb +0 -24
- data/test/geos_capi/multi_point_test.rb +0 -24
- data/test/geos_capi/multi_polygon_test.rb +0 -39
- data/test/geos_capi/parsing_unparsing_test.rb +0 -40
- data/test/geos_capi/point_test.rb +0 -72
- data/test/geos_capi/polygon_test.rb +0 -154
- data/test/geos_capi/zmfactory_test.rb +0 -57
- data/test/geos_ffi/factory_test.rb +0 -31
- data/test/geos_ffi/geometry_collection_test.rb +0 -24
- data/test/geos_ffi/line_string_test.rb +0 -24
- data/test/geos_ffi/misc_test.rb +0 -63
- data/test/geos_ffi/multi_line_string_test.rb +0 -24
- data/test/geos_ffi/multi_point_test.rb +0 -24
- data/test/geos_ffi/multi_polygon_test.rb +0 -33
- data/test/geos_ffi/parsing_unparsing_test.rb +0 -41
- data/test/geos_ffi/point_test.rb +0 -77
- data/test/geos_ffi/polygon_test.rb +0 -46
- data/test/geos_ffi/zmfactory_test.rb +0 -58
- data/test/mixins_test.rb +0 -141
- data/test/oneoff_test.rb +0 -26
- data/test/projected_geographic/factory_test.rb +0 -25
- data/test/projected_geographic/geometry_collection_test.rb +0 -24
- data/test/projected_geographic/line_string_test.rb +0 -24
- data/test/projected_geographic/multi_line_string_test.rb +0 -26
- data/test/projected_geographic/multi_point_test.rb +0 -30
- data/test/projected_geographic/multi_polygon_test.rb +0 -25
- data/test/projected_geographic/point_test.rb +0 -51
- data/test/projected_geographic/polygon_test.rb +0 -24
- data/test/simple_cartesian/calculations_test.rb +0 -99
- data/test/simple_cartesian/factory_test.rb +0 -27
- data/test/simple_cartesian/geometry_collection_test.rb +0 -30
- data/test/simple_cartesian/line_string_test.rb +0 -31
- data/test/simple_cartesian/multi_line_string_test.rb +0 -28
- data/test/simple_cartesian/multi_point_test.rb +0 -31
- data/test/simple_cartesian/multi_polygon_test.rb +0 -31
- data/test/simple_cartesian/point_test.rb +0 -50
- data/test/simple_cartesian/polygon_test.rb +0 -28
- data/test/simple_mercator/factory_test.rb +0 -25
- data/test/simple_mercator/geometry_collection_test.rb +0 -24
- data/test/simple_mercator/line_string_test.rb +0 -24
- data/test/simple_mercator/multi_line_string_test.rb +0 -26
- data/test/simple_mercator/multi_point_test.rb +0 -29
- data/test/simple_mercator/multi_polygon_test.rb +0 -25
- data/test/simple_mercator/point_test.rb +0 -55
- data/test/simple_mercator/polygon_test.rb +0 -24
- data/test/simple_mercator/window_test.rb +0 -173
- data/test/spherical_geographic/calculations_test.rb +0 -167
- data/test/spherical_geographic/factory_test.rb +0 -27
- data/test/spherical_geographic/geometry_collection_test.rb +0 -31
- data/test/spherical_geographic/line_string_test.rb +0 -31
- data/test/spherical_geographic/multi_line_string_test.rb +0 -29
- data/test/spherical_geographic/multi_point_test.rb +0 -31
- data/test/spherical_geographic/multi_polygon_test.rb +0 -31
- data/test/spherical_geographic/point_test.rb +0 -78
- data/test/spherical_geographic/polygon_test.rb +0 -28
- data/test/types_test.rb +0 -42
- data/test/wkrep/wkb_generator_test.rb +0 -185
- data/test/wkrep/wkb_parser_test.rb +0 -293
- data/test/wkrep/wkt_generator_test.rb +0 -294
- data/test/wkrep/wkt_parser_test.rb +0 -412
@@ -1,294 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for WKT generator
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
module RGeo
|
11
|
-
module Tests # :nodoc:
|
12
|
-
module WKRep # :nodoc:
|
13
|
-
class TestWKTGenerator < ::Test::Unit::TestCase # :nodoc:
|
14
|
-
def setup
|
15
|
-
@factory = ::RGeo::Cartesian.preferred_factory(srid: 1000)
|
16
|
-
@factoryz = ::RGeo::Cartesian.preferred_factory(srid: 1000, has_z_coordinate: true)
|
17
|
-
@factorym = ::RGeo::Cartesian.preferred_factory(srid: 1000, has_m_coordinate: true)
|
18
|
-
@factoryzm = ::RGeo::Cartesian.preferred_factory(srid: 1000, has_z_coordinate: true, has_m_coordinate: true)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_point_2d
|
22
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
23
|
-
obj_ = @factory.point(1, 2)
|
24
|
-
assert_equal("Point (1.0 2.0)", generator_.generate(obj_))
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_point_z
|
28
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
29
|
-
obj_ = @factoryz.point(1, 2, 3)
|
30
|
-
assert_equal("Point (1.0 2.0 3.0)", generator_.generate(obj_))
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_point_z_wkt11strict
|
34
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(tag_format: :wkt11_strict)
|
35
|
-
obj_ = @factoryz.point(1, 2, 3)
|
36
|
-
assert_equal("Point (1.0 2.0)", generator_.generate(obj_))
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_point_m
|
40
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
41
|
-
obj_ = @factorym.point(1, 2, 3)
|
42
|
-
assert_equal("Point (1.0 2.0 3.0)", generator_.generate(obj_))
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_point_zm
|
46
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
47
|
-
obj_ = @factoryzm.point(1, 2, 3, 4)
|
48
|
-
assert_equal("Point (1.0 2.0 3.0 4.0)", generator_.generate(obj_))
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_point_squarebrackets
|
52
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(square_brackets: true)
|
53
|
-
obj_ = @factory.point(1, 2)
|
54
|
-
assert_equal("Point [1.0 2.0]", generator_.generate(obj_))
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_point_uppercase
|
58
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(convert_case: :upper)
|
59
|
-
obj_ = @factory.point(1, 2)
|
60
|
-
assert_equal("POINT (1.0 2.0)", generator_.generate(obj_))
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_point_lowercase
|
64
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(convert_case: :lower)
|
65
|
-
obj_ = @factory.point(1, 2)
|
66
|
-
assert_equal("point (1.0 2.0)", generator_.generate(obj_))
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_point_wkt12
|
70
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(tag_format: :wkt12)
|
71
|
-
obj_ = @factory.point(1, 2)
|
72
|
-
assert_equal("Point (1.0 2.0)", generator_.generate(obj_))
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_point_wkt12_z
|
76
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(tag_format: :wkt12)
|
77
|
-
obj_ = @factoryz.point(1, 2, 3)
|
78
|
-
assert_equal("Point Z (1.0 2.0 3.0)", generator_.generate(obj_))
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_point_wkt12_m
|
82
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(tag_format: :wkt12)
|
83
|
-
obj_ = @factorym.point(1, 2, 3)
|
84
|
-
assert_equal("Point M (1.0 2.0 3.0)", generator_.generate(obj_))
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_point_wkt12_zm
|
88
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(tag_format: :wkt12)
|
89
|
-
obj_ = @factoryzm.point(1, 2, 3, 4)
|
90
|
-
assert_equal("Point ZM (1.0 2.0 3.0 4.0)", generator_.generate(obj_))
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_point_ewkt
|
94
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(tag_format: :ewkt)
|
95
|
-
obj_ = @factory.point(1, 2)
|
96
|
-
assert_equal("Point (1.0 2.0)", generator_.generate(obj_))
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_point_ewkt_z
|
100
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(tag_format: :ewkt)
|
101
|
-
obj_ = @factoryz.point(1, 2, 3)
|
102
|
-
assert_equal("Point (1.0 2.0 3.0)", generator_.generate(obj_))
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_point_ewkt_m
|
106
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(tag_format: :ewkt)
|
107
|
-
obj_ = @factorym.point(1, 2, 3)
|
108
|
-
assert_equal("PointM (1.0 2.0 3.0)", generator_.generate(obj_))
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_point_ewkt_zm
|
112
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(tag_format: :ewkt)
|
113
|
-
obj_ = @factoryzm.point(1, 2, 3, 4)
|
114
|
-
assert_equal("Point (1.0 2.0 3.0 4.0)", generator_.generate(obj_))
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_point_ewkt_with_srid
|
118
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(tag_format: :ewkt, emit_ewkt_srid: true)
|
119
|
-
obj_ = @factory.point(1, 2)
|
120
|
-
assert_equal("SRID=1000;Point (1.0 2.0)", generator_.generate(obj_))
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_linestring_basic
|
124
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
125
|
-
p1_ = @factory.point(1, 2)
|
126
|
-
p2_ = @factory.point(2, 2)
|
127
|
-
p3_ = @factory.point(1, 1)
|
128
|
-
obj_ = @factory.line_string([p1_, p2_, p3_])
|
129
|
-
assert_equal("LineString (1.0 2.0, 2.0 2.0, 1.0 1.0)", generator_.generate(obj_))
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_linestring_empty
|
133
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
134
|
-
obj_ = @factory.line_string([])
|
135
|
-
assert_equal("LineString EMPTY", generator_.generate(obj_))
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_polygon_basic
|
139
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
140
|
-
p1_ = @factory.point(0, 0)
|
141
|
-
p2_ = @factory.point(10, 0)
|
142
|
-
p3_ = @factory.point(10, 10)
|
143
|
-
p4_ = @factory.point(0, 10)
|
144
|
-
ext_ = @factory.line_string([p1_, p2_, p3_, p4_, p1_])
|
145
|
-
obj_ = @factory.polygon(ext_)
|
146
|
-
assert_equal("Polygon ((0.0 0.0, 10.0 0.0, 10.0 10.0, 0.0 10.0, 0.0 0.0))", generator_.generate(obj_))
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_polygon_with_hole
|
150
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
151
|
-
p1_ = @factory.point(0, 0)
|
152
|
-
p2_ = @factory.point(10, 0)
|
153
|
-
p3_ = @factory.point(10, 10)
|
154
|
-
p4_ = @factory.point(0, 10)
|
155
|
-
p5_ = @factory.point(1, 1)
|
156
|
-
p6_ = @factory.point(2, 2)
|
157
|
-
p7_ = @factory.point(3, 1)
|
158
|
-
ext_ = @factory.line_string([p1_, p2_, p3_, p4_, p1_])
|
159
|
-
int_ = @factory.line_string([p5_, p6_, p7_, p5_])
|
160
|
-
obj_ = @factory.polygon(ext_, [int_])
|
161
|
-
assert_equal("Polygon ((0.0 0.0, 10.0 0.0, 10.0 10.0, 0.0 10.0, 0.0 0.0), (1.0 1.0, 2.0 2.0, 3.0 1.0, 1.0 1.0))", generator_.generate(obj_))
|
162
|
-
end
|
163
|
-
|
164
|
-
def test_polygon_empty
|
165
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
166
|
-
obj_ = @factory.polygon(@factory.line_string([]))
|
167
|
-
assert_equal("Polygon EMPTY", generator_.generate(obj_))
|
168
|
-
end
|
169
|
-
|
170
|
-
def test_multipoint_basic
|
171
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
172
|
-
p1_ = @factory.point(1, 2)
|
173
|
-
p2_ = @factory.point(2, 2)
|
174
|
-
p3_ = @factory.point(1, 1)
|
175
|
-
obj_ = @factory.multi_point([p1_, p2_, p3_])
|
176
|
-
assert_equal("MultiPoint ((1.0 2.0), (2.0 2.0), (1.0 1.0))", generator_.generate(obj_))
|
177
|
-
end
|
178
|
-
|
179
|
-
def test_multipoint_empty
|
180
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
181
|
-
obj_ = @factory.multi_point([])
|
182
|
-
assert_equal("MultiPoint EMPTY", generator_.generate(obj_))
|
183
|
-
end
|
184
|
-
|
185
|
-
def test_multilinestring_basic
|
186
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
187
|
-
p1_ = @factory.point(0, 0)
|
188
|
-
p2_ = @factory.point(10, 0)
|
189
|
-
p3_ = @factory.point(10, 10)
|
190
|
-
p4_ = @factory.point(0, 10)
|
191
|
-
p5_ = @factory.point(1, 1)
|
192
|
-
p6_ = @factory.point(2, 2)
|
193
|
-
p7_ = @factory.point(3, 1)
|
194
|
-
ls1_ = @factory.line_string([p1_, p2_, p3_, p4_, p1_])
|
195
|
-
ls2_ = @factory.line_string([p5_, p6_, p7_])
|
196
|
-
ls3_ = @factory.line_string([])
|
197
|
-
obj_ = @factory.multi_line_string([ls1_, ls2_, ls3_])
|
198
|
-
assert_equal("MultiLineString ((0.0 0.0, 10.0 0.0, 10.0 10.0, 0.0 10.0, 0.0 0.0), (1.0 1.0, 2.0 2.0, 3.0 1.0), EMPTY)", generator_.generate(obj_))
|
199
|
-
end
|
200
|
-
|
201
|
-
def test_multilinestring_empty
|
202
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
203
|
-
obj_ = @factory.multi_line_string([])
|
204
|
-
assert_equal("MultiLineString EMPTY", generator_.generate(obj_))
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_multipolygon_basic
|
208
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
209
|
-
p1_ = @factory.point(0, 0)
|
210
|
-
p2_ = @factory.point(10, 0)
|
211
|
-
p3_ = @factory.point(10, 10)
|
212
|
-
p4_ = @factory.point(0, 10)
|
213
|
-
p5_ = @factory.point(1, 1)
|
214
|
-
p6_ = @factory.point(2, 2)
|
215
|
-
p7_ = @factory.point(3, 1)
|
216
|
-
p8_ = @factory.point(20, 20)
|
217
|
-
p9_ = @factory.point(30, 20)
|
218
|
-
p10_ = @factory.point(30, 30)
|
219
|
-
p11_ = @factory.point(20, 30)
|
220
|
-
ext1_ = @factory.line_string([p1_, p2_, p3_, p4_, p1_])
|
221
|
-
int1_ = @factory.line_string([p5_, p6_, p7_, p5_])
|
222
|
-
ext3_ = @factory.line_string([p8_, p9_, p10_, p11_, p8_])
|
223
|
-
poly1_ = @factory.polygon(ext1_, [int1_])
|
224
|
-
poly2_ = @factory.polygon(@factory.line_string([]))
|
225
|
-
poly3_ = @factory.polygon(ext3_)
|
226
|
-
obj_ = @factory.multi_polygon([poly1_, poly2_, poly3_])
|
227
|
-
assert_equal("MultiPolygon (((0.0 0.0, 10.0 0.0, 10.0 10.0, 0.0 10.0, 0.0 0.0), (1.0 1.0, 2.0 2.0, 3.0 1.0, 1.0 1.0)), EMPTY, ((20.0 20.0, 30.0 20.0, 30.0 30.0, 20.0 30.0, 20.0 20.0)))", generator_.generate(obj_))
|
228
|
-
end
|
229
|
-
|
230
|
-
def test_multipolygon_empty
|
231
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
232
|
-
obj_ = @factory.multi_polygon([])
|
233
|
-
assert_equal("MultiPolygon EMPTY", generator_.generate(obj_))
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_collection_basic
|
237
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
238
|
-
p1_ = @factory.point(0, 0)
|
239
|
-
p2_ = @factory.point(10, 0)
|
240
|
-
p3_ = @factory.point(10, 10)
|
241
|
-
p4_ = @factory.point(0, 10)
|
242
|
-
p5_ = @factory.point(1, 1)
|
243
|
-
p6_ = @factory.point(2, 2)
|
244
|
-
p7_ = @factory.point(3, 1)
|
245
|
-
p8_ = @factory.point(20, 20)
|
246
|
-
p9_ = @factory.point(30, 20)
|
247
|
-
p10_ = @factory.point(30, 30)
|
248
|
-
p11_ = @factory.point(20, 30)
|
249
|
-
ext1_ = @factory.line_string([p1_, p2_, p3_, p4_, p1_])
|
250
|
-
int1_ = @factory.line_string([p5_, p6_, p7_, p5_])
|
251
|
-
ext3_ = @factory.line_string([p8_, p9_, p10_, p11_, p8_])
|
252
|
-
poly1_ = @factory.polygon(ext1_, [int1_])
|
253
|
-
poly2_ = @factory.polygon(@factory.line_string([]))
|
254
|
-
poly3_ = @factory.polygon(ext3_)
|
255
|
-
obj1_ = @factory.multi_polygon([poly1_, poly2_, poly3_])
|
256
|
-
obj2_ = @factory.point(1, 2)
|
257
|
-
obj_ = @factory.collection([obj1_, obj2_])
|
258
|
-
assert_equal("GeometryCollection (MultiPolygon (((0.0 0.0, 10.0 0.0, 10.0 10.0, 0.0 10.0, 0.0 0.0), (1.0 1.0, 2.0 2.0, 3.0 1.0, 1.0 1.0)), EMPTY, ((20.0 20.0, 30.0 20.0, 30.0 30.0, 20.0 30.0, 20.0 20.0))), Point (1.0 2.0))", generator_.generate(obj_))
|
259
|
-
end
|
260
|
-
|
261
|
-
def test_collection_wkt12_z
|
262
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new(tag_format: :wkt12)
|
263
|
-
p1_ = @factoryz.point(0, 0)
|
264
|
-
p2_ = @factoryz.point(10, 0)
|
265
|
-
p3_ = @factoryz.point(10, 10)
|
266
|
-
p4_ = @factoryz.point(0, 10)
|
267
|
-
p5_ = @factoryz.point(1, 1)
|
268
|
-
p6_ = @factoryz.point(2, 2)
|
269
|
-
p7_ = @factoryz.point(3, 1)
|
270
|
-
p8_ = @factoryz.point(20, 20)
|
271
|
-
p9_ = @factoryz.point(30, 20)
|
272
|
-
p10_ = @factoryz.point(30, 30)
|
273
|
-
p11_ = @factoryz.point(20, 30)
|
274
|
-
ext1_ = @factoryz.line_string([p1_, p2_, p3_, p4_, p1_])
|
275
|
-
int1_ = @factoryz.line_string([p5_, p6_, p7_, p5_])
|
276
|
-
ext3_ = @factoryz.line_string([p8_, p9_, p10_, p11_, p8_])
|
277
|
-
poly1_ = @factoryz.polygon(ext1_, [int1_])
|
278
|
-
poly2_ = @factoryz.polygon(@factory.line_string([]))
|
279
|
-
poly3_ = @factoryz.polygon(ext3_)
|
280
|
-
obj1_ = @factoryz.multi_polygon([poly1_, poly2_, poly3_])
|
281
|
-
obj2_ = @factoryz.point(1, 2, 3)
|
282
|
-
obj_ = @factoryz.collection([obj1_, obj2_])
|
283
|
-
assert_equal("GeometryCollection Z (MultiPolygon Z (((0.0 0.0 0.0, 10.0 0.0 0.0, 10.0 10.0 0.0, 0.0 10.0 0.0, 0.0 0.0 0.0), (1.0 1.0 0.0, 2.0 2.0 0.0, 3.0 1.0 0.0, 1.0 1.0 0.0)), EMPTY, ((20.0 20.0 0.0, 30.0 20.0 0.0, 30.0 30.0 0.0, 20.0 30.0 0.0, 20.0 20.0 0.0))), Point Z (1.0 2.0 3.0))", generator_.generate(obj_))
|
284
|
-
end
|
285
|
-
|
286
|
-
def test_collection_empty
|
287
|
-
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
288
|
-
obj_ = @factory.collection([])
|
289
|
-
assert_equal("GeometryCollection EMPTY", generator_.generate(obj_))
|
290
|
-
end
|
291
|
-
end
|
292
|
-
end
|
293
|
-
end
|
294
|
-
end
|
@@ -1,412 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for WKT parser
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
module RGeo
|
11
|
-
module Tests # :nodoc:
|
12
|
-
module WKRep # :nodoc:
|
13
|
-
class TestWKTParser < ::Test::Unit::TestCase # :nodoc:
|
14
|
-
def test_point_2d
|
15
|
-
parser_ = ::RGeo::WKRep::WKTParser.new
|
16
|
-
obj_ = parser_.parse("POINT(1 2)")
|
17
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
18
|
-
assert_equal(1, obj_.x)
|
19
|
-
assert_equal(2, obj_.y)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_values_fractional
|
23
|
-
parser_ = ::RGeo::WKRep::WKTParser.new
|
24
|
-
obj_ = parser_.parse("POINT(1.000 2.5)")
|
25
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
26
|
-
assert_equal(1.0, obj_.x)
|
27
|
-
assert_equal(2.5, obj_.y)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_values_fractional2
|
31
|
-
parser_ = ::RGeo::WKRep::WKTParser.new
|
32
|
-
obj_ = parser_.parse("POINT(1. .5)")
|
33
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
34
|
-
assert_equal(1.0, obj_.x)
|
35
|
-
assert_equal(0.5, obj_.y)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_values_negative
|
39
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
|
40
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
41
|
-
obj_ = parser_.parse("POINT(-1. -.5 -5.5)")
|
42
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
43
|
-
assert_equal(-1.0, obj_.x)
|
44
|
-
assert_equal(-0.5, obj_.y)
|
45
|
-
assert_equal(-5.5, obj_.z)
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_point_square_brackets
|
49
|
-
parser_ = ::RGeo::WKRep::WKTParser.new
|
50
|
-
obj_ = parser_.parse("POINT[1 2]")
|
51
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
52
|
-
assert_equal(1, obj_.x)
|
53
|
-
assert_equal(2, obj_.y)
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_point_empty
|
57
|
-
parser_ = ::RGeo::WKRep::WKTParser.new
|
58
|
-
obj_ = parser_.parse("POINT EMPTY")
|
59
|
-
assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
|
60
|
-
assert_equal(0, obj_.num_geometries)
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_point_with_z
|
64
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
|
65
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
66
|
-
obj_ = parser_.parse("POINT(1 2 3)")
|
67
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
68
|
-
assert_equal(3, obj_.z)
|
69
|
-
assert_nil(obj_.m)
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_point_with_m
|
73
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_m_coordinate: true)
|
74
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
75
|
-
obj_ = parser_.parse("POINT(1 2 3)")
|
76
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
77
|
-
assert_equal(3, obj_.m)
|
78
|
-
assert_nil(obj_.z)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_point_with_too_many_coords
|
82
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
83
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
84
|
-
assert_raise(::RGeo::Error::ParseError) do
|
85
|
-
parser_.parse("POINT(1 2 3)")
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_point_wkt12_z
|
90
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
|
91
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
|
92
|
-
obj_ = parser_.parse("POINT Z(1 2 3)")
|
93
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
94
|
-
assert_equal(3, obj_.z)
|
95
|
-
assert_nil(obj_.m)
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_point_wkt12_z_unsupported_factory
|
99
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
100
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
|
101
|
-
assert_raise(::RGeo::Error::ParseError) do
|
102
|
-
parser_.parse("POINT Z(1 2 3)")
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_point_wkt12_m
|
107
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_m_coordinate: true)
|
108
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
|
109
|
-
obj_ = parser_.parse("POINT M(1 2 3)")
|
110
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
111
|
-
assert_equal(3, obj_.m)
|
112
|
-
assert_nil(obj_.z)
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_point_wkt12_m_with_factory_zm
|
116
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true, has_m_coordinate: true)
|
117
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
|
118
|
-
obj_ = parser_.parse("POINT M(1 2 3)")
|
119
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
120
|
-
assert_equal(3, obj_.m)
|
121
|
-
assert_equal(0, obj_.z)
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_point_wkt12_m_too_many_coords
|
125
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_m_coordinate: true)
|
126
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
|
127
|
-
assert_raise(::RGeo::Error::ParseError) do
|
128
|
-
parser_.parse("POINT M(1 2 3 4)")
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_point_wkt12_zm
|
133
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true, has_m_coordinate: true)
|
134
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
|
135
|
-
obj_ = parser_.parse("POINT ZM(1 2 3 4)")
|
136
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
137
|
-
assert_equal(3, obj_.z)
|
138
|
-
assert_equal(4, obj_.m)
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_point_wkt12_zm_not_enough_coords
|
142
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true, has_m_coordinate: true)
|
143
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
|
144
|
-
assert_raise(::RGeo::Error::ParseError) do
|
145
|
-
parser_.parse("POINT ZM(1 2 3)")
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_point_ewkt_z
|
150
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
|
151
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_ewkt: true)
|
152
|
-
obj_ = parser_.parse("POINT(1 2 3)")
|
153
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
154
|
-
assert_equal(3, obj_.z)
|
155
|
-
assert_nil(obj_.m)
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_point_ewkt_m
|
159
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_m_coordinate: true)
|
160
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_ewkt: true)
|
161
|
-
obj_ = parser_.parse("POINTM(1 2 3)")
|
162
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
163
|
-
assert_equal(3, obj_.m)
|
164
|
-
assert_nil(obj_.z)
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_point_ewkt_with_srid
|
168
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(::RGeo::Cartesian.method(:preferred_factory), support_ewkt: true)
|
169
|
-
obj_ = parser_.parse("SRID=1000;POINTM(1 2 3)")
|
170
|
-
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
171
|
-
assert_equal(3, obj_.m)
|
172
|
-
assert_nil(obj_.z)
|
173
|
-
assert_equal(1000, obj_.srid)
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_point_ewkt_m_too_many_coords
|
177
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_m_coordinate: true)
|
178
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_ewkt: true)
|
179
|
-
assert_raise(::RGeo::Error::ParseError) do
|
180
|
-
parser_.parse("POINTM(1 2 3 4)")
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
def test_point_strict_wkt11_with_z
|
185
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
|
186
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, strict_wkt11: true)
|
187
|
-
assert_raise(::RGeo::Error::ParseError) do
|
188
|
-
parser_.parse("POINT(1 2 3)")
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_point_non_ewkt_with_srid
|
193
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(::RGeo::Cartesian.method(:preferred_factory))
|
194
|
-
assert_raise(::RGeo::Error::ParseError) do
|
195
|
-
parser_.parse("SRID=1000;POINT(1 2)")
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
def test_linestring_basic
|
200
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
201
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
202
|
-
obj_ = parser_.parse("LINESTRING(1 2, 3 4, 5 6)")
|
203
|
-
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
204
|
-
assert_equal(3, obj_.num_points)
|
205
|
-
assert_equal(1, obj_.point_n(0).x)
|
206
|
-
assert_equal(6, obj_.point_n(2).y)
|
207
|
-
end
|
208
|
-
|
209
|
-
def test_linestring_with_z
|
210
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
|
211
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
212
|
-
obj_ = parser_.parse("LINESTRING(1 2 3, 4 5 6,7 8 9)")
|
213
|
-
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
214
|
-
assert_equal(3, obj_.num_points)
|
215
|
-
assert_equal(1, obj_.point_n(0).x)
|
216
|
-
assert_equal(9, obj_.point_n(2).z)
|
217
|
-
end
|
218
|
-
|
219
|
-
def test_linestring_with_inconsistent_coords
|
220
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
|
221
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
222
|
-
assert_raise(::RGeo::Error::ParseError) do
|
223
|
-
parser_.parse("LINESTRING(1 2 3, 4 5,7 8 9)")
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
def test_linestring_wkt12_m
|
228
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true, has_m_coordinate: true)
|
229
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
|
230
|
-
obj_ = parser_.parse("LINESTRING M(1 2 3,5 6 7)")
|
231
|
-
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
232
|
-
assert_equal(2, obj_.num_points)
|
233
|
-
assert_equal(0, obj_.point_n(0).z)
|
234
|
-
assert_equal(3, obj_.point_n(0).m)
|
235
|
-
assert_equal(0, obj_.point_n(1).z)
|
236
|
-
assert_equal(7, obj_.point_n(1).m)
|
237
|
-
end
|
238
|
-
|
239
|
-
def test_linestring_ewkt_with_srid
|
240
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(::RGeo::Cartesian.method(:preferred_factory), support_ewkt: true)
|
241
|
-
obj_ = parser_.parse("SRID=1000;LINESTRINGM(1 2 3, 4 5 6)")
|
242
|
-
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
243
|
-
assert_equal(3, obj_.point_n(0).m)
|
244
|
-
assert_nil(obj_.point_n(0).z)
|
245
|
-
assert_equal(1000, obj_.srid)
|
246
|
-
end
|
247
|
-
|
248
|
-
def test_linestring_empty
|
249
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
250
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
251
|
-
obj_ = parser_.parse("LINESTRING EMPTY")
|
252
|
-
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
253
|
-
assert_equal(0, obj_.num_points)
|
254
|
-
end
|
255
|
-
|
256
|
-
def test_polygon_basic
|
257
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
258
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
259
|
-
obj_ = parser_.parse("POLYGON((1 2, 3 4, 5 7, 1 2))")
|
260
|
-
assert_equal(::RGeo::Feature::Polygon, obj_.geometry_type)
|
261
|
-
assert_equal(4, obj_.exterior_ring.num_points)
|
262
|
-
assert_equal(1, obj_.exterior_ring.point_n(0).x)
|
263
|
-
assert_equal(7, obj_.exterior_ring.point_n(2).y)
|
264
|
-
end
|
265
|
-
|
266
|
-
def test_polygon_with_holes_and_z
|
267
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
|
268
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
269
|
-
obj_ = parser_.parse("POLYGON((0 0 -1, 10 0 -2, 10 10 -3, 0 10 -4, 0 0 -5),(1 1 -6, 2 3 -7, 3 1 -8, 1 1 -9))")
|
270
|
-
assert_equal(::RGeo::Feature::Polygon, obj_.geometry_type)
|
271
|
-
assert_equal(5, obj_.exterior_ring.num_points)
|
272
|
-
assert_equal(0, obj_.exterior_ring.point_n(0).x)
|
273
|
-
assert_equal(10, obj_.exterior_ring.point_n(2).y)
|
274
|
-
assert_equal(1, obj_.num_interior_rings)
|
275
|
-
assert_equal(-6, obj_.interior_ring_n(0).point_n(0).z)
|
276
|
-
assert_equal(-7, obj_.interior_ring_n(0).point_n(1).z)
|
277
|
-
end
|
278
|
-
|
279
|
-
def test_polygon_empty
|
280
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
281
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
282
|
-
obj_ = parser_.parse("POLYGON EMPTY")
|
283
|
-
assert_equal(::RGeo::Feature::Polygon, obj_.geometry_type)
|
284
|
-
assert_equal(0, obj_.exterior_ring.num_points)
|
285
|
-
end
|
286
|
-
|
287
|
-
def test_multipoint_basic
|
288
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
289
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
290
|
-
obj_ = parser_.parse("MULTIPOINT((1 2),(0 3))")
|
291
|
-
assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
|
292
|
-
assert_equal(2, obj_.num_geometries)
|
293
|
-
assert_equal(1, obj_[0].x)
|
294
|
-
assert_equal(3, obj_[1].y)
|
295
|
-
end
|
296
|
-
|
297
|
-
def test_multipoint_without_parens
|
298
|
-
# This syntax isn't strictly allowed by the spec, but apparently
|
299
|
-
# it does get used occasionally, so we do support parsing it.
|
300
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
301
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
302
|
-
obj_ = parser_.parse("MULTIPOINT(1 2, 0 3)")
|
303
|
-
assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
|
304
|
-
assert_equal(2, obj_.num_geometries)
|
305
|
-
assert_equal(1, obj_[0].x)
|
306
|
-
assert_equal(3, obj_[1].y)
|
307
|
-
end
|
308
|
-
|
309
|
-
def test_multipoint_empty
|
310
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
311
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
312
|
-
obj_ = parser_.parse("MULTIPOINT EMPTY")
|
313
|
-
assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
|
314
|
-
assert_equal(0, obj_.num_geometries)
|
315
|
-
end
|
316
|
-
|
317
|
-
def test_multilinestring_basic
|
318
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
319
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
320
|
-
obj_ = parser_.parse("MULTILINESTRING((1 2, 3 4, 5 6),(0 -3, 0 -4, 1 -5))")
|
321
|
-
assert_equal(::RGeo::Feature::MultiLineString, obj_.geometry_type)
|
322
|
-
assert_equal(2, obj_.num_geometries)
|
323
|
-
assert_equal(1, obj_[0].point_n(0).x)
|
324
|
-
assert_equal(-5, obj_[1].point_n(2).y)
|
325
|
-
end
|
326
|
-
|
327
|
-
def test_multilinestring_empty
|
328
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
329
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
330
|
-
obj_ = parser_.parse("MULTILINESTRING EMPTY")
|
331
|
-
assert_equal(::RGeo::Feature::MultiLineString, obj_.geometry_type)
|
332
|
-
assert_equal(0, obj_.num_geometries)
|
333
|
-
end
|
334
|
-
|
335
|
-
def test_multipolygon_basic
|
336
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
|
337
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
338
|
-
obj_ = parser_.parse("MULTIPOLYGON(((-1 -2 0, -3 -4 0, -5 -7 0, -1 -2 0)),((0 0 -1, 10 0 -2, 10 10 -3, 0 10 -4, 0 0 -5),(1 1 -6, 2 3 -7, 3 1 -8, 1 1 -9)))")
|
339
|
-
assert_equal(::RGeo::Feature::MultiPolygon, obj_.geometry_type)
|
340
|
-
assert_equal(2, obj_.num_geometries)
|
341
|
-
assert_equal(4, obj_[0].exterior_ring.num_points)
|
342
|
-
assert_equal(-1, obj_[0].exterior_ring.point_n(0).x)
|
343
|
-
assert_equal(-7, obj_[0].exterior_ring.point_n(2).y)
|
344
|
-
assert_equal(5, obj_[1].exterior_ring.num_points)
|
345
|
-
assert_equal(0, obj_[1].exterior_ring.point_n(0).x)
|
346
|
-
assert_equal(10, obj_[1].exterior_ring.point_n(2).y)
|
347
|
-
assert_equal(1, obj_[1].num_interior_rings)
|
348
|
-
assert_equal(-6, obj_[1].interior_ring_n(0).point_n(0).z)
|
349
|
-
assert_equal(-7, obj_[1].interior_ring_n(0).point_n(1).z)
|
350
|
-
end
|
351
|
-
|
352
|
-
def test_multipolygon_empty
|
353
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
354
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
355
|
-
obj_ = parser_.parse("MULTIPOLYGON EMPTY")
|
356
|
-
assert_equal(::RGeo::Feature::MultiPolygon, obj_.geometry_type)
|
357
|
-
assert_equal(0, obj_.num_geometries)
|
358
|
-
end
|
359
|
-
|
360
|
-
def test_collection_basic
|
361
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
362
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
363
|
-
obj_ = parser_.parse("GEOMETRYCOLLECTION(POINT(-1 -2),LINESTRING(1 2, 3 4, 5 6))")
|
364
|
-
assert_equal(::RGeo::Feature::GeometryCollection, obj_.geometry_type)
|
365
|
-
assert_equal(2, obj_.num_geometries)
|
366
|
-
assert_equal(::RGeo::Feature::Point, obj_[0].geometry_type)
|
367
|
-
assert_equal(-1, obj_[0].x)
|
368
|
-
assert_equal(::RGeo::Feature::LineString, obj_[1].geometry_type)
|
369
|
-
assert_equal(1, obj_[1].point_n(0).x)
|
370
|
-
assert_equal(6, obj_[1].point_n(2).y)
|
371
|
-
end
|
372
|
-
|
373
|
-
def test_collection_z
|
374
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
|
375
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
376
|
-
obj_ = parser_.parse("GEOMETRYCOLLECTION(POINT(-1 -2 0),LINESTRING(1 2 0, 3 4 0, 5 6 0))")
|
377
|
-
assert_equal(::RGeo::Feature::GeometryCollection, obj_.geometry_type)
|
378
|
-
assert_equal(2, obj_.num_geometries)
|
379
|
-
assert_equal(::RGeo::Feature::Point, obj_[0].geometry_type)
|
380
|
-
assert_equal(-1, obj_[0].x)
|
381
|
-
assert_equal(::RGeo::Feature::LineString, obj_[1].geometry_type)
|
382
|
-
assert_equal(1, obj_[1].point_n(0).x)
|
383
|
-
assert_equal(6, obj_[1].point_n(2).y)
|
384
|
-
end
|
385
|
-
|
386
|
-
def test_collection_dimension_mismatch
|
387
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true)
|
388
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
389
|
-
assert_raise(::RGeo::Error::ParseError) do
|
390
|
-
parser_.parse("GEOMETRYCOLLECTION(POINT(-1 -2),LINESTRING(1 2 0, 3 4 0, 5 6 0))")
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
|
-
def test_collection_wkt12_type_mismatch
|
395
|
-
factory_ = ::RGeo::Cartesian.preferred_factory(has_z_coordinate: true, has_m_coordinate: true)
|
396
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, support_wkt12: true)
|
397
|
-
assert_raise(::RGeo::Error::ParseError) do
|
398
|
-
parser_.parse("GEOMETRYCOLLECTION Z(POINT Z(-1 -2 0),LINESTRING M(1 2 0, 3 4 0, 5 6 0))")
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
def test_collection_empty
|
403
|
-
factory_ = ::RGeo::Cartesian.preferred_factory
|
404
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
405
|
-
obj_ = parser_.parse("GEOMETRYCOLLECTION EMPTY")
|
406
|
-
assert_equal(::RGeo::Feature::GeometryCollection, obj_.geometry_type)
|
407
|
-
assert_equal(0, obj_.num_geometries)
|
408
|
-
end
|
409
|
-
end
|
410
|
-
end
|
411
|
-
end
|
412
|
-
end
|