rgeo 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. data/History.rdoc +6 -0
  2. data/README.rdoc +1 -1
  3. data/Version +1 -1
  4. data/ext/geos_c_impl/extconf.rb +13 -13
  5. data/ext/geos_c_impl/factory.c +30 -18
  6. data/ext/geos_c_impl/factory.h +18 -12
  7. data/ext/geos_c_impl/geometry.c +11 -11
  8. data/ext/geos_c_impl/geometry.h +7 -7
  9. data/ext/geos_c_impl/geometry_collection.c +15 -15
  10. data/ext/geos_c_impl/geometry_collection.h +8 -8
  11. data/ext/geos_c_impl/line_string.c +14 -14
  12. data/ext/geos_c_impl/line_string.h +7 -7
  13. data/ext/geos_c_impl/main.c +7 -7
  14. data/ext/geos_c_impl/point.c +9 -9
  15. data/ext/geos_c_impl/point.h +7 -7
  16. data/ext/geos_c_impl/polygon.c +9 -9
  17. data/ext/geos_c_impl/polygon.h +7 -7
  18. data/ext/geos_c_impl/preface.h +7 -7
  19. data/ext/proj4_c_impl/extconf.rb +13 -13
  20. data/ext/proj4_c_impl/main.c +12 -12
  21. data/lib/rgeo.rb +26 -26
  22. data/lib/rgeo/cartesian.rb +12 -12
  23. data/lib/rgeo/cartesian/analysis.rb +26 -26
  24. data/lib/rgeo/cartesian/bounding_box.rb +83 -83
  25. data/lib/rgeo/cartesian/calculations.rb +36 -36
  26. data/lib/rgeo/cartesian/factory.rb +78 -78
  27. data/lib/rgeo/cartesian/feature_classes.rb +74 -74
  28. data/lib/rgeo/cartesian/feature_methods.rb +34 -34
  29. data/lib/rgeo/cartesian/interface.rb +33 -33
  30. data/lib/rgeo/coord_sys.rb +15 -15
  31. data/lib/rgeo/coord_sys/cs/entities.rb +533 -534
  32. data/lib/rgeo/coord_sys/cs/factories.rb +69 -69
  33. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +44 -44
  34. data/lib/rgeo/coord_sys/proj4.rb +85 -85
  35. data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +31 -31
  36. data/lib/rgeo/coord_sys/srs_database/interface.rb +44 -44
  37. data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +31 -31
  38. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +31 -31
  39. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +29 -29
  40. data/lib/rgeo/error.rb +17 -17
  41. data/lib/rgeo/feature.rb +15 -15
  42. data/lib/rgeo/feature/curve.rb +58 -58
  43. data/lib/rgeo/feature/factory.rb +84 -84
  44. data/lib/rgeo/feature/factory_generator.rb +32 -32
  45. data/lib/rgeo/feature/geometry.rb +215 -215
  46. data/lib/rgeo/feature/geometry_collection.rb +46 -46
  47. data/lib/rgeo/feature/line.rb +21 -21
  48. data/lib/rgeo/feature/line_string.rb +35 -35
  49. data/lib/rgeo/feature/linear_ring.rb +20 -20
  50. data/lib/rgeo/feature/mixins.rb +61 -61
  51. data/lib/rgeo/feature/multi_curve.rb +37 -37
  52. data/lib/rgeo/feature/multi_line_string.rb +20 -20
  53. data/lib/rgeo/feature/multi_point.rb +22 -22
  54. data/lib/rgeo/feature/multi_polygon.rb +28 -28
  55. data/lib/rgeo/feature/multi_surface.rb +39 -39
  56. data/lib/rgeo/feature/point.rb +42 -42
  57. data/lib/rgeo/feature/polygon.rb +50 -50
  58. data/lib/rgeo/feature/surface.rb +42 -42
  59. data/lib/rgeo/feature/types.rb +58 -58
  60. data/lib/rgeo/geographic.rb +14 -14
  61. data/lib/rgeo/geographic/factory.rb +87 -87
  62. data/lib/rgeo/geographic/interface.rb +55 -55
  63. data/lib/rgeo/geographic/proj4_projector.rb +35 -35
  64. data/lib/rgeo/geographic/projected_feature_classes.rb +95 -95
  65. data/lib/rgeo/geographic/projected_feature_methods.rb +81 -81
  66. data/lib/rgeo/geographic/projected_window.rb +103 -103
  67. data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -32
  68. data/lib/rgeo/geographic/spherical_feature_classes.rb +93 -93
  69. data/lib/rgeo/geographic/spherical_feature_methods.rb +25 -25
  70. data/lib/rgeo/geographic/spherical_math.rb +58 -58
  71. data/lib/rgeo/geos.rb +22 -17
  72. data/lib/rgeo/geos/factory.rb +93 -93
  73. data/lib/rgeo/geos/ffi_classes.rb +306 -231
  74. data/lib/rgeo/geos/ffi_factory.rb +100 -96
  75. data/lib/rgeo/geos/impl_additions.rb +22 -22
  76. data/lib/rgeo/geos/interface.rb +45 -45
  77. data/lib/rgeo/geos/zm_factory.rb +90 -90
  78. data/lib/rgeo/geos/zm_impl.rb +167 -167
  79. data/lib/rgeo/impl_helper.rb +11 -11
  80. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +71 -71
  81. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +29 -29
  82. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +61 -61
  83. data/lib/rgeo/impl_helper/basic_point_methods.rb +43 -43
  84. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +35 -35
  85. data/lib/rgeo/impl_helper/math.rb +13 -13
  86. data/lib/rgeo/version.rb +10 -10
  87. data/lib/rgeo/wkrep.rb +16 -16
  88. data/lib/rgeo/wkrep/wkb_generator.rb +51 -51
  89. data/lib/rgeo/wkrep/wkb_parser.rb +52 -52
  90. data/lib/rgeo/wkrep/wkt_generator.rb +51 -51
  91. data/lib/rgeo/wkrep/wkt_parser.rb +66 -66
  92. data/lib/rgeo/yaml.rb +14 -14
  93. data/test/common/geometry_collection_tests.rb +53 -53
  94. data/test/common/line_string_tests.rb +57 -57
  95. data/test/common/multi_line_string_tests.rb +43 -43
  96. data/test/common/multi_point_tests.rb +43 -43
  97. data/test/common/multi_polygon_tests.rb +43 -43
  98. data/test/common/point_tests.rb +75 -75
  99. data/test/common/polygon_tests.rb +37 -37
  100. data/test/coord_sys/tc_active_record_table.rb +25 -25
  101. data/test/coord_sys/tc_ogc_cs.rb +72 -72
  102. data/test/coord_sys/tc_proj4.rb +51 -51
  103. data/test/coord_sys/tc_proj4_srs_data.rb +17 -17
  104. data/test/coord_sys/tc_sr_org.rb +15 -15
  105. data/test/coord_sys/tc_url_reader.rb +19 -19
  106. data/test/geos_capi/tc_factory.rb +21 -21
  107. data/test/geos_capi/tc_geometry_collection.rb +15 -15
  108. data/test/geos_capi/tc_line_string.rb +15 -15
  109. data/test/geos_capi/tc_misc.rb +33 -22
  110. data/test/geos_capi/tc_multi_line_string.rb +15 -15
  111. data/test/geos_capi/tc_multi_point.rb +15 -15
  112. data/test/geos_capi/tc_multi_polygon.rb +15 -15
  113. data/test/geos_capi/tc_parsing_unparsing.rb +19 -19
  114. data/test/geos_capi/tc_point.rb +21 -21
  115. data/test/geos_capi/tc_polygon.rb +19 -19
  116. data/test/geos_capi/tc_zmfactory.rb +17 -17
  117. data/test/geos_ffi/tc_factory.rb +21 -21
  118. data/test/geos_ffi/tc_geometry_collection.rb +15 -15
  119. data/test/geos_ffi/tc_line_string.rb +15 -15
  120. data/test/geos_ffi/tc_misc.rb +49 -15
  121. data/test/geos_ffi/tc_multi_line_string.rb +15 -15
  122. data/test/geos_ffi/tc_multi_point.rb +15 -15
  123. data/test/geos_ffi/tc_multi_polygon.rb +15 -15
  124. data/test/geos_ffi/tc_parsing_unparsing.rb +19 -19
  125. data/test/geos_ffi/tc_point.rb +21 -21
  126. data/test/geos_ffi/tc_polygon.rb +19 -19
  127. data/test/geos_ffi/tc_zmfactory.rb +17 -17
  128. data/test/projected_geographic/tc_geometry_collection.rb +15 -15
  129. data/test/projected_geographic/tc_line_string.rb +15 -15
  130. data/test/projected_geographic/tc_multi_line_string.rb +15 -15
  131. data/test/projected_geographic/tc_multi_point.rb +15 -15
  132. data/test/projected_geographic/tc_multi_polygon.rb +15 -15
  133. data/test/projected_geographic/tc_point.rb +23 -23
  134. data/test/projected_geographic/tc_polygon.rb +15 -15
  135. data/test/simple_cartesian/tc_calculations.rb +31 -31
  136. data/test/simple_cartesian/tc_geometry_collection.rb +17 -17
  137. data/test/simple_cartesian/tc_line_string.rb +17 -17
  138. data/test/simple_cartesian/tc_multi_line_string.rb +17 -17
  139. data/test/simple_cartesian/tc_multi_point.rb +17 -17
  140. data/test/simple_cartesian/tc_multi_polygon.rb +17 -17
  141. data/test/simple_cartesian/tc_point.rb +21 -21
  142. data/test/simple_cartesian/tc_polygon.rb +17 -17
  143. data/test/simple_mercator/tc_geometry_collection.rb +15 -15
  144. data/test/simple_mercator/tc_line_string.rb +15 -15
  145. data/test/simple_mercator/tc_multi_line_string.rb +15 -15
  146. data/test/simple_mercator/tc_multi_point.rb +15 -15
  147. data/test/simple_mercator/tc_multi_polygon.rb +15 -15
  148. data/test/simple_mercator/tc_point.rb +23 -23
  149. data/test/simple_mercator/tc_polygon.rb +15 -15
  150. data/test/simple_mercator/tc_window.rb +50 -50
  151. data/test/spherical_geographic/tc_calculations.rb +47 -47
  152. data/test/spherical_geographic/tc_geometry_collection.rb +17 -17
  153. data/test/spherical_geographic/tc_line_string.rb +17 -17
  154. data/test/spherical_geographic/tc_multi_line_string.rb +17 -17
  155. data/test/spherical_geographic/tc_multi_point.rb +17 -17
  156. data/test/spherical_geographic/tc_multi_polygon.rb +17 -17
  157. data/test/spherical_geographic/tc_point.rb +23 -23
  158. data/test/spherical_geographic/tc_polygon.rb +17 -17
  159. data/test/tc_cartesian_analysis.rb +23 -23
  160. data/test/tc_mixins.rb +39 -39
  161. data/test/tc_oneoff.rb +15 -15
  162. data/test/tc_types.rb +17 -17
  163. data/test/wkrep/tc_wkb_generator.rb +67 -67
  164. data/test/wkrep/tc_wkb_parser.rb +73 -73
  165. data/test/wkrep/tc_wkt_generator.rb +75 -75
  166. data/test/wkrep/tc_wkt_parser.rb +97 -97
  167. metadata +3 -3
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # FFI-GEOS geometry implementation
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
@@ -35,15 +35,15 @@
35
35
 
36
36
 
37
37
  module RGeo
38
-
38
+
39
39
  module Geos
40
-
41
-
40
+
41
+
42
42
  module FFIUtils # :nodoc:
43
-
43
+
44
44
  class << self
45
-
46
-
45
+
46
+
47
47
  def coord_seqs_equal?(cs1_, cs2_, check_z_)
48
48
  len1_ = cs1_.length
49
49
  len2_ = cs2_.length
@@ -58,8 +58,8 @@ module RGeo
58
58
  false
59
59
  end
60
60
  end
61
-
62
-
61
+
62
+
63
63
  def compute_dimension(geom_)
64
64
  result_ = -1
65
65
  case geom_.type_id
@@ -83,62 +83,102 @@ module RGeo
83
83
  end
84
84
  result_
85
85
  end
86
-
87
-
86
+
87
+
88
+ def _init
89
+ @supports_prepared_level_1 = ::Geos::FFIGeos.respond_to?(:GEOSPreparedContains_r)
90
+ @supports_prepared_level_2 = ::Geos::FFIGeos.respond_to?(:GEOSPreparedDisjoint_r)
91
+ end
92
+
93
+ attr_reader :supports_prepared_level_1
94
+ attr_reader :supports_prepared_level_2
95
+
96
+
88
97
  end
89
-
98
+
99
+
90
100
  end
91
-
92
-
101
+
102
+
93
103
  class FFIGeometryImpl # :nodoc:
94
-
104
+
95
105
  include Feature::Instance
96
-
106
+
97
107
  Feature::MixinCollection::GLOBAL.for_type(Feature::Geometry).include_in_class(self)
98
-
99
-
108
+
109
+
100
110
  def initialize(factory_, fg_geom_, klasses_)
101
111
  @factory = factory_
102
112
  @fg_geom = fg_geom_
113
+ @_fg_prep = factory_._auto_prepare ? 1 : 0
103
114
  @_klasses = klasses_
104
115
  fg_geom_.srid = factory_.srid
105
116
  end
106
-
107
-
117
+
118
+
108
119
  def inspect
109
120
  "#<#{self.class}:0x#{object_id.to_s(16)} #{as_text.inspect}>"
110
121
  end
111
-
112
-
122
+
123
+
113
124
  attr_reader :factory
114
125
  attr_reader :fg_geom
115
-
126
+
116
127
  attr_reader :_klasses # :nodoc:
117
-
118
-
128
+
129
+
119
130
  def initialize_copy(orig_)
120
131
  @factory = orig_.factory
121
132
  @fg_geom = orig_.fg_geom.clone
122
133
  @fg_geom.srid = orig_.fg_geom.srid
134
+ @_fg_prep = @factory._auto_prepare ? 1 : 0
123
135
  @_klasses = orig_._klasses
124
136
  end
125
-
126
-
137
+
138
+
127
139
  def srid
128
140
  @fg_geom.srid
129
141
  end
130
-
131
-
142
+
143
+
132
144
  def dimension
133
145
  FFIUtils.compute_dimension(@fg_geom)
134
146
  end
135
-
136
-
147
+
148
+
137
149
  def geometry_type
138
150
  Feature::Geometry
139
151
  end
140
-
141
-
152
+
153
+
154
+ def prepared?
155
+ !@_fg_prep.is_a?(::Integer)
156
+ end
157
+
158
+
159
+ def prepare!
160
+ if @_fg_prep.is_a?(::Integer)
161
+ @_fg_prep = ::Geos::PreparedGeometry.new(@fg_geom)
162
+ end
163
+ self
164
+ end
165
+
166
+
167
+ def _request_prepared # :nodoc:
168
+ case @_fg_prep
169
+ when 0
170
+ nil
171
+ when 1
172
+ @_fg_prep = 2
173
+ nil
174
+ when 2
175
+ @_fg_prep = ::Geos::PreparedGeometry.new(@fg_geom)
176
+ else
177
+ @_fg_prep
178
+ end
179
+ end
180
+
181
+
142
182
  def envelope
143
183
  fg_geom_ = @fg_geom.envelope
144
184
  # GEOS returns an "empty" point for an empty collection's envelope.
@@ -148,8 +188,8 @@ module RGeo
148
188
  end
149
189
  @factory.wrap_fg_geom(fg_geom_)
150
190
  end
151
-
152
-
191
+
192
+
153
193
  def boundary
154
194
  if self.class == FFIGeometryCollectionImpl
155
195
  nil
@@ -157,29 +197,29 @@ module RGeo
157
197
  @factory.wrap_fg_geom(@fg_geom.boundary)
158
198
  end
159
199
  end
160
-
161
-
200
+
201
+
162
202
  def as_text
163
203
  @factory._generate_wkt(self)
164
204
  end
165
205
  alias_method :to_s, :as_text
166
-
167
-
206
+
207
+
168
208
  def as_binary
169
209
  @factory._generate_wkb(self)
170
210
  end
171
-
172
-
211
+
212
+
173
213
  def is_empty?
174
214
  @fg_geom.empty?
175
215
  end
176
-
177
-
216
+
217
+
178
218
  def is_simple?
179
219
  @fg_geom.simple?
180
220
  end
181
-
182
-
221
+
222
+
183
223
  def equals?(rhs_)
184
224
  return false unless rhs_.kind_of?(::RGeo::Feature::Instance)
185
225
  fg_ = factory._convert_to_fg_geometry(rhs_)
@@ -194,121 +234,156 @@ module RGeo
194
234
  end
195
235
  end
196
236
  alias_method :==, :equals?
197
-
198
-
237
+
238
+
199
239
  def disjoint?(rhs_)
200
240
  fg_ = factory._convert_to_fg_geometry(rhs_)
201
- fg_ ? @fg_geom.disjoint?(fg_) : false
241
+ if fg_
242
+ prep_ = _request_prepared if FFIUtils.supports_prepared_level_2
243
+ prep_ ? prep_.disjoint?(fg_) : @fg_geom.disjoint?(fg_)
244
+ else
245
+ false
246
+ end
202
247
  end
203
-
204
-
248
+
249
+
205
250
  def intersects?(rhs_)
206
251
  fg_ = factory._convert_to_fg_geometry(rhs_)
207
- fg_ ? @fg_geom.intersects?(fg_) : false
252
+ if fg_
253
+ prep_ = _request_prepared if FFIUtils.supports_prepared_level_1
254
+ prep_ ? prep_.intersects?(fg_) : @fg_geom.intersects?(fg_)
255
+ else
256
+ false
257
+ end
208
258
  end
209
-
210
-
259
+
260
+
211
261
  def touches?(rhs_)
212
262
  fg_ = factory._convert_to_fg_geometry(rhs_)
213
- fg_ ? @fg_geom.touches?(fg_) : false
263
+ if fg_
264
+ prep_ = _request_prepared if FFIUtils.supports_prepared_level_2
265
+ prep_ ? prep_.touches?(fg_) : @fg_geom.touches?(fg_)
266
+ else
267
+ false
268
+ end
214
269
  end
215
-
216
-
270
+
271
+
217
272
  def crosses?(rhs_)
218
273
  fg_ = factory._convert_to_fg_geometry(rhs_)
219
- fg_ ? @fg_geom.crosses?(fg_) : false
274
+ if fg_
275
+ prep_ = _request_prepared if FFIUtils.supports_prepared_level_2
276
+ prep_ ? prep_.crosses?(fg_) : @fg_geom.crosses?(fg_)
277
+ else
278
+ false
279
+ end
220
280
  end
221
-
222
-
281
+
282
+
223
283
  def within?(rhs_)
224
284
  fg_ = factory._convert_to_fg_geometry(rhs_)
225
- fg_ ? @fg_geom.within?(fg_) : false
285
+ if fg_
286
+ prep_ = _request_prepared if FFIUtils.supports_prepared_level_2
287
+ prep_ ? prep_.within?(fg_) : @fg_geom.within?(fg_)
288
+ else
289
+ false
290
+ end
226
291
  end
227
-
228
-
292
+
293
+
229
294
  def contains?(rhs_)
230
295
  fg_ = factory._convert_to_fg_geometry(rhs_)
231
- fg_ ? @fg_geom.contains?(fg_) : false
296
+ if fg_
297
+ prep_ = _request_prepared if FFIUtils.supports_prepared_level_1
298
+ prep_ ? prep_.contains?(fg_) : @fg_geom.contains?(fg_)
299
+ else
300
+ false
301
+ end
232
302
  end
233
-
234
-
303
+
304
+
235
305
  def overlaps?(rhs_)
236
306
  fg_ = factory._convert_to_fg_geometry(rhs_)
237
- fg_ ? @fg_geom.overlaps?(fg_) : false
307
+ if fg_
308
+ prep_ = _request_prepared if FFIUtils.supports_prepared_level_2
309
+ prep_ ? prep_.overlaps?(fg_) : @fg_geom.overlaps?(fg_)
310
+ else
311
+ false
312
+ end
238
313
  end
239
-
240
-
314
+
315
+
241
316
  def relate(rhs_, pattern_)
242
317
  fg_ = factory._convert_to_fg_geometry(rhs_)
243
318
  fg_ ? @fg_geom.relate_pattern(fg_, pattern_) : nil
244
319
  end
245
-
246
-
320
+
321
+
247
322
  def distance(rhs_)
248
323
  fg_ = factory._convert_to_fg_geometry(rhs_)
249
324
  fg_ ? @fg_geom.distance(fg_) : nil
250
325
  end
251
-
252
-
326
+
327
+
253
328
  def buffer(distance_)
254
329
  @factory.wrap_fg_geom(@fg_geom.buffer(distance_, @factory.buffer_resolution))
255
330
  end
256
-
257
-
331
+
332
+
258
333
  def convex_hull
259
334
  @factory.wrap_fg_geom(@fg_geom.convex_hull)
260
335
  end
261
-
262
-
336
+
337
+
263
338
  def intersection(rhs_)
264
339
  fg_ = factory._convert_to_fg_geometry(rhs_)
265
340
  fg_ ? @factory.wrap_fg_geom(@fg_geom.intersection(fg_)) : nil
266
341
  end
267
-
268
-
342
+
343
+
269
344
  def union(rhs_)
270
345
  fg_ = factory._convert_to_fg_geometry(rhs_)
271
346
  fg_ ? @factory.wrap_fg_geom(@fg_geom.union(fg_)) : nil
272
347
  end
273
-
274
-
348
+
349
+
275
350
  def difference(rhs_)
276
351
  fg_ = factory._convert_to_fg_geometry(rhs_)
277
352
  fg_ ? @factory.wrap_fg_geom(@fg_geom.difference(fg_)) : nil
278
353
  end
279
-
280
-
354
+
355
+
281
356
  def sym_difference(rhs_)
282
357
  fg_ = factory._convert_to_fg_geometry(rhs_)
283
358
  fg_ ? @factory.wrap_fg_geom(@fg_geom.sym_difference(fg_)) : nil
284
359
  end
285
-
286
-
360
+
361
+
287
362
  def _detach_fg_geom # :nodoc:
288
363
  fg_ = @fg_geom
289
364
  @fg_geom = nil
290
365
  fg_
291
366
  end
292
-
293
-
367
+
368
+
294
369
  end
295
-
296
-
370
+
371
+
297
372
  class FFIPointImpl < FFIGeometryImpl # :nodoc:
298
-
373
+
299
374
  Feature::MixinCollection::GLOBAL.for_type(Feature::Point).include_in_class(self)
300
-
301
-
375
+
376
+
302
377
  def x
303
378
  @fg_geom.coord_seq.get_x(0)
304
379
  end
305
-
306
-
380
+
381
+
307
382
  def y
308
383
  @fg_geom.coord_seq.get_y(0)
309
384
  end
310
-
311
-
385
+
386
+
312
387
  def z
313
388
  if @factory.property(:has_z_coordinate)
314
389
  @fg_geom.coord_seq.get_z(0)
@@ -316,8 +391,8 @@ module RGeo
316
391
  nil
317
392
  end
318
393
  end
319
-
320
-
394
+
395
+
321
396
  def m
322
397
  if @factory.property(:has_m_coordinate)
323
398
  @fg_geom.coord_seq.get_z(0)
@@ -325,44 +400,44 @@ module RGeo
325
400
  nil
326
401
  end
327
402
  end
328
-
329
-
403
+
404
+
330
405
  def geometry_type
331
406
  Feature::Point
332
407
  end
333
-
334
-
408
+
409
+
335
410
  def eql?(rhs_)
336
411
  rhs_.class == self.class && rhs_.factory.eql?(@factory) &&
337
412
  FFIUtils.coord_seqs_equal?(rhs_.fg_geom.coord_seq, @fg_geom.coord_seq, @factory._has_3d)
338
413
  end
339
-
340
-
414
+
415
+
341
416
  end
342
-
343
-
417
+
418
+
344
419
  class FFILineStringImpl < FFIGeometryImpl # :nodoc:
345
-
346
-
420
+
421
+
347
422
  Feature::MixinCollection::GLOBAL.for_type(Feature::Curve).include_in_class(self)
348
423
  Feature::MixinCollection::GLOBAL.for_type(Feature::LineString).include_in_class(self)
349
-
350
-
424
+
425
+
351
426
  def geometry_type
352
427
  Feature::LineString
353
428
  end
354
-
355
-
429
+
430
+
356
431
  def length
357
432
  @fg_geom.length
358
433
  end
359
-
360
-
434
+
435
+
361
436
  def num_points
362
437
  @fg_geom.num_points
363
438
  end
364
-
365
-
439
+
440
+
366
441
  def point_n(n_)
367
442
  if n_ >= 0 && n_ < @fg_geom.num_points
368
443
  coord_seq_ = @fg_geom.coord_seq
@@ -374,18 +449,18 @@ module RGeo
374
449
  nil
375
450
  end
376
451
  end
377
-
378
-
452
+
453
+
379
454
  def start_point
380
455
  point_n(0)
381
456
  end
382
-
383
-
457
+
458
+
384
459
  def end_point
385
460
  point_n(@fg_geom.num_points - 1)
386
461
  end
387
-
388
-
462
+
463
+
389
464
  def points
390
465
  coord_seq_ = @fg_geom.coord_seq
391
466
  has_3d_ = @factory._has_3d
@@ -396,92 +471,92 @@ module RGeo
396
471
  @factory.point(x_, y_, *extra_)
397
472
  end
398
473
  end
399
-
400
-
474
+
475
+
401
476
  def is_closed?
402
477
  @fg_geom.closed?
403
478
  end
404
-
405
-
479
+
480
+
406
481
  def is_ring?
407
482
  @fg_geom.ring?
408
483
  end
409
-
410
-
484
+
485
+
411
486
  def eql?(rhs_)
412
487
  rhs_.class == self.class && rhs_.factory.eql?(@factory) &&
413
488
  FFIUtils.coord_seqs_equal?(rhs_.fg_geom.coord_seq, @fg_geom.coord_seq, @factory._has_3d)
414
489
  end
415
-
416
-
490
+
491
+
417
492
  end
418
-
419
-
493
+
494
+
420
495
  class FFILinearRingImpl < FFILineStringImpl # :nodoc:
421
-
422
-
496
+
497
+
423
498
  Feature::MixinCollection::GLOBAL.for_type(Feature::LinearRing).include_in_class(self)
424
-
425
-
499
+
500
+
426
501
  def geometry_type
427
502
  Feature::LinearRing
428
503
  end
429
-
430
-
504
+
505
+
431
506
  end
432
-
433
-
507
+
508
+
434
509
  class FFILineImpl < FFILineStringImpl # :nodoc:
435
-
436
-
510
+
511
+
437
512
  Feature::MixinCollection::GLOBAL.for_type(Feature::Line).include_in_class(self)
438
-
439
-
513
+
514
+
440
515
  def geometry_type
441
516
  Feature::Line
442
517
  end
443
-
444
-
518
+
519
+
445
520
  end
446
-
447
-
521
+
522
+
448
523
  class FFIPolygonImpl < FFIGeometryImpl # :nodoc:
449
-
450
-
524
+
525
+
451
526
  Feature::MixinCollection::GLOBAL.for_type(Feature::Surface).include_in_class(self)
452
527
  Feature::MixinCollection::GLOBAL.for_type(Feature::Polygon).include_in_class(self)
453
-
454
-
528
+
529
+
455
530
  def geometry_type
456
531
  Feature::Polygon
457
532
  end
458
-
459
-
533
+
534
+
460
535
  def area
461
536
  @fg_geom.area
462
537
  end
463
-
464
-
538
+
539
+
465
540
  def centroid
466
541
  @factory.wrap_fg_geom(@fg_geom.centroid, FFIPointImpl)
467
542
  end
468
-
469
-
543
+
544
+
470
545
  def point_on_surface
471
546
  @factory.wrap_fg_geom(@fg_geom.point_on_surface, FFIPointImpl)
472
547
  end
473
-
474
-
548
+
549
+
475
550
  def exterior_ring
476
551
  @factory.wrap_fg_geom(@fg_geom.exterior_ring, FFILinearRingImpl)
477
552
  end
478
-
479
-
553
+
554
+
480
555
  def num_interior_rings
481
556
  @fg_geom.num_interior_rings
482
557
  end
483
-
484
-
558
+
559
+
485
560
  def interior_ring_n(n_)
486
561
  if n_ >= 0 && n_ < @fg_geom.num_interior_rings
487
562
  @factory.wrap_fg_geom(@fg_geom.interior_ring_n(n_), FFILinearRingImpl)
@@ -489,15 +564,15 @@ module RGeo
489
564
  nil
490
565
  end
491
566
  end
492
-
493
-
567
+
568
+
494
569
  def interior_rings
495
570
  ::Array.new(@fg_geom.num_interior_rings) do |n_|
496
571
  @factory.wrap_fg_geom(@fg_geom.interior_ring_n(n_), FFILinearRingImpl)
497
572
  end
498
573
  end
499
-
500
-
574
+
575
+
501
576
  def eql?(rhs_)
502
577
  if rhs_.class == self.class && rhs_.factory.eql?(@factory) &&
503
578
  rhs_.exterior_ring.eql?(self.exterior_ring)
@@ -513,22 +588,22 @@ module RGeo
513
588
  end
514
589
  false
515
590
  end
516
-
517
-
591
+
592
+
518
593
  end
519
-
520
-
594
+
595
+
521
596
  class FFIGeometryCollectionImpl < FFIGeometryImpl # :nodoc:
522
-
523
-
597
+
598
+
524
599
  Feature::MixinCollection::GLOBAL.for_type(Feature::GeometryCollection).include_in_class(self)
525
-
526
-
600
+
601
+
527
602
  def geometry_type
528
603
  Feature::GeometryCollection
529
604
  end
530
-
531
-
605
+
606
+
532
607
  def eql?(rhs_)
533
608
  if rhs_.class == self.class && rhs_.factory.eql?(@factory)
534
609
  size_ = @fg_geom.num_geometries
@@ -541,14 +616,14 @@ module RGeo
541
616
  end
542
617
  false
543
618
  end
544
-
545
-
619
+
620
+
546
621
  def num_geometries
547
622
  @fg_geom.num_geometries
548
623
  end
549
624
  alias_method :size, :num_geometries
550
-
551
-
625
+
626
+
552
627
  def geometry_n(n_)
553
628
  if n_ >= 0 && n_ < @fg_geom.num_geometries
554
629
  @factory.wrap_fg_geom(@fg_geom.get_geometry_n(n_),
@@ -557,8 +632,8 @@ module RGeo
557
632
  nil
558
633
  end
559
634
  end
560
-
561
-
635
+
636
+
562
637
  def [](n_)
563
638
  n_ += @fg_geom.num_geometries if n_ < 0
564
639
  if n_ >= 0 && n_ < @fg_geom.num_geometries
@@ -568,52 +643,52 @@ module RGeo
568
643
  nil
569
644
  end
570
645
  end
571
-
572
-
646
+
647
+
573
648
  def each
574
649
  @fg_geom.num_geometries.times do |n_|
575
650
  yield @factory.wrap_fg_geom(@fg_geom.get_geometry_n(n_),
576
651
  @_klasses ? @_klasses[n_] : nil)
577
652
  end
578
653
  end
579
-
654
+
580
655
  include ::Enumerable
581
-
582
-
656
+
657
+
583
658
  end
584
-
585
-
659
+
660
+
586
661
  class FFIMultiPointImpl < FFIGeometryCollectionImpl # :nodoc:
587
-
588
-
662
+
663
+
589
664
  Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPoint).include_in_class(self)
590
-
591
-
665
+
666
+
592
667
  def geometry_type
593
668
  Feature::MultiPoint
594
669
  end
595
-
596
-
670
+
671
+
597
672
  end
598
-
599
-
673
+
674
+
600
675
  class FFIMultiLineStringImpl < FFIGeometryCollectionImpl # :nodoc:
601
-
602
-
676
+
677
+
603
678
  Feature::MixinCollection::GLOBAL.for_type(Feature::MultiCurve).include_in_class(self)
604
679
  Feature::MixinCollection::GLOBAL.for_type(Feature::MultiLineString).include_in_class(self)
605
-
606
-
680
+
681
+
607
682
  def geometry_type
608
683
  Feature::MultiLineString
609
684
  end
610
-
611
-
685
+
686
+
612
687
  def length
613
688
  @fg_geom.length
614
689
  end
615
-
616
-
690
+
691
+
617
692
  def is_closed?
618
693
  size_ = num_geometries
619
694
  size_.times do |n_|
@@ -621,41 +696,41 @@ module RGeo
621
696
  end
622
697
  true
623
698
  end
624
-
625
-
699
+
700
+
626
701
  end
627
-
628
-
702
+
703
+
629
704
  class FFIMultiPolygonImpl < FFIGeometryCollectionImpl # :nodoc:
630
-
631
-
705
+
706
+
632
707
  Feature::MixinCollection::GLOBAL.for_type(Feature::MultiSurface).include_in_class(self)
633
708
  Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPolygon).include_in_class(self)
634
-
635
-
709
+
710
+
636
711
  def geometry_type
637
712
  Feature::MultiPolygon
638
713
  end
639
-
640
-
714
+
715
+
641
716
  def area
642
717
  @fg_geom.area
643
718
  end
644
-
645
-
719
+
720
+
646
721
  def centroid
647
722
  @factory.wrap_fg_geom(@fg_geom.centroid, FFIPointImpl)
648
723
  end
649
-
650
-
724
+
725
+
651
726
  def point_on_surface
652
727
  @factory.wrap_fg_geom(@fg_geom.point_on_surface, FFIPointImpl)
653
728
  end
654
-
655
-
729
+
730
+
656
731
  end
657
-
658
-
732
+
733
+
659
734
  end
660
-
735
+
661
736
  end