rgeo-dschee 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +29 -0
  3. data/ext/geos_c_impl/coordinates.c +65 -0
  4. data/ext/geos_c_impl/coordinates.h +2 -0
  5. data/ext/geos_c_impl/extconf.rb +43 -0
  6. data/ext/geos_c_impl/factory.c +995 -0
  7. data/ext/geos_c_impl/factory.h +238 -0
  8. data/ext/geos_c_impl/geometry.c +1093 -0
  9. data/ext/geos_c_impl/geometry.h +23 -0
  10. data/ext/geos_c_impl/geometry_collection.c +757 -0
  11. data/ext/geos_c_impl/geometry_collection.h +46 -0
  12. data/ext/geos_c_impl/line_string.c +675 -0
  13. data/ext/geos_c_impl/line_string.h +32 -0
  14. data/ext/geos_c_impl/main.c +40 -0
  15. data/ext/geos_c_impl/point.c +236 -0
  16. data/ext/geos_c_impl/point.h +30 -0
  17. data/ext/geos_c_impl/polygon.c +359 -0
  18. data/ext/geos_c_impl/polygon.h +43 -0
  19. data/ext/geos_c_impl/preface.h +38 -0
  20. data/ext/proj4_c_impl/extconf.rb +62 -0
  21. data/ext/proj4_c_impl/main.c +315 -0
  22. data/lib/rgeo.rb +89 -0
  23. data/lib/rgeo/cartesian.rb +25 -0
  24. data/lib/rgeo/cartesian/analysis.rb +77 -0
  25. data/lib/rgeo/cartesian/bounding_box.rb +398 -0
  26. data/lib/rgeo/cartesian/calculations.rb +113 -0
  27. data/lib/rgeo/cartesian/factory.rb +347 -0
  28. data/lib/rgeo/cartesian/feature_classes.rb +100 -0
  29. data/lib/rgeo/cartesian/feature_methods.rb +88 -0
  30. data/lib/rgeo/cartesian/interface.rb +135 -0
  31. data/lib/rgeo/coord_sys.rb +43 -0
  32. data/lib/rgeo/coord_sys/cs/entities.rb +1315 -0
  33. data/lib/rgeo/coord_sys/cs/factories.rb +148 -0
  34. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +272 -0
  35. data/lib/rgeo/coord_sys/proj4.rb +293 -0
  36. data/lib/rgeo/coord_sys/srs_database/interface.rb +115 -0
  37. data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +140 -0
  38. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +62 -0
  39. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +63 -0
  40. data/lib/rgeo/error.rb +27 -0
  41. data/lib/rgeo/feature.rb +54 -0
  42. data/lib/rgeo/feature/curve.rb +111 -0
  43. data/lib/rgeo/feature/factory.rb +278 -0
  44. data/lib/rgeo/feature/factory_generator.rb +96 -0
  45. data/lib/rgeo/feature/geometry.rb +624 -0
  46. data/lib/rgeo/feature/geometry_collection.rb +95 -0
  47. data/lib/rgeo/feature/line.rb +26 -0
  48. data/lib/rgeo/feature/line_string.rb +60 -0
  49. data/lib/rgeo/feature/linear_ring.rb +26 -0
  50. data/lib/rgeo/feature/mixins.rb +143 -0
  51. data/lib/rgeo/feature/multi_curve.rb +71 -0
  52. data/lib/rgeo/feature/multi_line_string.rb +26 -0
  53. data/lib/rgeo/feature/multi_point.rb +33 -0
  54. data/lib/rgeo/feature/multi_polygon.rb +57 -0
  55. data/lib/rgeo/feature/multi_surface.rb +73 -0
  56. data/lib/rgeo/feature/point.rb +84 -0
  57. data/lib/rgeo/feature/polygon.rb +97 -0
  58. data/lib/rgeo/feature/surface.rb +79 -0
  59. data/lib/rgeo/feature/types.rb +284 -0
  60. data/lib/rgeo/geographic.rb +40 -0
  61. data/lib/rgeo/geographic/factory.rb +450 -0
  62. data/lib/rgeo/geographic/interface.rb +489 -0
  63. data/lib/rgeo/geographic/proj4_projector.rb +58 -0
  64. data/lib/rgeo/geographic/projected_feature_classes.rb +107 -0
  65. data/lib/rgeo/geographic/projected_feature_methods.rb +212 -0
  66. data/lib/rgeo/geographic/projected_window.rb +383 -0
  67. data/lib/rgeo/geographic/simple_mercator_projector.rb +110 -0
  68. data/lib/rgeo/geographic/spherical_feature_classes.rb +100 -0
  69. data/lib/rgeo/geographic/spherical_feature_methods.rb +134 -0
  70. data/lib/rgeo/geographic/spherical_math.rb +188 -0
  71. data/lib/rgeo/geos.rb +89 -0
  72. data/lib/rgeo/geos/capi_factory.rb +470 -0
  73. data/lib/rgeo/geos/capi_feature_classes.rb +129 -0
  74. data/lib/rgeo/geos/ffi_factory.rb +592 -0
  75. data/lib/rgeo/geos/ffi_feature_classes.rb +83 -0
  76. data/lib/rgeo/geos/ffi_feature_methods.rb +574 -0
  77. data/lib/rgeo/geos/interface.rb +202 -0
  78. data/lib/rgeo/geos/utils.rb +74 -0
  79. data/lib/rgeo/geos/zm_factory.rb +405 -0
  80. data/lib/rgeo/geos/zm_feature_classes.rb +80 -0
  81. data/lib/rgeo/geos/zm_feature_methods.rb +344 -0
  82. data/lib/rgeo/impl_helper.rb +19 -0
  83. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +185 -0
  84. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +61 -0
  85. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +146 -0
  86. data/lib/rgeo/impl_helper/basic_point_methods.rb +104 -0
  87. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +87 -0
  88. data/lib/rgeo/impl_helper/math.rb +14 -0
  89. data/lib/rgeo/impl_helper/utils.rb +29 -0
  90. data/lib/rgeo/version.rb +3 -0
  91. data/lib/rgeo/wkrep.rb +37 -0
  92. data/lib/rgeo/wkrep/wkb_generator.rb +201 -0
  93. data/lib/rgeo/wkrep/wkb_parser.rb +251 -0
  94. data/lib/rgeo/wkrep/wkt_generator.rb +207 -0
  95. data/lib/rgeo/wkrep/wkt_parser.rb +415 -0
  96. data/lib/rgeo/yaml.rb +23 -0
  97. data/test/cartesian_analysis_test.rb +65 -0
  98. data/test/cartesian_bbox_test.rb +123 -0
  99. data/test/common/factory_tests.rb +78 -0
  100. data/test/common/geometry_collection_tests.rb +237 -0
  101. data/test/common/line_string_tests.rb +330 -0
  102. data/test/common/multi_line_string_tests.rb +182 -0
  103. data/test/common/multi_point_tests.rb +200 -0
  104. data/test/common/multi_polygon_tests.rb +191 -0
  105. data/test/common/point_tests.rb +370 -0
  106. data/test/common/polygon_tests.rb +261 -0
  107. data/test/coord_sys/ogc_cs_test.rb +342 -0
  108. data/test/coord_sys/proj4_srs_data_test.rb +41 -0
  109. data/test/coord_sys/proj4_test.rb +150 -0
  110. data/test/coord_sys/sr_org_test.rb +32 -0
  111. data/test/coord_sys/url_reader_test.rb +42 -0
  112. data/test/geos_capi/factory_test.rb +31 -0
  113. data/test/geos_capi/geometry_collection_test.rb +24 -0
  114. data/test/geos_capi/line_string_test.rb +24 -0
  115. data/test/geos_capi/misc_test.rb +116 -0
  116. data/test/geos_capi/multi_line_string_test.rb +24 -0
  117. data/test/geos_capi/multi_point_test.rb +24 -0
  118. data/test/geos_capi/multi_polygon_test.rb +39 -0
  119. data/test/geos_capi/parsing_unparsing_test.rb +40 -0
  120. data/test/geos_capi/point_test.rb +72 -0
  121. data/test/geos_capi/polygon_test.rb +154 -0
  122. data/test/geos_capi/zmfactory_test.rb +57 -0
  123. data/test/geos_ffi/factory_test.rb +31 -0
  124. data/test/geos_ffi/geometry_collection_test.rb +24 -0
  125. data/test/geos_ffi/line_string_test.rb +24 -0
  126. data/test/geos_ffi/misc_test.rb +63 -0
  127. data/test/geos_ffi/multi_line_string_test.rb +24 -0
  128. data/test/geos_ffi/multi_point_test.rb +24 -0
  129. data/test/geos_ffi/multi_polygon_test.rb +33 -0
  130. data/test/geos_ffi/parsing_unparsing_test.rb +41 -0
  131. data/test/geos_ffi/point_test.rb +77 -0
  132. data/test/geos_ffi/polygon_test.rb +46 -0
  133. data/test/geos_ffi/zmfactory_test.rb +58 -0
  134. data/test/mixins_test.rb +141 -0
  135. data/test/oneoff_test.rb +26 -0
  136. data/test/projected_geographic/factory_test.rb +25 -0
  137. data/test/projected_geographic/geometry_collection_test.rb +24 -0
  138. data/test/projected_geographic/line_string_test.rb +24 -0
  139. data/test/projected_geographic/multi_line_string_test.rb +26 -0
  140. data/test/projected_geographic/multi_point_test.rb +30 -0
  141. data/test/projected_geographic/multi_polygon_test.rb +25 -0
  142. data/test/projected_geographic/point_test.rb +51 -0
  143. data/test/projected_geographic/polygon_test.rb +24 -0
  144. data/test/simple_cartesian/calculations_test.rb +99 -0
  145. data/test/simple_cartesian/factory_test.rb +27 -0
  146. data/test/simple_cartesian/geometry_collection_test.rb +30 -0
  147. data/test/simple_cartesian/line_string_test.rb +31 -0
  148. data/test/simple_cartesian/multi_line_string_test.rb +28 -0
  149. data/test/simple_cartesian/multi_point_test.rb +31 -0
  150. data/test/simple_cartesian/multi_polygon_test.rb +31 -0
  151. data/test/simple_cartesian/point_test.rb +50 -0
  152. data/test/simple_cartesian/polygon_test.rb +28 -0
  153. data/test/simple_mercator/factory_test.rb +25 -0
  154. data/test/simple_mercator/geometry_collection_test.rb +24 -0
  155. data/test/simple_mercator/line_string_test.rb +24 -0
  156. data/test/simple_mercator/multi_line_string_test.rb +26 -0
  157. data/test/simple_mercator/multi_point_test.rb +29 -0
  158. data/test/simple_mercator/multi_polygon_test.rb +25 -0
  159. data/test/simple_mercator/point_test.rb +55 -0
  160. data/test/simple_mercator/polygon_test.rb +24 -0
  161. data/test/simple_mercator/window_test.rb +173 -0
  162. data/test/spherical_geographic/calculations_test.rb +167 -0
  163. data/test/spherical_geographic/factory_test.rb +27 -0
  164. data/test/spherical_geographic/geometry_collection_test.rb +31 -0
  165. data/test/spherical_geographic/line_string_test.rb +31 -0
  166. data/test/spherical_geographic/multi_line_string_test.rb +29 -0
  167. data/test/spherical_geographic/multi_point_test.rb +31 -0
  168. data/test/spherical_geographic/multi_polygon_test.rb +31 -0
  169. data/test/spherical_geographic/point_test.rb +78 -0
  170. data/test/spherical_geographic/polygon_test.rb +28 -0
  171. data/test/types_test.rb +42 -0
  172. data/test/wkrep/wkb_generator_test.rb +185 -0
  173. data/test/wkrep/wkb_parser_test.rb +293 -0
  174. data/test/wkrep/wkt_generator_test.rb +294 -0
  175. data/test/wkrep/wkt_parser_test.rb +412 -0
  176. metadata +386 -0
@@ -0,0 +1,624 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Geometry feature interface
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+
7
+ module RGeo
8
+ module Feature
9
+ # == SFS 1.1 Description
10
+ #
11
+ # Geometry is the root class of the hierarchy. Geometry is an abstract
12
+ # (non-instantiable) class.
13
+ #
14
+ # The instantiable subclasses of Geometry defined in this International
15
+ # Standard are restricted to 0, 1 and 2-dimensional geometric objects
16
+ # that exist in 2-dimensional coordinate space (R2).
17
+ #
18
+ # All instantiable Geometry classes described in this part of ISO 19125
19
+ # are defined so that valid instances of a Geometry class are
20
+ # topologically closed, i.e. all defined geometries include their
21
+ # boundary.
22
+ #
23
+ # == Notes
24
+ #
25
+ # Geometry is defined as a module and is provided primarily for the
26
+ # sake of documentation. Implementations need not necessarily include
27
+ # this module itself. Therefore, you should not depend on the result
28
+ # of <tt>is_a?(Geometry)</tt> to check type. Instead, use the
29
+ # provided check_type class method (or === operator) defined in the
30
+ # Type module.
31
+ #
32
+ # Some implementations may support higher dimensional objects or
33
+ # coordinate systems, despite the limits of the SFS.
34
+ #
35
+ # == Forms of equivalence
36
+ #
37
+ # The Geometry model defines three forms of equivalence.
38
+ #
39
+ # * <b>Spatial equivalence</b> is the weakest form of equivalence,
40
+ # indicating that the objects represent the same region of space,
41
+ # but may be different representations of that region. For example,
42
+ # POINT(0 0) and a MULTIPOINT(0 0) are spatially equivalent, as are
43
+ # LINESTRING(0 0, 10 10) and
44
+ # GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0, 10 10, 0 0)).
45
+ # As a general rule, objects must have factories that are
46
+ # Factory#eql? in order to be spatially equivalent.
47
+ #
48
+ # * <b>Representational equivalence</b> is a stronger form, indicating
49
+ # that the objects have the same representation, but may be
50
+ # different objects. All representationally equivalent objects are
51
+ # spatially equivalent, but not all spatially equivalent objects are
52
+ # representationally equivalent. For example, none of the examples
53
+ # in the spatial equivalence section above are representationally
54
+ # equivalent. However, two separate objects that both represent
55
+ # POINT(1 2) are representationally equivalent as well as spatially
56
+ # equivalent.
57
+ #
58
+ # * <b>Objective equivalence</b> is the strongest form, indicating
59
+ # that the references refer to the same object. Of course, all
60
+ # pairs of references with the same objective identity are also
61
+ # both representationally and spatially equivalent.
62
+ #
63
+ # Different methods test for different types of equivalence:
64
+ #
65
+ # * <tt>equals?</tt> and <tt>==</tt> test for spatial equivalence.
66
+ # * <tt>rep_equals?</tt> and <tt>eql?</tt> test for representational
67
+ # equivalence.
68
+ # * <tt>equal?</tt> tests for objective equivalence.
69
+ #
70
+ # All ruby objects must provide a suitable test for objective
71
+ # equivalence. Normally, this is simply provided by the Ruby Object
72
+ # base class. Geometry implementations should normally also provide
73
+ # tests for representational and spatial equivalence, if possible.
74
+ # The <tt>==</tt> operator and the <tt>eql?</tt> method are standard
75
+ # Ruby methods that are often expected to be usable for every object.
76
+ # Therefore, if an implementation cannot provide a suitable test for
77
+ # their equivalence types, they must degrade to use a stronger form
78
+ # of equivalence.
79
+
80
+ module Geometry
81
+ extend Type
82
+
83
+ # Returns a factory for creating features related to this one.
84
+ # This does not necessarily need to be the same factory that created
85
+ # this object, but it should create objects that are "compatible"
86
+ # with this one. (i.e. they should be in the same spatial reference
87
+ # system by default, and it should be possible to perform relational
88
+ # operations on them.)
89
+
90
+ def factory
91
+ raise Error::UnsupportedOperation, "Method Geometry#factory not defined."
92
+ end
93
+
94
+ # === SFS 1.1 Description
95
+ #
96
+ # The inherent dimension of this geometric object, which must be less
97
+ # than or equal to the coordinate dimension. This specification is
98
+ # restricted to geometries in 2-dimensional coordinate space.
99
+ #
100
+ # === Notes
101
+ #
102
+ # Returns an integer. This value is -1 for an empty geometry, 0 for
103
+ # point geometries, 1 for curves, and 2 for surfaces.
104
+
105
+ def dimension
106
+ raise Error::UnsupportedOperation, "Method Geometry#dimension not defined."
107
+ end
108
+
109
+ # === SFS 1.1 Description
110
+ #
111
+ # Returns the instantiable subtype of Geometry of which this
112
+ # geometric object is an instantiable member.
113
+ #
114
+ # === Notes
115
+ #
116
+ # Returns one of the type modules in RGeo::Feature. e.g. a point
117
+ # object would return RGeo::Feature::Point. Note that this is
118
+ # different from the SFS specification, which stipulates that the
119
+ # string name of the type is returned. To obtain the name string,
120
+ # call the +type_name+ method of the returned module.
121
+
122
+ def geometry_type
123
+ raise Error::UnsupportedOperation, "Method Geometry#geometry_type not defined."
124
+ end
125
+
126
+ # === SFS 1.1 Description
127
+ #
128
+ # Returns the Spatial Reference System ID for this geometric object.
129
+ #
130
+ # === Notes
131
+ #
132
+ # Returns an integer.
133
+ #
134
+ # This will normally be a foreign key to an index of reference systems
135
+ # stored in either the same or some other datastore.
136
+
137
+ def srid
138
+ raise Error::UnsupportedOperation, "Method Geometry#srid not defined."
139
+ end
140
+
141
+ # === SFS 1.1 Description
142
+ #
143
+ # The minimum bounding box for this Geometry, returned as a Geometry.
144
+ # The polygon is defined by the corner points of the bounding box
145
+ # [(MINX, MINY), (MAXX, MINY), (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)].
146
+ #
147
+ # === Notes
148
+ #
149
+ # Returns an object that supports the Geometry interface.
150
+
151
+ def envelope
152
+ raise Error::UnsupportedOperation, "Method Geometry#envelope not defined."
153
+ end
154
+
155
+ # === SFS 1.1 Description
156
+ #
157
+ # Exports this geometric object to a specific Well-known Text
158
+ # Representation of Geometry.
159
+ #
160
+ # === Notes
161
+ #
162
+ # Returns an ASCII string.
163
+
164
+ def as_text
165
+ raise Error::UnsupportedOperation, "Method Geometry#as_text not defined."
166
+ end
167
+
168
+ # === SFS 1.1 Description
169
+ #
170
+ # Exports this geometric object to a specific Well-known Binary
171
+ # Representation of Geometry.
172
+ #
173
+ # === Notes
174
+ #
175
+ # Returns a binary string.
176
+
177
+ def as_binary
178
+ raise Error::UnsupportedOperation, "Method Geometry#as_binary not defined."
179
+ end
180
+
181
+ # === SFS 1.1 Description
182
+ #
183
+ # Returns true if this geometric object is the empty Geometry. If true,
184
+ # then this geometric object represents the empty point set for the
185
+ # coordinate space.
186
+ #
187
+ # === Notes
188
+ #
189
+ # Returns a boolean value. Note that this is different from the SFS
190
+ # specification, which stipulates an integer return value.
191
+
192
+ def is_empty?
193
+ raise Error::UnsupportedOperation, "Method Geometry#is_empty? not defined."
194
+ end
195
+
196
+ # === SFS 1.1 Description
197
+ #
198
+ # Returns true if this geometric object has no anomalous geometric
199
+ # points, such as self intersection or self tangency. The description
200
+ # of each instantiable geometric class will include the specific
201
+ # conditions that cause an instance of that class to be classified as
202
+ # not simple.
203
+ #
204
+ # === Notes
205
+ #
206
+ # Returns a boolean value. Note that this is different from the SFS
207
+ # specification, which stipulates an integer return value.
208
+
209
+ def is_simple?
210
+ raise Error::UnsupportedOperation, "Method Geometry#is_simple? not defined."
211
+ end
212
+
213
+ # === SFS 1.1 Description
214
+ #
215
+ # Returns the closure of the combinatorial boundary of this geometric
216
+ # object. Because the result of this function is a closure, and hence
217
+ # topologically closed, the resulting boundary can be represented using
218
+ # representational Geometry primitives.
219
+ #
220
+ # === Notes
221
+ #
222
+ # Returns an object that supports the Geometry interface.
223
+
224
+ def boundary
225
+ raise Error::UnsupportedOperation, "Method Geometry#boundary not defined."
226
+ end
227
+
228
+ # === SFS 1.1 Description
229
+ #
230
+ # Returns true if this geometric object is "spatially equal" to
231
+ # another_geometry.
232
+ #
233
+ # === Notes
234
+ #
235
+ # Returns a boolean value. Note that this is different from the SFS
236
+ # specification, which stipulates an integer return value.
237
+ #
238
+ # Although implementations are free to attempt to handle
239
+ # another_geometry values that do not share the same factory as
240
+ # this geometry, strictly speaking, the result of comparing objects
241
+ # from different factories is undefined.
242
+
243
+ def equals?(_another_geometry_)
244
+ raise Error::UnsupportedOperation, "Method Geometry#equals? not defined."
245
+ end
246
+
247
+ # === SFS 1.1 Description
248
+ #
249
+ # Returns true if this geometric object is "spatially disjoint" from
250
+ # another_geometry.
251
+ #
252
+ # === Notes
253
+ #
254
+ # Returns a boolean value. Note that this is different from the SFS
255
+ # specification, which stipulates an integer return value.
256
+ #
257
+ # Although implementations are free to attempt to handle
258
+ # another_geometry values that do not share the same factory as
259
+ # this geometry, strictly speaking, the result of comparing objects
260
+ # from different factories is undefined.
261
+
262
+ def disjoint?(_another_geometry_)
263
+ raise Error::UnsupportedOperation, "Method Geometry#disjoint? not defined."
264
+ end
265
+
266
+ # === SFS 1.1 Description
267
+ #
268
+ # Returns true if this geometric object "spatially intersects"
269
+ # another_geometry.
270
+ #
271
+ # === Notes
272
+ #
273
+ # Returns a boolean value. Note that this is different from the SFS
274
+ # specification, which stipulates an integer return value.
275
+ #
276
+ # Although implementations are free to attempt to handle
277
+ # another_geometry values that do not share the same factory as
278
+ # this geometry, strictly speaking, the result of comparing objects
279
+ # from different factories is undefined.
280
+
281
+ def intersects?(_another_geometry_)
282
+ raise Error::UnsupportedOperation, "Method Geometry#intersects? not defined."
283
+ end
284
+
285
+ # === SFS 1.1 Description
286
+ #
287
+ # Returns true if this geometric object "spatially touches"
288
+ # another_geometry.
289
+ #
290
+ # === Notes
291
+ #
292
+ # Returns a boolean value. Note that this is different from the SFS
293
+ # specification, which stipulates an integer return value.
294
+ #
295
+ # Although implementations are free to attempt to handle
296
+ # another_geometry values that do not share the same factory as
297
+ # this geometry, strictly speaking, the result of comparing objects
298
+ # from different factories is undefined.
299
+
300
+ def touches?(_another_geometry_)
301
+ raise Error::UnsupportedOperation, "Method Geometry#touches? not defined."
302
+ end
303
+
304
+ # === SFS 1.1 Description
305
+ #
306
+ # Returns true if this geometric object "spatially crosses"
307
+ # another_geometry.
308
+ #
309
+ # === Notes
310
+ #
311
+ # Returns a boolean value. Note that this is different from the SFS
312
+ # specification, which stipulates an integer return value.
313
+ #
314
+ # Although implementations are free to attempt to handle
315
+ # another_geometry values that do not share the same factory as
316
+ # this geometry, strictly speaking, the result of comparing objects
317
+ # from different factories is undefined.
318
+
319
+ def crosses?(_another_geometry_)
320
+ raise Error::UnsupportedOperation, "Method Geometry#crosses? not defined."
321
+ end
322
+
323
+ # === SFS 1.1 Description
324
+ #
325
+ # Returns true if this geometric object is "spatially within"
326
+ # another_geometry.
327
+ #
328
+ # === Notes
329
+ #
330
+ # Returns a boolean value. Note that this is different from the SFS
331
+ # specification, which stipulates an integer return value.
332
+ #
333
+ # Although implementations are free to attempt to handle
334
+ # another_geometry values that do not share the same factory as
335
+ # this geometry, strictly speaking, the result of comparing objects
336
+ # from different factories is undefined.
337
+
338
+ def within?(_another_geometry_)
339
+ raise Error::UnsupportedOperation, "Method Geometry#within? not defined."
340
+ end
341
+
342
+ # === SFS 1.1 Description
343
+ #
344
+ # Returns true if this geometric object "spatially contains"
345
+ # another_geometry.
346
+ #
347
+ # === Notes
348
+ #
349
+ # Returns a boolean value. Note that this is different from the SFS
350
+ # specification, which stipulates an integer return value.
351
+ #
352
+ # Although implementations are free to attempt to handle
353
+ # another_geometry values that do not share the same factory as
354
+ # this geometry, strictly speaking, the result of comparing objects
355
+ # from different factories is undefined.
356
+
357
+ def contains?(_another_geometry_)
358
+ raise Error::UnsupportedOperation, "Method Geometry#contains? not defined."
359
+ end
360
+
361
+ # === SFS 1.1 Description
362
+ #
363
+ # Returns true if this geometric object "spatially overlaps"
364
+ # another_geometry.
365
+ #
366
+ # === Notes
367
+ #
368
+ # Returns a boolean value. Note that this is different from the SFS
369
+ # specification, which stipulates an integer return value.
370
+ #
371
+ # Although implementations are free to attempt to handle
372
+ # another_geometry values that do not share the same factory as
373
+ # this geometry, strictly speaking, the result of comparing objects
374
+ # from different factories is undefined.
375
+
376
+ def overlaps?(_another_geometry_)
377
+ raise Error::UnsupportedOperation, "Method Geometry#overlaps? not defined."
378
+ end
379
+
380
+ # === SFS 1.1 Description
381
+ #
382
+ # Returns true if this geometric object is spatially related to
383
+ # another_geometry by testing for intersections between the interior,
384
+ # boundary and exterior of the two geometric objects as specified by
385
+ # the values in the intersection_pattern_matrix.
386
+ #
387
+ # === Notes
388
+ #
389
+ # The intersection_pattern_matrix is provided as a nine-character
390
+ # string in row-major order, representing the dimensionalities of
391
+ # the different intersections in the DE-9IM. Supported characters
392
+ # include T, F, *, 0, 1, and 2.
393
+ #
394
+ # Returns a boolean value. Note that this is different from the SFS
395
+ # specification, which stipulates an integer return value.
396
+ #
397
+ # Although implementations are free to attempt to handle
398
+ # another_geometry values that do not share the same factory as
399
+ # this geometry, strictly speaking, the result of comparing objects
400
+ # from different factories is undefined.
401
+
402
+ def relate?(_another_geometry_, _intersection_pattern_matrix_)
403
+ raise Error::UnsupportedOperation, "Method Geometry#relate not defined."
404
+ end
405
+
406
+ # Deprecated alias of Geometry#relate?
407
+
408
+ def relate(another_geometry_, intersection_pattern_matrix_)
409
+ relate?(another_geometry_, intersection_pattern_matrix_)
410
+ end
411
+
412
+ # === SFS 1.1 Description
413
+ #
414
+ # Returns the shortest distance between any two Points in the two
415
+ # geometric objects as calculated in the spatial reference system of
416
+ # this geometric object.
417
+ #
418
+ # === Notes
419
+ #
420
+ # Returns a floating-point scalar value.
421
+ #
422
+ # Although implementations are free to attempt to handle
423
+ # another_geometry values that do not share the same factory as
424
+ # this geometry, strictly speaking, the result of measuring the
425
+ # distance between objects from different factories is undefined.
426
+
427
+ def distance(_another_geometry_)
428
+ raise Error::UnsupportedOperation, "Method Geometry#distance not defined."
429
+ end
430
+
431
+ # === SFS 1.1 Description
432
+ #
433
+ # Returns a geometric object that represents all Points whose distance
434
+ # from this geometric object is less than or equal to distance.
435
+ # Calculations are in the spatial reference system of this geometric
436
+ # object.
437
+ #
438
+ # === Notes
439
+ #
440
+ # Returns an object that supports the Geometry interface.
441
+
442
+ def buffer(_distance_)
443
+ raise Error::UnsupportedOperation, "Method Geometry#buffer not defined."
444
+ end
445
+
446
+ # === SFS 1.1 Description
447
+ #
448
+ # Returns a geometric object that represents the convex hull of this
449
+ # geometric object.
450
+ #
451
+ # === Notes
452
+ #
453
+ # Returns an object that supports the Geometry interface.
454
+
455
+ def convex_hull
456
+ raise Error::UnsupportedOperation, "Method Geometry#convex_hull not defined."
457
+ end
458
+
459
+ # === SFS 1.1 Description
460
+ #
461
+ # Returns a geometric object that represents the Point set
462
+ # intersection of this geometric object with another_geometry.
463
+ #
464
+ # === Notes
465
+ #
466
+ # Returns an object that supports the Geometry interface.
467
+ #
468
+ # Although implementations are free to attempt to handle
469
+ # another_geometry values that do not share the same factory as
470
+ # this geometry, strictly speaking, the result of performing
471
+ # operations on objects from different factories is undefined.
472
+
473
+ def intersection(_another_geometry_)
474
+ raise Error::UnsupportedOperation, "Method Geometry#intersection not defined."
475
+ end
476
+
477
+ # === SFS 1.1 Description
478
+ #
479
+ # Returns a geometric object that represents the Point set
480
+ # union of this geometric object with another_geometry.
481
+ #
482
+ # === Notes
483
+ #
484
+ # Returns an object that supports the Geometry interface.
485
+ #
486
+ # Although implementations are free to attempt to handle
487
+ # another_geometry values that do not share the same factory as
488
+ # this geometry, strictly speaking, the result of performing
489
+ # operations on objects from different factories is undefined.
490
+
491
+ def union(_another_geometry_)
492
+ raise Error::UnsupportedOperation, "Method Geometry#union not defined."
493
+ end
494
+
495
+ # === SFS 1.1 Description
496
+ #
497
+ # Returns a geometric object that represents the Point set
498
+ # difference of this geometric object with another_geometry.
499
+ #
500
+ # === Notes
501
+ #
502
+ # Returns an object that supports the Geometry interface.
503
+ #
504
+ # Although implementations are free to attempt to handle
505
+ # another_geometry values that do not share the same factory as
506
+ # this geometry, strictly speaking, the result of performing
507
+ # operations on objects from different factories is undefined.
508
+
509
+ def difference(_another_geometry_)
510
+ raise Error::UnsupportedOperation, "Method Geometry#difference not defined."
511
+ end
512
+
513
+ # === SFS 1.1 Description
514
+ #
515
+ # Returns a geometric object that represents the Point set symmetric
516
+ # difference of this geometric object with another_geometry.
517
+ #
518
+ # === Notes
519
+ #
520
+ # Returns an object that supports the Geometry interface.
521
+ #
522
+ # Although implementations are free to attempt to handle
523
+ # another_geometry values that do not share the same factory as
524
+ # this geometry, strictly speaking, the result of performing
525
+ # operations on objects from different factories is undefined.
526
+
527
+ def sym_difference(_another_geometry_)
528
+ raise Error::UnsupportedOperation, "Method Geometry#sym_difference not defined."
529
+ end
530
+
531
+ # Returns true if this geometric object is representationally
532
+ # equivalent to the given object.
533
+ #
534
+ # Although implementations are free to attempt to handle
535
+ # another_geometry values that do not share the same factory as
536
+ # this geometry, strictly speaking, the result of comparing objects
537
+ # from different factories is undefined.
538
+
539
+ def rep_equals?(_another_geometry_)
540
+ raise Error::UnsupportedOperation, "Method Geometry#rep_equals? not defined."
541
+ end
542
+
543
+ # This method should behave almost the same as the rep_equals?
544
+ # method, with two key differences.
545
+ #
546
+ # First, the <tt>eql?</tt> method is required to handle rhs values
547
+ # that are not geometry objects (returning false in such cases) in
548
+ # order to fulfill the standard Ruby contract for the method,
549
+ # whereas the rep_equals? method may assume that any rhs is a
550
+ # geometry.
551
+ #
552
+ # Second, the <tt>eql?</tt> method should always be defined. That
553
+ # is, it should never raise Error::UnsupportedOperation. In cases
554
+ # where the underlying implementation cannot provide a
555
+ # representational equivalence test, this method must fall back on
556
+ # objective equivalence.
557
+
558
+ def eql?(rhs_)
559
+ if rhs_.is_a?(::RGeo::Feature::Instance)
560
+ begin
561
+ rep_equals?(rhs_)
562
+ rescue Error::UnsupportedOperation
563
+ equal?(rhs_)
564
+ end
565
+ else
566
+ false
567
+ end
568
+ end
569
+
570
+ # This operator should behave almost the same as the equals? method,
571
+ # with two key differences.
572
+ #
573
+ # First, the == operator is required to handle rhs values that are
574
+ # not geometry objects (returning false in such cases) in order to
575
+ # fulfill the standard Ruby contract for the == operator, whereas
576
+ # the equals? method may assume that any rhs is a geometry.
577
+ #
578
+ # Second, the == operator should always be defined. That is, it
579
+ # should never raise Error::UnsupportedOperation. In cases where
580
+ # the underlying implementation cannot provide a spatial equivalence
581
+ # test, the == operator must fall back on representational or
582
+ # objective equivalence.
583
+
584
+ def ==(rhs_)
585
+ if rhs_.is_a?(::RGeo::Feature::Instance)
586
+ begin
587
+ equals?(rhs_)
588
+ rescue Error::UnsupportedOperation
589
+ eql?(rhs_)
590
+ end
591
+ else
592
+ false
593
+ end
594
+ end
595
+
596
+ # If the given rhs is a geometry object, this operator must behave
597
+ # the same as the difference method. The behavior for other rhs
598
+ # types is not specified; an implementation may choose to provide
599
+ # additional capabilities as appropriate.
600
+
601
+ def -(rhs_)
602
+ difference(rhs_)
603
+ end
604
+
605
+ # If the given rhs is a geometry object, this operator must behave
606
+ # the same as the union method. The behavior for other rhs types
607
+ # is not specified; an implementation may choose to provide
608
+ # additional capabilities as appropriate.
609
+
610
+ def +(rhs_)
611
+ union(rhs_)
612
+ end
613
+
614
+ # If the given rhs is a geometry object, this operator must behave
615
+ # the same as the intersection method. The behavior for other rhs
616
+ # types is not specified; an implementation may choose to provide
617
+ # additional capabilities as appropriate.
618
+
619
+ def *(rhs_)
620
+ intersection(rhs_)
621
+ end
622
+ end
623
+ end
624
+ end