rgeo 2.4.0 → 3.1.0

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 (97) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +6 -0
  3. data/README.md +23 -14
  4. data/ext/geos_c_impl/analysis.c +29 -26
  5. data/ext/geos_c_impl/analysis.h +8 -5
  6. data/ext/geos_c_impl/coordinates.c +27 -21
  7. data/ext/geos_c_impl/coordinates.h +5 -2
  8. data/ext/geos_c_impl/errors.c +19 -10
  9. data/ext/geos_c_impl/errors.h +11 -4
  10. data/ext/geos_c_impl/extconf.rb +43 -29
  11. data/ext/geos_c_impl/factory.c +443 -351
  12. data/ext/geos_c_impl/factory.h +98 -55
  13. data/ext/geos_c_impl/geometry.c +589 -383
  14. data/ext/geos_c_impl/geometry.h +10 -3
  15. data/ext/geos_c_impl/geometry_collection.c +288 -316
  16. data/ext/geos_c_impl/geometry_collection.h +6 -18
  17. data/ext/geos_c_impl/globals.c +98 -21
  18. data/ext/geos_c_impl/globals.h +3 -2
  19. data/ext/geos_c_impl/line_string.c +263 -222
  20. data/ext/geos_c_impl/line_string.h +5 -6
  21. data/ext/geos_c_impl/main.c +8 -9
  22. data/ext/geos_c_impl/point.c +63 -65
  23. data/ext/geos_c_impl/point.h +4 -5
  24. data/ext/geos_c_impl/polygon.c +168 -131
  25. data/ext/geos_c_impl/polygon.h +11 -9
  26. data/ext/geos_c_impl/preface.h +15 -11
  27. data/ext/geos_c_impl/ruby_more.c +67 -0
  28. data/ext/geos_c_impl/ruby_more.h +25 -0
  29. data/lib/rgeo/cartesian/analysis.rb +5 -3
  30. data/lib/rgeo/cartesian/bounding_box.rb +74 -79
  31. data/lib/rgeo/cartesian/calculations.rb +64 -33
  32. data/lib/rgeo/cartesian/factory.rb +59 -104
  33. data/lib/rgeo/cartesian/feature_classes.rb +68 -46
  34. data/lib/rgeo/cartesian/feature_methods.rb +67 -25
  35. data/lib/rgeo/cartesian/interface.rb +6 -41
  36. data/lib/rgeo/cartesian/planar_graph.rb +373 -0
  37. data/lib/rgeo/cartesian/sweepline_intersector.rb +147 -0
  38. data/lib/rgeo/cartesian/valid_op.rb +69 -0
  39. data/lib/rgeo/cartesian.rb +3 -0
  40. data/lib/rgeo/coord_sys/cs/entities.rb +305 -101
  41. data/lib/rgeo/coord_sys/cs/factories.rb +0 -2
  42. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +90 -42
  43. data/lib/rgeo/coord_sys.rb +1 -20
  44. data/lib/rgeo/error.rb +15 -0
  45. data/lib/rgeo/feature/curve.rb +0 -11
  46. data/lib/rgeo/feature/factory.rb +26 -36
  47. data/lib/rgeo/feature/factory_generator.rb +6 -14
  48. data/lib/rgeo/feature/geometry.rb +146 -66
  49. data/lib/rgeo/feature/geometry_collection.rb +16 -9
  50. data/lib/rgeo/feature/line_string.rb +4 -5
  51. data/lib/rgeo/feature/linear_ring.rb +0 -1
  52. data/lib/rgeo/feature/multi_curve.rb +0 -6
  53. data/lib/rgeo/feature/multi_surface.rb +3 -4
  54. data/lib/rgeo/feature/point.rb +4 -5
  55. data/lib/rgeo/feature/polygon.rb +1 -2
  56. data/lib/rgeo/feature/surface.rb +3 -4
  57. data/lib/rgeo/feature/types.rb +71 -87
  58. data/lib/rgeo/geographic/factory.rb +100 -127
  59. data/lib/rgeo/geographic/interface.rb +71 -168
  60. data/lib/rgeo/geographic/projected_feature_classes.rb +21 -9
  61. data/lib/rgeo/geographic/projected_feature_methods.rb +67 -42
  62. data/lib/rgeo/geographic/projected_window.rb +36 -22
  63. data/lib/rgeo/geographic/{proj4_projector.rb → projector.rb} +3 -5
  64. data/lib/rgeo/geographic/simple_mercator_projector.rb +26 -25
  65. data/lib/rgeo/geographic/spherical_feature_classes.rb +29 -9
  66. data/lib/rgeo/geographic/spherical_feature_methods.rb +86 -9
  67. data/lib/rgeo/geographic/spherical_math.rb +17 -20
  68. data/lib/rgeo/geographic.rb +1 -1
  69. data/lib/rgeo/geos/capi_factory.rb +87 -158
  70. data/lib/rgeo/geos/capi_feature_classes.rb +50 -36
  71. data/lib/rgeo/geos/ffi_factory.rb +107 -175
  72. data/lib/rgeo/geos/ffi_feature_classes.rb +34 -10
  73. data/lib/rgeo/geos/ffi_feature_methods.rb +105 -127
  74. data/lib/rgeo/geos/interface.rb +20 -59
  75. data/lib/rgeo/geos/utils.rb +5 -5
  76. data/lib/rgeo/geos/zm_factory.rb +55 -97
  77. data/lib/rgeo/geos/zm_feature_methods.rb +30 -33
  78. data/lib/rgeo/geos.rb +15 -9
  79. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +11 -24
  80. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -2
  81. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +28 -56
  82. data/lib/rgeo/impl_helper/basic_point_methods.rb +2 -14
  83. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +17 -26
  84. data/lib/rgeo/impl_helper/utils.rb +21 -0
  85. data/lib/rgeo/impl_helper/valid_op.rb +350 -0
  86. data/lib/rgeo/impl_helper/validity_check.rb +139 -0
  87. data/lib/rgeo/impl_helper.rb +1 -0
  88. data/lib/rgeo/version.rb +1 -1
  89. data/lib/rgeo/wkrep/wkb_generator.rb +73 -63
  90. data/lib/rgeo/wkrep/wkb_parser.rb +33 -31
  91. data/lib/rgeo/wkrep/wkt_generator.rb +52 -45
  92. data/lib/rgeo/wkrep/wkt_parser.rb +48 -35
  93. data/lib/rgeo.rb +1 -3
  94. metadata +63 -16
  95. data/lib/rgeo/coord_sys/srs_database/entry.rb +0 -107
  96. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +0 -64
  97. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +0 -65
@@ -2,40 +2,35 @@
2
2
  Geometry collection methods for GEOS wrapper
3
3
  */
4
4
 
5
-
6
5
  #include "preface.h"
7
6
 
8
7
  #ifdef RGEO_GEOS_SUPPORTED
9
8
 
10
- #include <ruby.h>
11
9
  #include <geos_c.h>
10
+ #include <ruby.h>
12
11
 
13
- #include "globals.h"
14
-
12
+ #include "coordinates.h"
13
+ #include "errors.h"
15
14
  #include "factory.h"
16
15
  #include "geometry.h"
16
+ #include "geometry_collection.h"
17
+ #include "globals.h"
17
18
  #include "line_string.h"
18
19
  #include "polygon.h"
19
- #include "geometry_collection.h"
20
-
21
- #include "coordinates.h"
22
20
 
23
21
  RGEO_BEGIN_C
24
22
 
25
-
26
23
  /**** INTERNAL IMPLEMENTATION OF CREATE ****/
27
24
 
28
-
29
25
  // Main implementation of the "create" class method for geometry collections.
30
26
  // You must pass in the correct GEOS geometry type ID.
31
27
 
32
- static VALUE create_geometry_collection(VALUE module, int type, VALUE factory, VALUE array)
28
+ static VALUE
29
+ create_geometry_collection(VALUE module, int type, VALUE factory, VALUE array)
33
30
  {
34
31
  VALUE result;
35
32
  unsigned int len;
36
33
  GEOSGeometry** geoms;
37
- RGeo_FactoryData* factory_data;
38
- GEOSContextHandle_t geos_context;
39
34
  VALUE klass;
40
35
  unsigned int i;
41
36
  unsigned int j;
@@ -43,20 +38,19 @@ static VALUE create_geometry_collection(VALUE module, int type, VALUE factory, V
43
38
  VALUE cast_type;
44
39
  GEOSGeometry* geom;
45
40
  GEOSGeometry* collection;
46
- char problem;
47
- GEOSGeometry* igeom;
48
- GEOSGeometry* jgeom;
41
+ int state = 0;
49
42
 
50
43
  result = Qnil;
51
44
  Check_Type(array, T_ARRAY);
52
45
  len = (unsigned int)RARRAY_LEN(array);
53
46
  geoms = ALLOC_N(GEOSGeometry*, len == 0 ? 1 : len);
54
- if (geoms) {
55
- factory_data = RGEO_FACTORY_DATA_PTR(factory);
56
- geos_context = factory_data->geos_context;
57
- klasses = Qnil;
58
- cast_type = Qnil;
59
- switch (type) {
47
+ if (!geoms) {
48
+ rb_raise(rb_eRGeoError, "not enough memory available");
49
+ }
50
+
51
+ klasses = Qnil;
52
+ cast_type = Qnil;
53
+ switch (type) {
60
54
  case GEOS_MULTIPOINT:
61
55
  cast_type = rgeo_feature_point_module;
62
56
  break;
@@ -66,76 +60,51 @@ static VALUE create_geometry_collection(VALUE module, int type, VALUE factory, V
66
60
  case GEOS_MULTIPOLYGON:
67
61
  cast_type = rgeo_feature_polygon_module;
68
62
  break;
69
- }
70
- for (i=0; i<len; ++i) {
71
- geom = rgeo_convert_to_detached_geos_geometry(rb_ary_entry(array, i), factory, cast_type, &klass);
72
- if (!geom) {
73
- break;
74
- }
75
- geoms[i] = geom;
76
- if (!NIL_P(klass) && NIL_P(klasses)) {
77
- klasses = rb_ary_new2(len);
78
- for (j=0; j<i; ++j) {
79
- rb_ary_push(klasses, Qnil);
80
- }
81
- }
82
- if (!NIL_P(klasses)) {
83
- rb_ary_push(klasses, klass);
63
+ }
64
+ for (i = 0; i < len; ++i) {
65
+ geom = rgeo_convert_to_detached_geos_geometry(
66
+ rb_ary_entry(array, i), factory, cast_type, &klass, &state);
67
+ if (state) {
68
+ for (j = 0; j < i; j++) {
69
+ GEOSGeom_destroy(geoms[j]);
84
70
  }
71
+ FREE(geoms);
72
+ rb_jump_tag(state);
85
73
  }
86
- if (i != len) {
87
- for (j=0; j<i; ++j) {
88
- GEOSGeom_destroy_r(geos_context, geoms[j]);
74
+
75
+ geoms[i] = geom;
76
+ if (!NIL_P(klass) && NIL_P(klasses)) {
77
+ klasses = rb_ary_new2(len);
78
+ for (j = 0; j < i; ++j) {
79
+ rb_ary_push(klasses, Qnil);
89
80
  }
90
81
  }
91
- else {
92
- collection = GEOSGeom_createCollection_r(geos_context, type, geoms, len);
93
- // Due to a limitation of GEOS, the MultiPolygon assertions are not checked.
94
- // We do that manually here.
95
- if (collection && type == GEOS_MULTIPOLYGON && (factory_data->flags & 1) == 0) {
96
- problem = 0;
97
- for (i=1; i<len; ++i) {
98
- for (j=0; j<i; ++j) {
99
- igeom = geoms[i];
100
- jgeom = geoms[j];
101
- problem = GEOSRelatePattern_r(geos_context, igeom, jgeom, "2********");
102
- if (problem) {
103
- break;
104
- }
105
- problem = GEOSRelatePattern_r(geos_context, igeom, jgeom, "****1****");
106
- if (problem) {
107
- break;
108
- }
109
- }
110
- if (problem) {
111
- break;
112
- }
113
- }
114
- if (problem) {
115
- GEOSGeom_destroy_r(geos_context, collection);
116
- collection = NULL;
117
- }
118
- }
119
- if (collection) {
120
- result = rgeo_wrap_geos_geometry(factory, collection, module);
121
- RGEO_GEOMETRY_DATA_PTR(result)->klasses = klasses;
122
- }
123
- // NOTE: We are assuming that GEOS will do its own cleanup of the
124
- // element geometries if it fails to create the collection, so we
125
- // are not doing that ourselves. If that turns out not to be the
126
- // case, this will be a memory leak.
82
+ if (!NIL_P(klasses)) {
83
+ rb_ary_push(klasses, klass);
127
84
  }
128
- free(geoms);
85
+ }
86
+ collection = GEOSGeom_createCollection(type, geoms, len);
87
+ if (collection) {
88
+ result = rgeo_wrap_geos_geometry(factory, collection, module);
89
+ RGEO_GEOMETRY_DATA_PTR(result)->klasses = klasses;
90
+ }
91
+
92
+ // NOTE: We are assuming that GEOS will do its own cleanup of the
93
+ // element geometries if it fails to create the collection, so we
94
+ // are not doing that ourselves. If that turns out not to be the
95
+ // case, this will be a memory leak.
96
+ FREE(geoms);
97
+ if (state) {
98
+ rb_jump_tag(state);
129
99
  }
130
100
 
131
101
  return result;
132
102
  }
133
103
 
134
-
135
104
  /**** RUBY METHOD DEFINITIONS ****/
136
105
 
137
-
138
- static VALUE method_geometry_collection_eql(VALUE self, VALUE rhs)
106
+ static VALUE
107
+ method_geometry_collection_eql(VALUE self, VALUE rhs)
139
108
  {
140
109
  VALUE result;
141
110
  RGeo_GeometryData* self_data;
@@ -143,13 +112,14 @@ static VALUE method_geometry_collection_eql(VALUE self, VALUE rhs)
143
112
  result = rgeo_geos_klasses_and_factories_eql(self, rhs);
144
113
  if (RTEST(result)) {
145
114
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
146
- result = rgeo_geos_geometry_collections_eql(self_data->geos_context, self_data->geom, RGEO_GEOMETRY_DATA_PTR(rhs)->geom, RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
115
+ result = rgeo_geos_geometries_strict_eql(self_data->geom,
116
+ RGEO_GEOMETRY_DATA_PTR(rhs)->geom);
147
117
  }
148
118
  return result;
149
119
  }
150
120
 
151
-
152
- static VALUE method_geometry_collection_hash(VALUE self)
121
+ static VALUE
122
+ method_geometry_collection_hash(VALUE self)
153
123
  {
154
124
  st_index_t hash;
155
125
  RGeo_GeometryData* self_data;
@@ -158,13 +128,14 @@ static VALUE method_geometry_collection_hash(VALUE self)
158
128
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
159
129
  factory = self_data->factory;
160
130
  hash = rb_hash_start(0);
161
- hash = rgeo_geos_objbase_hash(factory, rgeo_feature_geometry_collection_module, hash);
162
- hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
131
+ hash = rgeo_geos_objbase_hash(
132
+ factory, rgeo_feature_geometry_collection_module, hash);
133
+ hash = rgeo_geos_geometry_collection_hash(self_data->geom, hash);
163
134
  return LONG2FIX(rb_hash_end(hash));
164
135
  }
165
136
 
166
-
167
- static VALUE method_geometry_collection_geometry_type(VALUE self)
137
+ static VALUE
138
+ method_geometry_collection_geometry_type(VALUE self)
168
139
  {
169
140
  VALUE result;
170
141
  RGeo_GeometryData* self_data;
@@ -177,8 +148,8 @@ static VALUE method_geometry_collection_geometry_type(VALUE self)
177
148
  return result;
178
149
  }
179
150
 
180
-
181
- static VALUE method_geometry_collection_num_geometries(VALUE self)
151
+ static VALUE
152
+ method_geometry_collection_num_geometries(VALUE self)
182
153
  {
183
154
  VALUE result;
184
155
  RGeo_GeometryData* self_data;
@@ -188,13 +159,13 @@ static VALUE method_geometry_collection_num_geometries(VALUE self)
188
159
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
189
160
  self_geom = self_data->geom;
190
161
  if (self_geom) {
191
- result = INT2NUM(GEOSGetNumGeometries_r(self_data->geos_context, self_geom));
162
+ result = INT2NUM(GEOSGetNumGeometries(self_geom));
192
163
  }
193
164
  return result;
194
165
  }
195
166
 
196
-
197
- static VALUE impl_geometry_n(VALUE self, VALUE n, char allow_negatives)
167
+ static VALUE
168
+ impl_geometry_n(VALUE self, VALUE n, char allow_negatives)
198
169
  {
199
170
  VALUE result;
200
171
  RGeo_GeometryData* self_data;
@@ -208,16 +179,16 @@ static VALUE impl_geometry_n(VALUE self, VALUE n, char allow_negatives)
208
179
  self_geom = self_data->geom;
209
180
  if (self_geom) {
210
181
  klasses = self_data->klasses;
211
- i = NUM2INT(n);
182
+ i = RB_NUM2INT(n);
212
183
  if (allow_negatives || i >= 0) {
213
- GEOSContextHandle_t self_context = self_data->geos_context;
214
- len = GEOSGetNumGeometries_r(self_context, self_geom);
184
+ len = GEOSGetNumGeometries(self_geom);
215
185
  if (i < 0) {
216
186
  i += len;
217
187
  }
218
188
  if (i >= 0 && i < len) {
219
- result = rgeo_wrap_geos_geometry_clone(self_data->factory,
220
- GEOSGetGeometryN_r(self_context, self_geom, i),
189
+ result = rgeo_wrap_geos_geometry_clone(
190
+ self_data->factory,
191
+ GEOSGetGeometryN(self_geom, i),
221
192
  NIL_P(klasses) ? Qnil : rb_ary_entry(klasses, i));
222
193
  }
223
194
  }
@@ -225,22 +196,23 @@ static VALUE impl_geometry_n(VALUE self, VALUE n, char allow_negatives)
225
196
  return result;
226
197
  }
227
198
 
228
-
229
- static VALUE method_geometry_collection_geometry_n(VALUE self, VALUE n)
199
+ static VALUE
200
+ method_geometry_collection_geometry_n(VALUE self, VALUE n)
230
201
  {
231
202
  return impl_geometry_n(self, n, 0);
232
203
  }
233
204
 
234
-
235
- static VALUE method_geometry_collection_brackets(VALUE self, VALUE n)
205
+ static VALUE
206
+ method_geometry_collection_brackets(VALUE self, VALUE n)
236
207
  {
237
208
  return impl_geometry_n(self, n, 1);
238
209
  }
239
210
 
240
-
241
- static VALUE method_geometry_collection_each(VALUE self)
211
+ static VALUE
212
+ method_geometry_collection_each(VALUE self)
242
213
  {
243
- RETURN_ENUMERATOR(self, 0, 0); /* return enum_for(__callee__) unless block_given? */
214
+ RETURN_ENUMERATOR(
215
+ self, 0, 0); /* return enum_for(__callee__) unless block_given? */
244
216
 
245
217
  RGeo_GeometryData* self_data;
246
218
  const GEOSGeometry* self_geom;
@@ -254,13 +226,15 @@ static VALUE method_geometry_collection_each(VALUE self)
254
226
 
255
227
  self_geom = self_data->geom;
256
228
  if (self_geom) {
257
- GEOSContextHandle_t self_context = self_data->geos_context;
258
- len = GEOSGetNumGeometries_r(self_context, self_geom);
229
+ len = GEOSGetNumGeometries(self_geom);
259
230
  if (len > 0) {
260
231
  klasses = self_data->klasses;
261
- for (i=0; i<len; ++i) {
262
- elem_geom = GEOSGetGeometryN_r(self_context, self_geom, i);
263
- elem = rgeo_wrap_geos_geometry_clone(self_data->factory, elem_geom, NIL_P(klasses) ? Qnil : rb_ary_entry(klasses, i));
232
+ for (i = 0; i < len; ++i) {
233
+ elem_geom = GEOSGetGeometryN(self_geom, i);
234
+ elem = rgeo_wrap_geos_geometry_clone(
235
+ self_data->factory,
236
+ elem_geom,
237
+ NIL_P(klasses) ? Qnil : rb_ary_entry(klasses, i));
264
238
  if (!NIL_P(elem)) {
265
239
  rb_yield(elem);
266
240
  }
@@ -270,7 +244,8 @@ static VALUE method_geometry_collection_each(VALUE self)
270
244
  return self;
271
245
  }
272
246
 
273
- static VALUE method_multi_point_geometry_type(VALUE self)
247
+ static VALUE
248
+ method_multi_point_geometry_type(VALUE self)
274
249
  {
275
250
  VALUE result;
276
251
  RGeo_GeometryData* self_data;
@@ -283,8 +258,8 @@ static VALUE method_multi_point_geometry_type(VALUE self)
283
258
  return result;
284
259
  }
285
260
 
286
-
287
- static VALUE method_multi_point_hash(VALUE self)
261
+ static VALUE
262
+ method_multi_point_hash(VALUE self)
288
263
  {
289
264
  st_index_t hash;
290
265
  RGeo_GeometryData* self_data;
@@ -294,17 +269,16 @@ static VALUE method_multi_point_hash(VALUE self)
294
269
  factory = self_data->factory;
295
270
  hash = rb_hash_start(0);
296
271
  hash = rgeo_geos_objbase_hash(factory, rgeo_feature_multi_point_module, hash);
297
- hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
272
+ hash = rgeo_geos_geometry_collection_hash(self_data->geom, hash);
298
273
  return LONG2FIX(rb_hash_end(hash));
299
274
  }
300
275
 
301
-
302
- static VALUE method_multi_point_coordinates(VALUE self)
276
+ static VALUE
277
+ method_multi_point_coordinates(VALUE self)
303
278
  {
304
279
  VALUE result = Qnil;
305
280
  RGeo_GeometryData* self_data;
306
281
  const GEOSGeometry* self_geom;
307
- GEOSContextHandle_t context;
308
282
  const GEOSCoordSequence* coord_sequence;
309
283
 
310
284
  const GEOSGeometry* point;
@@ -315,23 +289,26 @@ static VALUE method_multi_point_coordinates(VALUE self)
315
289
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
316
290
  self_geom = self_data->geom;
317
291
 
318
- if(self_geom) {
319
- zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
320
- context = self_data->geos_context;
321
- count = GEOSGetNumGeometries_r(context, self_geom);
292
+ if (self_geom) {
293
+ zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
294
+ RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
295
+
296
+ count = GEOSGetNumGeometries(self_geom);
322
297
  result = rb_ary_new2(count);
323
- for(i = 0; i < count; ++i) {
324
- point = GEOSGetGeometryN_r(context, self_geom, i);
325
- coord_sequence = GEOSGeom_getCoordSeq_r(context, point);
326
- rb_ary_push(result, rb_ary_pop(extract_points_from_coordinate_sequence(context, coord_sequence, zCoordinate)));
298
+ for (i = 0; i < count; ++i) {
299
+ point = GEOSGetGeometryN(self_geom, i);
300
+ coord_sequence = GEOSGeom_getCoordSeq(point);
301
+ rb_ary_push(result,
302
+ rb_ary_pop(extract_points_from_coordinate_sequence(
303
+ coord_sequence, zCoordinate)));
327
304
  }
328
305
  }
329
306
 
330
307
  return result;
331
308
  }
332
309
 
333
-
334
- static VALUE method_multi_line_string_geometry_type(VALUE self)
310
+ static VALUE
311
+ method_multi_line_string_geometry_type(VALUE self)
335
312
  {
336
313
  VALUE result;
337
314
  RGeo_GeometryData* self_data;
@@ -344,8 +321,8 @@ static VALUE method_multi_line_string_geometry_type(VALUE self)
344
321
  return result;
345
322
  }
346
323
 
347
-
348
- static VALUE method_multi_line_string_hash(VALUE self)
324
+ static VALUE
325
+ method_multi_line_string_hash(VALUE self)
349
326
  {
350
327
  st_index_t hash;
351
328
  RGeo_GeometryData* self_data;
@@ -354,35 +331,35 @@ static VALUE method_multi_line_string_hash(VALUE self)
354
331
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
355
332
  factory = self_data->factory;
356
333
  hash = rb_hash_start(0);
357
- hash = rgeo_geos_objbase_hash(factory, rgeo_feature_multi_line_string_module, hash);
358
- hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
334
+ hash = rgeo_geos_objbase_hash(
335
+ factory, rgeo_feature_multi_line_string_module, hash);
336
+ hash = rgeo_geos_geometry_collection_hash(self_data->geom, hash);
359
337
  return LONG2FIX(rb_hash_end(hash));
360
338
  }
361
339
 
362
- static VALUE method_geometry_collection_node(VALUE self)
340
+ static VALUE
341
+ method_geometry_collection_node(VALUE self)
363
342
  {
364
343
  VALUE result = Qnil;
365
344
  RGeo_GeometryData* self_data;
366
345
  const GEOSGeometry* self_geom;
367
346
  GEOSGeometry* noded;
368
- GEOSContextHandle_t context;
369
347
 
370
348
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
371
349
  self_geom = self_data->geom;
372
- context = self_data->geos_context;
373
350
 
374
- noded = GEOSNode_r(context, self_geom);
351
+ noded = GEOSNode(self_geom);
375
352
  result = rgeo_wrap_geos_geometry(self_data->factory, noded, Qnil);
376
353
 
377
354
  return result;
378
355
  }
379
356
 
380
- static VALUE method_multi_line_string_coordinates(VALUE self)
357
+ static VALUE
358
+ method_multi_line_string_coordinates(VALUE self)
381
359
  {
382
360
  VALUE result = Qnil;
383
361
  RGeo_GeometryData* self_data;
384
362
  const GEOSGeometry* self_geom;
385
- GEOSContextHandle_t context;
386
363
  const GEOSCoordSequence* coord_sequence;
387
364
 
388
365
  const GEOSGeometry* line_string;
@@ -393,22 +370,25 @@ static VALUE method_multi_line_string_coordinates(VALUE self)
393
370
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
394
371
  self_geom = self_data->geom;
395
372
 
396
- if(self_geom) {
397
- zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
398
- context = self_data->geos_context;
399
- count = GEOSGetNumGeometries_r(context, self_geom);
373
+ if (self_geom) {
374
+ zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
375
+ RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
376
+ count = GEOSGetNumGeometries(self_geom);
400
377
  result = rb_ary_new2(count);
401
- for(i = 0; i < count; ++i) {
402
- line_string = GEOSGetGeometryN_r(context, self_geom, i);
403
- coord_sequence = GEOSGeom_getCoordSeq_r(context, line_string);
404
- rb_ary_push(result, extract_points_from_coordinate_sequence(context, coord_sequence, zCoordinate));
378
+ for (i = 0; i < count; ++i) {
379
+ line_string = GEOSGetGeometryN(self_geom, i);
380
+ coord_sequence = GEOSGeom_getCoordSeq(line_string);
381
+ rb_ary_push(
382
+ result,
383
+ extract_points_from_coordinate_sequence(coord_sequence, zCoordinate));
405
384
  }
406
385
  }
407
386
 
408
387
  return result;
409
388
  }
410
389
 
411
- static VALUE method_multi_line_string_length(VALUE self)
390
+ static VALUE
391
+ method_multi_line_string_length(VALUE self)
412
392
  {
413
393
  VALUE result;
414
394
  RGeo_GeometryData* self_data;
@@ -419,20 +399,19 @@ static VALUE method_multi_line_string_length(VALUE self)
419
399
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
420
400
  self_geom = self_data->geom;
421
401
  if (self_geom) {
422
- if (GEOSLength_r(self_data->geos_context, self_geom, &len)) {
402
+ if (GEOSLength(self_geom, &len)) {
423
403
  result = rb_float_new(len);
424
404
  }
425
405
  }
426
406
  return result;
427
407
  }
428
408
 
429
-
430
- static VALUE method_multi_line_string_is_closed(VALUE self)
409
+ static VALUE
410
+ method_multi_line_string_is_closed(VALUE self)
431
411
  {
432
412
  VALUE result;
433
413
  RGeo_GeometryData* self_data;
434
414
  const GEOSGeometry* self_geom;
435
- GEOSContextHandle_t self_context;
436
415
  int len;
437
416
  int i;
438
417
  const GEOSGeometry* geom;
@@ -441,14 +420,13 @@ static VALUE method_multi_line_string_is_closed(VALUE self)
441
420
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
442
421
  self_geom = self_data->geom;
443
422
  if (self_geom) {
444
- self_context = self_data->geos_context;
445
423
  result = Qtrue;
446
- len = GEOSGetNumGeometries_r(self_context, self_geom);
424
+ len = GEOSGetNumGeometries(self_geom);
447
425
  if (len > 0) {
448
- for (i=0; i<len; ++i) {
449
- geom = GEOSGetGeometryN_r(self_context, self_geom, i);
426
+ for (i = 0; i < len; ++i) {
427
+ geom = GEOSGetGeometryN(self_geom, i);
450
428
  if (geom) {
451
- result = rgeo_is_geos_line_string_closed(self_context, self_geom);
429
+ result = rgeo_is_geos_line_string_closed(self_geom);
452
430
  if (result != Qtrue) {
453
431
  break;
454
432
  }
@@ -459,8 +437,8 @@ static VALUE method_multi_line_string_is_closed(VALUE self)
459
437
  return result;
460
438
  }
461
439
 
462
-
463
- static VALUE method_multi_polygon_geometry_type(VALUE self)
440
+ static VALUE
441
+ method_multi_polygon_geometry_type(VALUE self)
464
442
  {
465
443
  VALUE result;
466
444
  RGeo_GeometryData* self_data;
@@ -473,8 +451,8 @@ static VALUE method_multi_polygon_geometry_type(VALUE self)
473
451
  return result;
474
452
  }
475
453
 
476
-
477
- static VALUE method_multi_polygon_hash(VALUE self)
454
+ static VALUE
455
+ method_multi_polygon_hash(VALUE self)
478
456
  {
479
457
  st_index_t hash;
480
458
  RGeo_GeometryData* self_data;
@@ -483,18 +461,18 @@ static VALUE method_multi_polygon_hash(VALUE self)
483
461
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
484
462
  factory = self_data->factory;
485
463
  hash = rb_hash_start(0);
486
- hash = rgeo_geos_objbase_hash(factory, rgeo_feature_multi_polygon_module, hash);
487
- hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
464
+ hash =
465
+ rgeo_geos_objbase_hash(factory, rgeo_feature_multi_polygon_module, hash);
466
+ hash = rgeo_geos_geometry_collection_hash(self_data->geom, hash);
488
467
  return LONG2FIX(rb_hash_end(hash));
489
468
  }
490
469
 
491
-
492
- static VALUE method_multi_polygon_coordinates(VALUE self)
470
+ static VALUE
471
+ method_multi_polygon_coordinates(VALUE self)
493
472
  {
494
473
  VALUE result = Qnil;
495
474
  RGeo_GeometryData* self_data;
496
475
  const GEOSGeometry* self_geom;
497
- GEOSContextHandle_t context;
498
476
 
499
477
  const GEOSGeometry* poly;
500
478
  unsigned int count;
@@ -504,22 +482,22 @@ static VALUE method_multi_polygon_coordinates(VALUE self)
504
482
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
505
483
  self_geom = self_data->geom;
506
484
 
507
- if(self_geom) {
508
- zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
509
- context = self_data->geos_context;
510
- count = GEOSGetNumGeometries_r(context, self_geom);
485
+ if (self_geom) {
486
+ zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
487
+ RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
488
+ count = GEOSGetNumGeometries(self_geom);
511
489
  result = rb_ary_new2(count);
512
- for(i = 0; i < count; ++i) {
513
- poly = GEOSGetGeometryN_r(context, self_geom, i);
514
- rb_ary_push(result, extract_points_from_polygon(context, poly, zCoordinate));
490
+ for (i = 0; i < count; ++i) {
491
+ poly = GEOSGetGeometryN(self_geom, i);
492
+ rb_ary_push(result, extract_points_from_polygon(poly, zCoordinate));
515
493
  }
516
494
  }
517
495
 
518
496
  return result;
519
497
  }
520
498
 
521
-
522
- static VALUE method_multi_polygon_area(VALUE self)
499
+ static VALUE
500
+ method_multi_polygon_area(VALUE self)
523
501
  {
524
502
  VALUE result;
525
503
  RGeo_GeometryData* self_data;
@@ -530,15 +508,15 @@ static VALUE method_multi_polygon_area(VALUE self)
530
508
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
531
509
  self_geom = self_data->geom;
532
510
  if (self_geom) {
533
- if (GEOSArea_r(self_data->geos_context, self_geom, &area)) {
511
+ if (GEOSArea(self_geom, &area)) {
534
512
  result = rb_float_new(area);
535
513
  }
536
514
  }
537
515
  return result;
538
516
  }
539
517
 
540
-
541
- static VALUE method_multi_polygon_centroid(VALUE self)
518
+ static VALUE
519
+ method_multi_polygon_centroid(VALUE self)
542
520
  {
543
521
  VALUE result;
544
522
  RGeo_GeometryData* self_data;
@@ -548,40 +526,42 @@ static VALUE method_multi_polygon_centroid(VALUE self)
548
526
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
549
527
  self_geom = self_data->geom;
550
528
  if (self_geom) {
551
- result = rgeo_wrap_geos_geometry(self_data->factory, GEOSGetCentroid_r(self_data->geos_context, self_geom), Qnil);
529
+ result = rgeo_wrap_geos_geometry(
530
+ self_data->factory, GEOSGetCentroid(self_geom), Qnil);
552
531
  }
553
532
  return result;
554
533
  }
555
534
 
556
-
557
- static VALUE cmethod_geometry_collection_create(VALUE module, VALUE factory, VALUE array)
535
+ static VALUE
536
+ cmethod_geometry_collection_create(VALUE module, VALUE factory, VALUE array)
558
537
  {
559
- return create_geometry_collection(module, GEOS_GEOMETRYCOLLECTION, factory, array);
538
+ return create_geometry_collection(
539
+ module, GEOS_GEOMETRYCOLLECTION, factory, array);
560
540
  }
561
541
 
562
-
563
- static VALUE cmethod_multi_point_create(VALUE module, VALUE factory, VALUE array)
542
+ static VALUE
543
+ cmethod_multi_point_create(VALUE module, VALUE factory, VALUE array)
564
544
  {
565
545
  return create_geometry_collection(module, GEOS_MULTIPOINT, factory, array);
566
546
  }
567
547
 
568
-
569
- static VALUE cmethod_multi_line_string_create(VALUE module, VALUE factory, VALUE array)
548
+ static VALUE
549
+ cmethod_multi_line_string_create(VALUE module, VALUE factory, VALUE array)
570
550
  {
571
- return create_geometry_collection(module, GEOS_MULTILINESTRING, factory, array);
551
+ return create_geometry_collection(
552
+ module, GEOS_MULTILINESTRING, factory, array);
572
553
  }
573
554
 
574
-
575
- static VALUE cmethod_multi_polygon_create(VALUE module, VALUE factory, VALUE array)
555
+ static VALUE
556
+ cmethod_multi_polygon_create(VALUE module, VALUE factory, VALUE array)
576
557
  {
577
558
  return create_geometry_collection(module, GEOS_MULTIPOLYGON, factory, array);
578
559
  }
579
560
 
580
-
581
561
  /**** INITIALIZATION FUNCTION ****/
582
562
 
583
-
584
- void rgeo_init_geos_geometry_collection()
563
+ void
564
+ rgeo_init_geos_geometry_collection()
585
565
  {
586
566
  VALUE geos_geometry_collection_methods;
587
567
  VALUE geos_multi_point_methods;
@@ -589,127 +569,120 @@ void rgeo_init_geos_geometry_collection()
589
569
  VALUE geos_multi_polygon_methods;
590
570
 
591
571
  // Class methods for geometry collection classes
592
- rb_define_module_function(rgeo_geos_geometry_collection_class, "create", cmethod_geometry_collection_create, 2);
593
- rb_define_module_function(rgeo_geos_multi_point_class, "create", cmethod_multi_point_create, 2);
594
- rb_define_module_function(rgeo_geos_multi_line_string_class, "create", cmethod_multi_line_string_create, 2);
595
- rb_define_module_function(rgeo_geos_multi_polygon_class, "create", cmethod_multi_polygon_create, 2);
572
+ rb_define_module_function(rgeo_geos_geometry_collection_class,
573
+ "create",
574
+ cmethod_geometry_collection_create,
575
+ 2);
576
+ rb_define_module_function(
577
+ rgeo_geos_multi_point_class, "create", cmethod_multi_point_create, 2);
578
+ rb_define_module_function(rgeo_geos_multi_line_string_class,
579
+ "create",
580
+ cmethod_multi_line_string_create,
581
+ 2);
582
+ rb_define_module_function(
583
+ rgeo_geos_multi_polygon_class, "create", cmethod_multi_polygon_create, 2);
596
584
 
597
585
  // Methods for GeometryCollectionImpl
598
- geos_geometry_collection_methods = rb_define_module_under(rgeo_geos_module, "CAPIGeometryCollectionMethods");
599
- rb_define_method(geos_geometry_collection_methods, "rep_equals?", method_geometry_collection_eql, 1);
600
- rb_define_method(geos_geometry_collection_methods, "eql?", method_geometry_collection_eql, 1);
601
- rb_define_method(geos_geometry_collection_methods, "hash", method_geometry_collection_hash, 0);
602
- rb_define_method(geos_geometry_collection_methods, "geometry_type", method_geometry_collection_geometry_type, 0);
603
- rb_define_method(geos_geometry_collection_methods, "num_geometries", method_geometry_collection_num_geometries, 0);
604
- rb_define_method(geos_geometry_collection_methods, "size", method_geometry_collection_num_geometries, 0);
605
- rb_define_method(geos_geometry_collection_methods, "geometry_n", method_geometry_collection_geometry_n, 1);
606
- rb_define_method(geos_geometry_collection_methods, "[]", method_geometry_collection_brackets, 1);
607
- rb_define_method(geos_geometry_collection_methods, "each", method_geometry_collection_each, 0);
608
- rb_define_method(geos_geometry_collection_methods, "node", method_geometry_collection_node, 0);
609
-
586
+ geos_geometry_collection_methods =
587
+ rb_define_module_under(rgeo_geos_module, "CAPIGeometryCollectionMethods");
588
+ rb_define_method(geos_geometry_collection_methods,
589
+ "rep_equals?",
590
+ method_geometry_collection_eql,
591
+ 1);
592
+ rb_define_method(geos_geometry_collection_methods,
593
+ "eql?",
594
+ method_geometry_collection_eql,
595
+ 1);
596
+ rb_define_method(geos_geometry_collection_methods,
597
+ "hash",
598
+ method_geometry_collection_hash,
599
+ 0);
600
+ rb_define_method(geos_geometry_collection_methods,
601
+ "geometry_type",
602
+ method_geometry_collection_geometry_type,
603
+ 0);
604
+ rb_define_method(geos_geometry_collection_methods,
605
+ "num_geometries",
606
+ method_geometry_collection_num_geometries,
607
+ 0);
608
+ rb_define_method(geos_geometry_collection_methods,
609
+ "size",
610
+ method_geometry_collection_num_geometries,
611
+ 0);
612
+ rb_define_method(geos_geometry_collection_methods,
613
+ "geometry_n",
614
+ method_geometry_collection_geometry_n,
615
+ 1);
616
+ rb_define_method(geos_geometry_collection_methods,
617
+ "[]",
618
+ method_geometry_collection_brackets,
619
+ 1);
620
+ rb_define_method(geos_geometry_collection_methods,
621
+ "each",
622
+ method_geometry_collection_each,
623
+ 0);
624
+ rb_define_method(geos_geometry_collection_methods,
625
+ "node",
626
+ method_geometry_collection_node,
627
+ 0);
610
628
 
611
629
  // Methods for MultiPointImpl
612
- geos_multi_point_methods = rb_define_module_under(rgeo_geos_module, "CAPIMultiPointMethods");
613
- rb_define_method(geos_multi_point_methods, "geometry_type", method_multi_point_geometry_type, 0);
614
- rb_define_method(geos_multi_point_methods, "hash", method_multi_point_hash, 0);
615
- rb_define_method(geos_multi_point_methods, "coordinates", method_multi_point_coordinates, 0);
630
+ geos_multi_point_methods =
631
+ rb_define_module_under(rgeo_geos_module, "CAPIMultiPointMethods");
632
+ rb_define_method(geos_multi_point_methods,
633
+ "geometry_type",
634
+ method_multi_point_geometry_type,
635
+ 0);
636
+ rb_define_method(
637
+ geos_multi_point_methods, "hash", method_multi_point_hash, 0);
638
+ rb_define_method(
639
+ geos_multi_point_methods, "coordinates", method_multi_point_coordinates, 0);
616
640
 
617
641
  // Methods for MultiLineStringImpl
618
- geos_multi_line_string_methods = rb_define_module_under(rgeo_geos_module, "CAPIMultiLineStringMethods");
619
- rb_define_method(geos_multi_line_string_methods, "geometry_type", method_multi_line_string_geometry_type, 0);
620
- rb_define_method(geos_multi_line_string_methods, "length", method_multi_line_string_length, 0);
621
- rb_define_method(geos_multi_line_string_methods, "closed?", method_multi_line_string_is_closed, 0);
622
- rb_define_method(geos_multi_line_string_methods, "hash", method_multi_line_string_hash, 0);
623
- rb_define_method(geos_multi_line_string_methods, "coordinates", method_multi_line_string_coordinates, 0);
642
+ geos_multi_line_string_methods =
643
+ rb_define_module_under(rgeo_geos_module, "CAPIMultiLineStringMethods");
644
+ rb_define_method(geos_multi_line_string_methods,
645
+ "geometry_type",
646
+ method_multi_line_string_geometry_type,
647
+ 0);
648
+ rb_define_method(geos_multi_line_string_methods,
649
+ "length",
650
+ method_multi_line_string_length,
651
+ 0);
652
+ rb_define_method(geos_multi_line_string_methods,
653
+ "closed?",
654
+ method_multi_line_string_is_closed,
655
+ 0);
656
+ rb_define_method(
657
+ geos_multi_line_string_methods, "hash", method_multi_line_string_hash, 0);
658
+ rb_define_method(geos_multi_line_string_methods,
659
+ "coordinates",
660
+ method_multi_line_string_coordinates,
661
+ 0);
624
662
 
625
663
  // Methods for MultiPolygonImpl
626
- geos_multi_polygon_methods = rb_define_module_under(rgeo_geos_module, "CAPIMultiPolygonMethods");
627
- rb_define_method(geos_multi_polygon_methods, "geometry_type", method_multi_polygon_geometry_type, 0);
628
- rb_define_method(geos_multi_polygon_methods, "area", method_multi_polygon_area, 0);
629
- rb_define_method(geos_multi_polygon_methods, "centroid", method_multi_polygon_centroid, 0);
630
- rb_define_method(geos_multi_polygon_methods, "hash", method_multi_polygon_hash, 0);
631
- rb_define_method(geos_multi_polygon_methods, "coordinates", method_multi_polygon_coordinates, 0);
664
+ geos_multi_polygon_methods =
665
+ rb_define_module_under(rgeo_geos_module, "CAPIMultiPolygonMethods");
666
+ rb_define_method(geos_multi_polygon_methods,
667
+ "geometry_type",
668
+ method_multi_polygon_geometry_type,
669
+ 0);
670
+ rb_define_method(
671
+ geos_multi_polygon_methods, "area", method_multi_polygon_area, 0);
672
+ rb_define_method(
673
+ geos_multi_polygon_methods, "centroid", method_multi_polygon_centroid, 0);
674
+ rb_define_method(
675
+ geos_multi_polygon_methods, "hash", method_multi_polygon_hash, 0);
676
+ rb_define_method(geos_multi_polygon_methods,
677
+ "coordinates",
678
+ method_multi_polygon_coordinates,
679
+ 0);
632
680
  }
633
681
 
634
-
635
682
  /**** OTHER PUBLIC FUNCTIONS ****/
636
683
 
637
-
638
- VALUE rgeo_geos_geometry_collections_eql(GEOSContextHandle_t context, const GEOSGeometry* geom1, const GEOSGeometry* geom2, char check_z)
639
- {
640
- VALUE result;
641
- int len1;
642
- int len2;
643
- int i;
644
- const GEOSGeometry* sub_geom1;
645
- const GEOSGeometry* sub_geom2;
646
- int type1;
647
- int type2;
648
-
649
- result = Qnil;
650
- if (geom1 && geom2) {
651
- len1 = GEOSGetNumGeometries_r(context, geom1);
652
- len2 = GEOSGetNumGeometries_r(context, geom2);
653
- if (len1 >= 0 && len2 >= 0) {
654
- if (len1 == len2) {
655
- result = Qtrue;
656
- for (i=0; i<len1; ++i) {
657
- sub_geom1 = GEOSGetGeometryN_r(context, geom1, i);
658
- sub_geom2 = GEOSGetGeometryN_r(context, geom2, i);
659
- if (sub_geom1 && sub_geom2) {
660
- type1 = GEOSGeomTypeId_r(context, sub_geom1);
661
- type2 = GEOSGeomTypeId_r(context, sub_geom2);
662
- if (type1 >= 0 && type2 >= 0) {
663
- if (type1 == type2) {
664
- switch (type1) {
665
- case GEOS_POINT:
666
- case GEOS_LINESTRING:
667
- case GEOS_LINEARRING:
668
- result = rgeo_geos_coordseqs_eql(context, sub_geom1, sub_geom2, check_z);
669
- break;
670
- case GEOS_POLYGON:
671
- result = rgeo_geos_polygons_eql(context, sub_geom1, sub_geom2, check_z);
672
- break;
673
- case GEOS_GEOMETRYCOLLECTION:
674
- case GEOS_MULTIPOINT:
675
- case GEOS_MULTILINESTRING:
676
- case GEOS_MULTIPOLYGON:
677
- result = rgeo_geos_geometry_collections_eql(context, sub_geom1, sub_geom2, check_z);
678
- break;
679
- default:
680
- result = Qnil;
681
- break;
682
- }
683
- if (!RTEST(result)) {
684
- break;
685
- }
686
- }
687
- else {
688
- result = Qfalse;
689
- break;
690
- }
691
- }
692
- else {
693
- result = Qnil;
694
- break;
695
- }
696
- }
697
- else {
698
- result = Qnil;
699
- break;
700
- }
701
- }
702
- }
703
- else {
704
- result = Qfalse;
705
- }
706
- }
707
- }
708
- return result;
709
- }
710
-
711
-
712
- st_index_t rgeo_geos_geometry_collection_hash(GEOSContextHandle_t context, const GEOSGeometry* geom, st_index_t hash)
684
+ st_index_t
685
+ rgeo_geos_geometry_collection_hash(const GEOSGeometry* geom, st_index_t hash)
713
686
  {
714
687
  const GEOSGeometry* sub_geom;
715
688
  int type;
@@ -717,28 +690,28 @@ st_index_t rgeo_geos_geometry_collection_hash(GEOSContextHandle_t context, const
717
690
  unsigned int i;
718
691
 
719
692
  if (geom) {
720
- len = GEOSGetNumGeometries_r(context, geom);
721
- for (i=0; i<len; ++i) {
722
- sub_geom = GEOSGetGeometryN_r(context, geom, i);
693
+ len = GEOSGetNumGeometries(geom);
694
+ for (i = 0; i < len; ++i) {
695
+ sub_geom = GEOSGetGeometryN(geom, i);
723
696
  if (sub_geom) {
724
- type = GEOSGeomTypeId_r(context, sub_geom);
697
+ type = GEOSGeomTypeId(sub_geom);
725
698
  if (type >= 0) {
726
699
  hash = hash ^ type;
727
700
  switch (type) {
728
- case GEOS_POINT:
729
- case GEOS_LINESTRING:
730
- case GEOS_LINEARRING:
731
- hash = rgeo_geos_coordseq_hash(context, sub_geom, hash);
732
- break;
733
- case GEOS_POLYGON:
734
- hash = rgeo_geos_polygon_hash(context, sub_geom, hash);
735
- break;
736
- case GEOS_GEOMETRYCOLLECTION:
737
- case GEOS_MULTIPOINT:
738
- case GEOS_MULTILINESTRING:
739
- case GEOS_MULTIPOLYGON:
740
- hash = rgeo_geos_geometry_collection_hash(context, sub_geom, hash);
741
- break;
701
+ case GEOS_POINT:
702
+ case GEOS_LINESTRING:
703
+ case GEOS_LINEARRING:
704
+ hash = rgeo_geos_coordseq_hash(sub_geom, hash);
705
+ break;
706
+ case GEOS_POLYGON:
707
+ hash = rgeo_geos_polygon_hash(sub_geom, hash);
708
+ break;
709
+ case GEOS_GEOMETRYCOLLECTION:
710
+ case GEOS_MULTIPOINT:
711
+ case GEOS_MULTILINESTRING:
712
+ case GEOS_MULTIPOLYGON:
713
+ hash = rgeo_geos_geometry_collection_hash(sub_geom, hash);
714
+ break;
742
715
  }
743
716
  }
744
717
  }
@@ -747,7 +720,6 @@ st_index_t rgeo_geos_geometry_collection_hash(GEOSContextHandle_t context, const
747
720
  return hash;
748
721
  }
749
722
 
750
-
751
723
  RGEO_END_C
752
724
 
753
725
  #endif