rgeo 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +6 -0
- data/README.rdoc +1 -1
- data/Version +1 -1
- data/ext/geos_c_impl/extconf.rb +13 -13
- data/ext/geos_c_impl/factory.c +30 -18
- data/ext/geos_c_impl/factory.h +18 -12
- data/ext/geos_c_impl/geometry.c +11 -11
- data/ext/geos_c_impl/geometry.h +7 -7
- data/ext/geos_c_impl/geometry_collection.c +15 -15
- data/ext/geos_c_impl/geometry_collection.h +8 -8
- data/ext/geos_c_impl/line_string.c +14 -14
- data/ext/geos_c_impl/line_string.h +7 -7
- data/ext/geos_c_impl/main.c +7 -7
- data/ext/geos_c_impl/point.c +9 -9
- data/ext/geos_c_impl/point.h +7 -7
- data/ext/geos_c_impl/polygon.c +9 -9
- data/ext/geos_c_impl/polygon.h +7 -7
- data/ext/geos_c_impl/preface.h +7 -7
- data/ext/proj4_c_impl/extconf.rb +13 -13
- data/ext/proj4_c_impl/main.c +12 -12
- data/lib/rgeo.rb +26 -26
- data/lib/rgeo/cartesian.rb +12 -12
- data/lib/rgeo/cartesian/analysis.rb +26 -26
- data/lib/rgeo/cartesian/bounding_box.rb +83 -83
- data/lib/rgeo/cartesian/calculations.rb +36 -36
- data/lib/rgeo/cartesian/factory.rb +78 -78
- data/lib/rgeo/cartesian/feature_classes.rb +74 -74
- data/lib/rgeo/cartesian/feature_methods.rb +34 -34
- data/lib/rgeo/cartesian/interface.rb +33 -33
- data/lib/rgeo/coord_sys.rb +15 -15
- data/lib/rgeo/coord_sys/cs/entities.rb +533 -534
- data/lib/rgeo/coord_sys/cs/factories.rb +69 -69
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +44 -44
- data/lib/rgeo/coord_sys/proj4.rb +85 -85
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/interface.rb +44 -44
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +29 -29
- data/lib/rgeo/error.rb +17 -17
- data/lib/rgeo/feature.rb +15 -15
- data/lib/rgeo/feature/curve.rb +58 -58
- data/lib/rgeo/feature/factory.rb +84 -84
- data/lib/rgeo/feature/factory_generator.rb +32 -32
- data/lib/rgeo/feature/geometry.rb +215 -215
- data/lib/rgeo/feature/geometry_collection.rb +46 -46
- data/lib/rgeo/feature/line.rb +21 -21
- data/lib/rgeo/feature/line_string.rb +35 -35
- data/lib/rgeo/feature/linear_ring.rb +20 -20
- data/lib/rgeo/feature/mixins.rb +61 -61
- data/lib/rgeo/feature/multi_curve.rb +37 -37
- data/lib/rgeo/feature/multi_line_string.rb +20 -20
- data/lib/rgeo/feature/multi_point.rb +22 -22
- data/lib/rgeo/feature/multi_polygon.rb +28 -28
- data/lib/rgeo/feature/multi_surface.rb +39 -39
- data/lib/rgeo/feature/point.rb +42 -42
- data/lib/rgeo/feature/polygon.rb +50 -50
- data/lib/rgeo/feature/surface.rb +42 -42
- data/lib/rgeo/feature/types.rb +58 -58
- data/lib/rgeo/geographic.rb +14 -14
- data/lib/rgeo/geographic/factory.rb +87 -87
- data/lib/rgeo/geographic/interface.rb +55 -55
- data/lib/rgeo/geographic/proj4_projector.rb +35 -35
- data/lib/rgeo/geographic/projected_feature_classes.rb +95 -95
- data/lib/rgeo/geographic/projected_feature_methods.rb +81 -81
- data/lib/rgeo/geographic/projected_window.rb +103 -103
- data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -32
- data/lib/rgeo/geographic/spherical_feature_classes.rb +93 -93
- data/lib/rgeo/geographic/spherical_feature_methods.rb +25 -25
- data/lib/rgeo/geographic/spherical_math.rb +58 -58
- data/lib/rgeo/geos.rb +22 -17
- data/lib/rgeo/geos/factory.rb +93 -93
- data/lib/rgeo/geos/ffi_classes.rb +306 -231
- data/lib/rgeo/geos/ffi_factory.rb +100 -96
- data/lib/rgeo/geos/impl_additions.rb +22 -22
- data/lib/rgeo/geos/interface.rb +45 -45
- data/lib/rgeo/geos/zm_factory.rb +90 -90
- data/lib/rgeo/geos/zm_impl.rb +167 -167
- data/lib/rgeo/impl_helper.rb +11 -11
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +71 -71
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +29 -29
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +61 -61
- data/lib/rgeo/impl_helper/basic_point_methods.rb +43 -43
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +35 -35
- data/lib/rgeo/impl_helper/math.rb +13 -13
- data/lib/rgeo/version.rb +10 -10
- data/lib/rgeo/wkrep.rb +16 -16
- data/lib/rgeo/wkrep/wkb_generator.rb +51 -51
- data/lib/rgeo/wkrep/wkb_parser.rb +52 -52
- data/lib/rgeo/wkrep/wkt_generator.rb +51 -51
- data/lib/rgeo/wkrep/wkt_parser.rb +66 -66
- data/lib/rgeo/yaml.rb +14 -14
- data/test/common/geometry_collection_tests.rb +53 -53
- data/test/common/line_string_tests.rb +57 -57
- data/test/common/multi_line_string_tests.rb +43 -43
- data/test/common/multi_point_tests.rb +43 -43
- data/test/common/multi_polygon_tests.rb +43 -43
- data/test/common/point_tests.rb +75 -75
- data/test/common/polygon_tests.rb +37 -37
- data/test/coord_sys/tc_active_record_table.rb +25 -25
- data/test/coord_sys/tc_ogc_cs.rb +72 -72
- data/test/coord_sys/tc_proj4.rb +51 -51
- data/test/coord_sys/tc_proj4_srs_data.rb +17 -17
- data/test/coord_sys/tc_sr_org.rb +15 -15
- data/test/coord_sys/tc_url_reader.rb +19 -19
- data/test/geos_capi/tc_factory.rb +21 -21
- data/test/geos_capi/tc_geometry_collection.rb +15 -15
- data/test/geos_capi/tc_line_string.rb +15 -15
- data/test/geos_capi/tc_misc.rb +33 -22
- data/test/geos_capi/tc_multi_line_string.rb +15 -15
- data/test/geos_capi/tc_multi_point.rb +15 -15
- data/test/geos_capi/tc_multi_polygon.rb +15 -15
- data/test/geos_capi/tc_parsing_unparsing.rb +19 -19
- data/test/geos_capi/tc_point.rb +21 -21
- data/test/geos_capi/tc_polygon.rb +19 -19
- data/test/geos_capi/tc_zmfactory.rb +17 -17
- data/test/geos_ffi/tc_factory.rb +21 -21
- data/test/geos_ffi/tc_geometry_collection.rb +15 -15
- data/test/geos_ffi/tc_line_string.rb +15 -15
- data/test/geos_ffi/tc_misc.rb +49 -15
- data/test/geos_ffi/tc_multi_line_string.rb +15 -15
- data/test/geos_ffi/tc_multi_point.rb +15 -15
- data/test/geos_ffi/tc_multi_polygon.rb +15 -15
- data/test/geos_ffi/tc_parsing_unparsing.rb +19 -19
- data/test/geos_ffi/tc_point.rb +21 -21
- data/test/geos_ffi/tc_polygon.rb +19 -19
- data/test/geos_ffi/tc_zmfactory.rb +17 -17
- data/test/projected_geographic/tc_geometry_collection.rb +15 -15
- data/test/projected_geographic/tc_line_string.rb +15 -15
- data/test/projected_geographic/tc_multi_line_string.rb +15 -15
- data/test/projected_geographic/tc_multi_point.rb +15 -15
- data/test/projected_geographic/tc_multi_polygon.rb +15 -15
- data/test/projected_geographic/tc_point.rb +23 -23
- data/test/projected_geographic/tc_polygon.rb +15 -15
- data/test/simple_cartesian/tc_calculations.rb +31 -31
- data/test/simple_cartesian/tc_geometry_collection.rb +17 -17
- data/test/simple_cartesian/tc_line_string.rb +17 -17
- data/test/simple_cartesian/tc_multi_line_string.rb +17 -17
- data/test/simple_cartesian/tc_multi_point.rb +17 -17
- data/test/simple_cartesian/tc_multi_polygon.rb +17 -17
- data/test/simple_cartesian/tc_point.rb +21 -21
- data/test/simple_cartesian/tc_polygon.rb +17 -17
- data/test/simple_mercator/tc_geometry_collection.rb +15 -15
- data/test/simple_mercator/tc_line_string.rb +15 -15
- data/test/simple_mercator/tc_multi_line_string.rb +15 -15
- data/test/simple_mercator/tc_multi_point.rb +15 -15
- data/test/simple_mercator/tc_multi_polygon.rb +15 -15
- data/test/simple_mercator/tc_point.rb +23 -23
- data/test/simple_mercator/tc_polygon.rb +15 -15
- data/test/simple_mercator/tc_window.rb +50 -50
- data/test/spherical_geographic/tc_calculations.rb +47 -47
- data/test/spherical_geographic/tc_geometry_collection.rb +17 -17
- data/test/spherical_geographic/tc_line_string.rb +17 -17
- data/test/spherical_geographic/tc_multi_line_string.rb +17 -17
- data/test/spherical_geographic/tc_multi_point.rb +17 -17
- data/test/spherical_geographic/tc_multi_polygon.rb +17 -17
- data/test/spherical_geographic/tc_point.rb +23 -23
- data/test/spherical_geographic/tc_polygon.rb +17 -17
- data/test/tc_cartesian_analysis.rb +23 -23
- data/test/tc_mixins.rb +39 -39
- data/test/tc_oneoff.rb +15 -15
- data/test/tc_types.rb +17 -17
- data/test/wkrep/tc_wkb_generator.rb +67 -67
- data/test/wkrep/tc_wkb_parser.rb +73 -73
- data/test/wkrep/tc_wkt_generator.rb +75 -75
- data/test/wkrep/tc_wkt_parser.rb +97 -97
- metadata +3 -3
data/test/wkrep/tc_wkb_parser.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Tests for WKT parser
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -41,10 +41,10 @@ require 'rgeo'
|
|
41
41
|
module RGeo
|
42
42
|
module Tests # :nodoc:
|
43
43
|
module WKRep # :nodoc:
|
44
|
-
|
44
|
+
|
45
45
|
class TestWKBParser < ::Test::Unit::TestCase # :nodoc:
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
def test_point_2d_xdr_hex
|
49
49
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
50
50
|
obj_ = parser_.parse('00000000013ff00000000000004000000000000000')
|
@@ -52,8 +52,8 @@ module RGeo
|
|
52
52
|
assert_equal(1, obj_.x)
|
53
53
|
assert_equal(2, obj_.y)
|
54
54
|
end
|
55
|
-
|
56
|
-
|
55
|
+
|
56
|
+
|
57
57
|
def test_point_2d_xdr_binary
|
58
58
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
59
59
|
obj_ = parser_.parse(['00000000013ff00000000000004000000000000000'].pack('H*'))
|
@@ -61,8 +61,8 @@ module RGeo
|
|
61
61
|
assert_equal(1, obj_.x)
|
62
62
|
assert_equal(2, obj_.y)
|
63
63
|
end
|
64
|
-
|
65
|
-
|
64
|
+
|
65
|
+
|
66
66
|
def test_point_2d_ndr
|
67
67
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
68
68
|
obj_ = parser_.parse('0101000000000000000000f03f0000000000000040')
|
@@ -70,8 +70,8 @@ module RGeo
|
|
70
70
|
assert_equal(1, obj_.x)
|
71
71
|
assert_equal(2, obj_.y)
|
72
72
|
end
|
73
|
-
|
74
|
-
|
73
|
+
|
74
|
+
|
75
75
|
def test_point_with_ewkb_z
|
76
76
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
77
77
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
@@ -80,8 +80,8 @@ module RGeo
|
|
80
80
|
assert_equal(3, obj_.z)
|
81
81
|
assert_nil(obj_.m)
|
82
82
|
end
|
83
|
-
|
84
|
-
|
83
|
+
|
84
|
+
|
85
85
|
def test_point_with_ewkb_m
|
86
86
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_m_coordinate => true)
|
87
87
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
@@ -90,8 +90,8 @@ module RGeo
|
|
90
90
|
assert_equal(3, obj_.m)
|
91
91
|
assert_nil(obj_.z)
|
92
92
|
end
|
93
|
-
|
94
|
-
|
93
|
+
|
94
|
+
|
95
95
|
def test_point_with_ewkb_zm
|
96
96
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :has_m_coordinate => true)
|
97
97
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
@@ -100,8 +100,8 @@ module RGeo
|
|
100
100
|
assert_equal(3, obj_.z)
|
101
101
|
assert_equal(4, obj_.m)
|
102
102
|
end
|
103
|
-
|
104
|
-
|
103
|
+
|
104
|
+
|
105
105
|
def test_point_with_wkb12_z
|
106
106
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
107
107
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
@@ -110,8 +110,8 @@ module RGeo
|
|
110
110
|
assert_equal(3, obj_.z)
|
111
111
|
assert_nil(obj_.m)
|
112
112
|
end
|
113
|
-
|
114
|
-
|
113
|
+
|
114
|
+
|
115
115
|
def test_point_with_wkb12_m
|
116
116
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_m_coordinate => true)
|
117
117
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
@@ -120,8 +120,8 @@ module RGeo
|
|
120
120
|
assert_equal(3, obj_.m)
|
121
121
|
assert_nil(obj_.z)
|
122
122
|
end
|
123
|
-
|
124
|
-
|
123
|
+
|
124
|
+
|
125
125
|
def test_point_with_wkb12_zm
|
126
126
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :has_m_coordinate => true)
|
127
127
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
@@ -130,8 +130,8 @@ module RGeo
|
|
130
130
|
assert_equal(3, obj_.z)
|
131
131
|
assert_equal(4, obj_.m)
|
132
132
|
end
|
133
|
-
|
134
|
-
|
133
|
+
|
134
|
+
|
135
135
|
def test_point_with_wkb12_z_without_wkb12_support
|
136
136
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
137
137
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_)
|
@@ -139,8 +139,8 @@ module RGeo
|
|
139
139
|
obj_ = parser_.parse('00000003e93ff000000000000040000000000000004008000000000000')
|
140
140
|
end
|
141
141
|
end
|
142
|
-
|
143
|
-
|
142
|
+
|
143
|
+
|
144
144
|
def test_point_with_wkb12_z_without_enough_data
|
145
145
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
146
146
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
@@ -148,8 +148,8 @@ module RGeo
|
|
148
148
|
obj_ = parser_.parse('00000003e93ff00000000000004000000000000000')
|
149
149
|
end
|
150
150
|
end
|
151
|
-
|
152
|
-
|
151
|
+
|
152
|
+
|
153
153
|
def test_point_with_ewkb_z_and_srid
|
154
154
|
factory_generator_ = ::Proc.new do |config_|
|
155
155
|
::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :srid => config_[:srid])
|
@@ -161,8 +161,8 @@ module RGeo
|
|
161
161
|
assert_nil(obj_.m)
|
162
162
|
assert_equal(1000, obj_.srid)
|
163
163
|
end
|
164
|
-
|
165
|
-
|
164
|
+
|
165
|
+
|
166
166
|
def test_linestring_basic
|
167
167
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
168
168
|
obj_ = parser_.parse('0000000002000000033ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000')
|
@@ -171,8 +171,8 @@ module RGeo
|
|
171
171
|
assert_equal(1, obj_.point_n(0).x)
|
172
172
|
assert_equal(6, obj_.point_n(2).y)
|
173
173
|
end
|
174
|
-
|
175
|
-
|
174
|
+
|
175
|
+
|
176
176
|
def test_linestring_with_ewkb_z
|
177
177
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
178
178
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
@@ -182,8 +182,8 @@ module RGeo
|
|
182
182
|
assert_equal(1, obj_.point_n(0).x)
|
183
183
|
assert_equal(6, obj_.point_n(1).z)
|
184
184
|
end
|
185
|
-
|
186
|
-
|
185
|
+
|
186
|
+
|
187
187
|
def test_linestring_with_ewkb_z_and_srid
|
188
188
|
factory_generator_ = ::Proc.new do |config_|
|
189
189
|
::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :srid => config_[:srid])
|
@@ -196,8 +196,8 @@ module RGeo
|
|
196
196
|
assert_equal(6, obj_.point_n(1).z)
|
197
197
|
assert_equal(1000, obj_.srid)
|
198
198
|
end
|
199
|
-
|
200
|
-
|
199
|
+
|
200
|
+
|
201
201
|
def test_linestring_with_wkb12_z
|
202
202
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
203
203
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
@@ -207,16 +207,16 @@ module RGeo
|
|
207
207
|
assert_equal(1, obj_.point_n(0).x)
|
208
208
|
assert_equal(6, obj_.point_n(1).z)
|
209
209
|
end
|
210
|
-
|
211
|
-
|
210
|
+
|
211
|
+
|
212
212
|
def test_linestring_empty
|
213
213
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
214
214
|
obj_ = parser_.parse('000000000200000000')
|
215
215
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
216
216
|
assert_equal(0, obj_.num_points)
|
217
217
|
end
|
218
|
-
|
219
|
-
|
218
|
+
|
219
|
+
|
220
220
|
def test_polygon_basic
|
221
221
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
222
222
|
obj_ = parser_.parse('000000000300000001000000043ff0000000000000400000000000000040080000000000004010000000000000401800000000000040140000000000003ff00000000000004000000000000000')
|
@@ -225,16 +225,16 @@ module RGeo
|
|
225
225
|
assert_equal(1, obj_.exterior_ring.point_n(0).x)
|
226
226
|
assert_equal(5, obj_.exterior_ring.point_n(2).y)
|
227
227
|
end
|
228
|
-
|
229
|
-
|
228
|
+
|
229
|
+
|
230
230
|
def test_polygon_empty
|
231
231
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
232
232
|
obj_ = parser_.parse('000000000300000000')
|
233
233
|
assert_equal(::RGeo::Feature::Polygon, obj_.geometry_type)
|
234
234
|
assert_equal(0, obj_.exterior_ring.num_points)
|
235
235
|
end
|
236
|
-
|
237
|
-
|
236
|
+
|
237
|
+
|
238
238
|
def test_multipoint_basic
|
239
239
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
240
240
|
obj_ = parser_.parse('00000000040000000200000000013ff00000000000004000000000000000000000000140080000000000004010000000000000')
|
@@ -243,8 +243,8 @@ module RGeo
|
|
243
243
|
assert_equal(1, obj_[0].x)
|
244
244
|
assert_equal(4, obj_[1].y)
|
245
245
|
end
|
246
|
-
|
247
|
-
|
246
|
+
|
247
|
+
|
248
248
|
def test_multipoint_mixed_byte_order
|
249
249
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
250
250
|
obj_ = parser_.parse('0000000004000000020101000000000000000000f03f0000000000000040000000000140080000000000004010000000000000')
|
@@ -253,8 +253,8 @@ module RGeo
|
|
253
253
|
assert_equal(1, obj_[0].x)
|
254
254
|
assert_equal(4, obj_[1].y)
|
255
255
|
end
|
256
|
-
|
257
|
-
|
256
|
+
|
257
|
+
|
258
258
|
def test_multipoint_with_ewkb_z
|
259
259
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
260
260
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
@@ -267,8 +267,8 @@ module RGeo
|
|
267
267
|
assert_equal(6, obj_[1].z)
|
268
268
|
assert_nil(obj_[0].m)
|
269
269
|
end
|
270
|
-
|
271
|
-
|
270
|
+
|
271
|
+
|
272
272
|
def test_multipoint_ewkb_with_mixed_z
|
273
273
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
274
274
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
@@ -276,16 +276,16 @@ module RGeo
|
|
276
276
|
obj_ = parser_.parse('00800000040000000200800000013ff000000000000040000000000000004014000000000000000000000140080000000000004010000000000000')
|
277
277
|
end
|
278
278
|
end
|
279
|
-
|
280
|
-
|
279
|
+
|
280
|
+
|
281
281
|
def test_multipoint_empty
|
282
282
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
283
283
|
obj_ = parser_.parse('000000000400000000')
|
284
284
|
assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
|
285
285
|
assert_equal(0, obj_.num_geometries)
|
286
286
|
end
|
287
|
-
|
288
|
-
|
287
|
+
|
288
|
+
|
289
289
|
def test_multilinestring_basic
|
290
290
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
291
291
|
obj_ = parser_.parse('0000000005000000020000000002000000033ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000000000000200000002bff0000000000000c000000000000000c008000000000000c010000000000000')
|
@@ -294,24 +294,24 @@ module RGeo
|
|
294
294
|
assert_equal(1, obj_[0].point_n(0).x)
|
295
295
|
assert_equal(-4, obj_[1].point_n(1).y)
|
296
296
|
end
|
297
|
-
|
298
|
-
|
297
|
+
|
298
|
+
|
299
299
|
def test_multilinestring_wrong_element_type
|
300
300
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
301
301
|
assert_raise(::RGeo::Error::ParseError) do
|
302
302
|
obj_ = parser_.parse('0000000005000000020000000002000000033ff00000000000004000000000000000400800000000000040100000000000004014000000000000401800000000000000000000013ff00000000000004000000000000000')
|
303
303
|
end
|
304
304
|
end
|
305
|
-
|
306
|
-
|
305
|
+
|
306
|
+
|
307
307
|
def test_multilinestring_empty
|
308
308
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
309
309
|
obj_ = parser_.parse('000000000500000000')
|
310
310
|
assert_equal(::RGeo::Feature::MultiLineString, obj_.geometry_type)
|
311
311
|
assert_equal(0, obj_.num_geometries)
|
312
312
|
end
|
313
|
-
|
314
|
-
|
313
|
+
|
314
|
+
|
315
315
|
def test_multipolygon_basic
|
316
316
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
317
317
|
obj_ = parser_.parse('000000000600000002000000000300000001000000043ff0000000000000400000000000000040080000000000004010000000000000401800000000000040140000000000003ff00000000000004000000000000000000000000300000000')
|
@@ -322,16 +322,16 @@ module RGeo
|
|
322
322
|
assert_equal(5, obj_[0].exterior_ring.point_n(2).y)
|
323
323
|
assert_equal(0, obj_[1].exterior_ring.num_points)
|
324
324
|
end
|
325
|
-
|
326
|
-
|
325
|
+
|
326
|
+
|
327
327
|
def test_multipolygon_empty
|
328
328
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
329
329
|
obj_ = parser_.parse('000000000600000000')
|
330
330
|
assert_equal(::RGeo::Feature::MultiPolygon, obj_.geometry_type)
|
331
331
|
assert_equal(0, obj_.num_geometries)
|
332
332
|
end
|
333
|
-
|
334
|
-
|
333
|
+
|
334
|
+
|
335
335
|
def test_collection_basic
|
336
336
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
337
337
|
obj_ = parser_.parse('0000000007000000020000000002000000033ff0000000000000400000000000000040080000000000004010000000000000401400000000000040180000000000000000000001bff0000000000000c000000000000000')
|
@@ -343,18 +343,18 @@ module RGeo
|
|
343
343
|
assert_equal(::RGeo::Feature::Point, obj_[1].geometry_type)
|
344
344
|
assert_equal(-1, obj_[1].x)
|
345
345
|
end
|
346
|
-
|
347
|
-
|
346
|
+
|
347
|
+
|
348
348
|
def test_collection_empty
|
349
349
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
350
350
|
obj_ = parser_.parse('000000000700000000')
|
351
351
|
assert_equal(::RGeo::Feature::GeometryCollection, obj_.geometry_type)
|
352
352
|
assert_equal(0, obj_.num_geometries)
|
353
353
|
end
|
354
|
-
|
355
|
-
|
354
|
+
|
355
|
+
|
356
356
|
end
|
357
|
-
|
357
|
+
|
358
358
|
end
|
359
359
|
end
|
360
360
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Tests for WKT generator
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -41,137 +41,137 @@ require 'rgeo'
|
|
41
41
|
module RGeo
|
42
42
|
module Tests # :nodoc:
|
43
43
|
module WKRep # :nodoc:
|
44
|
-
|
44
|
+
|
45
45
|
class TestWKTGenerator < ::Test::Unit::TestCase # :nodoc:
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
def setup
|
49
49
|
@factory = ::RGeo::Cartesian.preferred_factory(:srid => 1000)
|
50
50
|
@factoryz = ::RGeo::Cartesian.preferred_factory(:srid => 1000, :has_z_coordinate => true)
|
51
51
|
@factorym = ::RGeo::Cartesian.preferred_factory(:srid => 1000, :has_m_coordinate => true)
|
52
52
|
@factoryzm = ::RGeo::Cartesian.preferred_factory(:srid => 1000, :has_z_coordinate => true, :has_m_coordinate => true)
|
53
53
|
end
|
54
|
-
|
55
|
-
|
54
|
+
|
55
|
+
|
56
56
|
def test_point_2d
|
57
57
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
58
58
|
obj_ = @factory.point(1, 2)
|
59
59
|
assert_equal('Point (1.0 2.0)', generator_.generate(obj_))
|
60
60
|
end
|
61
|
-
|
62
|
-
|
61
|
+
|
62
|
+
|
63
63
|
def test_point_z
|
64
64
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
65
65
|
obj_ = @factoryz.point(1, 2, 3)
|
66
66
|
assert_equal('Point (1.0 2.0 3.0)', generator_.generate(obj_))
|
67
67
|
end
|
68
|
-
|
69
|
-
|
68
|
+
|
69
|
+
|
70
70
|
def test_point_z_wkt11strict
|
71
71
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:tag_format => :wkt11_strict)
|
72
72
|
obj_ = @factoryz.point(1, 2, 3)
|
73
73
|
assert_equal('Point (1.0 2.0)', generator_.generate(obj_))
|
74
74
|
end
|
75
|
-
|
76
|
-
|
75
|
+
|
76
|
+
|
77
77
|
def test_point_m
|
78
78
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
79
79
|
obj_ = @factorym.point(1, 2, 3)
|
80
80
|
assert_equal('Point (1.0 2.0 3.0)', generator_.generate(obj_))
|
81
81
|
end
|
82
|
-
|
83
|
-
|
82
|
+
|
83
|
+
|
84
84
|
def test_point_zm
|
85
85
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
86
86
|
obj_ = @factoryzm.point(1, 2, 3, 4)
|
87
87
|
assert_equal('Point (1.0 2.0 3.0 4.0)', generator_.generate(obj_))
|
88
88
|
end
|
89
|
-
|
90
|
-
|
89
|
+
|
90
|
+
|
91
91
|
def test_point_squarebrackets
|
92
92
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:square_brackets => true)
|
93
93
|
obj_ = @factory.point(1, 2)
|
94
94
|
assert_equal('Point [1.0 2.0]', generator_.generate(obj_))
|
95
95
|
end
|
96
|
-
|
97
|
-
|
96
|
+
|
97
|
+
|
98
98
|
def test_point_uppercase
|
99
99
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:convert_case => :upper)
|
100
100
|
obj_ = @factory.point(1, 2)
|
101
101
|
assert_equal('POINT (1.0 2.0)', generator_.generate(obj_))
|
102
102
|
end
|
103
|
-
|
104
|
-
|
103
|
+
|
104
|
+
|
105
105
|
def test_point_lowercase
|
106
106
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:convert_case => :lower)
|
107
107
|
obj_ = @factory.point(1, 2)
|
108
108
|
assert_equal('point (1.0 2.0)', generator_.generate(obj_))
|
109
109
|
end
|
110
|
-
|
111
|
-
|
110
|
+
|
111
|
+
|
112
112
|
def test_point_wkt12
|
113
113
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:tag_format => :wkt12)
|
114
114
|
obj_ = @factory.point(1, 2)
|
115
115
|
assert_equal('Point (1.0 2.0)', generator_.generate(obj_))
|
116
116
|
end
|
117
|
-
|
118
|
-
|
117
|
+
|
118
|
+
|
119
119
|
def test_point_wkt12_z
|
120
120
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:tag_format => :wkt12)
|
121
121
|
obj_ = @factoryz.point(1, 2, 3)
|
122
122
|
assert_equal('Point Z (1.0 2.0 3.0)', generator_.generate(obj_))
|
123
123
|
end
|
124
|
-
|
125
|
-
|
124
|
+
|
125
|
+
|
126
126
|
def test_point_wkt12_m
|
127
127
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:tag_format => :wkt12)
|
128
128
|
obj_ = @factorym.point(1, 2, 3)
|
129
129
|
assert_equal('Point M (1.0 2.0 3.0)', generator_.generate(obj_))
|
130
130
|
end
|
131
|
-
|
132
|
-
|
131
|
+
|
132
|
+
|
133
133
|
def test_point_wkt12_zm
|
134
134
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:tag_format => :wkt12)
|
135
135
|
obj_ = @factoryzm.point(1, 2, 3, 4)
|
136
136
|
assert_equal('Point ZM (1.0 2.0 3.0 4.0)', generator_.generate(obj_))
|
137
137
|
end
|
138
|
-
|
139
|
-
|
138
|
+
|
139
|
+
|
140
140
|
def test_point_ewkt
|
141
141
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:tag_format => :ewkt)
|
142
142
|
obj_ = @factory.point(1, 2)
|
143
143
|
assert_equal('Point (1.0 2.0)', generator_.generate(obj_))
|
144
144
|
end
|
145
|
-
|
146
|
-
|
145
|
+
|
146
|
+
|
147
147
|
def test_point_ewkt_z
|
148
148
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:tag_format => :ewkt)
|
149
149
|
obj_ = @factoryz.point(1, 2, 3)
|
150
150
|
assert_equal('Point (1.0 2.0 3.0)', generator_.generate(obj_))
|
151
151
|
end
|
152
|
-
|
153
|
-
|
152
|
+
|
153
|
+
|
154
154
|
def test_point_ewkt_m
|
155
155
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:tag_format => :ewkt)
|
156
156
|
obj_ = @factorym.point(1, 2, 3)
|
157
157
|
assert_equal('PointM (1.0 2.0 3.0)', generator_.generate(obj_))
|
158
158
|
end
|
159
|
-
|
160
|
-
|
159
|
+
|
160
|
+
|
161
161
|
def test_point_ewkt_zm
|
162
162
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:tag_format => :ewkt)
|
163
163
|
obj_ = @factoryzm.point(1, 2, 3, 4)
|
164
164
|
assert_equal('Point (1.0 2.0 3.0 4.0)', generator_.generate(obj_))
|
165
165
|
end
|
166
|
-
|
167
|
-
|
166
|
+
|
167
|
+
|
168
168
|
def test_point_ewkt_with_srid
|
169
169
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:tag_format => :ewkt, :emit_ewkt_srid => true)
|
170
170
|
obj_ = @factory.point(1, 2)
|
171
171
|
assert_equal('SRID=1000;Point (1.0 2.0)', generator_.generate(obj_))
|
172
172
|
end
|
173
|
-
|
174
|
-
|
173
|
+
|
174
|
+
|
175
175
|
def test_linestring_basic
|
176
176
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
177
177
|
p1_ = @factory.point(1, 2)
|
@@ -180,15 +180,15 @@ module RGeo
|
|
180
180
|
obj_ = @factory.line_string([p1_, p2_, p3_])
|
181
181
|
assert_equal('LineString (1.0 2.0, 2.0 2.0, 1.0 1.0)', generator_.generate(obj_))
|
182
182
|
end
|
183
|
-
|
184
|
-
|
183
|
+
|
184
|
+
|
185
185
|
def test_linestring_empty
|
186
186
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
187
187
|
obj_ = @factory.line_string([])
|
188
188
|
assert_equal('LineString EMPTY', generator_.generate(obj_))
|
189
189
|
end
|
190
|
-
|
191
|
-
|
190
|
+
|
191
|
+
|
192
192
|
def test_polygon_basic
|
193
193
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
194
194
|
p1_ = @factory.point(0, 0)
|
@@ -199,8 +199,8 @@ module RGeo
|
|
199
199
|
obj_ = @factory.polygon(ext_)
|
200
200
|
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_))
|
201
201
|
end
|
202
|
-
|
203
|
-
|
202
|
+
|
203
|
+
|
204
204
|
def test_polygon_with_hole
|
205
205
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
206
206
|
p1_ = @factory.point(0, 0)
|
@@ -215,15 +215,15 @@ module RGeo
|
|
215
215
|
obj_ = @factory.polygon(ext_, [int_])
|
216
216
|
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_))
|
217
217
|
end
|
218
|
-
|
219
|
-
|
218
|
+
|
219
|
+
|
220
220
|
def test_polygon_empty
|
221
221
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
222
222
|
obj_ = @factory.polygon(@factory.line_string([]))
|
223
223
|
assert_equal('Polygon EMPTY', generator_.generate(obj_))
|
224
224
|
end
|
225
|
-
|
226
|
-
|
225
|
+
|
226
|
+
|
227
227
|
def test_multipoint_basic
|
228
228
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
229
229
|
p1_ = @factory.point(1, 2)
|
@@ -232,15 +232,15 @@ module RGeo
|
|
232
232
|
obj_ = @factory.multi_point([p1_, p2_, p3_])
|
233
233
|
assert_equal('MultiPoint ((1.0 2.0), (2.0 2.0), (1.0 1.0))', generator_.generate(obj_))
|
234
234
|
end
|
235
|
-
|
236
|
-
|
235
|
+
|
236
|
+
|
237
237
|
def test_multipoint_empty
|
238
238
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
239
239
|
obj_ = @factory.multi_point([])
|
240
240
|
assert_equal('MultiPoint EMPTY', generator_.generate(obj_))
|
241
241
|
end
|
242
|
-
|
243
|
-
|
242
|
+
|
243
|
+
|
244
244
|
def test_multilinestring_basic
|
245
245
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
246
246
|
p1_ = @factory.point(0, 0)
|
@@ -256,15 +256,15 @@ module RGeo
|
|
256
256
|
obj_ = @factory.multi_line_string([ls1_, ls2_, ls3_])
|
257
257
|
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_))
|
258
258
|
end
|
259
|
-
|
260
|
-
|
259
|
+
|
260
|
+
|
261
261
|
def test_multilinestring_empty
|
262
262
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
263
263
|
obj_ = @factory.multi_line_string([])
|
264
264
|
assert_equal('MultiLineString EMPTY', generator_.generate(obj_))
|
265
265
|
end
|
266
|
-
|
267
|
-
|
266
|
+
|
267
|
+
|
268
268
|
def test_multipolygon_basic
|
269
269
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
270
270
|
p1_ = @factory.point(0, 0)
|
@@ -287,15 +287,15 @@ module RGeo
|
|
287
287
|
obj_ = @factory.multi_polygon([poly1_, poly2_, poly3_])
|
288
288
|
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_))
|
289
289
|
end
|
290
|
-
|
291
|
-
|
290
|
+
|
291
|
+
|
292
292
|
def test_multipolygon_empty
|
293
293
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
294
294
|
obj_ = @factory.multi_polygon([])
|
295
295
|
assert_equal('MultiPolygon EMPTY', generator_.generate(obj_))
|
296
296
|
end
|
297
|
-
|
298
|
-
|
297
|
+
|
298
|
+
|
299
299
|
def test_collection_basic
|
300
300
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
301
301
|
p1_ = @factory.point(0, 0)
|
@@ -320,8 +320,8 @@ module RGeo
|
|
320
320
|
obj_ = @factory.collection([obj1_, obj2_])
|
321
321
|
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_))
|
322
322
|
end
|
323
|
-
|
324
|
-
|
323
|
+
|
324
|
+
|
325
325
|
def test_collection_wkt12_z
|
326
326
|
generator_ = ::RGeo::WKRep::WKTGenerator.new(:tag_format => :wkt12)
|
327
327
|
p1_ = @factoryz.point(0, 0)
|
@@ -346,17 +346,17 @@ module RGeo
|
|
346
346
|
obj_ = @factoryz.collection([obj1_, obj2_])
|
347
347
|
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_))
|
348
348
|
end
|
349
|
-
|
350
|
-
|
349
|
+
|
350
|
+
|
351
351
|
def test_collection_empty
|
352
352
|
generator_ = ::RGeo::WKRep::WKTGenerator.new
|
353
353
|
obj_ = @factory.collection([])
|
354
354
|
assert_equal('GeometryCollection EMPTY', generator_.generate(obj_))
|
355
355
|
end
|
356
|
-
|
357
|
-
|
356
|
+
|
357
|
+
|
358
358
|
end
|
359
|
-
|
359
|
+
|
360
360
|
end
|
361
361
|
end
|
362
362
|
end
|