rgeo 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +11 -3
- data/Spatial_Programming_With_RGeo.rdoc +8 -8
- data/Version +1 -1
- data/ext/geos_c_impl/factory.c +20 -3
- data/ext/geos_c_impl/factory.h +2 -0
- data/ext/geos_c_impl/geometry.c +31 -19
- data/lib/rgeo/cartesian/factory.rb +32 -3
- data/lib/rgeo/cartesian/interface.rb +22 -2
- data/lib/rgeo/feature/factory.rb +1 -1
- data/lib/rgeo/feature/factory_generator.rb +1 -1
- data/lib/rgeo/feature/types.rb +3 -3
- data/lib/rgeo/geographic/factory.rb +31 -2
- data/lib/rgeo/geographic/interface.rb +68 -5
- data/lib/rgeo/geographic/proj4_projector.rb +8 -1
- data/lib/rgeo/geos.rb +1 -1
- data/lib/rgeo/geos/factory.rb +69 -4
- data/lib/rgeo/geos/impl_additions.rb +1 -1
- data/lib/rgeo/geos/interface.rb +31 -0
- data/lib/rgeo/geos/zm_factory.rb +33 -2
- data/lib/rgeo/geos/zm_impl.rb +3 -3
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +2 -2
- data/lib/rgeo/wkrep/wkb_generator.rb +1 -24
- data/lib/rgeo/wkrep/wkb_parser.rb +32 -43
- data/lib/rgeo/wkrep/wkt_generator.rb +21 -43
- data/lib/rgeo/wkrep/wkt_parser.rb +10 -41
- data/test/common/point_tests.rb +7 -1
- data/test/geos/tc_parsing_unparsing.rb +80 -0
- data/test/wkrep/tc_wkb_parser.rb +44 -37
- data/test/wkrep/tc_wkt_generator.rb +25 -25
- data/test/wkrep/tc_wkt_parser.rb +1 -3
- metadata +4 -2
@@ -95,44 +95,22 @@ module RGeo
|
|
95
95
|
@tag_format
|
96
96
|
end
|
97
97
|
|
98
|
-
# Sets the format for type tags. See WKTGenerator for details.
|
99
|
-
def tag_format=(value_)
|
100
|
-
@tag_format = value_
|
101
|
-
end
|
102
|
-
|
103
98
|
# Returns whether SRID is embedded. See WKTGenerator for details.
|
104
99
|
def emit_ewkt_srid?
|
105
100
|
@emit_ewkt_srid
|
106
101
|
end
|
107
102
|
|
108
|
-
# Sets whether SRID is embedded. Available only when the tag_format
|
109
|
-
# is <tt>:ewkt</tt>. See WKTGenerator for details.
|
110
|
-
def emit_ewkt_srid=(value_)
|
111
|
-
@emit_ewkt_srid = @type_format == :ewkt && value_
|
112
|
-
end
|
113
|
-
|
114
103
|
# Returns whether square brackets rather than parens are output.
|
115
104
|
# See WKTGenerator for details.
|
116
105
|
def square_brackets?
|
117
106
|
@square_brackets
|
118
107
|
end
|
119
108
|
|
120
|
-
# Sets whether square brackets rather than parens are output.
|
121
|
-
# See WKTGenerator for details.
|
122
|
-
def square_brackets=(value_)
|
123
|
-
@square_brackets = value_ ? true : false
|
124
|
-
end
|
125
|
-
|
126
109
|
# Returns the case for output. See WKTGenerator for details.
|
127
110
|
def convert_case
|
128
111
|
@convert_case
|
129
112
|
end
|
130
113
|
|
131
|
-
# Sets the case for output. See WKTGenerator for details.
|
132
|
-
def convert_case=(value_)
|
133
|
-
@convert_case = value_
|
134
|
-
end
|
135
|
-
|
136
114
|
|
137
115
|
# Generate and return the WKT format for the given geometry object,
|
138
116
|
# according to the current settings.
|
@@ -181,19 +159,19 @@ module RGeo
|
|
181
159
|
end
|
182
160
|
end
|
183
161
|
if type_ == Feature::Point
|
184
|
-
tag_
|
162
|
+
"#{tag_} #{_generate_point(obj_)}"
|
185
163
|
elsif type_.subtype_of?(Feature::LineString)
|
186
|
-
tag_
|
164
|
+
"#{tag_} #{_generate_line_string(obj_)}"
|
187
165
|
elsif type_ == Feature::Polygon
|
188
|
-
tag_
|
166
|
+
"#{tag_} #{_generate_polygon(obj_)}"
|
189
167
|
elsif type_ == Feature::GeometryCollection
|
190
|
-
tag_
|
168
|
+
"#{tag_} #{_generate_geometry_collection(obj_)}"
|
191
169
|
elsif type_ == Feature::MultiPoint
|
192
|
-
tag_
|
170
|
+
"#{tag_} #{_generate_multi_point(obj_)}"
|
193
171
|
elsif type_ == Feature::MultiLineString
|
194
|
-
tag_
|
172
|
+
"#{tag_} #{_generate_multi_line_string(obj_)}"
|
195
173
|
elsif type_ == Feature::MultiPolygon
|
196
|
-
tag_
|
174
|
+
"#{tag_} #{_generate_multi_polygon(obj_)}"
|
197
175
|
else
|
198
176
|
raise Error::ParseError, "Unrecognized geometry type: #{type_}"
|
199
177
|
end
|
@@ -213,56 +191,56 @@ module RGeo
|
|
213
191
|
end
|
214
192
|
|
215
193
|
|
216
|
-
def _generate_line_string(obj_
|
194
|
+
def _generate_line_string(obj_) # :nodoc:
|
217
195
|
if obj_.is_empty?
|
218
|
-
|
196
|
+
'EMPTY'
|
219
197
|
else
|
220
|
-
"#{@begin_bracket}#{obj_.points.map{ |p_| _generate_coords(p_) }.join(',')}#{@end_bracket}"
|
198
|
+
"#{@begin_bracket}#{obj_.points.map{ |p_| _generate_coords(p_) }.join(', ')}#{@end_bracket}"
|
221
199
|
end
|
222
200
|
end
|
223
201
|
|
224
202
|
|
225
|
-
def _generate_polygon(obj_
|
203
|
+
def _generate_polygon(obj_) # :nodoc:
|
226
204
|
if obj_.is_empty?
|
227
|
-
|
205
|
+
'EMPTY'
|
228
206
|
else
|
229
|
-
"#{@begin_bracket}#{([_generate_line_string(obj_.exterior_ring
|
207
|
+
"#{@begin_bracket}#{([_generate_line_string(obj_.exterior_ring)] + obj_.interior_rings.map{ |r_| _generate_line_string(r_) }).join(', ')}#{@end_bracket}"
|
230
208
|
end
|
231
209
|
end
|
232
210
|
|
233
211
|
|
234
212
|
def _generate_geometry_collection(obj_) # :nodoc:
|
235
213
|
if obj_.is_empty?
|
236
|
-
'
|
214
|
+
'EMPTY'
|
237
215
|
else
|
238
|
-
"#{@begin_bracket}#{obj_.map{ |f_| _generate_feature(f_) }.join(',')}#{@end_bracket}"
|
216
|
+
"#{@begin_bracket}#{obj_.map{ |f_| _generate_feature(f_) }.join(', ')}#{@end_bracket}"
|
239
217
|
end
|
240
218
|
end
|
241
219
|
|
242
220
|
|
243
221
|
def _generate_multi_point(obj_) # :nodoc:
|
244
222
|
if obj_.is_empty?
|
245
|
-
|
223
|
+
'EMPTY'
|
246
224
|
else
|
247
|
-
"#{@begin_bracket}#{obj_.map{ |f_| _generate_point(f_) }.join(',')}#{@end_bracket}"
|
225
|
+
"#{@begin_bracket}#{obj_.map{ |f_| _generate_point(f_) }.join(', ')}#{@end_bracket}"
|
248
226
|
end
|
249
227
|
end
|
250
228
|
|
251
229
|
|
252
230
|
def _generate_multi_line_string(obj_) # :nodoc:
|
253
231
|
if obj_.is_empty?
|
254
|
-
|
232
|
+
'EMPTY'
|
255
233
|
else
|
256
|
-
"#{@begin_bracket}#{obj_.map{ |f_| _generate_line_string(f_
|
234
|
+
"#{@begin_bracket}#{obj_.map{ |f_| _generate_line_string(f_) }.join(', ')}#{@end_bracket}"
|
257
235
|
end
|
258
236
|
end
|
259
237
|
|
260
238
|
|
261
239
|
def _generate_multi_polygon(obj_) # :nodoc:
|
262
240
|
if obj_.is_empty?
|
263
|
-
|
241
|
+
'EMPTY'
|
264
242
|
else
|
265
|
-
"#{@begin_bracket}#{obj_.map{ |f_| _generate_polygon(f_
|
243
|
+
"#{@begin_bracket}#{obj_.map{ |f_| _generate_polygon(f_) }.join(', ')}#{@end_bracket}"
|
266
244
|
end
|
267
245
|
end
|
268
246
|
|
@@ -88,7 +88,16 @@ module RGeo
|
|
88
88
|
# documentation for the options that can be passed.
|
89
89
|
|
90
90
|
def initialize(factory_generator_=nil, opts_={})
|
91
|
-
|
91
|
+
if factory_generator_.kind_of?(Feature::Factory::Instance)
|
92
|
+
@factory_generator = Feature::FactoryGenerator.single(factory_generator_)
|
93
|
+
@exact_factory = factory_generator_
|
94
|
+
elsif factory_generator_.respond_to?(:call)
|
95
|
+
@factory_generator = factory_generator_
|
96
|
+
@exact_factory = nil
|
97
|
+
else
|
98
|
+
@factory_generator = Cartesian.method(:preferred_factory)
|
99
|
+
@exact_factory = nil
|
100
|
+
end
|
92
101
|
@support_ewkt = opts_[:support_ewkt] ? true : false
|
93
102
|
@support_wkt12 = opts_[:support_wkt12] ? true : false
|
94
103
|
@strict_wkt11 = @support_ewkt || @support_wkt12 ? false : opts_[:strict_wkt11] ? true : false
|
@@ -108,70 +117,30 @@ module RGeo
|
|
108
117
|
@exact_factory
|
109
118
|
end
|
110
119
|
|
111
|
-
# Sets the factory_generator. See WKTParser for details.
|
112
|
-
def factory_generator=(value_)
|
113
|
-
if value_.kind_of?(Feature::Factory::Instance)
|
114
|
-
@factory_generator = Feature::FactoryGenerator.single(value_)
|
115
|
-
@exact_factory = value_
|
116
|
-
elsif value_.respond_to?(:call)
|
117
|
-
@factory_generator = value_
|
118
|
-
@exact_factory = nil
|
119
|
-
else
|
120
|
-
@factory_generator = Cartesian.method(:preferred_factory)
|
121
|
-
@exact_factory = nil
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
# Sets the factory_generator to the given block.
|
126
|
-
# See WKTParser for details.
|
127
|
-
def to_generate_factory(&block_)
|
128
|
-
self.factory_generator = block_
|
129
|
-
end
|
130
|
-
|
131
120
|
# Returns true if this parser supports EWKT.
|
132
121
|
# See WKTParser for details.
|
133
122
|
def support_ewkt?
|
134
123
|
@support_ewkt
|
135
124
|
end
|
136
125
|
|
137
|
-
# Sets the the support_ewkt flag. See WKTParser for details.
|
138
|
-
def support_ewkt=(value_)
|
139
|
-
@support_ewkt = value_ ? true : false
|
140
|
-
end
|
141
|
-
|
142
126
|
# Returns true if this parser supports SFS 1.2 extensions.
|
143
127
|
# See WKTParser for details.
|
144
128
|
def support_wkt12?
|
145
129
|
@support_wkt12
|
146
130
|
end
|
147
131
|
|
148
|
-
# Sets the the support_wkt12 flag. See WKTParser for details.
|
149
|
-
def support_wkt12=(value_)
|
150
|
-
@support_wkt12 = value_ ? true : false
|
151
|
-
end
|
152
|
-
|
153
132
|
# Returns true if this parser strictly adheres to WKT 1.1.
|
154
133
|
# See WKTParser for details.
|
155
134
|
def strict_wkt11?
|
156
135
|
@strict_wkt11
|
157
136
|
end
|
158
137
|
|
159
|
-
# Sets the the strict_wkt11 flag. See WKTParser for details.
|
160
|
-
def strict_wkt11=(value_)
|
161
|
-
@strict_wkt11 = value_ ? true : false
|
162
|
-
end
|
163
|
-
|
164
138
|
# Returns true if this parser ignores extra tokens.
|
165
139
|
# See WKTParser for details.
|
166
140
|
def ignore_extra_tokens?
|
167
141
|
@ignore_extra_tokens
|
168
142
|
end
|
169
143
|
|
170
|
-
# Sets the the ignore_extra_tokens flag. See WKTParser for details.
|
171
|
-
def ignore_extra_tokens=(value_)
|
172
|
-
@ignore_extra_tokens = value_ ? true : false
|
173
|
-
end
|
174
|
-
|
175
144
|
|
176
145
|
# Parse the given string, and return a geometry object.
|
177
146
|
|
data/test/common/point_tests.rb
CHANGED
@@ -62,7 +62,7 @@ module RGeo
|
|
62
62
|
|
63
63
|
|
64
64
|
def test_wkt_creation
|
65
|
-
point1_ = @factory.parse_wkt('
|
65
|
+
point1_ = @factory.parse_wkt('Point (21 -22)')
|
66
66
|
assert_equal(21, point1_.x)
|
67
67
|
assert_equal(-22, point1_.y)
|
68
68
|
end
|
@@ -106,6 +106,12 @@ module RGeo
|
|
106
106
|
end
|
107
107
|
|
108
108
|
|
109
|
+
def test_as_text
|
110
|
+
point_ = @factory.point(11, 12)
|
111
|
+
assert_equal('POINT (11.0 12.0)', point_.as_text)
|
112
|
+
end
|
113
|
+
|
114
|
+
|
109
115
|
def test_as_text_wkt_round_trip
|
110
116
|
point1_ = @factory.point(11, 12)
|
111
117
|
text_ = point1_.as_text
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the GEOS point implementation
|
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 Geos # :nodoc:
|
44
|
+
|
45
|
+
class TestParsingUnparsing < ::Test::Unit::TestCase # :nodoc:
|
46
|
+
|
47
|
+
|
48
|
+
def test_wkt_generator_default_floating_point
|
49
|
+
# Bug report GH-4
|
50
|
+
factory_ = ::RGeo::Geos.factory
|
51
|
+
point_ = factory_.point(111.99, -40.37)
|
52
|
+
assert_equal('POINT (111.99 -40.37)', point_.as_text)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def test_wkt_generator_downcase
|
57
|
+
factory_ = ::RGeo::Geos.factory(:wkt_generator => {:convert_case => :lower})
|
58
|
+
point_ = factory_.point(1, 1)
|
59
|
+
assert_equal('point (1.0 1.0)', point_.as_text)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def test_wkt_generator_geos
|
64
|
+
factory_ = ::RGeo::Geos.factory(:wkt_generator => :geos)
|
65
|
+
point_ = factory_.point(1, 1)
|
66
|
+
assert_equal('POINT (1.0000000000000000 1.0000000000000000)', point_.as_text)
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def test_wkt_parser_default_with_non_geosable_input
|
71
|
+
factory_ = ::RGeo::Geos.factory
|
72
|
+
assert_not_nil(factory_.parse_wkt('Point (1 1)'))
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end if ::RGeo::Geos.supported?
|
data/test/wkrep/tc_wkb_parser.rb
CHANGED
@@ -45,9 +45,18 @@ module RGeo
|
|
45
45
|
class TestWKBParser < ::Test::Unit::TestCase # :nodoc:
|
46
46
|
|
47
47
|
|
48
|
-
def
|
48
|
+
def test_point_2d_xdr_hex
|
49
49
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
50
|
-
obj_ = parser_.
|
50
|
+
obj_ = parser_.parse('00000000013ff00000000000004000000000000000')
|
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
|
+
|
57
|
+
def test_point_2d_xdr_binary
|
58
|
+
parser_ = ::RGeo::WKRep::WKBParser.new
|
59
|
+
obj_ = parser_.parse(['00000000013ff00000000000004000000000000000'].pack('H*'))
|
51
60
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
52
61
|
assert_equal(1, obj_.x)
|
53
62
|
assert_equal(2, obj_.y)
|
@@ -56,7 +65,7 @@ module RGeo
|
|
56
65
|
|
57
66
|
def test_point_2d_ndr
|
58
67
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
59
|
-
obj_ = parser_.
|
68
|
+
obj_ = parser_.parse('0101000000000000000000f03f0000000000000040')
|
60
69
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
61
70
|
assert_equal(1, obj_.x)
|
62
71
|
assert_equal(2, obj_.y)
|
@@ -66,7 +75,7 @@ module RGeo
|
|
66
75
|
def test_point_with_ewkb_z
|
67
76
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
68
77
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
69
|
-
obj_ = parser_.
|
78
|
+
obj_ = parser_.parse('00800000013ff000000000000040000000000000004008000000000000')
|
70
79
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
71
80
|
assert_equal(3, obj_.z)
|
72
81
|
assert_nil(obj_.m)
|
@@ -76,7 +85,7 @@ module RGeo
|
|
76
85
|
def test_point_with_ewkb_m
|
77
86
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_m_coordinate => true)
|
78
87
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
79
|
-
obj_ = parser_.
|
88
|
+
obj_ = parser_.parse('00400000013ff000000000000040000000000000004008000000000000')
|
80
89
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
81
90
|
assert_equal(3, obj_.m)
|
82
91
|
assert_nil(obj_.z)
|
@@ -86,7 +95,7 @@ module RGeo
|
|
86
95
|
def test_point_with_ewkb_zm
|
87
96
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :has_m_coordinate => true)
|
88
97
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
89
|
-
obj_ = parser_.
|
98
|
+
obj_ = parser_.parse('00c00000013ff0000000000000400000000000000040080000000000004010000000000000')
|
90
99
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
91
100
|
assert_equal(3, obj_.z)
|
92
101
|
assert_equal(4, obj_.m)
|
@@ -96,7 +105,7 @@ module RGeo
|
|
96
105
|
def test_point_with_wkb12_z
|
97
106
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
98
107
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
99
|
-
obj_ = parser_.
|
108
|
+
obj_ = parser_.parse('00000003e93ff000000000000040000000000000004008000000000000')
|
100
109
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
101
110
|
assert_equal(3, obj_.z)
|
102
111
|
assert_nil(obj_.m)
|
@@ -106,7 +115,7 @@ module RGeo
|
|
106
115
|
def test_point_with_wkb12_m
|
107
116
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_m_coordinate => true)
|
108
117
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
109
|
-
obj_ = parser_.
|
118
|
+
obj_ = parser_.parse('00000007d13ff000000000000040000000000000004008000000000000')
|
110
119
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
111
120
|
assert_equal(3, obj_.m)
|
112
121
|
assert_nil(obj_.z)
|
@@ -116,7 +125,7 @@ module RGeo
|
|
116
125
|
def test_point_with_wkb12_zm
|
117
126
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :has_m_coordinate => true)
|
118
127
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
119
|
-
obj_ = parser_.
|
128
|
+
obj_ = parser_.parse('0000000bb93ff0000000000000400000000000000040080000000000004010000000000000')
|
120
129
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
121
130
|
assert_equal(3, obj_.z)
|
122
131
|
assert_equal(4, obj_.m)
|
@@ -127,7 +136,7 @@ module RGeo
|
|
127
136
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
128
137
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_)
|
129
138
|
assert_raise(::RGeo::Error::ParseError) do
|
130
|
-
obj_ = parser_.
|
139
|
+
obj_ = parser_.parse('00000003e93ff000000000000040000000000000004008000000000000')
|
131
140
|
end
|
132
141
|
end
|
133
142
|
|
@@ -136,18 +145,17 @@ module RGeo
|
|
136
145
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
137
146
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
138
147
|
assert_raise(::RGeo::Error::ParseError) do
|
139
|
-
obj_ = parser_.
|
148
|
+
obj_ = parser_.parse('00000003e93ff00000000000004000000000000000')
|
140
149
|
end
|
141
150
|
end
|
142
151
|
|
143
152
|
|
144
153
|
def test_point_with_ewkb_z_and_srid
|
145
|
-
|
146
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
147
|
-
parser_.to_generate_factory do |config_|
|
154
|
+
factory_generator_ = ::Proc.new do |config_|
|
148
155
|
::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :srid => config_[:srid])
|
149
156
|
end
|
150
|
-
|
157
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_generator_, :support_ewkb => true)
|
158
|
+
obj_ = parser_.parse('00a0000001000003e83ff000000000000040000000000000004008000000000000')
|
151
159
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
152
160
|
assert_equal(3, obj_.z)
|
153
161
|
assert_nil(obj_.m)
|
@@ -157,7 +165,7 @@ module RGeo
|
|
157
165
|
|
158
166
|
def test_linestring_basic
|
159
167
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
160
|
-
obj_ = parser_.
|
168
|
+
obj_ = parser_.parse('0000000002000000033ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000')
|
161
169
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
162
170
|
assert_equal(3, obj_.num_points)
|
163
171
|
assert_equal(1, obj_.point_n(0).x)
|
@@ -168,7 +176,7 @@ module RGeo
|
|
168
176
|
def test_linestring_with_ewkb_z
|
169
177
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
170
178
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
171
|
-
obj_ = parser_.
|
179
|
+
obj_ = parser_.parse('0080000002000000023ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000')
|
172
180
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
173
181
|
assert_equal(2, obj_.num_points)
|
174
182
|
assert_equal(1, obj_.point_n(0).x)
|
@@ -177,12 +185,11 @@ module RGeo
|
|
177
185
|
|
178
186
|
|
179
187
|
def test_linestring_with_ewkb_z_and_srid
|
180
|
-
|
181
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
182
|
-
parser_.to_generate_factory do |config_|
|
188
|
+
factory_generator_ = ::Proc.new do |config_|
|
183
189
|
::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true, :srid => config_[:srid])
|
184
190
|
end
|
185
|
-
|
191
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_generator_, :support_ewkb => true)
|
192
|
+
obj_ = parser_.parse('00a0000002000003e8000000023ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000')
|
186
193
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
187
194
|
assert_equal(2, obj_.num_points)
|
188
195
|
assert_equal(1, obj_.point_n(0).x)
|
@@ -194,7 +201,7 @@ module RGeo
|
|
194
201
|
def test_linestring_with_wkb12_z
|
195
202
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
196
203
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
197
|
-
obj_ = parser_.
|
204
|
+
obj_ = parser_.parse('00000003ea000000023ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000')
|
198
205
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
199
206
|
assert_equal(2, obj_.num_points)
|
200
207
|
assert_equal(1, obj_.point_n(0).x)
|
@@ -204,7 +211,7 @@ module RGeo
|
|
204
211
|
|
205
212
|
def test_linestring_empty
|
206
213
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
207
|
-
obj_ = parser_.
|
214
|
+
obj_ = parser_.parse('000000000200000000')
|
208
215
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
209
216
|
assert_equal(0, obj_.num_points)
|
210
217
|
end
|
@@ -212,7 +219,7 @@ module RGeo
|
|
212
219
|
|
213
220
|
def test_polygon_basic
|
214
221
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
215
|
-
obj_ = parser_.
|
222
|
+
obj_ = parser_.parse('000000000300000001000000043ff0000000000000400000000000000040080000000000004010000000000000401800000000000040140000000000003ff00000000000004000000000000000')
|
216
223
|
assert_equal(::RGeo::Feature::Polygon, obj_.geometry_type)
|
217
224
|
assert_equal(4, obj_.exterior_ring.num_points)
|
218
225
|
assert_equal(1, obj_.exterior_ring.point_n(0).x)
|
@@ -222,7 +229,7 @@ module RGeo
|
|
222
229
|
|
223
230
|
def test_polygon_empty
|
224
231
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
225
|
-
obj_ = parser_.
|
232
|
+
obj_ = parser_.parse('000000000300000000')
|
226
233
|
assert_equal(::RGeo::Feature::Polygon, obj_.geometry_type)
|
227
234
|
assert_equal(0, obj_.exterior_ring.num_points)
|
228
235
|
end
|
@@ -230,7 +237,7 @@ module RGeo
|
|
230
237
|
|
231
238
|
def test_multipoint_basic
|
232
239
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
233
|
-
obj_ = parser_.
|
240
|
+
obj_ = parser_.parse('00000000040000000200000000013ff00000000000004000000000000000000000000140080000000000004010000000000000')
|
234
241
|
assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
|
235
242
|
assert_equal(2, obj_.num_geometries)
|
236
243
|
assert_equal(1, obj_[0].x)
|
@@ -240,7 +247,7 @@ module RGeo
|
|
240
247
|
|
241
248
|
def test_multipoint_mixed_byte_order
|
242
249
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
243
|
-
obj_ = parser_.
|
250
|
+
obj_ = parser_.parse('0000000004000000020101000000000000000000f03f0000000000000040000000000140080000000000004010000000000000')
|
244
251
|
assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
|
245
252
|
assert_equal(2, obj_.num_geometries)
|
246
253
|
assert_equal(1, obj_[0].x)
|
@@ -251,7 +258,7 @@ module RGeo
|
|
251
258
|
def test_multipoint_with_ewkb_z
|
252
259
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
253
260
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
254
|
-
obj_ = parser_.
|
261
|
+
obj_ = parser_.parse('00800000040000000200800000013ff0000000000000400000000000000040140000000000000080000001400800000000000040100000000000004018000000000000')
|
255
262
|
assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
|
256
263
|
assert_equal(2, obj_.num_geometries)
|
257
264
|
assert_equal(1, obj_[0].x)
|
@@ -266,14 +273,14 @@ module RGeo
|
|
266
273
|
factory_ = ::RGeo::Cartesian.preferred_factory(:has_z_coordinate => true)
|
267
274
|
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
268
275
|
assert_raise(::RGeo::Error::ParseError) do
|
269
|
-
obj_ = parser_.
|
276
|
+
obj_ = parser_.parse('00800000040000000200800000013ff000000000000040000000000000004014000000000000000000000140080000000000004010000000000000')
|
270
277
|
end
|
271
278
|
end
|
272
279
|
|
273
280
|
|
274
281
|
def test_multipoint_empty
|
275
282
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
276
|
-
obj_ = parser_.
|
283
|
+
obj_ = parser_.parse('000000000400000000')
|
277
284
|
assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
|
278
285
|
assert_equal(0, obj_.num_geometries)
|
279
286
|
end
|
@@ -281,7 +288,7 @@ module RGeo
|
|
281
288
|
|
282
289
|
def test_multilinestring_basic
|
283
290
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
284
|
-
obj_ = parser_.
|
291
|
+
obj_ = parser_.parse('0000000005000000020000000002000000033ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000000000000200000002bff0000000000000c000000000000000c008000000000000c010000000000000')
|
285
292
|
assert_equal(::RGeo::Feature::MultiLineString, obj_.geometry_type)
|
286
293
|
assert_equal(2, obj_.num_geometries)
|
287
294
|
assert_equal(1, obj_[0].point_n(0).x)
|
@@ -292,14 +299,14 @@ module RGeo
|
|
292
299
|
def test_multilinestring_wrong_element_type
|
293
300
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
294
301
|
assert_raise(::RGeo::Error::ParseError) do
|
295
|
-
obj_ = parser_.
|
302
|
+
obj_ = parser_.parse('0000000005000000020000000002000000033ff00000000000004000000000000000400800000000000040100000000000004014000000000000401800000000000000000000013ff00000000000004000000000000000')
|
296
303
|
end
|
297
304
|
end
|
298
305
|
|
299
306
|
|
300
307
|
def test_multilinestring_empty
|
301
308
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
302
|
-
obj_ = parser_.
|
309
|
+
obj_ = parser_.parse('000000000500000000')
|
303
310
|
assert_equal(::RGeo::Feature::MultiLineString, obj_.geometry_type)
|
304
311
|
assert_equal(0, obj_.num_geometries)
|
305
312
|
end
|
@@ -307,7 +314,7 @@ module RGeo
|
|
307
314
|
|
308
315
|
def test_multipolygon_basic
|
309
316
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
310
|
-
obj_ = parser_.
|
317
|
+
obj_ = parser_.parse('000000000600000002000000000300000001000000043ff0000000000000400000000000000040080000000000004010000000000000401800000000000040140000000000003ff00000000000004000000000000000000000000300000000')
|
311
318
|
assert_equal(::RGeo::Feature::MultiPolygon, obj_.geometry_type)
|
312
319
|
assert_equal(2, obj_.num_geometries)
|
313
320
|
assert_equal(4, obj_[0].exterior_ring.num_points)
|
@@ -319,7 +326,7 @@ module RGeo
|
|
319
326
|
|
320
327
|
def test_multipolygon_empty
|
321
328
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
322
|
-
obj_ = parser_.
|
329
|
+
obj_ = parser_.parse('000000000600000000')
|
323
330
|
assert_equal(::RGeo::Feature::MultiPolygon, obj_.geometry_type)
|
324
331
|
assert_equal(0, obj_.num_geometries)
|
325
332
|
end
|
@@ -327,7 +334,7 @@ module RGeo
|
|
327
334
|
|
328
335
|
def test_collection_basic
|
329
336
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
330
|
-
obj_ = parser_.
|
337
|
+
obj_ = parser_.parse('0000000007000000020000000002000000033ff0000000000000400000000000000040080000000000004010000000000000401400000000000040180000000000000000000001bff0000000000000c000000000000000')
|
331
338
|
assert_equal(::RGeo::Feature::GeometryCollection, obj_.geometry_type)
|
332
339
|
assert_equal(2, obj_.num_geometries)
|
333
340
|
assert_equal(::RGeo::Feature::LineString, obj_[0].geometry_type)
|
@@ -340,7 +347,7 @@ module RGeo
|
|
340
347
|
|
341
348
|
def test_collection_empty
|
342
349
|
parser_ = ::RGeo::WKRep::WKBParser.new
|
343
|
-
obj_ = parser_.
|
350
|
+
obj_ = parser_.parse('000000000700000000')
|
344
351
|
assert_equal(::RGeo::Feature::GeometryCollection, obj_.geometry_type)
|
345
352
|
assert_equal(0, obj_.num_geometries)
|
346
353
|
end
|