schleyfox-rgeo 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +199 -0
- data/README.rdoc +172 -0
- data/Spatial_Programming_With_RGeo.rdoc +440 -0
- data/Version +1 -0
- data/ext/geos_c_impl/extconf.rb +84 -0
- data/ext/geos_c_impl/factory.c +468 -0
- data/ext/geos_c_impl/factory.h +224 -0
- data/ext/geos_c_impl/geometry.c +705 -0
- data/ext/geos_c_impl/geometry.h +55 -0
- data/ext/geos_c_impl/geometry_collection.c +482 -0
- data/ext/geos_c_impl/geometry_collection.h +69 -0
- data/ext/geos_c_impl/line_string.c +509 -0
- data/ext/geos_c_impl/line_string.h +64 -0
- data/ext/geos_c_impl/main.c +70 -0
- data/ext/geos_c_impl/point.c +193 -0
- data/ext/geos_c_impl/point.h +62 -0
- data/ext/geos_c_impl/polygon.c +265 -0
- data/ext/geos_c_impl/polygon.h +66 -0
- data/ext/geos_c_impl/preface.h +50 -0
- data/ext/proj4_c_impl/extconf.rb +88 -0
- data/ext/proj4_c_impl/main.c +271 -0
- data/lib/rgeo.rb +124 -0
- data/lib/rgeo/cartesian.rb +60 -0
- data/lib/rgeo/cartesian/analysis.rb +118 -0
- data/lib/rgeo/cartesian/bounding_box.rb +337 -0
- data/lib/rgeo/cartesian/calculations.rb +161 -0
- data/lib/rgeo/cartesian/factory.rb +209 -0
- data/lib/rgeo/cartesian/feature_classes.rb +173 -0
- data/lib/rgeo/cartesian/feature_methods.rb +106 -0
- data/lib/rgeo/cartesian/interface.rb +150 -0
- data/lib/rgeo/coord_sys.rb +79 -0
- data/lib/rgeo/coord_sys/cs/entities.rb +1524 -0
- data/lib/rgeo/coord_sys/cs/factories.rb +208 -0
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +308 -0
- data/lib/rgeo/coord_sys/proj4.rb +312 -0
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +194 -0
- data/lib/rgeo/coord_sys/srs_database/interface.rb +165 -0
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +188 -0
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +108 -0
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +108 -0
- data/lib/rgeo/error.rb +63 -0
- data/lib/rgeo/feature.rb +88 -0
- data/lib/rgeo/feature/curve.rb +156 -0
- data/lib/rgeo/feature/factory.rb +332 -0
- data/lib/rgeo/feature/factory_generator.rb +138 -0
- data/lib/rgeo/feature/geometry.rb +614 -0
- data/lib/rgeo/feature/geometry_collection.rb +129 -0
- data/lib/rgeo/feature/line.rb +66 -0
- data/lib/rgeo/feature/line_string.rb +102 -0
- data/lib/rgeo/feature/linear_ring.rb +66 -0
- data/lib/rgeo/feature/multi_curve.rb +113 -0
- data/lib/rgeo/feature/multi_line_string.rb +66 -0
- data/lib/rgeo/feature/multi_point.rb +73 -0
- data/lib/rgeo/feature/multi_polygon.rb +97 -0
- data/lib/rgeo/feature/multi_surface.rb +116 -0
- data/lib/rgeo/feature/point.rb +120 -0
- data/lib/rgeo/feature/polygon.rb +141 -0
- data/lib/rgeo/feature/surface.rb +122 -0
- data/lib/rgeo/feature/types.rb +305 -0
- data/lib/rgeo/geographic.rb +75 -0
- data/lib/rgeo/geographic/factory.rb +287 -0
- data/lib/rgeo/geographic/interface.rb +410 -0
- data/lib/rgeo/geographic/proj4_projector.rb +98 -0
- data/lib/rgeo/geographic/projected_feature_classes.rb +213 -0
- data/lib/rgeo/geographic/projected_feature_methods.rb +228 -0
- data/lib/rgeo/geographic/projected_window.rb +467 -0
- data/lib/rgeo/geographic/simple_mercator_projector.rb +157 -0
- data/lib/rgeo/geographic/spherical_feature_classes.rb +212 -0
- data/lib/rgeo/geographic/spherical_feature_methods.rb +97 -0
- data/lib/rgeo/geographic/spherical_math.rb +206 -0
- data/lib/rgeo/geos.rb +72 -0
- data/lib/rgeo/geos/factory.rb +301 -0
- data/lib/rgeo/geos/impl_additions.rb +76 -0
- data/lib/rgeo/geos/interface.rb +139 -0
- data/lib/rgeo/geos/zm_factory.rb +275 -0
- data/lib/rgeo/geos/zm_impl.rb +432 -0
- data/lib/rgeo/impl_helper.rb +53 -0
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +235 -0
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +85 -0
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +197 -0
- data/lib/rgeo/impl_helper/basic_point_methods.rb +138 -0
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +121 -0
- data/lib/rgeo/impl_helper/math.rb +50 -0
- data/lib/rgeo/version.rb +52 -0
- data/lib/rgeo/wkrep.rb +72 -0
- data/lib/rgeo/wkrep/wkb_generator.rb +267 -0
- data/lib/rgeo/wkrep/wkb_parser.rb +315 -0
- data/lib/rgeo/wkrep/wkt_generator.rb +275 -0
- data/lib/rgeo/wkrep/wkt_parser.rb +496 -0
- data/test/common/geometry_collection_tests.rb +238 -0
- data/test/common/line_string_tests.rb +324 -0
- data/test/common/multi_line_string_tests.rb +209 -0
- data/test/common/multi_point_tests.rb +201 -0
- data/test/common/multi_polygon_tests.rb +208 -0
- data/test/common/point_tests.rb +331 -0
- data/test/common/polygon_tests.rb +232 -0
- data/test/coord_sys/tc_active_record_table.rb +102 -0
- data/test/coord_sys/tc_ogc_cs.rb +356 -0
- data/test/coord_sys/tc_proj4.rb +138 -0
- data/test/coord_sys/tc_proj4_srs_data.rb +76 -0
- data/test/coord_sys/tc_sr_org.rb +70 -0
- data/test/coord_sys/tc_url_reader.rb +82 -0
- data/test/geos/tc_factory.rb +91 -0
- data/test/geos/tc_geometry_collection.rb +62 -0
- data/test/geos/tc_line_string.rb +62 -0
- data/test/geos/tc_misc.rb +72 -0
- data/test/geos/tc_multi_line_string.rb +62 -0
- data/test/geos/tc_multi_point.rb +62 -0
- data/test/geos/tc_multi_polygon.rb +63 -0
- data/test/geos/tc_point.rb +86 -0
- data/test/geos/tc_polygon.rb +86 -0
- data/test/geos/tc_zmfactory.rb +85 -0
- data/test/projected_geographic/tc_geometry_collection.rb +62 -0
- data/test/projected_geographic/tc_line_string.rb +62 -0
- data/test/projected_geographic/tc_multi_line_string.rb +62 -0
- data/test/projected_geographic/tc_multi_point.rb +62 -0
- data/test/projected_geographic/tc_multi_polygon.rb +63 -0
- data/test/projected_geographic/tc_point.rb +93 -0
- data/test/projected_geographic/tc_polygon.rb +62 -0
- data/test/simple_cartesian/tc_calculations.rb +145 -0
- data/test/simple_cartesian/tc_geometry_collection.rb +69 -0
- data/test/simple_cartesian/tc_line_string.rb +70 -0
- data/test/simple_cartesian/tc_multi_line_string.rb +67 -0
- data/test/simple_cartesian/tc_multi_point.rb +67 -0
- data/test/simple_cartesian/tc_multi_polygon.rb +70 -0
- data/test/simple_cartesian/tc_point.rb +91 -0
- data/test/simple_cartesian/tc_polygon.rb +67 -0
- data/test/simple_mercator/tc_geometry_collection.rb +62 -0
- data/test/simple_mercator/tc_line_string.rb +62 -0
- data/test/simple_mercator/tc_multi_line_string.rb +62 -0
- data/test/simple_mercator/tc_multi_point.rb +62 -0
- data/test/simple_mercator/tc_multi_polygon.rb +63 -0
- data/test/simple_mercator/tc_point.rb +93 -0
- data/test/simple_mercator/tc_polygon.rb +62 -0
- data/test/simple_mercator/tc_window.rb +219 -0
- data/test/spherical_geographic/tc_calculations.rb +203 -0
- data/test/spherical_geographic/tc_geometry_collection.rb +70 -0
- data/test/spherical_geographic/tc_line_string.rb +70 -0
- data/test/spherical_geographic/tc_multi_line_string.rb +67 -0
- data/test/spherical_geographic/tc_multi_point.rb +67 -0
- data/test/spherical_geographic/tc_multi_polygon.rb +70 -0
- data/test/spherical_geographic/tc_point.rb +100 -0
- data/test/spherical_geographic/tc_polygon.rb +67 -0
- data/test/tc_cartesian_analysis.rb +107 -0
- data/test/tc_oneoff.rb +63 -0
- data/test/wkrep/tc_wkb_generator.rb +249 -0
- data/test/wkrep/tc_wkb_parser.rb +353 -0
- data/test/wkrep/tc_wkt_generator.rb +362 -0
- data/test/wkrep/tc_wkt_parser.rb +480 -0
- metadata +267 -0
@@ -0,0 +1,432 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# GEOS implementation additions written in Ruby
|
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
|
+
module RGeo
|
38
|
+
|
39
|
+
module Geos
|
40
|
+
|
41
|
+
|
42
|
+
class ZMGeometryImpl # :nodoc:
|
43
|
+
|
44
|
+
include Feature::Instance
|
45
|
+
|
46
|
+
|
47
|
+
def initialize(factory_, zgeometry_, mgeometry_)
|
48
|
+
@factory = factory_
|
49
|
+
@zgeometry = zgeometry_
|
50
|
+
@mgeometry = mgeometry_
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def inspect # :nodoc:
|
55
|
+
"#<#{self.class}:0x#{object_id.to_s(16)} #{as_text.inspect}>"
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_s # :nodoc:
|
59
|
+
as_text
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def factory
|
64
|
+
@factory
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def z_geometry
|
69
|
+
@zgeometry
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def m_geometry
|
74
|
+
@mgeometry
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def eql?(rhs_)
|
79
|
+
rhs_.is_a?(self.class) && @factory.eql?(rhs_.factory) && @zgeometry.eql?(rhs_.z_geometry) && @mgeometry.eql?(rhs_.m_geometry)
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
def dimension
|
84
|
+
@zgeometry.dimension
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def geometry_type
|
89
|
+
@zgeometry.geometry_type
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
def srid
|
94
|
+
@factory.srid
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def envelope
|
99
|
+
ZMGeometryImpl.create(@factory, @zgeometry.envelope, @mgeometry.envelope)
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
def as_text
|
104
|
+
WKRep::WKTGenerator.new.generate(self)
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
def as_binary
|
109
|
+
WKRep::WKBGenerator.new.generate(self)
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
def is_empty?
|
114
|
+
@zgeometry.is_empty?
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
def is_simple?
|
119
|
+
@zgeometry.is_simple?
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
def boundary
|
124
|
+
ZMGeometryImpl.create(@factory, @zgeometry.boundary, @mgeometry.boundary)
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
def equals?(rhs_)
|
129
|
+
@zgeometry.equals?(rhs_)
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
def disjoint?(rhs_)
|
134
|
+
@zgeometry.disjoint?(rhs_)
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
def intersects?(rhs_)
|
139
|
+
@zgeometry.intersects?(rhs_)
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
def touches?(rhs_)
|
144
|
+
@zgeometry.touches?(rhs_)
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
def crosses?(rhs_)
|
149
|
+
@zgeometry.crosses?(rhs_)
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
def within?(rhs_)
|
154
|
+
@zgeometry.within?(rhs_)
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
def contains?(rhs_)
|
159
|
+
@zgeometry.contains?(rhs_)
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
def overlaps?(rhs_)
|
164
|
+
@zgeometry.overlaps?(rhs_)
|
165
|
+
end
|
166
|
+
|
167
|
+
|
168
|
+
def relate(rhs_, pattern_)
|
169
|
+
@zgeometry.relate(rhs_, pattern_)
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
def distance(rhs_)
|
174
|
+
@zgeometry.distance(rhs_)
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
def buffer(distance_)
|
179
|
+
ZMGeometryImpl.create(@factory, @zgeometry.buffer(distance_), @mgeometry.buffer(distance_))
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
def convex_hull
|
184
|
+
ZMGeometryImpl.create(@factory, @zgeometry.convex_hull, @mgeometry.convex_hull)
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
def intersection(rhs_)
|
189
|
+
ZMGeometryImpl.create(@factory, @zgeometry.intersection(rhs_), @mgeometry.intersection(rhs_))
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
def union(rhs_)
|
194
|
+
ZMGeometryImpl.create(@factory, @zgeometry.union(rhs_), @mgeometry.union(rhs_))
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
def difference(rhs_)
|
199
|
+
ZMGeometryImpl.create(@factory, @zgeometry.difference(rhs_), @mgeometry.difference(rhs_))
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
def sym_difference(rhs_)
|
204
|
+
ZMGeometryImpl.create(@factory, @zgeometry.sym_difference(rhs_), @mgeometry.sym_difference(rhs_))
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
alias_method :==, :equals?
|
209
|
+
alias_method :-, :difference
|
210
|
+
alias_method :+, :union
|
211
|
+
alias_method :*, :intersection
|
212
|
+
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
class ZMPointImpl < ZMGeometryImpl # :nodoc:
|
217
|
+
|
218
|
+
|
219
|
+
def x
|
220
|
+
@zgeometry.x
|
221
|
+
end
|
222
|
+
|
223
|
+
|
224
|
+
def y
|
225
|
+
@zgeometry.y
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
def z
|
230
|
+
@zgeometry.z
|
231
|
+
end
|
232
|
+
|
233
|
+
|
234
|
+
def m
|
235
|
+
@mgeometry.m
|
236
|
+
end
|
237
|
+
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
|
242
|
+
class ZMLineStringImpl < ZMGeometryImpl # :nodoc:
|
243
|
+
|
244
|
+
|
245
|
+
def length
|
246
|
+
@zgeometry.length
|
247
|
+
end
|
248
|
+
|
249
|
+
|
250
|
+
def start_point
|
251
|
+
point_n(0)
|
252
|
+
end
|
253
|
+
|
254
|
+
|
255
|
+
def end_point
|
256
|
+
point_n(num_points - 1)
|
257
|
+
end
|
258
|
+
|
259
|
+
|
260
|
+
def is_closed?
|
261
|
+
@zgeometry.is_closed?
|
262
|
+
end
|
263
|
+
|
264
|
+
|
265
|
+
def is_ring?
|
266
|
+
@zgeometry.is_ring?
|
267
|
+
end
|
268
|
+
|
269
|
+
|
270
|
+
def num_points
|
271
|
+
@zgeometry.num_points
|
272
|
+
end
|
273
|
+
|
274
|
+
|
275
|
+
def point_n(n_)
|
276
|
+
ZMPointImpl.create(@factory, @zgeometry.point_n(n_), @mgeometry.point_n(n_))
|
277
|
+
end
|
278
|
+
|
279
|
+
|
280
|
+
def points
|
281
|
+
result_ = []
|
282
|
+
zpoints_ = @zgeometry.points
|
283
|
+
mpoints_ = @mgeometry.points
|
284
|
+
zpoints_.size.times do |i_|
|
285
|
+
result_ << ZMPointImpl.create(@factory, zpoints_[i_], mpoints_[i_])
|
286
|
+
end
|
287
|
+
result_
|
288
|
+
end
|
289
|
+
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
|
294
|
+
class ZMPolygonImpl < ZMGeometryImpl # :nodoc:
|
295
|
+
|
296
|
+
|
297
|
+
def area
|
298
|
+
@zgeometry.area
|
299
|
+
end
|
300
|
+
|
301
|
+
|
302
|
+
def centroid
|
303
|
+
ZMPointImpl.create(@factory, @zgeometry.centroid, @mgeometry.centroid)
|
304
|
+
end
|
305
|
+
|
306
|
+
|
307
|
+
def point_on_surface
|
308
|
+
ZMPointImpl.create(@factory, @zgeometry.centroid, @mgeometry.centroid)
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
def exterior_ring
|
313
|
+
ZMLineStringImpl.create(@factory, @zgeometry.exterior_ring, @mgeometry.exterior_ring)
|
314
|
+
end
|
315
|
+
|
316
|
+
|
317
|
+
def num_interior_rings
|
318
|
+
@zgeometry.num_interior_rings
|
319
|
+
end
|
320
|
+
|
321
|
+
|
322
|
+
def interior_ring_n(n_)
|
323
|
+
ZMLineStringImpl.create(@factory, @zgeometry.interior_ring_n(n_), @mgeometry.interior_ring_n(n_))
|
324
|
+
end
|
325
|
+
|
326
|
+
|
327
|
+
def interior_rings
|
328
|
+
result_ = []
|
329
|
+
zrings_ = @zgeometry.interior_rings
|
330
|
+
mrings_ = @mgeometry.interior_rings
|
331
|
+
zrings_.size.times do |i_|
|
332
|
+
result_ << ZMLineStringImpl.create(@factory, zrings_[i_], mrings_[i_])
|
333
|
+
end
|
334
|
+
result_
|
335
|
+
end
|
336
|
+
|
337
|
+
|
338
|
+
end
|
339
|
+
|
340
|
+
|
341
|
+
class ZMGeometryCollectionImpl < ZMGeometryImpl # :nodoc:
|
342
|
+
|
343
|
+
|
344
|
+
include ::Enumerable
|
345
|
+
|
346
|
+
|
347
|
+
def num_geometries
|
348
|
+
@zgeometry.num_geometries
|
349
|
+
end
|
350
|
+
alias_method :size, :num_geometries
|
351
|
+
|
352
|
+
|
353
|
+
def geometry_n(n_)
|
354
|
+
ZMGeometryImpl.create(@factory, @zgeometry.geometry_n(n_), @mgeometry.geometry_n(n_))
|
355
|
+
end
|
356
|
+
alias_method :[], :geometry_n
|
357
|
+
|
358
|
+
|
359
|
+
def each
|
360
|
+
num_geometries.times do |i_|
|
361
|
+
yield geometry_n(i_)
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
|
366
|
+
end
|
367
|
+
|
368
|
+
|
369
|
+
class ZMMultiLineStringImpl < ZMGeometryCollectionImpl # :nodoc:
|
370
|
+
|
371
|
+
|
372
|
+
def length
|
373
|
+
@zgeometry.length
|
374
|
+
end
|
375
|
+
|
376
|
+
|
377
|
+
def is_closed?
|
378
|
+
@zgeometry.is_closed?
|
379
|
+
end
|
380
|
+
|
381
|
+
|
382
|
+
end
|
383
|
+
|
384
|
+
|
385
|
+
class ZMMultiPolygonImpl < ZMGeometryCollectionImpl # :nodoc:
|
386
|
+
|
387
|
+
|
388
|
+
def area
|
389
|
+
@zgeometry.area
|
390
|
+
end
|
391
|
+
|
392
|
+
|
393
|
+
def centroid
|
394
|
+
ZMPointImpl.create(@factory, @zgeometry.centroid, @mgeometry.centroid)
|
395
|
+
end
|
396
|
+
|
397
|
+
|
398
|
+
def point_on_surface
|
399
|
+
ZMPointImpl.create(@factory, @zgeometry.centroid, @mgeometry.centroid)
|
400
|
+
end
|
401
|
+
|
402
|
+
|
403
|
+
end
|
404
|
+
|
405
|
+
|
406
|
+
class ZMGeometryImpl # :nodoc:
|
407
|
+
|
408
|
+
TYPE_KLASSES = {
|
409
|
+
Feature::Point => ZMPointImpl,
|
410
|
+
Feature::LineString => ZMLineStringImpl,
|
411
|
+
Feature::Line => ZMLineStringImpl,
|
412
|
+
Feature::LinearRing => ZMLineStringImpl,
|
413
|
+
Feature::Polygon => ZMPolygonImpl,
|
414
|
+
Feature::GeometryCollection => ZMGeometryCollectionImpl,
|
415
|
+
Feature::MultiPoint => ZMGeometryCollectionImpl,
|
416
|
+
Feature::MultiLineString => ZMMultiLineStringImpl,
|
417
|
+
Feature::MultiPolygon => ZMMultiPolygonImpl,
|
418
|
+
}
|
419
|
+
|
420
|
+
|
421
|
+
def self.create(factory_, zgeometry_, mgeometry_)
|
422
|
+
klass_ = self == ZMGeometryImpl ? TYPE_KLASSES[zgeometry_.geometry_type] : self
|
423
|
+
klass_ && zgeometry_ && mgeometry_ ? klass_.new(factory_, zgeometry_, mgeometry_) : nil
|
424
|
+
end
|
425
|
+
|
426
|
+
|
427
|
+
end
|
428
|
+
|
429
|
+
|
430
|
+
end
|
431
|
+
|
432
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Implementation helpers namespace for RGeo
|
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
|
+
module RGeo
|
38
|
+
|
39
|
+
|
40
|
+
module ImplHelper # :nodoc:
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
# Implementation files
|
48
|
+
require 'rgeo/impl_helper/math'
|
49
|
+
require 'rgeo/impl_helper/basic_geometry_methods'
|
50
|
+
require 'rgeo/impl_helper/basic_geometry_collection_methods'
|
51
|
+
require 'rgeo/impl_helper/basic_point_methods'
|
52
|
+
require 'rgeo/impl_helper/basic_line_string_methods'
|
53
|
+
require 'rgeo/impl_helper/basic_polygon_methods'
|