rgeo 3.0.0.pre.rc.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -1
  3. data/ext/geos_c_impl/analysis.c +26 -23
  4. data/ext/geos_c_impl/analysis.h +8 -5
  5. data/ext/geos_c_impl/coordinates.c +27 -21
  6. data/ext/geos_c_impl/coordinates.h +5 -2
  7. data/ext/geos_c_impl/errors.c +15 -8
  8. data/ext/geos_c_impl/errors.h +4 -1
  9. data/ext/geos_c_impl/extconf.rb +40 -30
  10. data/ext/geos_c_impl/factory.c +405 -389
  11. data/ext/geos_c_impl/factory.h +71 -49
  12. data/ext/geos_c_impl/geometry.c +485 -408
  13. data/ext/geos_c_impl/geometry.h +5 -5
  14. data/ext/geos_c_impl/geometry_collection.c +269 -198
  15. data/ext/geos_c_impl/geometry_collection.h +6 -7
  16. data/ext/geos_c_impl/globals.c +99 -21
  17. data/ext/geos_c_impl/globals.h +3 -2
  18. data/ext/geos_c_impl/line_string.c +261 -220
  19. data/ext/geos_c_impl/line_string.h +5 -6
  20. data/ext/geos_c_impl/main.c +8 -9
  21. data/ext/geos_c_impl/point.c +62 -65
  22. data/ext/geos_c_impl/point.h +4 -5
  23. data/ext/geos_c_impl/polygon.c +121 -90
  24. data/ext/geos_c_impl/polygon.h +11 -9
  25. data/ext/geos_c_impl/preface.h +4 -13
  26. data/ext/geos_c_impl/ruby_more.c +39 -37
  27. data/ext/geos_c_impl/ruby_more.h +11 -2
  28. data/lib/rgeo/cartesian/analysis.rb +5 -3
  29. data/lib/rgeo/cartesian/bounding_box.rb +74 -79
  30. data/lib/rgeo/cartesian/calculations.rb +20 -26
  31. data/lib/rgeo/cartesian/factory.rb +52 -89
  32. data/lib/rgeo/cartesian/feature_methods.rb +0 -5
  33. data/lib/rgeo/cartesian/interface.rb +6 -5
  34. data/lib/rgeo/cartesian/planar_graph.rb +10 -16
  35. data/lib/rgeo/cartesian/sweepline_intersector.rb +1 -3
  36. data/lib/rgeo/cartesian/valid_op.rb +1 -3
  37. data/lib/rgeo/coord_sys/cs/entities.rb +299 -99
  38. data/lib/rgeo/coord_sys/cs/factories.rb +0 -2
  39. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +85 -37
  40. data/lib/rgeo/coord_sys.rb +1 -9
  41. data/lib/rgeo/feature/curve.rb +0 -11
  42. data/lib/rgeo/feature/factory.rb +26 -36
  43. data/lib/rgeo/feature/factory_generator.rb +6 -11
  44. data/lib/rgeo/feature/geometry.rb +41 -40
  45. data/lib/rgeo/feature/geometry_collection.rb +3 -4
  46. data/lib/rgeo/feature/line_string.rb +1 -2
  47. data/lib/rgeo/feature/linear_ring.rb +0 -1
  48. data/lib/rgeo/feature/multi_curve.rb +0 -6
  49. data/lib/rgeo/feature/multi_surface.rb +0 -1
  50. data/lib/rgeo/feature/point.rb +0 -1
  51. data/lib/rgeo/feature/polygon.rb +1 -2
  52. data/lib/rgeo/feature/surface.rb +0 -1
  53. data/lib/rgeo/feature/types.rb +73 -83
  54. data/lib/rgeo/geographic/factory.rb +93 -119
  55. data/lib/rgeo/geographic/interface.rb +62 -116
  56. data/lib/rgeo/geographic/projected_feature_methods.rb +2 -16
  57. data/lib/rgeo/geographic/projected_window.rb +36 -22
  58. data/lib/rgeo/geographic/{proj4_projector.rb → projector.rb} +3 -3
  59. data/lib/rgeo/geographic/simple_mercator_projector.rb +24 -21
  60. data/lib/rgeo/geographic/spherical_feature_methods.rb +8 -8
  61. data/lib/rgeo/geographic/spherical_math.rb +17 -20
  62. data/lib/rgeo/geographic.rb +1 -1
  63. data/lib/rgeo/geos/capi_factory.rb +70 -124
  64. data/lib/rgeo/geos/capi_feature_classes.rb +0 -29
  65. data/lib/rgeo/geos/ffi_factory.rb +90 -131
  66. data/lib/rgeo/geos/ffi_feature_methods.rb +73 -128
  67. data/lib/rgeo/geos/interface.rb +21 -36
  68. data/lib/rgeo/geos/utils.rb +3 -3
  69. data/lib/rgeo/geos/zm_factory.rb +53 -76
  70. data/lib/rgeo/geos/zm_feature_methods.rb +16 -34
  71. data/lib/rgeo/geos.rb +2 -5
  72. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +5 -18
  73. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -2
  74. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +18 -42
  75. data/lib/rgeo/impl_helper/basic_point_methods.rb +1 -13
  76. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +16 -25
  77. data/lib/rgeo/impl_helper/utils.rb +21 -0
  78. data/lib/rgeo/impl_helper/valid_op.rb +12 -16
  79. data/lib/rgeo/impl_helper/validity_check.rb +3 -3
  80. data/lib/rgeo/version.rb +1 -1
  81. data/lib/rgeo/wkrep/wkb_generator.rb +73 -63
  82. data/lib/rgeo/wkrep/wkb_parser.rb +33 -31
  83. data/lib/rgeo/wkrep/wkt_generator.rb +52 -45
  84. data/lib/rgeo/wkrep/wkt_parser.rb +48 -35
  85. data/lib/rgeo.rb +1 -3
  86. metadata +10 -9
@@ -2,31 +2,28 @@
2
2
  Geometry base class 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 <string.h>
11
- #include <ruby.h>
12
9
  #include <geos_c.h>
13
-
14
- #include "globals.h"
10
+ #include <ruby.h>
11
+ #include <string.h>
15
12
 
16
13
  #include "errors.h"
17
14
  #include "factory.h"
18
15
  #include "geometry.h"
16
+ #include "globals.h"
19
17
 
20
18
  RGEO_BEGIN_C
21
19
 
22
-
23
20
  /**** INTERNAL UTILITY FUNCTIONS ****/
24
21
 
22
+ // Determine the dimension of the given geometry. Empty collections have
23
+ // dimension -1. Recursively checks collection elemenets.
25
24
 
26
- // Determine the dimension of the given geometry. Empty collections have dimension -1.
27
- // Recursively checks collection elemenets.
28
-
29
- static int compute_dimension(GEOSContextHandle_t context, const GEOSGeometry* geom)
25
+ static int
26
+ compute_dimension(const GEOSGeometry* geom)
30
27
  {
31
28
  int result;
32
29
  int size;
@@ -35,50 +32,50 @@ static int compute_dimension(GEOSContextHandle_t context, const GEOSGeometry* ge
35
32
 
36
33
  result = -1;
37
34
  if (geom) {
38
- switch (GEOSGeomTypeId_r(context, geom)) {
39
- case GEOS_POINT:
40
- result = 0;
41
- break;
42
- case GEOS_MULTIPOINT:
43
- if (!GEOSisEmpty_r(context, geom)) {
35
+ switch (GEOSGeomTypeId(geom)) {
36
+ case GEOS_POINT:
44
37
  result = 0;
45
- }
46
- break;
47
- case GEOS_LINESTRING:
48
- case GEOS_LINEARRING:
49
- result = 1;
50
- break;
51
- case GEOS_MULTILINESTRING:
52
- if (!GEOSisEmpty_r(context, geom)) {
38
+ break;
39
+ case GEOS_MULTIPOINT:
40
+ if (!GEOSisEmpty(geom)) {
41
+ result = 0;
42
+ }
43
+ break;
44
+ case GEOS_LINESTRING:
45
+ case GEOS_LINEARRING:
53
46
  result = 1;
54
- }
55
- break;
56
- case GEOS_POLYGON:
57
- result = 2;
58
- break;
59
- case GEOS_MULTIPOLYGON:
60
- if (!GEOSisEmpty_r(context, geom)) {
47
+ break;
48
+ case GEOS_MULTILINESTRING:
49
+ if (!GEOSisEmpty(geom)) {
50
+ result = 1;
51
+ }
52
+ break;
53
+ case GEOS_POLYGON:
61
54
  result = 2;
62
- }
63
- break;
64
- case GEOS_GEOMETRYCOLLECTION:
65
- size = GEOSGetNumGeometries_r(context, geom);
66
- for (i=0; i<size; ++i) {
67
- dim = compute_dimension(context, GEOSGetGeometryN_r(context, geom, i));
68
- if (dim > result) {
69
- result = dim;
55
+ break;
56
+ case GEOS_MULTIPOLYGON:
57
+ if (!GEOSisEmpty(geom)) {
58
+ result = 2;
70
59
  }
71
- }
72
- break;
60
+ break;
61
+ case GEOS_GEOMETRYCOLLECTION:
62
+ size = GEOSGetNumGeometries(geom);
63
+ for (i = 0; i < size; ++i) {
64
+ dim = compute_dimension(GEOSGetGeometryN(geom, i));
65
+ if (dim > result) {
66
+ result = dim;
67
+ }
68
+ }
69
+ break;
73
70
  }
74
71
  }
75
72
  return result;
76
73
  }
77
74
 
78
-
79
75
  // Returns a prepared geometry, honoring the preparation policy.
80
76
 
81
- static const GEOSPreparedGeometry* rgeo_request_prepared_geometry(RGeo_GeometryData* object_data)
77
+ static const GEOSPreparedGeometry*
78
+ rgeo_request_prepared_geometry(RGeo_GeometryData* object_data)
82
79
  {
83
80
  const GEOSPreparedGeometry* prep;
84
81
 
@@ -86,62 +83,59 @@ static const GEOSPreparedGeometry* rgeo_request_prepared_geometry(RGeo_GeometryD
86
83
  if (prep == (const GEOSPreparedGeometry*)1) {
87
84
  object_data->prep = (GEOSPreparedGeometry*)2;
88
85
  prep = NULL;
89
- }
90
- else if (prep == (const GEOSPreparedGeometry*)2) {
86
+ } else if (prep == (const GEOSPreparedGeometry*)2) {
91
87
  if (object_data->geom) {
92
- prep = GEOSPrepare_r(object_data->geos_context, object_data->geom);
93
- }
94
- else {
88
+ prep = GEOSPrepare(object_data->geom);
89
+ } else {
95
90
  prep = NULL;
96
91
  }
97
92
  if (prep) {
98
93
  object_data->prep = prep;
99
- }
100
- else {
94
+ } else {
101
95
  object_data->prep = (const GEOSPreparedGeometry*)3;
102
96
  }
103
- }
104
- else if (prep == (const GEOSPreparedGeometry*)3) {
97
+ } else if (prep == (const GEOSPreparedGeometry*)3) {
105
98
  prep = NULL;
106
99
  }
107
100
  return prep;
108
101
  }
109
102
 
110
-
111
103
  /**** RUBY METHOD DEFINITIONS ****/
112
104
 
113
-
114
- static VALUE method_geometry_initialized_p(VALUE self)
105
+ static VALUE
106
+ method_geometry_initialized_p(VALUE self)
115
107
  {
116
108
  return RGEO_GEOMETRY_DATA_PTR(self)->geom ? Qtrue : Qfalse;
117
109
  }
118
110
 
119
-
120
- static VALUE method_geometry_factory(VALUE self)
111
+ static VALUE
112
+ method_geometry_factory(VALUE self)
121
113
  {
122
114
  return RGEO_GEOMETRY_DATA_PTR(self)->factory;
123
115
  }
124
116
 
125
-
126
- static VALUE method_geometry_set_factory(VALUE self, VALUE factory)
117
+ static VALUE
118
+ method_geometry_set_factory(VALUE self, VALUE factory)
127
119
  {
128
120
  RGEO_GEOMETRY_DATA_PTR(self)->factory = factory;
129
121
  return factory;
130
122
  }
131
123
 
132
-
133
- static VALUE method_geometry_prepared_p(VALUE self)
124
+ static VALUE
125
+ method_geometry_prepared_p(VALUE self)
134
126
  {
135
127
  const GEOSPreparedGeometry* prep;
136
128
 
137
129
  prep = RGEO_GEOMETRY_DATA_PTR(self)->prep;
138
130
  return (prep && prep != (const GEOSPreparedGeometry*)1 &&
139
- prep != (const GEOSPreparedGeometry*)2 &&
140
- prep != (GEOSPreparedGeometry*)3) ? Qtrue : Qfalse;
131
+ prep != (const GEOSPreparedGeometry*)2 &&
132
+ prep != (GEOSPreparedGeometry*)3)
133
+ ? Qtrue
134
+ : Qfalse;
141
135
  }
142
136
 
143
-
144
- static VALUE method_geometry_prepare(VALUE self)
137
+ static VALUE
138
+ method_geometry_prepare(VALUE self)
145
139
  {
146
140
  RGeo_GeometryData* self_data;
147
141
  const GEOSPreparedGeometry* prep;
@@ -149,12 +143,12 @@ static VALUE method_geometry_prepare(VALUE self)
149
143
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
150
144
  if (self_data->geom) {
151
145
  prep = self_data->prep;
152
- if (!prep || prep == (const GEOSPreparedGeometry*)1 || prep == (const GEOSPreparedGeometry*)2) {
153
- prep = GEOSPrepare_r(self_data->geos_context, self_data->geom);
146
+ if (!prep || prep == (const GEOSPreparedGeometry*)1 ||
147
+ prep == (const GEOSPreparedGeometry*)2) {
148
+ prep = GEOSPrepare(self_data->geom);
154
149
  if (prep) {
155
150
  self_data->prep = prep;
156
- }
157
- else {
151
+ } else {
158
152
  self_data->prep = (const GEOSPreparedGeometry*)3;
159
153
  }
160
154
  }
@@ -162,8 +156,8 @@ static VALUE method_geometry_prepare(VALUE self)
162
156
  return self;
163
157
  }
164
158
 
165
-
166
- static VALUE method_geometry_dimension(VALUE self)
159
+ static VALUE
160
+ method_geometry_dimension(VALUE self)
167
161
  {
168
162
  VALUE result;
169
163
  RGeo_GeometryData* self_data;
@@ -173,13 +167,13 @@ static VALUE method_geometry_dimension(VALUE self)
173
167
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
174
168
  self_geom = self_data->geom;
175
169
  if (self_geom) {
176
- result = INT2NUM(compute_dimension(self_data->geos_context, self_geom));
170
+ result = INT2NUM(compute_dimension(self_geom));
177
171
  }
178
172
  return result;
179
173
  }
180
174
 
181
-
182
- static VALUE method_geometry_geometry_type(VALUE self)
175
+ static VALUE
176
+ method_geometry_geometry_type(VALUE self)
183
177
  {
184
178
  VALUE result;
185
179
  RGeo_GeometryData* self_data;
@@ -192,8 +186,8 @@ static VALUE method_geometry_geometry_type(VALUE self)
192
186
  return result;
193
187
  }
194
188
 
195
-
196
- static VALUE method_geometry_srid(VALUE self)
189
+ static VALUE
190
+ method_geometry_srid(VALUE self)
197
191
  {
198
192
  VALUE result;
199
193
  RGeo_GeometryData* self_data;
@@ -203,49 +197,45 @@ static VALUE method_geometry_srid(VALUE self)
203
197
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
204
198
  self_geom = self_data->geom;
205
199
  if (self_geom) {
206
- result = INT2NUM(GEOSGetSRID_r(self_data->geos_context, self_geom));
200
+ result = INT2NUM(GEOSGetSRID(self_geom));
207
201
  }
208
202
  return result;
209
203
  }
210
204
 
211
-
212
- static VALUE method_geometry_envelope(VALUE self)
205
+ static VALUE
206
+ method_geometry_envelope(VALUE self)
213
207
  {
214
208
  VALUE result;
215
209
  RGeo_GeometryData* self_data;
216
210
  const GEOSGeometry* self_geom;
217
- GEOSContextHandle_t geos_context;
218
211
  GEOSGeometry* envelope;
219
212
 
220
213
  result = Qnil;
221
214
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
222
215
  self_geom = self_data->geom;
223
216
  if (self_geom) {
224
- geos_context = self_data->geos_context;
225
- envelope = GEOSEnvelope_r(geos_context, self_geom);
217
+ envelope = GEOSEnvelope(self_geom);
226
218
  if (!envelope) {
227
- envelope = GEOSGeom_createCollection_r(geos_context, GEOS_GEOMETRYCOLLECTION, NULL, 0);
219
+ envelope = GEOSGeom_createCollection(GEOS_GEOMETRYCOLLECTION, NULL, 0);
228
220
  }
229
221
  result = rgeo_wrap_geos_geometry(self_data->factory, envelope, Qnil);
230
222
  }
231
223
  return result;
232
224
  }
233
225
 
234
-
235
- static VALUE method_geometry_boundary(VALUE self)
226
+ static VALUE
227
+ method_geometry_boundary(VALUE self)
236
228
  {
237
229
  VALUE result;
238
230
  RGeo_GeometryData* self_data;
239
231
  const GEOSGeometry* self_geom;
240
- GEOSContextHandle_t geos_context;
241
232
  GEOSGeometry* boundary;
242
233
 
243
234
  result = Qnil;
244
235
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
245
236
  self_geom = self_data->geom;
246
237
  if (self_geom) {
247
- geos_context = self_data->geos_context;
248
- boundary = GEOSBoundary_r(geos_context, self_geom);
238
+ boundary = GEOSBoundary(self_geom);
249
239
  if (boundary) {
250
240
  result = rgeo_wrap_geos_geometry(self_data->factory, boundary, Qnil);
251
241
  }
@@ -253,8 +243,8 @@ static VALUE method_geometry_boundary(VALUE self)
253
243
  return result;
254
244
  }
255
245
 
256
-
257
- static VALUE method_geometry_as_text(VALUE self)
246
+ static VALUE
247
+ method_geometry_as_text(VALUE self)
258
248
  {
259
249
  VALUE result;
260
250
  RGeo_GeometryData* self_data;
@@ -262,7 +252,6 @@ static VALUE method_geometry_as_text(VALUE self)
262
252
  RGeo_FactoryData* factory_data;
263
253
  VALUE wkt_generator;
264
254
  GEOSWKTWriter* wkt_writer;
265
- GEOSContextHandle_t geos_context;
266
255
  char* str;
267
256
 
268
257
  result = Qnil;
@@ -273,26 +262,25 @@ static VALUE method_geometry_as_text(VALUE self)
273
262
  wkt_generator = factory_data->wkrep_wkt_generator;
274
263
  if (!NIL_P(wkt_generator)) {
275
264
  result = rb_funcall(wkt_generator, rb_intern("generate"), 1, self);
276
- }
277
- else {
265
+ } else {
278
266
  wkt_writer = factory_data->wkt_writer;
279
- geos_context = self_data->geos_context;
280
267
  if (!wkt_writer) {
281
- wkt_writer = GEOSWKTWriter_create_r(geos_context);
268
+ wkt_writer = GEOSWKTWriter_create();
269
+ GEOSWKTWriter_setTrim(wkt_writer, 1);
282
270
  factory_data->wkt_writer = wkt_writer;
283
271
  }
284
- str = GEOSWKTWriter_write_r(geos_context, wkt_writer, self_geom);
272
+ str = GEOSWKTWriter_write(wkt_writer, self_geom);
285
273
  if (str) {
286
274
  result = rb_str_new2(str);
287
- GEOSFree_r(geos_context, str);
275
+ GEOSFree(str);
288
276
  }
289
277
  }
290
278
  }
291
279
  return result;
292
280
  }
293
281
 
294
-
295
- static VALUE method_geometry_as_binary(VALUE self)
282
+ static VALUE
283
+ method_geometry_as_binary(VALUE self)
296
284
  {
297
285
  VALUE result;
298
286
  RGeo_GeometryData* self_data;
@@ -300,7 +288,6 @@ static VALUE method_geometry_as_binary(VALUE self)
300
288
  RGeo_FactoryData* factory_data;
301
289
  VALUE wkb_generator;
302
290
  GEOSWKBWriter* wkb_writer;
303
- GEOSContextHandle_t geos_context;
304
291
  size_t size;
305
292
  char* str;
306
293
 
@@ -312,26 +299,25 @@ static VALUE method_geometry_as_binary(VALUE self)
312
299
  wkb_generator = factory_data->wkrep_wkb_generator;
313
300
  if (!NIL_P(wkb_generator)) {
314
301
  result = rb_funcall(wkb_generator, rb_intern("generate"), 1, self);
315
- }
316
- else {
302
+ } else {
317
303
  wkb_writer = factory_data->wkb_writer;
318
- geos_context = self_data->geos_context;
304
+
319
305
  if (!wkb_writer) {
320
- wkb_writer = GEOSWKBWriter_create_r(geos_context);
306
+ wkb_writer = GEOSWKBWriter_create();
321
307
  factory_data->wkb_writer = wkb_writer;
322
308
  }
323
- str = (char*)GEOSWKBWriter_write_r(geos_context, wkb_writer, self_geom, &size);
309
+ str = (char*)GEOSWKBWriter_write(wkb_writer, self_geom, &size);
324
310
  if (str) {
325
311
  result = rb_str_new(str, size);
326
- GEOSFree_r(geos_context, str);
312
+ GEOSFree(str);
327
313
  }
328
314
  }
329
315
  }
330
316
  return result;
331
317
  }
332
318
 
333
-
334
- static VALUE method_geometry_is_empty(VALUE self)
319
+ static VALUE
320
+ method_geometry_is_empty(VALUE self)
335
321
  {
336
322
  VALUE result;
337
323
  RGeo_GeometryData* self_data;
@@ -342,19 +328,18 @@ static VALUE method_geometry_is_empty(VALUE self)
342
328
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
343
329
  self_geom = self_data->geom;
344
330
  if (self_geom) {
345
- val = GEOSisEmpty_r(self_data->geos_context, self_geom);
331
+ val = GEOSisEmpty(self_geom);
346
332
  if (val == 0) {
347
333
  result = Qfalse;
348
- }
349
- else if (val == 1) {
334
+ } else if (val == 1) {
350
335
  result = Qtrue;
351
336
  }
352
337
  }
353
338
  return result;
354
339
  }
355
340
 
356
-
357
- static VALUE method_geometry_is_simple(VALUE self)
341
+ static VALUE
342
+ method_geometry_is_simple(VALUE self)
358
343
  {
359
344
  VALUE result;
360
345
  RGeo_GeometryData* self_data;
@@ -365,26 +350,23 @@ static VALUE method_geometry_is_simple(VALUE self)
365
350
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
366
351
  self_geom = self_data->geom;
367
352
  if (self_geom) {
368
- val = GEOSisSimple_r(self_data->geos_context, self_geom);
353
+ val = GEOSisSimple(self_geom);
369
354
  if (val == 0) {
370
355
  result = Qfalse;
371
- }
372
- else if (val == 1) {
356
+ } else if (val == 1) {
373
357
  result = Qtrue;
374
358
  }
375
359
  }
376
360
  return result;
377
361
  }
378
362
 
379
-
380
- static VALUE method_geometry_equals(VALUE self, VALUE rhs)
363
+ static VALUE
364
+ method_geometry_equals(VALUE self, VALUE rhs)
381
365
  {
382
366
  VALUE result;
383
367
  RGeo_GeometryData* self_data;
384
368
  const GEOSGeometry* self_geom;
385
369
  const GEOSGeometry* rhs_geom;
386
- GEOSContextHandle_t self_context;
387
- char val;
388
370
 
389
371
  // Shortcut when self and rhs are the same object.
390
372
  if (self == rhs) {
@@ -397,42 +379,33 @@ static VALUE method_geometry_equals(VALUE self, VALUE rhs)
397
379
  if (self_geom) {
398
380
  rhs_geom = rgeo_get_geos_geometry_safe(rhs);
399
381
  if (rhs_geom) {
400
- self_context = self_data->geos_context;
401
382
  // GEOS has a bug where empty geometries are not spatially equal
402
383
  // to each other. Work around this case first.
403
- if (GEOSisEmpty_r(self_context, self_geom) == 1 &&
404
- GEOSisEmpty_r(RGEO_GEOMETRY_DATA_PTR(rhs)->geos_context, rhs_geom) == 1) {
384
+ if (GEOSisEmpty(self_geom) == 1 && GEOSisEmpty(rhs_geom) == 1) {
405
385
  result = Qtrue;
406
- }
407
- else {
408
- val = GEOSEquals_r(self_context, self_geom, rhs_geom);
409
- if (val == 0) {
410
- result = Qfalse;
411
- }
412
- else if (val == 1) {
413
- result = Qtrue;
414
- }
386
+ } else {
387
+ result = GEOSEquals(self_geom, rhs_geom) ? Qtrue : Qfalse;
415
388
  }
416
389
  }
417
390
  }
418
391
  return result;
419
392
  }
420
393
 
421
-
422
- static VALUE method_geometry_eql(VALUE self, VALUE rhs)
394
+ static VALUE
395
+ method_geometry_eql(VALUE self, VALUE rhs)
423
396
  {
424
397
  // This should be overridden by the subclass.
425
398
  return self == rhs ? Qtrue : Qfalse;
426
399
  }
427
400
 
428
-
429
- static VALUE method_geometry_disjoint(VALUE self, VALUE rhs)
401
+ static VALUE
402
+ method_geometry_disjoint(VALUE self, VALUE rhs)
430
403
  {
431
404
  VALUE result;
432
405
  RGeo_GeometryData* self_data;
433
406
  const GEOSGeometry* self_geom;
434
407
  const GEOSGeometry* rhs_geom;
435
- char val;
408
+ int state = 0;
436
409
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED2
437
410
  const GEOSPreparedGeometry* prep;
438
411
  #endif
@@ -441,34 +414,31 @@ static VALUE method_geometry_disjoint(VALUE self, VALUE rhs)
441
414
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
442
415
  self_geom = self_data->geom;
443
416
  if (self_geom) {
444
- rhs_geom = rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil);
445
- if (rhs_geom) {
417
+ rhs_geom =
418
+ rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
419
+ if (state) {
420
+ rb_jump_tag(state);
421
+ }
446
422
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED2
447
- prep = rgeo_request_prepared_geometry(self_data);
448
- if (prep)
449
- val = GEOSPreparedDisjoint_r(self_data->geos_context, prep, rhs_geom);
450
- else
423
+ prep = rgeo_request_prepared_geometry(self_data);
424
+ if (prep)
425
+ result = GEOSPreparedDisjoint(prep, rhs_geom) ? Qtrue : Qfalse;
426
+ else
451
427
  #endif
452
- val = GEOSDisjoint_r(self_data->geos_context, self_geom, rhs_geom);
453
- if (val == 0) {
454
- result = Qfalse;
455
- }
456
- else if (val == 1) {
457
- result = Qtrue;
458
- }
459
- }
428
+ result = GEOSDisjoint(self_geom, rhs_geom) ? Qtrue : Qfalse;
460
429
  }
461
430
  return result;
462
431
  }
463
432
 
464
-
465
- static VALUE method_geometry_intersects(VALUE self, VALUE rhs)
433
+ static VALUE
434
+ method_geometry_intersects(VALUE self, VALUE rhs)
466
435
  {
467
436
  VALUE result;
468
437
  RGeo_GeometryData* self_data;
469
438
  const GEOSGeometry* self_geom;
470
439
  const GEOSGeometry* rhs_geom;
471
440
  char val;
441
+ int state = 0;
472
442
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED1
473
443
  const GEOSPreparedGeometry* prep;
474
444
  #endif
@@ -477,34 +447,36 @@ static VALUE method_geometry_intersects(VALUE self, VALUE rhs)
477
447
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
478
448
  self_geom = self_data->geom;
479
449
  if (self_geom) {
480
- rhs_geom = rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil);
481
- if (rhs_geom) {
450
+ rhs_geom =
451
+ rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
452
+ if (state) {
453
+ rb_jump_tag(state);
454
+ }
482
455
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED1
483
- prep = rgeo_request_prepared_geometry(self_data);
484
- if (prep)
485
- val = GEOSPreparedIntersects_r(self_data->geos_context, prep, rhs_geom);
486
- else
456
+ prep = rgeo_request_prepared_geometry(self_data);
457
+ if (prep)
458
+ val = GEOSPreparedIntersects(prep, rhs_geom);
459
+ else
487
460
  #endif
488
- val = GEOSIntersects_r(self_data->geos_context, self_geom, rhs_geom);
489
- if (val == 0) {
490
- result = Qfalse;
491
- }
492
- else if (val == 1) {
493
- result = Qtrue;
494
- }
461
+ val = GEOSIntersects(self_geom, rhs_geom);
462
+ if (val == 0) {
463
+ result = Qfalse;
464
+ } else if (val == 1) {
465
+ result = Qtrue;
495
466
  }
496
467
  }
497
468
  return result;
498
469
  }
499
470
 
500
-
501
- static VALUE method_geometry_touches(VALUE self, VALUE rhs)
471
+ static VALUE
472
+ method_geometry_touches(VALUE self, VALUE rhs)
502
473
  {
503
474
  VALUE result;
504
475
  RGeo_GeometryData* self_data;
505
476
  const GEOSGeometry* self_geom;
506
477
  const GEOSGeometry* rhs_geom;
507
478
  char val;
479
+ int state = 0;
508
480
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED2
509
481
  const GEOSPreparedGeometry* prep;
510
482
  #endif
@@ -513,34 +485,36 @@ static VALUE method_geometry_touches(VALUE self, VALUE rhs)
513
485
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
514
486
  self_geom = self_data->geom;
515
487
  if (self_geom) {
516
- rhs_geom = rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil);
517
- if (rhs_geom) {
488
+ rhs_geom =
489
+ rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
490
+ if (state) {
491
+ rb_jump_tag(state);
492
+ }
518
493
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED2
519
- prep = rgeo_request_prepared_geometry(self_data);
520
- if (prep)
521
- val = GEOSPreparedTouches_r(self_data->geos_context, prep, rhs_geom);
522
- else
494
+ prep = rgeo_request_prepared_geometry(self_data);
495
+ if (prep)
496
+ val = GEOSPreparedTouches(prep, rhs_geom);
497
+ else
523
498
  #endif
524
- val = GEOSTouches_r(self_data->geos_context, self_geom, rhs_geom);
525
- if (val == 0) {
526
- result = Qfalse;
527
- }
528
- else if (val == 1) {
529
- result = Qtrue;
530
- }
499
+ val = GEOSTouches(self_geom, rhs_geom);
500
+ if (val == 0) {
501
+ result = Qfalse;
502
+ } else if (val == 1) {
503
+ result = Qtrue;
531
504
  }
532
505
  }
533
506
  return result;
534
507
  }
535
508
 
536
-
537
- static VALUE method_geometry_crosses(VALUE self, VALUE rhs)
509
+ static VALUE
510
+ method_geometry_crosses(VALUE self, VALUE rhs)
538
511
  {
539
512
  VALUE result;
540
513
  RGeo_GeometryData* self_data;
541
514
  const GEOSGeometry* self_geom;
542
515
  const GEOSGeometry* rhs_geom;
543
516
  char val;
517
+ int state = 0;
544
518
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED2
545
519
  const GEOSPreparedGeometry* prep;
546
520
  #endif
@@ -549,34 +523,36 @@ static VALUE method_geometry_crosses(VALUE self, VALUE rhs)
549
523
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
550
524
  self_geom = self_data->geom;
551
525
  if (self_geom) {
552
- rhs_geom = rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil);
553
- if (rhs_geom) {
526
+ rhs_geom =
527
+ rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
528
+ if (state) {
529
+ rb_jump_tag(state);
530
+ }
554
531
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED2
555
- prep = rgeo_request_prepared_geometry(self_data);
556
- if (prep)
557
- val = GEOSPreparedCrosses_r(self_data->geos_context, prep, rhs_geom);
558
- else
532
+ prep = rgeo_request_prepared_geometry(self_data);
533
+ if (prep)
534
+ val = GEOSPreparedCrosses(prep, rhs_geom);
535
+ else
559
536
  #endif
560
- val = GEOSCrosses_r(self_data->geos_context, self_geom, rhs_geom);
561
- if (val == 0) {
562
- result = Qfalse;
563
- }
564
- else if (val == 1) {
565
- result = Qtrue;
566
- }
537
+ val = GEOSCrosses(self_geom, rhs_geom);
538
+ if (val == 0) {
539
+ result = Qfalse;
540
+ } else if (val == 1) {
541
+ result = Qtrue;
567
542
  }
568
543
  }
569
544
  return result;
570
545
  }
571
546
 
572
-
573
- static VALUE method_geometry_within(VALUE self, VALUE rhs)
547
+ static VALUE
548
+ method_geometry_within(VALUE self, VALUE rhs)
574
549
  {
575
550
  VALUE result;
576
551
  RGeo_GeometryData* self_data;
577
552
  const GEOSGeometry* self_geom;
578
553
  const GEOSGeometry* rhs_geom;
579
554
  char val;
555
+ int state = 0;
580
556
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED2
581
557
  const GEOSPreparedGeometry* prep;
582
558
  #endif
@@ -585,34 +561,36 @@ static VALUE method_geometry_within(VALUE self, VALUE rhs)
585
561
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
586
562
  self_geom = self_data->geom;
587
563
  if (self_geom) {
588
- rhs_geom = rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil);
589
- if (rhs_geom) {
564
+ rhs_geom =
565
+ rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
566
+ if (state) {
567
+ rb_jump_tag(state);
568
+ }
590
569
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED2
591
- prep = rgeo_request_prepared_geometry(self_data);
592
- if (prep)
593
- val = GEOSPreparedWithin_r(self_data->geos_context, prep, rhs_geom);
594
- else
570
+ prep = rgeo_request_prepared_geometry(self_data);
571
+ if (prep)
572
+ val = GEOSPreparedWithin(prep, rhs_geom);
573
+ else
595
574
  #endif
596
- val = GEOSWithin_r(self_data->geos_context, self_geom, rhs_geom);
597
- if (val == 0) {
598
- result = Qfalse;
599
- }
600
- else if (val == 1) {
601
- result = Qtrue;
602
- }
575
+ val = GEOSWithin(self_geom, rhs_geom);
576
+ if (val == 0) {
577
+ result = Qfalse;
578
+ } else if (val == 1) {
579
+ result = Qtrue;
603
580
  }
604
581
  }
605
582
  return result;
606
583
  }
607
584
 
608
-
609
- static VALUE method_geometry_contains(VALUE self, VALUE rhs)
585
+ static VALUE
586
+ method_geometry_contains(VALUE self, VALUE rhs)
610
587
  {
611
588
  VALUE result;
612
589
  RGeo_GeometryData* self_data;
613
590
  const GEOSGeometry* self_geom;
614
591
  const GEOSGeometry* rhs_geom;
615
592
  char val;
593
+ int state = 0;
616
594
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED1
617
595
  const GEOSPreparedGeometry* prep;
618
596
  #endif
@@ -621,34 +599,36 @@ static VALUE method_geometry_contains(VALUE self, VALUE rhs)
621
599
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
622
600
  self_geom = self_data->geom;
623
601
  if (self_geom) {
624
- rhs_geom = rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil);
625
- if (rhs_geom) {
602
+ rhs_geom =
603
+ rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
604
+ if (state) {
605
+ rb_jump_tag(state);
606
+ }
626
607
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED1
627
- prep = rgeo_request_prepared_geometry(self_data);
628
- if (prep)
629
- val = GEOSPreparedContains_r(self_data->geos_context, prep, rhs_geom);
630
- else
608
+ prep = rgeo_request_prepared_geometry(self_data);
609
+ if (prep)
610
+ val = GEOSPreparedContains(prep, rhs_geom);
611
+ else
631
612
  #endif
632
- val = GEOSContains_r(self_data->geos_context, self_geom, rhs_geom);
633
- if (val == 0) {
634
- result = Qfalse;
635
- }
636
- else if (val == 1) {
637
- result = Qtrue;
638
- }
613
+ val = GEOSContains(self_geom, rhs_geom);
614
+ if (val == 0) {
615
+ result = Qfalse;
616
+ } else if (val == 1) {
617
+ result = Qtrue;
639
618
  }
640
619
  }
641
620
  return result;
642
621
  }
643
622
 
644
-
645
- static VALUE method_geometry_overlaps(VALUE self, VALUE rhs)
623
+ static VALUE
624
+ method_geometry_overlaps(VALUE self, VALUE rhs)
646
625
  {
647
626
  VALUE result;
648
627
  RGeo_GeometryData* self_data;
649
628
  const GEOSGeometry* self_geom;
650
629
  const GEOSGeometry* rhs_geom;
651
630
  char val;
631
+ int state = 0;
652
632
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED2
653
633
  const GEOSPreparedGeometry* prep;
654
634
  #endif
@@ -657,78 +637,86 @@ static VALUE method_geometry_overlaps(VALUE self, VALUE rhs)
657
637
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
658
638
  self_geom = self_data->geom;
659
639
  if (self_geom) {
660
- rhs_geom = rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil);
661
- if (rhs_geom) {
640
+ rhs_geom =
641
+ rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
642
+ if (state) {
643
+ rb_jump_tag(state);
644
+ }
662
645
  #ifdef RGEO_GEOS_SUPPORTS_PREPARED2
663
- prep = rgeo_request_prepared_geometry(self_data);
664
- if (prep)
665
- val = GEOSPreparedOverlaps_r(self_data->geos_context, prep, rhs_geom);
666
- else
646
+ prep = rgeo_request_prepared_geometry(self_data);
647
+ if (prep)
648
+ val = GEOSPreparedOverlaps(prep, rhs_geom);
649
+ else
667
650
  #endif
668
- val = GEOSOverlaps_r(self_data->geos_context, self_geom, rhs_geom);
669
- if (val == 0) {
670
- result = Qfalse;
671
- }
672
- else if (val == 1) {
673
- result = Qtrue;
674
- }
651
+ val = GEOSOverlaps(self_geom, rhs_geom);
652
+ if (val == 0) {
653
+ result = Qfalse;
654
+ } else if (val == 1) {
655
+ result = Qtrue;
675
656
  }
676
657
  }
677
658
  return result;
678
659
  }
679
660
 
680
-
681
- static VALUE method_geometry_relate(VALUE self, VALUE rhs, VALUE pattern)
661
+ static VALUE
662
+ method_geometry_relate(VALUE self, VALUE rhs, VALUE pattern)
682
663
  {
683
664
  VALUE result;
684
665
  RGeo_GeometryData* self_data;
685
666
  const GEOSGeometry* self_geom;
686
667
  const GEOSGeometry* rhs_geom;
687
668
  char val;
669
+ int state = 0;
688
670
 
689
671
  result = Qnil;
690
672
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
691
673
  self_geom = self_data->geom;
692
674
  if (self_geom) {
693
- rhs_geom = rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil);
694
- if (rhs_geom) {
695
- val = GEOSRelatePattern_r(self_data->geos_context, self_geom, rhs_geom, StringValuePtr(pattern));
696
- if (val == 0) {
697
- result = Qfalse;
698
- }
699
- else if (val == 1) {
700
- result = Qtrue;
701
- }
675
+ rhs_geom =
676
+ rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
677
+ if (state) {
678
+ rb_jump_tag(state);
679
+ }
680
+
681
+ val = GEOSRelatePattern(self_geom, rhs_geom, StringValuePtr(pattern));
682
+ if (val == 0) {
683
+ result = Qfalse;
684
+ } else if (val == 1) {
685
+ result = Qtrue;
702
686
  }
703
687
  }
704
688
  return result;
705
689
  }
706
690
 
707
-
708
- static VALUE method_geometry_distance(VALUE self, VALUE rhs)
691
+ static VALUE
692
+ method_geometry_distance(VALUE self, VALUE rhs)
709
693
  {
710
694
  VALUE result;
711
695
  RGeo_GeometryData* self_data;
712
696
  const GEOSGeometry* self_geom;
713
697
  const GEOSGeometry* rhs_geom;
714
698
  double dist;
699
+ int state = 0;
715
700
 
716
701
  result = Qnil;
717
702
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
718
703
  self_geom = self_data->geom;
719
704
  if (self_geom) {
720
- rhs_geom = rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil);
721
- if (rhs_geom) {
722
- if (GEOSDistance_r(self_data->geos_context, self_geom, rhs_geom, &dist)) {
723
- result = rb_float_new(dist);
724
- }
705
+ rhs_geom =
706
+ rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
707
+ if (state) {
708
+ rb_jump_tag(state);
709
+ }
710
+
711
+ if (GEOSDistance(self_geom, rhs_geom, &dist)) {
712
+ result = rb_float_new(dist);
725
713
  }
726
714
  }
727
715
  return result;
728
716
  }
729
717
 
730
-
731
- static VALUE method_geometry_buffer(VALUE self, VALUE distance)
718
+ static VALUE
719
+ method_geometry_buffer(VALUE self, VALUE distance)
732
720
  {
733
721
  VALUE result;
734
722
  RGeo_GeometryData* self_data;
@@ -740,13 +728,22 @@ static VALUE method_geometry_buffer(VALUE self, VALUE distance)
740
728
  self_geom = self_data->geom;
741
729
  if (self_geom) {
742
730
  factory = self_data->factory;
743
- result = rgeo_wrap_geos_geometry(factory, GEOSBuffer_r(self_data->geos_context, self_geom,
744
- rb_num2dbl(distance), RGEO_FACTORY_DATA_PTR(factory)->buffer_resolution), Qnil);
731
+ result = rgeo_wrap_geos_geometry(
732
+ factory,
733
+ GEOSBuffer(self_geom,
734
+ rb_num2dbl(distance),
735
+ RGEO_FACTORY_DATA_PTR(factory)->buffer_resolution),
736
+ Qnil);
745
737
  }
746
738
  return result;
747
739
  }
748
740
 
749
- static VALUE method_geometry_buffer_with_style(VALUE self, VALUE distance, VALUE endCapStyle, VALUE joinStyle, VALUE mitreLimit)
741
+ static VALUE
742
+ method_geometry_buffer_with_style(VALUE self,
743
+ VALUE distance,
744
+ VALUE endCapStyle,
745
+ VALUE joinStyle,
746
+ VALUE mitreLimit)
750
747
  {
751
748
  VALUE result;
752
749
  RGeo_GeometryData* self_data;
@@ -758,19 +755,21 @@ static VALUE method_geometry_buffer_with_style(VALUE self, VALUE distance, VALUE
758
755
  self_geom = self_data->geom;
759
756
  if (self_geom) {
760
757
  factory = self_data->factory;
761
- result = rgeo_wrap_geos_geometry(factory,
762
- GEOSBufferWithStyle_r(self_data->geos_context, self_geom,
763
- rb_num2dbl(distance),
764
- RGEO_FACTORY_DATA_PTR(factory)->buffer_resolution,
765
- rb_num2int(endCapStyle),
766
- rb_num2int(joinStyle),
767
- rb_num2dbl(mitreLimit)),
768
- Qnil);
758
+ result = rgeo_wrap_geos_geometry(
759
+ factory,
760
+ GEOSBufferWithStyle(self_geom,
761
+ rb_num2dbl(distance),
762
+ RGEO_FACTORY_DATA_PTR(factory)->buffer_resolution,
763
+ RB_NUM2INT(endCapStyle),
764
+ RB_NUM2INT(joinStyle),
765
+ rb_num2dbl(mitreLimit)),
766
+ Qnil);
769
767
  }
770
768
  return result;
771
769
  }
772
770
 
773
- static VALUE method_geometry_simplify(VALUE self, VALUE tolerance)
771
+ static VALUE
772
+ method_geometry_simplify(VALUE self, VALUE tolerance)
774
773
  {
775
774
  VALUE result;
776
775
  RGeo_GeometryData* self_data;
@@ -782,13 +781,14 @@ static VALUE method_geometry_simplify(VALUE self, VALUE tolerance)
782
781
  self_geom = self_data->geom;
783
782
  if (self_geom) {
784
783
  factory = self_data->factory;
785
- result = rgeo_wrap_geos_geometry(factory, GEOSSimplify_r(self_data->geos_context, self_geom,
786
- rb_num2dbl(tolerance)), Qnil);
784
+ result = rgeo_wrap_geos_geometry(
785
+ factory, GEOSSimplify(self_geom, rb_num2dbl(tolerance)), Qnil);
787
786
  }
788
787
  return result;
789
788
  }
790
789
 
791
- static VALUE method_geometry_simplify_preserve_topology(VALUE self, VALUE tolerance)
790
+ static VALUE
791
+ method_geometry_simplify_preserve_topology(VALUE self, VALUE tolerance)
792
792
  {
793
793
  VALUE result;
794
794
  RGeo_GeometryData* self_data;
@@ -800,14 +800,16 @@ static VALUE method_geometry_simplify_preserve_topology(VALUE self, VALUE tolera
800
800
  self_geom = self_data->geom;
801
801
  if (self_geom) {
802
802
  factory = self_data->factory;
803
- result = rgeo_wrap_geos_geometry(factory, GEOSTopologyPreserveSimplify_r(self_data->geos_context, self_geom,
804
- rb_num2dbl(tolerance)), Qnil);
803
+ result = rgeo_wrap_geos_geometry(
804
+ factory,
805
+ GEOSTopologyPreserveSimplify(self_geom, rb_num2dbl(tolerance)),
806
+ Qnil);
805
807
  }
806
808
  return result;
807
809
  }
808
810
 
809
-
810
- static VALUE method_geometry_convex_hull(VALUE self)
811
+ static VALUE
812
+ method_geometry_convex_hull(VALUE self)
811
813
  {
812
814
  VALUE result;
813
815
  RGeo_GeometryData* self_data;
@@ -817,57 +819,66 @@ static VALUE method_geometry_convex_hull(VALUE self)
817
819
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
818
820
  self_geom = self_data->geom;
819
821
  if (self_geom) {
820
- result = rgeo_wrap_geos_geometry(self_data->factory, GEOSConvexHull_r(self_data->geos_context, self_geom), Qnil);
822
+ result = rgeo_wrap_geos_geometry(
823
+ self_data->factory, GEOSConvexHull(self_geom), Qnil);
821
824
  }
822
825
  return result;
823
826
  }
824
827
 
825
-
826
- static VALUE method_geometry_intersection(VALUE self, VALUE rhs)
828
+ static VALUE
829
+ method_geometry_intersection(VALUE self, VALUE rhs)
827
830
  {
828
831
  VALUE result;
829
832
  RGeo_GeometryData* self_data;
830
833
  const GEOSGeometry* self_geom;
831
834
  VALUE factory;
832
835
  const GEOSGeometry* rhs_geom;
836
+ int state = 0;
833
837
 
834
838
  result = Qnil;
835
839
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
836
840
  self_geom = self_data->geom;
837
841
  if (self_geom) {
838
842
  factory = self_data->factory;
839
- rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil);
840
- if (rhs_geom) {
841
- result = rgeo_wrap_geos_geometry(factory, GEOSIntersection_r(self_data->geos_context, self_geom, rhs_geom), Qnil);
843
+ rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil, &state);
844
+ if (state) {
845
+ rb_jump_tag(state);
842
846
  }
847
+
848
+ result = rgeo_wrap_geos_geometry(
849
+ factory, GEOSIntersection(self_geom, rhs_geom), Qnil);
843
850
  }
844
851
  return result;
845
852
  }
846
853
 
847
-
848
- static VALUE method_geometry_union(VALUE self, VALUE rhs)
854
+ static VALUE
855
+ method_geometry_union(VALUE self, VALUE rhs)
849
856
  {
850
857
  VALUE result;
851
858
  RGeo_GeometryData* self_data;
852
859
  const GEOSGeometry* self_geom;
853
860
  VALUE factory;
854
861
  const GEOSGeometry* rhs_geom;
862
+ int state = 0;
855
863
 
856
864
  result = Qnil;
857
865
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
858
866
  self_geom = self_data->geom;
859
867
  if (self_geom) {
860
868
  factory = self_data->factory;
861
- rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil);
862
- if (rhs_geom) {
863
- result = rgeo_wrap_geos_geometry(factory, GEOSUnion_r(self_data->geos_context, self_geom, rhs_geom), Qnil);
869
+ rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil, &state);
870
+ if (state) {
871
+ rb_jump_tag(state);
864
872
  }
873
+
874
+ result =
875
+ rgeo_wrap_geos_geometry(factory, GEOSUnion(self_geom, rhs_geom), Qnil);
865
876
  }
866
877
  return result;
867
878
  }
868
879
 
869
-
870
- static VALUE method_geometry_unary_union(VALUE self)
880
+ static VALUE
881
+ method_geometry_unary_union(VALUE self)
871
882
  {
872
883
  #ifdef RGEO_GEOS_SUPPORTS_UNARYUNION
873
884
  RGeo_GeometryData* self_data;
@@ -876,83 +887,88 @@ static VALUE method_geometry_unary_union(VALUE self)
876
887
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
877
888
  self_geom = self_data->geom;
878
889
  if (self_geom) {
879
- GEOSContextHandle_t self_context = self_data->geos_context;
880
- return rgeo_wrap_geos_geometry(self_data->factory,
881
- GEOSUnaryUnion_r(self_context, self_geom),
882
- Qnil);
890
+ return rgeo_wrap_geos_geometry(
891
+ self_data->factory, GEOSUnaryUnion(self_geom), Qnil);
883
892
  }
884
893
  #endif
885
894
 
886
895
  return Qnil;
887
896
  }
888
897
 
889
-
890
- static VALUE method_geometry_difference(VALUE self, VALUE rhs)
898
+ static VALUE
899
+ method_geometry_difference(VALUE self, VALUE rhs)
891
900
  {
892
901
  VALUE result;
893
902
  RGeo_GeometryData* self_data;
894
903
  const GEOSGeometry* self_geom;
895
904
  VALUE factory;
896
905
  const GEOSGeometry* rhs_geom;
906
+ int state = 0;
897
907
 
898
908
  result = Qnil;
899
909
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
900
910
  self_geom = self_data->geom;
901
911
  if (self_geom) {
902
912
  factory = self_data->factory;
903
- rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil);
904
- if (rhs_geom) {
905
- result = rgeo_wrap_geos_geometry(factory, GEOSDifference_r(self_data->geos_context, self_geom, rhs_geom), Qnil);
913
+ rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil, &state);
914
+ if (state) {
915
+ rb_jump_tag(state);
906
916
  }
917
+
918
+ result = rgeo_wrap_geos_geometry(
919
+ factory, GEOSDifference(self_geom, rhs_geom), Qnil);
907
920
  }
908
921
  return result;
909
922
  }
910
923
 
911
-
912
- static VALUE method_geometry_sym_difference(VALUE self, VALUE rhs)
924
+ static VALUE
925
+ method_geometry_sym_difference(VALUE self, VALUE rhs)
913
926
  {
914
927
  VALUE result;
915
928
  RGeo_GeometryData* self_data;
916
929
  const GEOSGeometry* self_geom;
917
930
  VALUE factory;
918
931
  const GEOSGeometry* rhs_geom;
932
+ int state = 0;
919
933
 
920
934
  result = Qnil;
921
935
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
922
936
  self_geom = self_data->geom;
923
937
  if (self_geom) {
924
938
  factory = self_data->factory;
925
- rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil);
926
- if (rhs_geom) {
927
- result = rgeo_wrap_geos_geometry(factory, GEOSSymDifference_r(self_data->geos_context, self_geom, rhs_geom), Qnil);
939
+ rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil, &state);
940
+ if (state) {
941
+ rb_jump_tag(state);
928
942
  }
943
+
944
+ result = rgeo_wrap_geos_geometry(
945
+ factory, GEOSSymDifference(self_geom, rhs_geom), Qnil);
929
946
  }
930
947
  return result;
931
948
  }
932
949
 
933
-
934
- static VALUE method_geometry_initialize_copy(VALUE self, VALUE orig)
950
+ static VALUE
951
+ method_geometry_initialize_copy(VALUE self, VALUE orig)
935
952
  {
936
953
  RGeo_GeometryData* self_data;
937
954
  const GEOSPreparedGeometry* prep;
938
955
  const GEOSGeometry* geom;
939
956
  RGeo_GeometryData* orig_data;
940
- GEOSContextHandle_t orig_context;
941
957
  GEOSGeometry* clone_geom;
942
958
  RGeo_FactoryData* factory_data;
943
959
 
944
960
  // Clear out any existing value
945
961
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
946
962
  if (self_data->geom) {
947
- GEOSGeom_destroy_r(self_data->geos_context, self_data->geom);
963
+ GEOSGeom_destroy(self_data->geom);
948
964
  self_data->geom = NULL;
949
965
  }
950
966
  prep = self_data->prep;
951
- if (prep && prep != (GEOSPreparedGeometry*)1 && prep != (GEOSPreparedGeometry*)2) {
952
- GEOSPreparedGeom_destroy_r(self_data->geos_context, prep);
967
+ if (prep && prep != (GEOSPreparedGeometry*)1 &&
968
+ prep != (GEOSPreparedGeometry*)2) {
969
+ GEOSPreparedGeom_destroy(prep);
953
970
  }
954
971
  self_data->prep = NULL;
955
- self_data->geos_context = NULL;
956
972
  self_data->factory = Qnil;
957
973
  self_data->klasses = Qnil;
958
974
 
@@ -960,15 +976,16 @@ static VALUE method_geometry_initialize_copy(VALUE self, VALUE orig)
960
976
  geom = rgeo_get_geos_geometry_safe(orig);
961
977
  if (geom) {
962
978
  orig_data = RGEO_GEOMETRY_DATA_PTR(orig);
963
- orig_context = orig_data->geos_context;
964
- clone_geom = GEOSGeom_clone_r(orig_context, geom);
979
+ clone_geom = GEOSGeom_clone(geom);
965
980
  if (clone_geom) {
966
981
  factory_data = RGEO_FACTORY_DATA_PTR(orig_data->factory);
967
- GEOSSetSRID_r(orig_context, clone_geom, GEOSGetSRID_r(orig_context, geom));
982
+ GEOSSetSRID(clone_geom, GEOSGetSRID(geom));
968
983
  self_data->geom = clone_geom;
969
- self_data->geos_context = orig_context;
970
- self_data->prep = factory_data && ((factory_data->flags & RGEO_FACTORYFLAGS_PREPARE_HEURISTIC) != 0) ?
971
- (GEOSPreparedGeometry*)1 : NULL;
984
+ self_data->prep =
985
+ factory_data &&
986
+ ((factory_data->flags & RGEO_FACTORYFLAGS_PREPARE_HEURISTIC) != 0)
987
+ ? (GEOSPreparedGeometry*)1
988
+ : NULL;
972
989
  self_data->factory = orig_data->factory;
973
990
  self_data->klasses = orig_data->klasses;
974
991
  }
@@ -976,8 +993,8 @@ static VALUE method_geometry_initialize_copy(VALUE self, VALUE orig)
976
993
  return self;
977
994
  }
978
995
 
979
-
980
- static VALUE method_geometry_steal(VALUE self, VALUE orig)
996
+ static VALUE
997
+ method_geometry_steal(VALUE self, VALUE orig)
981
998
  {
982
999
  RGeo_GeometryData* self_data;
983
1000
  const GEOSPreparedGeometry* prep;
@@ -989,32 +1006,32 @@ static VALUE method_geometry_steal(VALUE self, VALUE orig)
989
1006
  // Clear out any existing value
990
1007
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
991
1008
  if (self_data->geom) {
992
- GEOSGeom_destroy_r(self_data->geos_context, self_data->geom);
1009
+ GEOSGeom_destroy(self_data->geom);
993
1010
  }
994
1011
  prep = self_data->prep;
995
- if (prep && prep != (GEOSPreparedGeometry*)1 && prep != (GEOSPreparedGeometry*)2) {
996
- GEOSPreparedGeom_destroy_r(self_data->geos_context, prep);
1012
+ if (prep && prep != (GEOSPreparedGeometry*)1 &&
1013
+ prep != (GEOSPreparedGeometry*)2) {
1014
+ GEOSPreparedGeom_destroy(prep);
997
1015
  }
998
1016
 
999
1017
  // Steal value from orig
1000
1018
  orig_data = RGEO_GEOMETRY_DATA_PTR(orig);
1001
1019
  self_data->geom = orig_data->geom;
1002
1020
  self_data->prep = orig_data->prep;
1003
- self_data->geos_context = orig_data->geos_context;
1004
1021
  self_data->factory = orig_data->factory;
1005
1022
  self_data->klasses = orig_data->klasses;
1006
1023
 
1007
1024
  // Clear out orig
1008
1025
  orig_data->geom = NULL;
1009
1026
  orig_data->prep = NULL;
1010
- orig_data->geos_context = NULL;
1011
1027
  orig_data->factory = Qnil;
1012
1028
  orig_data->klasses = Qnil;
1013
1029
  }
1014
1030
  return self;
1015
1031
  }
1016
1032
 
1017
- static VALUE method_geometry_is_valid(VALUE self)
1033
+ static VALUE
1034
+ method_geometry_is_valid(VALUE self)
1018
1035
  {
1019
1036
  VALUE result;
1020
1037
  RGeo_GeometryData* self_data;
@@ -1025,18 +1042,18 @@ static VALUE method_geometry_is_valid(VALUE self)
1025
1042
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
1026
1043
  self_geom = self_data->geom;
1027
1044
  if (self_geom) {
1028
- val = GEOSisValid_r(self_data->geos_context, self_geom);
1045
+ val = GEOSisValid(self_geom);
1029
1046
  if (val == 0) {
1030
1047
  result = Qfalse;
1031
- }
1032
- else if (val == 1) {
1048
+ } else if (val == 1) {
1033
1049
  result = Qtrue;
1034
1050
  }
1035
1051
  }
1036
1052
  return result;
1037
1053
  }
1038
1054
 
1039
- static VALUE method_geometry_invalid_reason(VALUE self)
1055
+ static VALUE
1056
+ method_geometry_invalid_reason(VALUE self)
1040
1057
  {
1041
1058
  VALUE result;
1042
1059
  RGeo_GeometryData* self_data;
@@ -1048,7 +1065,7 @@ static VALUE method_geometry_invalid_reason(VALUE self)
1048
1065
  self_geom = self_data->geom;
1049
1066
  if (self_geom) {
1050
1067
  // We use NULL there to tell GEOS that we don't care about the position.
1051
- switch(GEOSisValidDetail_r(self_data->geos_context, self_geom, 0, &str, NULL)) {
1068
+ switch (GEOSisValidDetail(self_geom, 0, &str, NULL)) {
1052
1069
  case 0: // invalid
1053
1070
  result = rb_utf8_str_new_cstr(str);
1054
1071
  case 1: // valid
@@ -1058,12 +1075,14 @@ static VALUE method_geometry_invalid_reason(VALUE self)
1058
1075
  result = rb_utf8_str_new_cstr("Exception");
1059
1076
  break;
1060
1077
  };
1061
- if (str) GEOSFree_r(self_data->geos_context, str);
1078
+ if (str)
1079
+ GEOSFree(str);
1062
1080
  }
1063
1081
  return result;
1064
1082
  }
1065
1083
 
1066
- static VALUE method_geometry_invalid_reason_location(VALUE self)
1084
+ static VALUE
1085
+ method_geometry_invalid_reason_location(VALUE self)
1067
1086
  {
1068
1087
  VALUE result;
1069
1088
  RGeo_GeometryData* self_data;
@@ -1075,7 +1094,7 @@ static VALUE method_geometry_invalid_reason_location(VALUE self)
1075
1094
  self_geom = self_data->geom;
1076
1095
  if (self_geom) {
1077
1096
  // We use NULL there to tell GEOS that we don't care about the reason.
1078
- switch(GEOSisValidDetail_r(self_data->geos_context, self_geom, 0, NULL, &location)) {
1097
+ switch (GEOSisValidDetail(self_geom, 0, NULL, &location)) {
1079
1098
  case 0: // invalid
1080
1099
  result = rgeo_wrap_geos_geometry(self_data->factory, location, Qnil);
1081
1100
  case 1: // valid
@@ -1089,24 +1108,29 @@ static VALUE method_geometry_invalid_reason_location(VALUE self)
1089
1108
  return result;
1090
1109
  }
1091
1110
 
1092
- static VALUE method_geometry_make_valid(VALUE self)
1111
+ static VALUE
1112
+ method_geometry_make_valid(VALUE self)
1093
1113
  {
1094
1114
  RGeo_GeometryData* self_data;
1095
1115
  const GEOSGeometry* self_geom;
1096
1116
  GEOSGeometry* valid_geom;
1097
1117
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
1098
1118
  self_geom = self_data->geom;
1099
- if (!self_geom) return Qnil;
1119
+ if (!self_geom)
1120
+ return Qnil;
1100
1121
 
1101
1122
  // According to GEOS implementation, MakeValid always returns.
1102
- valid_geom = GEOSMakeValid_r(self_data->geos_context, self_geom);
1123
+ valid_geom = GEOSMakeValid(self_geom);
1103
1124
  if (!valid_geom) {
1104
- rb_raise(rb_eRGeoInvalidGeometry, "%"PRIsVALUE, method_geometry_invalid_reason(self));
1125
+ rb_raise(rb_eRGeoInvalidGeometry,
1126
+ "%" PRIsVALUE,
1127
+ method_geometry_invalid_reason(self));
1105
1128
  }
1106
1129
  return rgeo_wrap_geos_geometry(self_data->factory, valid_geom, Qnil);
1107
1130
  }
1108
1131
 
1109
- static VALUE method_geometry_point_on_surface(VALUE self)
1132
+ static VALUE
1133
+ method_geometry_point_on_surface(VALUE self)
1110
1134
  {
1111
1135
  VALUE result;
1112
1136
  RGeo_GeometryData* self_data;
@@ -1116,27 +1140,31 @@ static VALUE method_geometry_point_on_surface(VALUE self)
1116
1140
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
1117
1141
  self_geom = self_data->geom;
1118
1142
  if (self_geom) {
1119
- result = rgeo_wrap_geos_geometry(self_data->factory, GEOSPointOnSurface_r(self_data->geos_context, self_geom), Qnil);
1143
+ result = rgeo_wrap_geos_geometry(
1144
+ self_data->factory, GEOSPointOnSurface(self_geom), Qnil);
1120
1145
  }
1121
1146
  return result;
1122
1147
  }
1123
1148
 
1124
1149
  /**
1125
- * call-seq:
1126
- * some.polygonize -> RGeo::Feature::GeometryCollection
1127
- *
1128
- * Polygonizes a set of Geometries which contain linework that
1129
- * represents the edges of a planar graph.
1130
- *
1131
- * All types of Geometry are accepted as input;
1132
- * the constituent linework is extracted as the edges to be polygonized.
1133
- *
1134
- * The edges must be correctly noded;
1135
- * that is, they must only meet at their endpoints and not overlap anywhere.
1136
- *
1137
- * @see https://libgeos.org/doxygen/geos__c_8h.html#a9d98e448d3b846d591c726d1c0000d25 GEOSPolygonize
1138
- */
1139
- static VALUE method_geometry_polygonize(VALUE self)
1150
+ * call-seq:
1151
+ * some.polygonize -> RGeo::Feature::GeometryCollection
1152
+ *
1153
+ * Polygonizes a set of Geometries which contain linework that
1154
+ * represents the edges of a planar graph.
1155
+ *
1156
+ * All types of Geometry are accepted as input;
1157
+ * the constituent linework is extracted as the edges to be polygonized.
1158
+ *
1159
+ * The edges must be correctly noded;
1160
+ * that is, they must only meet at their endpoints and not overlap anywhere.
1161
+ *
1162
+ * @see
1163
+ * https://libgeos.org/doxygen/geos__c_8h.html#a9d98e448d3b846d591c726d1c0000d25
1164
+ * GEOSPolygonize
1165
+ */
1166
+ static VALUE
1167
+ method_geometry_polygonize(VALUE self)
1140
1168
  {
1141
1169
  VALUE result;
1142
1170
  RGeo_GeometryData* self_data;
@@ -1147,90 +1175,139 @@ static VALUE method_geometry_polygonize(VALUE self)
1147
1175
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
1148
1176
  self_geom = self_data->geom;
1149
1177
  if (self_geom) {
1150
- geos_polygon_collection = GEOSPolygonize_r(self_data->geos_context, &self_geom, 1);
1178
+ geos_polygon_collection = GEOSPolygonize(&self_geom, 1);
1151
1179
 
1152
1180
  if (geos_polygon_collection == NULL) {
1153
1181
  rb_raise(rb_eGeosError, "GEOS can't polygonize this geometry.");
1154
1182
  }
1155
1183
 
1156
- result = rgeo_wrap_geos_geometry(self_data->factory, geos_polygon_collection, Qnil);
1184
+ result = rgeo_wrap_geos_geometry(
1185
+ self_data->factory, geos_polygon_collection, Qnil);
1157
1186
  }
1158
1187
  return result;
1159
1188
  }
1160
1189
 
1161
- VALUE rgeo_geos_geometries_strict_eql(GEOSContextHandle_t context, const GEOSGeometry* geom1, const GEOSGeometry* geom2)
1190
+ VALUE
1191
+ rgeo_geos_geometries_strict_eql(const GEOSGeometry* geom1,
1192
+ const GEOSGeometry* geom2)
1162
1193
  {
1163
- switch (GEOSEqualsExact_r(context, geom1, geom2, 0.0)) {
1164
- case 0:
1165
- return Qfalse;
1166
- case 1:
1167
- return Qtrue;
1168
- case 2:
1169
- default:
1170
- rb_raise(rb_eGeosError, "Cannot test equality.");
1194
+ switch (GEOSEqualsExact(geom1, geom2, 0.0)) {
1195
+ case 0:
1196
+ return Qfalse;
1197
+ case 1:
1198
+ return Qtrue;
1199
+ case 2:
1200
+ default:
1201
+ rb_raise(rb_eGeosError, "Cannot test equality.");
1171
1202
  }
1172
1203
  }
1173
1204
 
1174
1205
  /**** INITIALIZATION FUNCTION ****/
1175
1206
 
1176
-
1177
- void rgeo_init_geos_geometry()
1207
+ void
1208
+ rgeo_init_geos_geometry()
1178
1209
  {
1179
1210
  VALUE geos_geometry_methods;
1180
1211
 
1181
- geos_geometry_methods = rb_define_module_under(rgeo_geos_module, "CAPIGeometryMethods");
1212
+ geos_geometry_methods =
1213
+ rb_define_module_under(rgeo_geos_module, "CAPIGeometryMethods");
1182
1214
 
1183
- rb_define_method(geos_geometry_methods, "factory=", method_geometry_set_factory, 1);
1184
- rb_define_method(geos_geometry_methods, "initialize_copy", method_geometry_initialize_copy, 1);
1215
+ rb_define_method(
1216
+ geos_geometry_methods, "factory=", method_geometry_set_factory, 1);
1217
+ rb_define_method(geos_geometry_methods,
1218
+ "initialize_copy",
1219
+ method_geometry_initialize_copy,
1220
+ 1);
1185
1221
  rb_define_method(geos_geometry_methods, "_steal", method_geometry_steal, 1);
1186
- rb_define_method(geos_geometry_methods, "initialized?", method_geometry_initialized_p, 0);
1187
- rb_define_method(geos_geometry_methods, "factory", method_geometry_factory, 0);
1188
- rb_define_method(geos_geometry_methods, "prepared?", method_geometry_prepared_p, 0);
1189
- rb_define_method(geos_geometry_methods, "prepare!", method_geometry_prepare, 0);
1190
- rb_define_method(geos_geometry_methods, "dimension", method_geometry_dimension, 0);
1191
- rb_define_method(geos_geometry_methods, "geometry_type", method_geometry_geometry_type, 0);
1222
+ rb_define_method(
1223
+ geos_geometry_methods, "initialized?", method_geometry_initialized_p, 0);
1224
+ rb_define_method(
1225
+ geos_geometry_methods, "factory", method_geometry_factory, 0);
1226
+ rb_define_method(
1227
+ geos_geometry_methods, "prepared?", method_geometry_prepared_p, 0);
1228
+ rb_define_method(
1229
+ geos_geometry_methods, "prepare!", method_geometry_prepare, 0);
1230
+ rb_define_method(
1231
+ geos_geometry_methods, "dimension", method_geometry_dimension, 0);
1232
+ rb_define_method(
1233
+ geos_geometry_methods, "geometry_type", method_geometry_geometry_type, 0);
1192
1234
  rb_define_method(geos_geometry_methods, "srid", method_geometry_srid, 0);
1193
- rb_define_method(geos_geometry_methods, "envelope", method_geometry_envelope, 0);
1194
- rb_define_method(geos_geometry_methods, "boundary", method_geometry_boundary, 0);
1195
- rb_define_method(geos_geometry_methods, "_as_text", method_geometry_as_text, 0);
1196
- rb_define_method(geos_geometry_methods, "as_binary", method_geometry_as_binary, 0);
1197
- rb_define_method(geos_geometry_methods, "empty?", method_geometry_is_empty, 0);
1198
- rb_define_method(geos_geometry_methods, "simple?", method_geometry_is_simple, 0);
1235
+ rb_define_method(
1236
+ geos_geometry_methods, "envelope", method_geometry_envelope, 0);
1237
+ rb_define_method(
1238
+ geos_geometry_methods, "boundary", method_geometry_boundary, 0);
1239
+ rb_define_method(
1240
+ geos_geometry_methods, "_as_text", method_geometry_as_text, 0);
1241
+ rb_define_method(
1242
+ geos_geometry_methods, "as_binary", method_geometry_as_binary, 0);
1243
+ rb_define_method(
1244
+ geos_geometry_methods, "empty?", method_geometry_is_empty, 0);
1245
+ rb_define_method(
1246
+ geos_geometry_methods, "simple?", method_geometry_is_simple, 0);
1199
1247
  rb_define_method(geos_geometry_methods, "equals?", method_geometry_equals, 1);
1200
1248
  rb_define_method(geos_geometry_methods, "==", method_geometry_equals, 1);
1201
- rb_define_method(geos_geometry_methods, "rep_equals?", method_geometry_eql, 1);
1249
+ rb_define_method(
1250
+ geos_geometry_methods, "rep_equals?", method_geometry_eql, 1);
1202
1251
  rb_define_method(geos_geometry_methods, "eql?", method_geometry_eql, 1);
1203
- rb_define_method(geos_geometry_methods, "disjoint?", method_geometry_disjoint, 1);
1204
- rb_define_method(geos_geometry_methods, "intersects?", method_geometry_intersects, 1);
1205
- rb_define_method(geos_geometry_methods, "touches?", method_geometry_touches, 1);
1206
- rb_define_method(geos_geometry_methods, "crosses?", method_geometry_crosses, 1);
1252
+ rb_define_method(
1253
+ geos_geometry_methods, "disjoint?", method_geometry_disjoint, 1);
1254
+ rb_define_method(
1255
+ geos_geometry_methods, "intersects?", method_geometry_intersects, 1);
1256
+ rb_define_method(
1257
+ geos_geometry_methods, "touches?", method_geometry_touches, 1);
1258
+ rb_define_method(
1259
+ geos_geometry_methods, "crosses?", method_geometry_crosses, 1);
1207
1260
  rb_define_method(geos_geometry_methods, "within?", method_geometry_within, 1);
1208
- rb_define_method(geos_geometry_methods, "contains?", method_geometry_contains, 1);
1209
- rb_define_method(geos_geometry_methods, "overlaps?", method_geometry_overlaps, 1);
1261
+ rb_define_method(
1262
+ geos_geometry_methods, "contains?", method_geometry_contains, 1);
1263
+ rb_define_method(
1264
+ geos_geometry_methods, "overlaps?", method_geometry_overlaps, 1);
1210
1265
  rb_define_method(geos_geometry_methods, "relate?", method_geometry_relate, 2);
1211
- rb_define_method(geos_geometry_methods, "distance", method_geometry_distance, 1);
1266
+ rb_define_method(
1267
+ geos_geometry_methods, "distance", method_geometry_distance, 1);
1212
1268
  rb_define_method(geos_geometry_methods, "buffer", method_geometry_buffer, 1);
1213
- rb_define_method(geos_geometry_methods, "buffer_with_style", method_geometry_buffer_with_style, 4);
1214
- rb_define_method(geos_geometry_methods, "simplify", method_geometry_simplify, 1);
1215
- rb_define_method(geos_geometry_methods, "simplify_preserve_topology", method_geometry_simplify_preserve_topology, 1);
1216
- rb_define_method(geos_geometry_methods, "convex_hull", method_geometry_convex_hull, 0);
1217
- rb_define_method(geos_geometry_methods, "intersection", method_geometry_intersection, 1);
1269
+ rb_define_method(geos_geometry_methods,
1270
+ "buffer_with_style",
1271
+ method_geometry_buffer_with_style,
1272
+ 4);
1273
+ rb_define_method(
1274
+ geos_geometry_methods, "simplify", method_geometry_simplify, 1);
1275
+ rb_define_method(geos_geometry_methods,
1276
+ "simplify_preserve_topology",
1277
+ method_geometry_simplify_preserve_topology,
1278
+ 1);
1279
+ rb_define_method(
1280
+ geos_geometry_methods, "convex_hull", method_geometry_convex_hull, 0);
1281
+ rb_define_method(
1282
+ geos_geometry_methods, "intersection", method_geometry_intersection, 1);
1218
1283
  rb_define_method(geos_geometry_methods, "*", method_geometry_intersection, 1);
1219
1284
  rb_define_method(geos_geometry_methods, "union", method_geometry_union, 1);
1220
- rb_define_method(geos_geometry_methods, "unary_union", method_geometry_unary_union, 0);
1285
+ rb_define_method(
1286
+ geos_geometry_methods, "unary_union", method_geometry_unary_union, 0);
1221
1287
  rb_define_method(geos_geometry_methods, "+", method_geometry_union, 1);
1222
- rb_define_method(geos_geometry_methods, "difference", method_geometry_difference, 1);
1288
+ rb_define_method(
1289
+ geos_geometry_methods, "difference", method_geometry_difference, 1);
1223
1290
  rb_define_method(geos_geometry_methods, "-", method_geometry_difference, 1);
1224
- rb_define_method(geos_geometry_methods, "sym_difference", method_geometry_sym_difference, 1);
1225
- rb_define_method(geos_geometry_methods, "valid?", method_geometry_is_valid, 0);
1226
- rb_define_method(geos_geometry_methods, "invalid_reason", method_geometry_invalid_reason, 0);
1227
- rb_define_method(geos_geometry_methods, "invalid_reason_location", method_geometry_invalid_reason_location, 0);
1228
- rb_define_method(geos_geometry_methods, "point_on_surface", method_geometry_point_on_surface, 0);
1229
- rb_define_method(geos_geometry_methods, "make_valid", method_geometry_make_valid, 0);
1230
- rb_define_method(geos_geometry_methods, "polygonize", method_geometry_polygonize, 0);
1291
+ rb_define_method(
1292
+ geos_geometry_methods, "sym_difference", method_geometry_sym_difference, 1);
1293
+ rb_define_method(
1294
+ geos_geometry_methods, "valid?", method_geometry_is_valid, 0);
1295
+ rb_define_method(
1296
+ geos_geometry_methods, "invalid_reason", method_geometry_invalid_reason, 0);
1297
+ rb_define_method(geos_geometry_methods,
1298
+ "invalid_reason_location",
1299
+ method_geometry_invalid_reason_location,
1300
+ 0);
1301
+ rb_define_method(geos_geometry_methods,
1302
+ "point_on_surface",
1303
+ method_geometry_point_on_surface,
1304
+ 0);
1305
+ rb_define_method(
1306
+ geos_geometry_methods, "make_valid", method_geometry_make_valid, 0);
1307
+ rb_define_method(
1308
+ geos_geometry_methods, "polygonize", method_geometry_polygonize, 0);
1231
1309
  }
1232
1310
 
1233
-
1234
1311
  RGEO_END_C
1235
1312
 
1236
1313
  #endif