rgeo 2.3.1 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
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 +30 -25
  5. data/ext/geos_c_impl/analysis.h +8 -7
  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 +42 -28
  11. data/ext/geos_c_impl/factory.c +540 -451
  12. data/ext/geos_c_impl/factory.h +105 -95
  13. data/ext/geos_c_impl/geometry.c +593 -387
  14. data/ext/geos_c_impl/geometry.h +10 -5
  15. data/ext/geos_c_impl/geometry_collection.c +306 -339
  16. data/ext/geos_c_impl/geometry_collection.h +6 -20
  17. data/ext/geos_c_impl/globals.c +169 -0
  18. data/ext/geos_c_impl/globals.h +46 -0
  19. data/ext/geos_c_impl/line_string.c +271 -231
  20. data/ext/geos_c_impl/line_string.h +5 -8
  21. data/ext/geos_c_impl/main.c +16 -16
  22. data/ext/geos_c_impl/point.c +65 -67
  23. data/ext/geos_c_impl/point.h +4 -7
  24. data/ext/geos_c_impl/polygon.c +137 -135
  25. data/ext/geos_c_impl/polygon.h +11 -11
  26. data/ext/geos_c_impl/preface.h +16 -10
  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 +57 -102
  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 +303 -99
  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 +69 -85
  58. data/lib/rgeo/geographic/factory.rb +98 -125
  59. data/lib/rgeo/geographic/interface.rb +69 -166
  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 +105 -173
  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 +53 -95
  77. data/lib/rgeo/geos/zm_feature_methods.rb +30 -33
  78. data/lib/rgeo/geos.rb +8 -8
  79. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +9 -22
  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 +50 -13
  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,26 +2,25 @@
2
2
  Line string 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>
10
+ #include <ruby.h>
11
+ #include <string.h>
13
12
 
13
+ #include "coordinates.h"
14
14
  #include "factory.h"
15
15
  #include "geometry.h"
16
- #include "point.h"
16
+ #include "globals.h"
17
17
  #include "line_string.h"
18
-
19
- #include "coordinates.h"
18
+ #include "point.h"
20
19
 
21
20
  RGEO_BEGIN_C
22
21
 
23
-
24
- static VALUE method_line_string_geometry_type(VALUE self)
22
+ static VALUE
23
+ method_line_string_geometry_type(VALUE self)
25
24
  {
26
25
  VALUE result;
27
26
  RGeo_GeometryData* self_data;
@@ -29,13 +28,13 @@ static VALUE method_line_string_geometry_type(VALUE self)
29
28
  result = Qnil;
30
29
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
31
30
  if (self_data->geom) {
32
- result = RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->feature_line_string;
31
+ result = rgeo_feature_line_string_module;
33
32
  }
34
33
  return result;
35
34
  }
36
35
 
37
-
38
- static VALUE method_linear_ring_geometry_type(VALUE self)
36
+ static VALUE
37
+ method_linear_ring_geometry_type(VALUE self)
39
38
  {
40
39
  VALUE result;
41
40
  RGeo_GeometryData* self_data;
@@ -43,13 +42,13 @@ static VALUE method_linear_ring_geometry_type(VALUE self)
43
42
  result = Qnil;
44
43
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
45
44
  if (self_data->geom) {
46
- result = RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->feature_linear_ring;
45
+ result = rgeo_feature_linear_ring_module;
47
46
  }
48
47
  return result;
49
48
  }
50
49
 
51
-
52
- static VALUE method_line_geometry_type(VALUE self)
50
+ static VALUE
51
+ method_line_geometry_type(VALUE self)
53
52
  {
54
53
  VALUE result;
55
54
  RGeo_GeometryData* self_data;
@@ -57,13 +56,13 @@ static VALUE method_line_geometry_type(VALUE self)
57
56
  result = Qnil;
58
57
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
59
58
  if (self_data->geom) {
60
- result = RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->feature_line;
59
+ result = rgeo_feature_line_module;
61
60
  }
62
61
  return result;
63
62
  }
64
63
 
65
-
66
- static VALUE method_line_string_length(VALUE self)
64
+ static VALUE
65
+ method_line_string_length(VALUE self)
67
66
  {
68
67
  VALUE result;
69
68
  RGeo_GeometryData* self_data;
@@ -74,15 +73,15 @@ static VALUE method_line_string_length(VALUE self)
74
73
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
75
74
  self_geom = self_data->geom;
76
75
  if (self_geom) {
77
- if (GEOSLength_r(self_data->geos_context, self_geom, &len)) {
76
+ if (GEOSLength(self_geom, &len)) {
78
77
  result = rb_float_new(len);
79
78
  }
80
79
  }
81
80
  return result;
82
81
  }
83
82
 
84
-
85
- static VALUE method_line_string_num_points(VALUE self)
83
+ static VALUE
84
+ method_line_string_num_points(VALUE self)
86
85
  {
87
86
  VALUE result;
88
87
  RGeo_GeometryData* self_data;
@@ -92,13 +91,13 @@ static VALUE method_line_string_num_points(VALUE self)
92
91
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
93
92
  self_geom = self_data->geom;
94
93
  if (self_geom) {
95
- result = INT2NUM(GEOSGetNumCoordinates_r(self_data->geos_context, self_geom));
94
+ result = INT2NUM(GEOSGetNumCoordinates(self_geom));
96
95
  }
97
96
  return result;
98
97
  }
99
98
 
100
-
101
- static VALUE method_line_string_coordinates(VALUE self)
99
+ static VALUE
100
+ method_line_string_coordinates(VALUE self)
102
101
  {
103
102
  VALUE result;
104
103
  RGeo_GeometryData* self_data;
@@ -106,43 +105,41 @@ static VALUE method_line_string_coordinates(VALUE self)
106
105
  const GEOSCoordSequence* coord_sequence;
107
106
  int zCoordinate;
108
107
 
109
- GEOSContextHandle_t context;
110
-
111
108
  result = Qnil;
112
109
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
113
110
  self_geom = self_data->geom;
114
111
 
115
112
  if (self_geom) {
116
- zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
117
- context = self_data->geos_context;
118
- coord_sequence = GEOSGeom_getCoordSeq_r(context, self_geom);
119
- if(coord_sequence) {
120
- result = extract_points_from_coordinate_sequence(context, coord_sequence, zCoordinate);
113
+ zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
114
+ RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
115
+ coord_sequence = GEOSGeom_getCoordSeq(self_geom);
116
+ if (coord_sequence) {
117
+ result =
118
+ extract_points_from_coordinate_sequence(coord_sequence, zCoordinate);
121
119
  }
122
120
  }
123
121
  return result;
124
122
  }
125
123
 
126
-
127
-
128
- static VALUE get_point_from_coordseq(VALUE self, const GEOSCoordSequence* coord_seq, unsigned int i, char has_z)
124
+ static VALUE
125
+ get_point_from_coordseq(VALUE self,
126
+ const GEOSCoordSequence* coord_seq,
127
+ unsigned int i,
128
+ char has_z)
129
129
  {
130
130
  VALUE result;
131
131
  RGeo_GeometryData* self_data;
132
- GEOSContextHandle_t self_context;
133
132
  double x, y, z;
134
133
 
135
134
  result = Qnil;
136
135
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
137
- self_context = self_data->geos_context;
138
- if (GEOSCoordSeq_getX_r(self_context, coord_seq, i, &x)) {
139
- if (GEOSCoordSeq_getY_r(self_context, coord_seq, i, &y)) {
136
+ if (GEOSCoordSeq_getX(coord_seq, i, &x)) {
137
+ if (GEOSCoordSeq_getY(coord_seq, i, &y)) {
140
138
  if (has_z) {
141
- if (!GEOSCoordSeq_getZ_r(self_context, coord_seq, i, &z)) {
139
+ if (!GEOSCoordSeq_getZ(coord_seq, i, &z)) {
142
140
  z = 0.0;
143
141
  }
144
- }
145
- else {
142
+ } else {
146
143
  z = 0.0;
147
144
  }
148
145
  result = rgeo_create_geos_point(self_data->factory, x, y, z);
@@ -151,13 +148,12 @@ static VALUE get_point_from_coordseq(VALUE self, const GEOSCoordSequence* coord_
151
148
  return result;
152
149
  }
153
150
 
154
-
155
- static VALUE method_line_string_point_n(VALUE self, VALUE n)
151
+ static VALUE
152
+ method_line_string_point_n(VALUE self, VALUE n)
156
153
  {
157
154
  VALUE result;
158
155
  RGeo_GeometryData* self_data;
159
156
  const GEOSGeometry* self_geom;
160
- GEOSContextHandle_t self_context;
161
157
  const GEOSCoordSequence* coord_seq;
162
158
  char has_z;
163
159
  int si;
@@ -168,14 +164,14 @@ static VALUE method_line_string_point_n(VALUE self, VALUE n)
168
164
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
169
165
  self_geom = self_data->geom;
170
166
  if (self_geom) {
171
- self_context = self_data->geos_context;
172
- coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
167
+ coord_seq = GEOSGeom_getCoordSeq(self_geom);
173
168
  if (coord_seq) {
174
- has_z = (char)(RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
175
- si = NUM2INT(n);
169
+ has_z = (char)(RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
170
+ RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
171
+ si = RB_NUM2INT(n);
176
172
  if (si >= 0) {
177
173
  i = si;
178
- if (GEOSCoordSeq_getSize_r(self_context, coord_seq, &size)) {
174
+ if (GEOSCoordSeq_getSize(coord_seq, &size)) {
179
175
  if (i < size) {
180
176
  result = get_point_from_coordseq(self, coord_seq, i, has_z);
181
177
  }
@@ -186,13 +182,12 @@ static VALUE method_line_string_point_n(VALUE self, VALUE n)
186
182
  return result;
187
183
  }
188
184
 
189
-
190
- static VALUE method_line_string_points(VALUE self)
185
+ static VALUE
186
+ method_line_string_points(VALUE self)
191
187
  {
192
188
  VALUE result;
193
189
  RGeo_GeometryData* self_data;
194
190
  const GEOSGeometry* self_geom;
195
- GEOSContextHandle_t self_context;
196
191
  const GEOSCoordSequence* coord_seq;
197
192
  char has_z;
198
193
  unsigned int size;
@@ -203,13 +198,13 @@ static VALUE method_line_string_points(VALUE self)
203
198
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
204
199
  self_geom = self_data->geom;
205
200
  if (self_geom) {
206
- self_context = self_data->geos_context;
207
- coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
201
+ coord_seq = GEOSGeom_getCoordSeq(self_geom);
208
202
  if (coord_seq) {
209
- has_z = (char)(RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
210
- if (GEOSCoordSeq_getSize_r(self_context, coord_seq, &size)) {
203
+ has_z = (char)(RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
204
+ RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
205
+ if (GEOSCoordSeq_getSize(coord_seq, &size)) {
211
206
  result = rb_ary_new2(size);
212
- for (i=0; i<size; ++i) {
207
+ for (i = 0; i < size; ++i) {
213
208
  point = get_point_from_coordseq(self, coord_seq, i, has_z);
214
209
  if (!NIL_P(point)) {
215
210
  rb_ary_store(result, i, point);
@@ -221,14 +216,14 @@ static VALUE method_line_string_points(VALUE self)
221
216
  return result;
222
217
  }
223
218
 
224
-
225
- static VALUE method_line_string_start_point(VALUE self)
219
+ static VALUE
220
+ method_line_string_start_point(VALUE self)
226
221
  {
227
222
  return method_line_string_point_n(self, INT2NUM(0));
228
223
  }
229
224
 
230
-
231
- static VALUE method_line_string_end_point(VALUE self)
225
+ static VALUE
226
+ method_line_string_end_point(VALUE self)
232
227
  {
233
228
  VALUE result;
234
229
  RGeo_GeometryData* self_data;
@@ -239,41 +234,46 @@ static VALUE method_line_string_end_point(VALUE self)
239
234
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
240
235
  self_geom = self_data->geom;
241
236
  if (self_geom) {
242
- n = GEOSGetNumCoordinates_r(self_data->geos_context, self_geom);
237
+ n = GEOSGetNumCoordinates(self_geom);
243
238
  if (n > 0) {
244
- result = method_line_string_point_n(self, INT2NUM(n-1));
239
+ result = method_line_string_point_n(self, INT2NUM(n - 1));
245
240
  }
246
241
  }
247
242
  return result;
248
243
  }
249
244
 
250
- static VALUE method_line_string_project_point(VALUE self, VALUE point)
245
+ static VALUE
246
+ method_line_string_project_point(VALUE self, VALUE point)
251
247
  {
252
- RGeo_FactoryData* factory_data;
253
248
  VALUE result = Qnil;
254
249
  VALUE factory;
255
250
  RGeo_GeometryData* self_data;
256
251
  const GEOSGeometry* self_geom;
257
- const GEOSGeometry *geos_point;
252
+ const GEOSGeometry* geos_point;
253
+ int state = 0;
258
254
 
259
255
  double location;
260
256
 
261
257
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
262
258
  factory = self_data->factory;
263
259
  self_geom = self_data->geom;
264
- factory_data = RGEO_FACTORY_DATA_PTR(factory);
265
260
 
266
- if(self_geom && point) {
267
- geos_point = rgeo_convert_to_geos_geometry(factory, point, factory_data->globals->geos_point);
268
- location = GEOSProject_r(self_data->geos_context, self_geom, geos_point);
261
+ if (self_geom && point) {
262
+ geos_point = rgeo_convert_to_geos_geometry(
263
+ factory, point, rgeo_geos_point_class, &state);
264
+ if (state) {
265
+ rb_jump_tag(state);
266
+ }
267
+
268
+ location = GEOSProject(self_geom, geos_point);
269
269
  result = DBL2NUM(location);
270
270
  }
271
271
  return result;
272
272
  }
273
273
 
274
- static VALUE method_line_string_interpolate_point(VALUE self, VALUE loc_num)
274
+ static VALUE
275
+ method_line_string_interpolate_point(VALUE self, VALUE loc_num)
275
276
  {
276
- RGeo_FactoryData* factory_data;
277
277
  VALUE result = Qnil;
278
278
  VALUE factory;
279
279
  RGeo_GeometryData* self_data;
@@ -285,18 +285,19 @@ static VALUE method_line_string_interpolate_point(VALUE self, VALUE loc_num)
285
285
  location = NUM2DBL(loc_num);
286
286
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
287
287
  factory = self_data->factory;
288
- factory_data = RGEO_FACTORY_DATA_PTR(factory);
289
288
  self_geom = self_data->geom;
290
289
 
291
- if(self_geom) {
292
- geos_point = GEOSInterpolate_r(self_data->geos_context, self_geom, location);
293
- result = rgeo_wrap_geos_geometry(factory, geos_point, factory_data->globals->geos_point);
290
+ if (self_geom) {
291
+ geos_point = GEOSInterpolate(self_geom, location);
292
+ result =
293
+ rgeo_wrap_geos_geometry(factory, geos_point, rgeo_geos_point_class);
294
294
  }
295
295
 
296
296
  return result;
297
297
  }
298
298
 
299
- static VALUE method_line_string_is_closed(VALUE self)
299
+ static VALUE
300
+ method_line_string_is_closed(VALUE self)
300
301
  {
301
302
  VALUE result;
302
303
  RGeo_GeometryData* self_data;
@@ -306,13 +307,13 @@ static VALUE method_line_string_is_closed(VALUE self)
306
307
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
307
308
  self_geom = self_data->geom;
308
309
  if (self_geom) {
309
- result = rgeo_is_geos_line_string_closed(self_data->geos_context, self_geom);
310
+ result = rgeo_is_geos_line_string_closed(self_geom);
310
311
  }
311
312
  return result;
312
313
  }
313
314
 
314
-
315
- static VALUE method_line_string_is_ring(VALUE self)
315
+ static VALUE
316
+ method_line_string_is_ring(VALUE self)
316
317
  {
317
318
  VALUE result;
318
319
  RGeo_GeometryData* self_data;
@@ -323,19 +324,18 @@ static VALUE method_line_string_is_ring(VALUE self)
323
324
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
324
325
  self_geom = self_data->geom;
325
326
  if (self_geom) {
326
- val = GEOSisRing_r(self_data->geos_context, self_geom);
327
+ val = GEOSisRing(self_geom);
327
328
  if (val == 0) {
328
329
  result = Qfalse;
329
- }
330
- else if (val == 1) {
330
+ } else if (val == 1) {
331
331
  result = Qtrue;
332
332
  }
333
333
  }
334
334
  return result;
335
335
  }
336
336
 
337
-
338
- static VALUE method_line_string_eql(VALUE self, VALUE rhs)
337
+ static VALUE
338
+ method_line_string_eql(VALUE self, VALUE rhs)
339
339
  {
340
340
  VALUE result;
341
341
  RGeo_GeometryData* self_data;
@@ -343,13 +343,14 @@ static VALUE method_line_string_eql(VALUE self, VALUE rhs)
343
343
  result = rgeo_geos_klasses_and_factories_eql(self, rhs);
344
344
  if (RTEST(result)) {
345
345
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
346
- result = rgeo_geos_coordseqs_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);
346
+ result = rgeo_geos_geometries_strict_eql(self_data->geom,
347
+ RGEO_GEOMETRY_DATA_PTR(rhs)->geom);
347
348
  }
348
349
  return result;
349
350
  }
350
351
 
351
-
352
- static VALUE method_line_string_hash(VALUE self)
352
+ static VALUE
353
+ method_line_string_hash(VALUE self)
353
354
  {
354
355
  st_index_t hash;
355
356
  RGeo_GeometryData* self_data;
@@ -358,14 +359,13 @@ static VALUE method_line_string_hash(VALUE self)
358
359
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
359
360
  factory = self_data->factory;
360
361
  hash = rb_hash_start(0);
361
- hash = rgeo_geos_objbase_hash(factory,
362
- RGEO_FACTORY_DATA_PTR(factory)->globals->feature_line_string, hash);
363
- hash = rgeo_geos_coordseq_hash(self_data->geos_context, self_data->geom, hash);
362
+ hash = rgeo_geos_objbase_hash(factory, rgeo_feature_line_string_module, hash);
363
+ hash = rgeo_geos_coordseq_hash(self_data->geom, hash);
364
364
  return LONG2FIX(rb_hash_end(hash));
365
365
  }
366
366
 
367
-
368
- static VALUE method_linear_ring_hash(VALUE self)
367
+ static VALUE
368
+ method_linear_ring_hash(VALUE self)
369
369
  {
370
370
  st_index_t hash;
371
371
  RGeo_GeometryData* self_data;
@@ -374,14 +374,13 @@ static VALUE method_linear_ring_hash(VALUE self)
374
374
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
375
375
  factory = self_data->factory;
376
376
  hash = rb_hash_start(0);
377
- hash = rgeo_geos_objbase_hash(factory,
378
- RGEO_FACTORY_DATA_PTR(factory)->globals->feature_linear_ring, hash);
379
- hash = rgeo_geos_coordseq_hash(self_data->geos_context, self_data->geom, hash);
377
+ hash = rgeo_geos_objbase_hash(factory, rgeo_feature_linear_ring_module, hash);
378
+ hash = rgeo_geos_coordseq_hash(self_data->geom, hash);
380
379
  return LONG2FIX(rb_hash_end(hash));
381
380
  }
382
381
 
383
-
384
- static VALUE method_line_hash(VALUE self)
382
+ static VALUE
383
+ method_line_hash(VALUE self)
385
384
  {
386
385
  st_index_t hash;
387
386
  RGeo_GeometryData* self_data;
@@ -390,201 +389,206 @@ static VALUE method_line_hash(VALUE self)
390
389
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
391
390
  factory = self_data->factory;
392
391
  hash = rb_hash_start(0);
393
- hash = rgeo_geos_objbase_hash(factory,
394
- RGEO_FACTORY_DATA_PTR(factory)->globals->feature_line, hash);
395
- hash = rgeo_geos_coordseq_hash(self_data->geos_context, self_data->geom, hash);
392
+ hash = rgeo_geos_objbase_hash(factory, rgeo_feature_line_module, hash);
393
+ hash = rgeo_geos_coordseq_hash(self_data->geom, hash);
396
394
  return LONG2FIX(rb_hash_end(hash));
397
395
  }
398
396
 
399
-
400
- static GEOSCoordSequence* coord_seq_from_array(VALUE factory, VALUE array, char close)
397
+ static GEOSCoordSequence*
398
+ coord_seq_from_array(VALUE factory, VALUE array, char close)
401
399
  {
402
- RGeo_FactoryData* factory_data;
403
400
  VALUE point_type;
404
401
  unsigned int len;
405
402
  char has_z;
406
403
  unsigned int dims;
407
404
  double* coords;
408
- GEOSContextHandle_t context;
409
405
  unsigned int i;
410
406
  char good;
411
407
  const GEOSGeometry* entry_geom;
412
408
  const GEOSCoordSequence* entry_cs;
413
409
  double x;
414
410
  GEOSCoordSequence* coord_seq;
411
+ int state = 0;
415
412
 
416
413
  Check_Type(array, T_ARRAY);
417
- factory_data = RGEO_FACTORY_DATA_PTR(factory);
418
- point_type = factory_data->globals->feature_point;
414
+ point_type = rgeo_feature_point_module;
419
415
  len = (unsigned int)RARRAY_LEN(array);
420
- has_z = (char)(RGEO_FACTORY_DATA_PTR(factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
416
+ has_z = (char)(RGEO_FACTORY_DATA_PTR(factory)->flags &
417
+ RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
421
418
  dims = has_z ? 3 : 2;
422
419
  coords = ALLOC_N(double, len == 0 ? 1 : len * dims);
423
420
  if (!coords) {
424
421
  return NULL;
425
422
  }
426
- context = factory_data->geos_context;
427
- for (i=0; i<len; ++i) {
423
+ for (i = 0; i < len; ++i) {
428
424
  good = 0;
429
- entry_geom = rgeo_convert_to_geos_geometry(factory, rb_ary_entry(array, i), point_type);
430
- if (entry_geom) {
431
- entry_cs = GEOSGeom_getCoordSeq_r(context, entry_geom);
432
- if (entry_cs) {
433
- if (GEOSCoordSeq_getX_r(context, entry_cs, 0, &x)) {
434
- coords[i*dims] = x;
435
- if (GEOSCoordSeq_getY_r(context, entry_cs, 0, &x)) {
436
- coords[i*dims+1] = x;
437
- good = 1;
438
- if (has_z) {
439
- if (GEOSCoordSeq_getZ_r(context, entry_cs, 0, &x)) {
440
- coords[i*dims+2] = x;
441
- }
442
- else {
443
- good = 0;
444
- }
425
+
426
+ entry_geom = rgeo_convert_to_geos_geometry(
427
+ factory, rb_ary_entry(array, i), point_type, &state);
428
+ if (state) {
429
+ FREE(coords);
430
+ rb_jump_tag(state);
431
+ }
432
+
433
+ entry_cs = GEOSGeom_getCoordSeq(entry_geom);
434
+ if (entry_cs) {
435
+ if (GEOSCoordSeq_getX(entry_cs, 0, &x)) {
436
+ coords[i * dims] = x;
437
+ if (GEOSCoordSeq_getY(entry_cs, 0, &x)) {
438
+ coords[i * dims + 1] = x;
439
+ good = 1;
440
+ if (has_z) {
441
+ if (GEOSCoordSeq_getZ(entry_cs, 0, &x)) {
442
+ coords[i * dims + 2] = x;
443
+ } else {
444
+ good = 0;
445
445
  }
446
446
  }
447
447
  }
448
448
  }
449
449
  }
450
450
  if (!good) {
451
- free(coords);
451
+ FREE(coords);
452
452
  return NULL;
453
453
  }
454
454
  }
455
455
  if (len > 0 && close) {
456
- if (coords[0] == coords[(len-1)*dims] && coords[1] == coords[(len-1)*dims+1]) {
456
+ if (coords[0] == coords[(len - 1) * dims] &&
457
+ coords[1] == coords[(len - 1) * dims + 1]) {
457
458
  close = 0;
458
459
  }
459
- }
460
- else {
460
+ } else {
461
461
  close = 0;
462
462
  }
463
- coord_seq = GEOSCoordSeq_create_r(context, len + close, 3);
463
+ coord_seq = GEOSCoordSeq_create(len + close, 3);
464
464
  if (coord_seq) {
465
- for (i=0; i<len; ++i) {
466
- GEOSCoordSeq_setX_r(context, coord_seq, i, coords[i*dims]);
467
- GEOSCoordSeq_setY_r(context, coord_seq, i, coords[i*dims+1]);
468
- GEOSCoordSeq_setZ_r(context, coord_seq, i, has_z ? coords[i*dims+2] : 0);
465
+ for (i = 0; i < len; ++i) {
466
+ GEOSCoordSeq_setX(coord_seq, i, coords[i * dims]);
467
+ GEOSCoordSeq_setY(coord_seq, i, coords[i * dims + 1]);
468
+ GEOSCoordSeq_setZ(coord_seq, i, has_z ? coords[i * dims + 2] : 0);
469
469
  }
470
470
  if (close) {
471
- GEOSCoordSeq_setX_r(context, coord_seq, len, coords[0]);
472
- GEOSCoordSeq_setY_r(context, coord_seq, len, coords[1]);
473
- GEOSCoordSeq_setZ_r(context, coord_seq, len, has_z ? coords[2] : 0);
471
+ GEOSCoordSeq_setX(coord_seq, len, coords[0]);
472
+ GEOSCoordSeq_setY(coord_seq, len, coords[1]);
473
+ GEOSCoordSeq_setZ(coord_seq, len, has_z ? coords[2] : 0);
474
474
  }
475
475
  }
476
- free(coords);
476
+ FREE(coords);
477
477
  return coord_seq;
478
478
  }
479
479
 
480
-
481
- static VALUE cmethod_create_line_string(VALUE module, VALUE factory, VALUE array)
480
+ static VALUE
481
+ cmethod_create_line_string(VALUE module, VALUE factory, VALUE array)
482
482
  {
483
483
  VALUE result;
484
484
  GEOSCoordSequence* coord_seq;
485
- RGeo_FactoryData* factory_data;
486
485
  GEOSGeometry* geom;
487
486
 
488
487
  result = Qnil;
489
488
  coord_seq = coord_seq_from_array(factory, array, 0);
490
489
  if (coord_seq) {
491
- factory_data = RGEO_FACTORY_DATA_PTR(factory);
492
- geom = GEOSGeom_createLineString_r(factory_data->geos_context, coord_seq);
490
+ geom = GEOSGeom_createLineString(coord_seq);
493
491
  if (geom) {
494
- result = rgeo_wrap_geos_geometry(factory, geom, factory_data->globals->geos_line_string);
492
+ result =
493
+ rgeo_wrap_geos_geometry(factory, geom, rgeo_geos_line_string_class);
495
494
  }
496
495
  }
497
496
  return result;
498
497
  }
499
498
 
500
-
501
- static VALUE cmethod_create_linear_ring(VALUE module, VALUE factory, VALUE array)
499
+ static VALUE
500
+ cmethod_create_linear_ring(VALUE module, VALUE factory, VALUE array)
502
501
  {
503
502
  VALUE result;
504
503
  GEOSCoordSequence* coord_seq;
505
- RGeo_FactoryData* factory_data;
506
504
  GEOSGeometry* geom;
507
505
 
508
506
  result = Qnil;
509
507
  coord_seq = coord_seq_from_array(factory, array, 1);
510
508
  if (coord_seq) {
511
- factory_data = RGEO_FACTORY_DATA_PTR(factory);
512
- geom = GEOSGeom_createLinearRing_r(factory_data->geos_context, coord_seq);
509
+ geom = GEOSGeom_createLinearRing(coord_seq);
513
510
  if (geom) {
514
- result = rgeo_wrap_geos_geometry(factory, geom, factory_data->globals->geos_linear_ring);
511
+ result =
512
+ rgeo_wrap_geos_geometry(factory, geom, rgeo_geos_linear_ring_class);
515
513
  }
516
514
  }
517
515
  return result;
518
516
  }
519
517
 
520
-
521
- static void populate_geom_into_coord_seq(GEOSContextHandle_t context, const GEOSGeometry* geom, GEOSCoordSequence* coord_seq, unsigned int i, char has_z)
518
+ static void
519
+ populate_geom_into_coord_seq(const GEOSGeometry* geom,
520
+ GEOSCoordSequence* coord_seq,
521
+ unsigned int i,
522
+ char has_z)
522
523
  {
523
524
  const GEOSCoordSequence* cs;
524
525
  double x;
525
526
 
526
- cs = GEOSGeom_getCoordSeq_r(context, geom);
527
+ cs = GEOSGeom_getCoordSeq(geom);
527
528
  x = 0;
528
529
  if (cs) {
529
- GEOSCoordSeq_getX_r(context, cs, 0, &x);
530
+ GEOSCoordSeq_getX(cs, 0, &x);
530
531
  }
531
- GEOSCoordSeq_setX_r(context, coord_seq, i, x);
532
+ GEOSCoordSeq_setX(coord_seq, i, x);
532
533
  x = 0;
533
534
  if (cs) {
534
- GEOSCoordSeq_getY_r(context, cs, 0, &x);
535
+ GEOSCoordSeq_getY(cs, 0, &x);
535
536
  }
536
- GEOSCoordSeq_setY_r(context, coord_seq, i, x);
537
+ GEOSCoordSeq_setY(coord_seq, i, x);
537
538
  x = 0;
538
539
  if (has_z && cs) {
539
- GEOSCoordSeq_getZ_r(context, cs, 0, &x);
540
+ GEOSCoordSeq_getZ(cs, 0, &x);
540
541
  }
541
- GEOSCoordSeq_setZ_r(context, coord_seq, i, x);
542
+ GEOSCoordSeq_setZ(coord_seq, i, x);
542
543
  }
543
544
 
544
-
545
- static VALUE cmethod_create_line(VALUE module, VALUE factory, VALUE start, VALUE end)
545
+ static VALUE
546
+ cmethod_create_line(VALUE module, VALUE factory, VALUE start, VALUE end)
546
547
  {
547
548
  VALUE result;
548
549
  RGeo_FactoryData* factory_data;
549
550
  char has_z;
550
551
  VALUE point_type;
551
- GEOSContextHandle_t context;
552
552
  const GEOSGeometry* start_geom;
553
553
  const GEOSGeometry* end_geom;
554
554
  GEOSCoordSequence* coord_seq;
555
555
  GEOSGeometry* geom;
556
+ int state = 0;
556
557
 
557
558
  result = Qnil;
558
559
  factory_data = RGEO_FACTORY_DATA_PTR(factory);
559
560
  has_z = (char)(factory_data->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
560
- point_type = factory_data->globals->feature_point;
561
- context = factory_data->geos_context;
562
-
563
- start_geom = rgeo_convert_to_geos_geometry(factory, start, point_type);
564
- if (start_geom) {
565
- end_geom = rgeo_convert_to_geos_geometry(factory, end, point_type);
566
- if (end_geom) {
567
- coord_seq = GEOSCoordSeq_create_r(context, 2, 3);
568
- if (coord_seq) {
569
- populate_geom_into_coord_seq(context, start_geom, coord_seq, 0, has_z);
570
- populate_geom_into_coord_seq(context, end_geom, coord_seq, 1, has_z);
571
- geom = GEOSGeom_createLineString_r(context, coord_seq);
572
- if (geom) {
573
- result = rgeo_wrap_geos_geometry(factory, geom, factory_data->globals->geos_line);
574
- }
575
- }
561
+ point_type = rgeo_feature_point_module;
562
+
563
+ start_geom =
564
+ rgeo_convert_to_geos_geometry(factory, start, point_type, &state);
565
+ if (state) {
566
+ rb_jump_tag(state);
567
+ }
568
+
569
+ end_geom = rgeo_convert_to_geos_geometry(factory, end, point_type, &state);
570
+ if (state) {
571
+ rb_jump_tag(state);
572
+ }
573
+
574
+ coord_seq = GEOSCoordSeq_create(2, 3);
575
+ if (coord_seq) {
576
+ populate_geom_into_coord_seq(start_geom, coord_seq, 0, has_z);
577
+ populate_geom_into_coord_seq(end_geom, coord_seq, 1, has_z);
578
+ geom = GEOSGeom_createLineString(coord_seq);
579
+ if (geom) {
580
+ result = rgeo_wrap_geos_geometry(factory, geom, rgeo_geos_line_class);
576
581
  }
577
582
  }
578
583
 
579
584
  return result;
580
585
  }
581
586
 
582
-
583
- static VALUE impl_copy_from(VALUE klass, VALUE factory, VALUE original, char subtype)
587
+ static VALUE
588
+ impl_copy_from(VALUE klass, VALUE factory, VALUE original, char subtype)
584
589
  {
585
590
  VALUE result;
586
591
  const GEOSGeometry* original_geom;
587
- GEOSContextHandle_t context;
588
592
  const GEOSCoordSequence* original_coord_seq;
589
593
  GEOSCoordSequence* coord_seq;
590
594
  GEOSGeometry* geom;
@@ -592,16 +596,16 @@ static VALUE impl_copy_from(VALUE klass, VALUE factory, VALUE original, char sub
592
596
  result = Qnil;
593
597
  original_geom = RGEO_GEOMETRY_DATA_PTR(original)->geom;
594
598
  if (original_geom) {
595
- context = RGEO_FACTORY_DATA_PTR(factory)->geos_context;
596
- if (subtype == 1 && GEOSGetNumCoordinates_r(context, original_geom) != 2) {
599
+ if (subtype == 1 && GEOSGetNumCoordinates(original_geom) != 2) {
597
600
  original_geom = NULL;
598
601
  }
599
602
  if (original_geom) {
600
- original_coord_seq = GEOSGeom_getCoordSeq_r(context, original_geom);
603
+ original_coord_seq = GEOSGeom_getCoordSeq(original_geom);
601
604
  if (original_coord_seq) {
602
- coord_seq = GEOSCoordSeq_clone_r(context, original_coord_seq);
605
+ coord_seq = GEOSCoordSeq_clone(original_coord_seq);
603
606
  if (coord_seq) {
604
- geom = subtype == 2 ? GEOSGeom_createLinearRing_r(context, coord_seq) : GEOSGeom_createLineString_r(context, coord_seq);
607
+ geom = subtype == 2 ? GEOSGeom_createLinearRing(coord_seq)
608
+ : GEOSGeom_createLineString(coord_seq);
605
609
  if (geom) {
606
610
  result = rgeo_wrap_geos_geometry(factory, geom, klass);
607
611
  }
@@ -612,74 +616,112 @@ static VALUE impl_copy_from(VALUE klass, VALUE factory, VALUE original, char sub
612
616
  return result;
613
617
  }
614
618
 
615
-
616
- static VALUE cmethod_line_string_copy_from(VALUE klass, VALUE factory, VALUE original)
619
+ static VALUE
620
+ cmethod_line_string_copy_from(VALUE klass, VALUE factory, VALUE original)
617
621
  {
618
622
  return impl_copy_from(klass, factory, original, 0);
619
623
  }
620
624
 
621
-
622
- static VALUE cmethod_line_copy_from(VALUE klass, VALUE factory, VALUE original)
625
+ static VALUE
626
+ cmethod_line_copy_from(VALUE klass, VALUE factory, VALUE original)
623
627
  {
624
628
  return impl_copy_from(klass, factory, original, 1);
625
629
  }
626
630
 
627
-
628
- static VALUE cmethod_linear_ring_copy_from(VALUE klass, VALUE factory, VALUE original)
631
+ static VALUE
632
+ cmethod_linear_ring_copy_from(VALUE klass, VALUE factory, VALUE original)
629
633
  {
630
634
  return impl_copy_from(klass, factory, original, 2);
631
635
  }
632
636
 
633
-
634
- void rgeo_init_geos_line_string(RGeo_Globals* globals)
637
+ void
638
+ rgeo_init_geos_line_string()
635
639
  {
636
640
  VALUE geos_line_string_methods;
637
641
  VALUE geos_linear_ring_methods;
638
642
  VALUE geos_line_methods;
639
643
 
640
644
  // Class methods for CAPILineStringImpl
641
- rb_define_module_function(globals->geos_line_string, "create", cmethod_create_line_string, 2);
642
- rb_define_module_function(globals->geos_line_string, "_copy_from", cmethod_line_string_copy_from, 2);
645
+ rb_define_module_function(
646
+ rgeo_geos_line_string_class, "create", cmethod_create_line_string, 2);
647
+ rb_define_module_function(rgeo_geos_line_string_class,
648
+ "_copy_from",
649
+ cmethod_line_string_copy_from,
650
+ 2);
643
651
 
644
652
  // Class methods for CAPILinearRingImpl
645
- rb_define_module_function(globals->geos_linear_ring, "create", cmethod_create_linear_ring, 2);
646
- rb_define_module_function(globals->geos_linear_ring, "_copy_from", cmethod_linear_ring_copy_from, 2);
653
+ rb_define_module_function(
654
+ rgeo_geos_linear_ring_class, "create", cmethod_create_linear_ring, 2);
655
+ rb_define_module_function(rgeo_geos_linear_ring_class,
656
+ "_copy_from",
657
+ cmethod_linear_ring_copy_from,
658
+ 2);
647
659
 
648
660
  // Class methods for CAPILineImpl
649
- rb_define_module_function(globals->geos_line, "create", cmethod_create_line, 3);
650
- rb_define_module_function(globals->geos_line, "_copy_from", cmethod_line_copy_from, 2);
661
+ rb_define_module_function(
662
+ rgeo_geos_line_class, "create", cmethod_create_line, 3);
663
+ rb_define_module_function(
664
+ rgeo_geos_line_class, "_copy_from", cmethod_line_copy_from, 2);
651
665
 
652
666
  // CAPILineStringMethods module
653
- geos_line_string_methods = rb_define_module_under(globals->geos_module, "CAPILineStringMethods");
654
- rb_define_method(geos_line_string_methods, "rep_equals?", method_line_string_eql, 1);
667
+ geos_line_string_methods =
668
+ rb_define_module_under(rgeo_geos_module, "CAPILineStringMethods");
669
+ rb_define_method(
670
+ geos_line_string_methods, "rep_equals?", method_line_string_eql, 1);
655
671
  rb_define_method(geos_line_string_methods, "eql?", method_line_string_eql, 1);
656
- rb_define_method(geos_line_string_methods, "hash", method_line_string_hash, 0);
657
- rb_define_method(geos_line_string_methods, "geometry_type", method_line_string_geometry_type, 0);
658
- rb_define_method(geos_line_string_methods, "length", method_line_string_length, 0);
659
- rb_define_method(geos_line_string_methods, "num_points", method_line_string_num_points, 0);
660
- rb_define_method(geos_line_string_methods, "point_n", method_line_string_point_n, 1);
661
- rb_define_method(geos_line_string_methods, "points", method_line_string_points, 0);
662
- rb_define_method(geos_line_string_methods, "start_point", method_line_string_start_point, 0);
663
- rb_define_method(geos_line_string_methods, "end_point", method_line_string_end_point, 0);
664
- rb_define_method(geos_line_string_methods, "project_point", method_line_string_project_point, 1);
665
- rb_define_method(geos_line_string_methods, "interpolate_point", method_line_string_interpolate_point, 1);
666
- rb_define_method(geos_line_string_methods, "closed?", method_line_string_is_closed, 0);
667
- rb_define_method(geos_line_string_methods, "ring?", method_line_string_is_ring, 0);
668
- rb_define_method(geos_line_string_methods, "coordinates", method_line_string_coordinates, 0);
672
+ rb_define_method(
673
+ geos_line_string_methods, "hash", method_line_string_hash, 0);
674
+ rb_define_method(geos_line_string_methods,
675
+ "geometry_type",
676
+ method_line_string_geometry_type,
677
+ 0);
678
+ rb_define_method(
679
+ geos_line_string_methods, "length", method_line_string_length, 0);
680
+ rb_define_method(
681
+ geos_line_string_methods, "num_points", method_line_string_num_points, 0);
682
+ rb_define_method(
683
+ geos_line_string_methods, "point_n", method_line_string_point_n, 1);
684
+ rb_define_method(
685
+ geos_line_string_methods, "points", method_line_string_points, 0);
686
+ rb_define_method(
687
+ geos_line_string_methods, "start_point", method_line_string_start_point, 0);
688
+ rb_define_method(
689
+ geos_line_string_methods, "end_point", method_line_string_end_point, 0);
690
+ rb_define_method(geos_line_string_methods,
691
+ "project_point",
692
+ method_line_string_project_point,
693
+ 1);
694
+ rb_define_method(geos_line_string_methods,
695
+ "interpolate_point",
696
+ method_line_string_interpolate_point,
697
+ 1);
698
+ rb_define_method(
699
+ geos_line_string_methods, "closed?", method_line_string_is_closed, 0);
700
+ rb_define_method(
701
+ geos_line_string_methods, "ring?", method_line_string_is_ring, 0);
702
+ rb_define_method(
703
+ geos_line_string_methods, "coordinates", method_line_string_coordinates, 0);
669
704
 
670
705
  // CAPILinearRingMethods module
671
- geos_linear_ring_methods = rb_define_module_under(globals->geos_module, "CAPILinearRingMethods");
672
- rb_define_method(geos_linear_ring_methods, "geometry_type", method_linear_ring_geometry_type, 0);
673
- rb_define_method(geos_linear_ring_methods, "hash", method_linear_ring_hash, 0);
706
+ geos_linear_ring_methods =
707
+ rb_define_module_under(rgeo_geos_module, "CAPILinearRingMethods");
708
+ rb_define_method(geos_linear_ring_methods,
709
+ "geometry_type",
710
+ method_linear_ring_geometry_type,
711
+ 0);
712
+ rb_define_method(
713
+ geos_linear_ring_methods, "hash", method_linear_ring_hash, 0);
674
714
 
675
715
  // CAPILineMethods module
676
- geos_line_methods = rb_define_module_under(globals->geos_module, "CAPILineMethods");
677
- rb_define_method(geos_line_methods, "geometry_type", method_line_geometry_type, 0);
716
+ geos_line_methods =
717
+ rb_define_module_under(rgeo_geos_module, "CAPILineMethods");
718
+ rb_define_method(
719
+ geos_line_methods, "geometry_type", method_line_geometry_type, 0);
678
720
  rb_define_method(geos_line_methods, "hash", method_line_hash, 0);
679
721
  }
680
722
 
681
-
682
- VALUE rgeo_is_geos_line_string_closed(GEOSContextHandle_t context, const GEOSGeometry* geom)
723
+ VALUE
724
+ rgeo_is_geos_line_string_closed(const GEOSGeometry* geom)
683
725
  {
684
726
  VALUE result;
685
727
  unsigned int n;
@@ -687,19 +729,18 @@ VALUE rgeo_is_geos_line_string_closed(GEOSContextHandle_t context, const GEOSGeo
687
729
  const GEOSCoordSequence* coord_seq;
688
730
 
689
731
  result = Qnil;
690
- n = GEOSGetNumCoordinates_r(context, geom);
732
+ n = GEOSGetNumCoordinates(geom);
691
733
  if (n > 0) {
692
- coord_seq = GEOSGeom_getCoordSeq_r(context, geom);
693
- if (GEOSCoordSeq_getX_r(context, coord_seq, 0, &x1)) {
694
- if (GEOSCoordSeq_getX_r(context, coord_seq, n-1, &x2)) {
734
+ coord_seq = GEOSGeom_getCoordSeq(geom);
735
+ if (GEOSCoordSeq_getX(coord_seq, 0, &x1)) {
736
+ if (GEOSCoordSeq_getX(coord_seq, n - 1, &x2)) {
695
737
  if (x1 == x2) {
696
- if (GEOSCoordSeq_getY_r(context, coord_seq, 0, &y1)) {
697
- if (GEOSCoordSeq_getY_r(context, coord_seq, n-1, &y2)) {
738
+ if (GEOSCoordSeq_getY(coord_seq, 0, &y1)) {
739
+ if (GEOSCoordSeq_getY(coord_seq, n - 1, &y2)) {
698
740
  result = y1 == y2 ? Qtrue : Qfalse;
699
741
  }
700
742
  }
701
- }
702
- else {
743
+ } else {
703
744
  result = Qfalse;
704
745
  }
705
746
  }
@@ -708,7 +749,6 @@ VALUE rgeo_is_geos_line_string_closed(GEOSContextHandle_t context, const GEOSGeo
708
749
  return result;
709
750
  }
710
751
 
711
-
712
752
  RGEO_END_C
713
753
 
714
754
  #endif