rgeo 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +11 -0
- data/Version +1 -1
- data/ext/geos_c_impl/factory.c +134 -3
- data/ext/geos_c_impl/factory.h +5 -0
- data/ext/geos_c_impl/geometry_collection.c +18 -12
- data/lib/rgeo/cartesian/factory.rb +40 -33
- data/lib/rgeo/cartesian/interface.rb +6 -0
- data/lib/rgeo/coord_sys/cs/entities.rb +4 -4
- data/lib/rgeo/coord_sys/proj4.rb +5 -5
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +5 -3
- data/lib/rgeo/feature/geometry.rb +8 -1
- data/lib/rgeo/geographic/factory.rb +124 -1
- data/lib/rgeo/geographic/interface.rb +6 -0
- data/lib/rgeo/geographic/proj4_projector.rb +6 -0
- data/lib/rgeo/geographic/simple_mercator_projector.rb +6 -0
- data/lib/rgeo/geos/factory.rb +119 -18
- data/lib/rgeo/geos/ffi_classes.rb +10 -5
- data/lib/rgeo/geos/ffi_factory.rb +106 -5
- data/lib/rgeo/geos/interface.rb +0 -2
- data/lib/rgeo/geos/zm_factory.rb +106 -2
- data/lib/rgeo/geos/zm_impl.rb +3 -2
- data/lib/rgeo/impl_helper.rb +1 -0
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +1 -1
- data/lib/rgeo/impl_helper/utils.rb +67 -0
- data/lib/rgeo/wkrep/wkb_generator.rb +4 -4
- data/lib/rgeo/wkrep/wkb_parser.rb +4 -4
- data/lib/rgeo/wkrep/wkt_generator.rb +4 -4
- data/lib/rgeo/wkrep/wkt_parser.rb +5 -5
- data/test/common/factory_tests.rb +117 -0
- data/test/common/geometry_collection_tests.rb +25 -0
- data/test/coord_sys/tc_active_record_table.rb +4 -5
- data/test/coord_sys/tc_ogc_cs.rb +0 -6
- data/test/coord_sys/tc_proj4.rb +4 -6
- data/test/geos_capi/tc_factory.rb +5 -33
- data/test/geos_capi/tc_zmfactory.rb +6 -0
- data/test/geos_ffi/tc_factory.rb +5 -33
- data/test/geos_ffi/tc_zmfactory.rb +6 -0
- data/test/projected_geographic/tc_factory.rb +63 -0
- data/test/simple_cartesian/tc_factory.rb +66 -0
- data/test/simple_mercator/tc_factory.rb +63 -0
- data/test/spherical_geographic/tc_factory.rb +66 -0
- data/test/tc_types.rb +4 -0
- metadata +12 -2
@@ -56,8 +56,8 @@ module RGeo
|
|
56
56
|
# Main flags
|
57
57
|
@uses_lenient_multi_polygon_assertions = opts_[:lenient_multi_polygon_assertions] ||
|
58
58
|
opts_[:uses_lenient_multi_polygon_assertions]
|
59
|
-
@has_z = opts_[:has_z_coordinate]
|
60
|
-
@has_m = opts_[:has_m_coordinate]
|
59
|
+
@has_z = opts_[:has_z_coordinate] ? true : false
|
60
|
+
@has_m = opts_[:has_m_coordinate] ? true : false
|
61
61
|
if @has_z && @has_m
|
62
62
|
raise Error::UnsupportedOperation, "GEOS cannot support both Z and M coordinates at the same time."
|
63
63
|
end
|
@@ -132,7 +132,7 @@ module RGeo
|
|
132
132
|
wkb_parser_ = opts_[:wkb_parser]
|
133
133
|
case wkb_parser_
|
134
134
|
when :geos
|
135
|
-
@wkb_reader = ::Geos::
|
135
|
+
@wkb_reader = ::Geos::WkbReader.new
|
136
136
|
@wkb_parser = nil
|
137
137
|
when ::Hash
|
138
138
|
@wkb_parser = WKRep::WKBParser.new(self, wkb_parser_)
|
@@ -159,6 +159,107 @@ module RGeo
|
|
159
159
|
alias_method :==, :eql?
|
160
160
|
|
161
161
|
|
162
|
+
# Marshal support
|
163
|
+
|
164
|
+
def marshal_dump # :nodoc:
|
165
|
+
hash_ = {
|
166
|
+
'hasz' => @has_z,
|
167
|
+
'hasm' => @has_m,
|
168
|
+
'srid' => @srid,
|
169
|
+
'bufr' => @buffer_resolution,
|
170
|
+
'wktg' => @wkt_generator._properties,
|
171
|
+
'wkbg' => @wkb_generator._properties,
|
172
|
+
'wktp' => @wkt_parser._properties,
|
173
|
+
'wkbp' => @wkb_parser._properties,
|
174
|
+
'lmpa' => @uses_lenient_multi_polygon_assertions,
|
175
|
+
'apre' => @_auto_prepare,
|
176
|
+
}
|
177
|
+
hash_['proj4'] = @proj4.marshal_dump if @proj4
|
178
|
+
hash_['cs'] = @coord_sys.to_wkt if @coord_sys
|
179
|
+
hash_
|
180
|
+
end
|
181
|
+
|
182
|
+
def marshal_load(data_) # :nodoc:
|
183
|
+
if CoordSys::Proj4.supported? && (proj4_data_ = data_['proj4'])
|
184
|
+
proj4_ = CoordSys::Proj4.allocate
|
185
|
+
proj4_.marshal_load(proj4_data_)
|
186
|
+
else
|
187
|
+
proj4_ = nil
|
188
|
+
end
|
189
|
+
if (coord_sys_data_ = data_['cs'])
|
190
|
+
coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_)
|
191
|
+
else
|
192
|
+
coord_sys_ = nil
|
193
|
+
end
|
194
|
+
initialize(
|
195
|
+
:has_z_coordinate => data_['hasz'],
|
196
|
+
:has_m_coordinate => data_['hasm'],
|
197
|
+
:srid => data_['srid'],
|
198
|
+
:buffer_resolution => data_['bufr'],
|
199
|
+
:wkt_generator => ImplHelper::Utils.symbolize_hash(data_['wktg']),
|
200
|
+
:wkb_generator => ImplHelper::Utils.symbolize_hash(data_['wkbg']),
|
201
|
+
:wkt_parser => ImplHelper::Utils.symbolize_hash(data_['wktp']),
|
202
|
+
:wkb_parser => ImplHelper::Utils.symbolize_hash(data_['wkbp']),
|
203
|
+
:uses_lenient_multi_polygon_assertions => data_['lmpa'],
|
204
|
+
:auto_prepare => (data_['apre'] ? :simple : :disabled),
|
205
|
+
:proj4 => proj4_,
|
206
|
+
:coord_sys => coord_sys_
|
207
|
+
)
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
# Psych support
|
212
|
+
|
213
|
+
def encode_with(coder_) # :nodoc:
|
214
|
+
coder_['has_z_coordinate'] = @has_z
|
215
|
+
coder_['has_m_coordinate'] = @has_m
|
216
|
+
coder_['srid'] = @srid
|
217
|
+
coder_['buffer_resolution'] = @buffer_resolution
|
218
|
+
coder_['lenient_multi_polygon_assertions'] = @uses_lenient_multi_polygon_assertions
|
219
|
+
coder_['wkt_generator'] = @wkt_generator._properties
|
220
|
+
coder_['wkb_generator'] = @wkb_generator._properties
|
221
|
+
coder_['wkt_parser'] = @wkt_parser._properties
|
222
|
+
coder_['wkb_parser'] = @wkb_parser._properties
|
223
|
+
coder_['auto_prepare'] = @_auto_prepare ? 'simple' : 'disabled'
|
224
|
+
if @proj4
|
225
|
+
str_ = @proj4.original_str || @proj4.canonical_str
|
226
|
+
coder_['proj4'] = @proj4.radians? ? {'proj4' => str_, 'radians' => true} : str_
|
227
|
+
end
|
228
|
+
coder_['coord_sys'] = @coord_sys.to_wkt if @coord_sys
|
229
|
+
end
|
230
|
+
|
231
|
+
def init_with(coder_) # :nodoc:
|
232
|
+
if (proj4_data_ = coder_['proj4'])
|
233
|
+
if proj4_data_.is_a?(::Hash)
|
234
|
+
proj4_ = CoordSys::Proj4.create(proj4_data_['proj4'], :radians => proj4_data_['radians'])
|
235
|
+
else
|
236
|
+
proj4_ = CoordSys::Proj4.create(proj4_data_.to_s)
|
237
|
+
end
|
238
|
+
else
|
239
|
+
proj4_ = nil
|
240
|
+
end
|
241
|
+
if (coord_sys_data_ = coder_['cs'])
|
242
|
+
coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_.to_s)
|
243
|
+
else
|
244
|
+
coord_sys_ = nil
|
245
|
+
end
|
246
|
+
initialize(
|
247
|
+
:has_z_coordinate => coder_['has_z_coordinate'],
|
248
|
+
:has_m_coordinate => coder_['has_m_coordinate'],
|
249
|
+
:srid => coder_['srid'],
|
250
|
+
:buffer_resolution => coder_['buffer_resolution'],
|
251
|
+
:wkt_generator => ImplHelper::Utils.symbolize_hash(coder_['wkt_generator']),
|
252
|
+
:wkb_generator => ImplHelper::Utils.symbolize_hash(coder_['wkb_generator']),
|
253
|
+
:wkt_parser => ImplHelper::Utils.symbolize_hash(coder_['wkt_parser']),
|
254
|
+
:wkb_parser => ImplHelper::Utils.symbolize_hash(coder_['wkb_parser']),
|
255
|
+
:auto_prepare => coder_['auto_prepare'] == 'disabled' ? :disabled : :simple,
|
256
|
+
:uses_lenient_multi_polygon_assertions => coder_['lenient_multi_polygon_assertions'],
|
257
|
+
:proj4 => proj4_,
|
258
|
+
:coord_sys => coord_sys_
|
259
|
+
)
|
260
|
+
end
|
261
|
+
|
262
|
+
|
162
263
|
# Returns the SRID of geometries created by this factory.
|
163
264
|
|
164
265
|
def srid
|
@@ -207,7 +308,7 @@ module RGeo
|
|
207
308
|
|
208
309
|
def parse_wkt(str_)
|
209
310
|
if @wkt_reader
|
210
|
-
@wkt_reader.read(str_)
|
311
|
+
wrap_fg_geom(@wkt_reader.read(str_))
|
211
312
|
else
|
212
313
|
@wkt_parser.parse(str_)
|
213
314
|
end
|
@@ -218,7 +319,7 @@ module RGeo
|
|
218
319
|
|
219
320
|
def parse_wkb(str_)
|
220
321
|
if @wkb_reader
|
221
|
-
@wkb_reader.read(str_)
|
322
|
+
wrap_fg_geom(@wkb_reader.read(str_))
|
222
323
|
else
|
223
324
|
@wkb_parser.parse(str_)
|
224
325
|
end
|
data/lib/rgeo/geos/interface.rb
CHANGED
@@ -195,8 +195,6 @@ module RGeo
|
|
195
195
|
# operation that would benefit from it is called. The latter
|
196
196
|
# never automatically generates a prepared geometry (unless you
|
197
197
|
# generate one explicitly using the <tt>prepare!</tt> method).
|
198
|
-
# Currently, prepared geometries are supported under CAPI but
|
199
|
-
# not FFI.
|
200
198
|
|
201
199
|
def factory(opts_={})
|
202
200
|
if supported?
|
data/lib/rgeo/geos/zm_factory.rb
CHANGED
@@ -74,8 +74,9 @@ module RGeo
|
|
74
74
|
end
|
75
75
|
srid_ ||= coord_sys_.authority_code if coord_sys_
|
76
76
|
config_ = {
|
77
|
-
:
|
78
|
-
|
77
|
+
:uses_lenient_multi_polygon_assertions => opts_[:lenient_multi_polygon_assertions] ||
|
78
|
+
opts_[:uses_lenient_multi_polygon_assertions],
|
79
|
+
:buffer_resolution => opts_[:buffer_resolution], :auto_prepare => opts_[:auto_prepare],
|
79
80
|
:wkt_generator => opts_[:wkt_generator], :wkt_parser => opts_[:wkt_parser],
|
80
81
|
:wkb_generator => opts_[:wkb_generator], :wkb_parser => opts_[:wkb_parser],
|
81
82
|
:srid => srid_.to_i, :proj4 => proj4_, :coord_sys => coord_sys_,
|
@@ -120,6 +121,109 @@ module RGeo
|
|
120
121
|
end
|
121
122
|
|
122
123
|
|
124
|
+
# Marshal support
|
125
|
+
|
126
|
+
def marshal_dump # :nodoc:
|
127
|
+
hash_ = {
|
128
|
+
'srid' => @zfactory.srid,
|
129
|
+
'bufr' => @zfactory.buffer_resolution,
|
130
|
+
'wktg' => @wkt_generator._properties,
|
131
|
+
'wkbg' => @wkb_generator._properties,
|
132
|
+
'wktp' => @wkt_parser._properties,
|
133
|
+
'wkbp' => @wkb_parser._properties,
|
134
|
+
'lmpa' => @zfactory.lenient_multi_polygon_assertions?,
|
135
|
+
'apre' => @zfactory.property(:auto_prepare) == :simple,
|
136
|
+
'nffi' => @zfactory.is_a?(FFIFactory),
|
137
|
+
}
|
138
|
+
proj4_ = @zfactory.proj4
|
139
|
+
coord_sys_ = @zfactory.coord_sys
|
140
|
+
hash_['proj4'] = proj4_.marshal_dump if proj4_
|
141
|
+
hash_['cs'] = coord_sys_.to_wkt if coord_sys_
|
142
|
+
hash_
|
143
|
+
end
|
144
|
+
|
145
|
+
def marshal_load(data_) # :nodoc:
|
146
|
+
if CoordSys::Proj4.supported? && (proj4_data_ = data_['proj4'])
|
147
|
+
proj4_ = CoordSys::Proj4.allocate
|
148
|
+
proj4_.marshal_load(proj4_data_)
|
149
|
+
else
|
150
|
+
proj4_ = nil
|
151
|
+
end
|
152
|
+
if (coord_sys_data_ = data_['cs'])
|
153
|
+
coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_)
|
154
|
+
else
|
155
|
+
coord_sys_ = nil
|
156
|
+
end
|
157
|
+
initialize(
|
158
|
+
:native_interface => (data_['nffi'] ? :ffi : :capi),
|
159
|
+
:has_z_coordinate => data_['hasz'],
|
160
|
+
:has_m_coordinate => data_['hasm'],
|
161
|
+
:srid => data_['srid'],
|
162
|
+
:buffer_resolution => data_['bufr'],
|
163
|
+
:wkt_generator => ImplHelper::Utils.symbolize_hash(data_['wktg']),
|
164
|
+
:wkb_generator => ImplHelper::Utils.symbolize_hash(data_['wkbg']),
|
165
|
+
:wkt_parser => ImplHelper::Utils.symbolize_hash(data_['wktp']),
|
166
|
+
:wkb_parser => ImplHelper::Utils.symbolize_hash(data_['wkbp']),
|
167
|
+
:uses_lenient_multi_polygon_assertions => data_['lmpa'],
|
168
|
+
:auto_prepare => (data_['apre'] ? :simple : :disabled),
|
169
|
+
:proj4 => proj4_,
|
170
|
+
:coord_sys => coord_sys_
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
# Psych support
|
176
|
+
|
177
|
+
def encode_with(coder_) # :nodoc:
|
178
|
+
coder_['srid'] = @zfactory.srid
|
179
|
+
coder_['buffer_resolution'] = @zfactory.buffer_resolution
|
180
|
+
coder_['lenient_multi_polygon_assertions'] = @zfactory.lenient_multi_polygon_assertions?
|
181
|
+
coder_['wkt_generator'] = @wkt_generator._properties
|
182
|
+
coder_['wkb_generator'] = @wkb_generator._properties
|
183
|
+
coder_['wkt_parser'] = @wkt_parser._properties
|
184
|
+
coder_['wkb_parser'] = @wkb_parser._properties
|
185
|
+
coder_['auto_prepare'] = @zfactory.property(:auto_prepare).to_s
|
186
|
+
coder_['native_interface'] = @zfactory.is_a?(FFIFactory) ? 'ffi' : 'capi'
|
187
|
+
if @proj4
|
188
|
+
str_ = @proj4.original_str || @proj4.canonical_str
|
189
|
+
coder_['proj4'] = @proj4.radians? ? {'proj4' => str_, 'radians' => true} : str_
|
190
|
+
end
|
191
|
+
coder_['coord_sys'] = @coord_sys.to_wkt if @coord_sys
|
192
|
+
end
|
193
|
+
|
194
|
+
def init_with(coder_) # :nodoc:
|
195
|
+
if (proj4_data_ = coder_['proj4'])
|
196
|
+
if proj4_data_.is_a?(::Hash)
|
197
|
+
proj4_ = CoordSys::Proj4.create(proj4_data_['proj4'], :radians => proj4_data_['radians'])
|
198
|
+
else
|
199
|
+
proj4_ = CoordSys::Proj4.create(proj4_data_.to_s)
|
200
|
+
end
|
201
|
+
else
|
202
|
+
proj4_ = nil
|
203
|
+
end
|
204
|
+
if (coord_sys_data_ = coder_['cs'])
|
205
|
+
coord_sys_ = CoordSys::CS.create_from_wkt(coord_sys_data_.to_s)
|
206
|
+
else
|
207
|
+
coord_sys_ = nil
|
208
|
+
end
|
209
|
+
initialize(
|
210
|
+
:native_interface => coder_['native_interface'] == 'ffi' ? :ffi : :capi,
|
211
|
+
:has_z_coordinate => coder_['has_z_coordinate'],
|
212
|
+
:has_m_coordinate => coder_['has_m_coordinate'],
|
213
|
+
:srid => coder_['srid'],
|
214
|
+
:buffer_resolution => coder_['buffer_resolution'],
|
215
|
+
:wkt_generator => ImplHelper::Utils.symbolize_hash(coder_['wkt_generator']),
|
216
|
+
:wkb_generator => ImplHelper::Utils.symbolize_hash(coder_['wkb_generator']),
|
217
|
+
:wkt_parser => ImplHelper::Utils.symbolize_hash(coder_['wkt_parser']),
|
218
|
+
:wkb_parser => ImplHelper::Utils.symbolize_hash(coder_['wkb_parser']),
|
219
|
+
:auto_prepare => coder_['auto_prepare'] == 'disabled' ? :disabled : :simple,
|
220
|
+
:uses_lenient_multi_polygon_assertions => coder_['lenient_multi_polygon_assertions'],
|
221
|
+
:proj4 => proj4_,
|
222
|
+
:coord_sys => coord_sys_
|
223
|
+
)
|
224
|
+
end
|
225
|
+
|
226
|
+
|
123
227
|
# Returns the SRID of geometries created by this factory.
|
124
228
|
|
125
229
|
def srid
|
data/lib/rgeo/geos/zm_impl.rb
CHANGED
@@ -160,9 +160,10 @@ module RGeo
|
|
160
160
|
end
|
161
161
|
|
162
162
|
|
163
|
-
def relate(rhs_, pattern_)
|
164
|
-
@zgeometry.relate(rhs_, pattern_)
|
163
|
+
def relate?(rhs_, pattern_)
|
164
|
+
@zgeometry.relate?(rhs_, pattern_)
|
165
165
|
end
|
166
|
+
alias_method :relate, :relate? # DEPRECATED
|
166
167
|
|
167
168
|
|
168
169
|
def distance(rhs_)
|
data/lib/rgeo/impl_helper.rb
CHANGED
@@ -177,7 +177,7 @@ module RGeo
|
|
177
177
|
super
|
178
178
|
if @points.size > 0
|
179
179
|
@points << @points.first if @points.first != @points.last
|
180
|
-
if !is_ring?
|
180
|
+
if !@factory.property(:uses_lenient_assertions) && !is_ring?
|
181
181
|
raise Error::InvalidGeometry, 'LinearRing failed ring test'
|
182
182
|
end
|
183
183
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Math constants and tools
|
4
|
+
#
|
5
|
+
# -----------------------------------------------------------------------------
|
6
|
+
# Copyright 2010-2012 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
|
+
module RGeo
|
38
|
+
|
39
|
+
module ImplHelper # :nodoc:
|
40
|
+
|
41
|
+
module Utils # :nodoc:
|
42
|
+
|
43
|
+
class << self
|
44
|
+
|
45
|
+
def stringize_hash(hash_)
|
46
|
+
nhash_ = {}
|
47
|
+
hash_.each do |k_, v_|
|
48
|
+
nhash_[k_.is_a?(::Symbol) ? k_.to_s : k_] = v_.is_a?(::Symbol) ? v_.to_s : v_
|
49
|
+
end
|
50
|
+
nhash_
|
51
|
+
end
|
52
|
+
|
53
|
+
def symbolize_hash(hash_)
|
54
|
+
nhash_ = {}
|
55
|
+
hash_.each do |k_, v_|
|
56
|
+
nhash_[k_.is_a?(::String) ? k_.to_sym : k_] = v_.is_a?(::String) ? v_.to_sym : v_
|
57
|
+
end
|
58
|
+
nhash_
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -125,10 +125,10 @@ module RGeo
|
|
125
125
|
|
126
126
|
def _properties # :nodoc:
|
127
127
|
{
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
'type_format' => @type_format.to_s,
|
129
|
+
'emit_ewkb_srid' => @emit_ewkb_srid,
|
130
|
+
'hex_format' => @hex_format,
|
131
|
+
'little_endian' => @little_endian,
|
132
132
|
}
|
133
133
|
end
|
134
134
|
|
@@ -130,10 +130,10 @@ module RGeo
|
|
130
130
|
|
131
131
|
def _properties # :nodoc:
|
132
132
|
{
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
133
|
+
'support_ewkb' => @support_ewkb,
|
134
|
+
'support_wkb12' => @support_wkb12,
|
135
|
+
'ignore_extra_bytes' => @ignore_extra_bytes,
|
136
|
+
'default_srid' => @default_srid,
|
137
137
|
}
|
138
138
|
end
|
139
139
|
|
@@ -116,10 +116,10 @@ module RGeo
|
|
116
116
|
|
117
117
|
def _properties # :nodoc:
|
118
118
|
{
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
119
|
+
'tag_format' => @tag_format.to_s,
|
120
|
+
'emit_ewkt_srid' => @emit_ewkt_srid,
|
121
|
+
'square_brackets' => @square_brackets,
|
122
|
+
'convert_case' => @convert_case ? @convert_case.to_s : nil,
|
123
123
|
}
|
124
124
|
end
|
125
125
|
|
@@ -144,11 +144,11 @@ module RGeo
|
|
144
144
|
|
145
145
|
def _properties # :nodoc:
|
146
146
|
{
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
147
|
+
'support_ewkt' => @support_ewkt,
|
148
|
+
'support_wkt12' => @support_wkt12,
|
149
|
+
'strict_wkt11' => @strict_wkt11,
|
150
|
+
'ignore_extra_tokens' => @ignore_extra_tokens,
|
151
|
+
'default_srid' => @default_srid,
|
152
152
|
}
|
153
153
|
end
|
154
154
|
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Common tests for geometry collection implementations
|
4
|
+
#
|
5
|
+
# -----------------------------------------------------------------------------
|
6
|
+
# Copyright 2010-2012 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 'rgeo'
|
38
|
+
|
39
|
+
|
40
|
+
module RGeo
|
41
|
+
module Tests # :nodoc:
|
42
|
+
module Common # :nodoc:
|
43
|
+
|
44
|
+
module FactoryTests # :nodoc:
|
45
|
+
|
46
|
+
|
47
|
+
def _srid
|
48
|
+
defined?(@srid) ? @srid : 0
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def test_srid_preserved_through_factory
|
53
|
+
geom_ = @factory.point(-10, 20)
|
54
|
+
assert_equal(_srid, geom_.srid)
|
55
|
+
factory_ = geom_.factory
|
56
|
+
assert_equal(_srid, factory_.srid)
|
57
|
+
geom2_ = factory_.point(-20, 25)
|
58
|
+
assert_equal(_srid, geom2_.srid)
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
def test_srid_preserved_through_geom_operations
|
63
|
+
geom1_ = @factory.point(-10, 20)
|
64
|
+
geom2_ = @factory.point(-20, 25)
|
65
|
+
geom3_ = geom1_.union(geom2_)
|
66
|
+
assert_equal(_srid, geom3_.srid)
|
67
|
+
assert_equal(_srid, geom3_.geometry_n(0).srid)
|
68
|
+
assert_equal(_srid, geom3_.geometry_n(1).srid)
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
def test_srid_preserved_through_geom_functions
|
73
|
+
geom1_ = @factory.point(-10, 20)
|
74
|
+
geom2_ = geom1_.boundary
|
75
|
+
assert_equal(_srid, geom2_.srid)
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
def test_srid_preserved_through_dup
|
80
|
+
geom1_ = @factory.point(-10, 20)
|
81
|
+
geom2_ = geom1_.clone
|
82
|
+
assert_equal(_srid, geom2_.srid)
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
def test_dup_factory
|
87
|
+
dup_factory_ = @factory.dup
|
88
|
+
assert_equal(@factory, dup_factory_)
|
89
|
+
assert_equal(_srid, dup_factory_.srid)
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
def test_marshal_dump_load_factory
|
94
|
+
data_ = ::Marshal.dump(@factory)
|
95
|
+
factory2_ = ::Marshal.load(data_)
|
96
|
+
assert_equal(@factory, factory2_)
|
97
|
+
assert_equal(_srid, factory2_.srid)
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
if ::RGeo.yaml_supported?
|
102
|
+
|
103
|
+
def test_psych_dump_load_factory
|
104
|
+
data_ = ::Psych.dump(@factory)
|
105
|
+
factory2_ = ::Psych.load(data_)
|
106
|
+
assert_equal(@factory, factory2_)
|
107
|
+
assert_equal(_srid, factory2_.srid)
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|