rgeo 0.1.12 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. data/History.rdoc +9 -7
  2. data/README.rdoc +7 -5
  3. data/Version +1 -1
  4. data/ext/geos_c_impl/factory.c +12 -19
  5. data/ext/geos_c_impl/factory.h +15 -21
  6. data/ext/geos_c_impl/geometry.c +19 -36
  7. data/ext/geos_c_impl/geometry.h +2 -12
  8. data/ext/geos_c_impl/geometry_collection.c +38 -157
  9. data/ext/geos_c_impl/geometry_collection.h +2 -12
  10. data/ext/geos_c_impl/line_string.c +83 -80
  11. data/ext/geos_c_impl/line_string.h +2 -12
  12. data/ext/geos_c_impl/main.c +5 -0
  13. data/ext/geos_c_impl/point.c +2 -12
  14. data/ext/geos_c_impl/point.h +2 -12
  15. data/ext/geos_c_impl/polygon.c +5 -14
  16. data/ext/geos_c_impl/polygon.h +2 -12
  17. data/ext/geos_c_impl/preface.h +8 -0
  18. data/lib/rgeo.rb +34 -16
  19. data/lib/rgeo/{geography/simple_spherical/geometry_collection_impl.rb → cartesian.rb} +19 -26
  20. data/lib/rgeo/cartesian/calculations.rb +129 -0
  21. data/lib/rgeo/cartesian/interface.rb +85 -0
  22. data/lib/rgeo/cartesian/simple_factory.rb +159 -0
  23. data/lib/rgeo/cartesian/simple_feature_classes.rb +187 -0
  24. data/lib/rgeo/cartesian/simple_feature_methods.rb +97 -0
  25. data/lib/rgeo/features.rb +1 -0
  26. data/lib/rgeo/features/curve.rb +3 -2
  27. data/lib/rgeo/features/factory.rb +62 -37
  28. data/lib/rgeo/features/geometry.rb +10 -32
  29. data/lib/rgeo/features/geometry_collection.rb +3 -2
  30. data/lib/rgeo/features/line.rb +3 -2
  31. data/lib/rgeo/features/line_string.rb +3 -2
  32. data/lib/rgeo/features/linear_ring.rb +3 -2
  33. data/lib/rgeo/features/multi_curve.rb +3 -2
  34. data/lib/rgeo/features/multi_line_string.rb +3 -2
  35. data/lib/rgeo/features/multi_point.rb +3 -2
  36. data/lib/rgeo/features/multi_polygon.rb +3 -2
  37. data/lib/rgeo/features/multi_surface.rb +3 -2
  38. data/lib/rgeo/features/point.rb +3 -2
  39. data/lib/rgeo/features/polygon.rb +3 -2
  40. data/lib/rgeo/features/surface.rb +3 -2
  41. data/lib/rgeo/features/types.rb +198 -0
  42. data/lib/rgeo/geography.rb +4 -14
  43. data/lib/rgeo/geography/factory.rb +7 -64
  44. data/lib/rgeo/geography/{simple_spherical/geometry_methods.rb → helper.rb} +4 -13
  45. data/lib/rgeo/geography/simple_mercator/feature_classes.rb +35 -89
  46. data/lib/rgeo/geography/simple_mercator/feature_methods.rb +22 -31
  47. data/lib/rgeo/geography/simple_mercator/projector.rb +4 -8
  48. data/lib/rgeo/geography/simple_spherical/calculations.rb +11 -9
  49. data/lib/rgeo/geography/simple_spherical/feature_classes.rb +189 -0
  50. data/lib/rgeo/geography/simple_spherical/{line_string_impl.rb → feature_methods.rb} +16 -64
  51. data/lib/rgeo/geos/factory.rb +26 -40
  52. data/lib/rgeo/geos/impl_additions.rb +3 -5
  53. data/lib/rgeo/{geography/simple_spherical/polygon_impl.rb → impl_helpers.rb} +16 -26
  54. data/lib/rgeo/impl_helpers/basic_geometry_collection_methods.rb +186 -0
  55. data/lib/rgeo/impl_helpers/basic_geometry_methods.rb +90 -0
  56. data/lib/rgeo/impl_helpers/basic_line_string_methods.rb +188 -0
  57. data/lib/rgeo/impl_helpers/basic_point_methods.rb +149 -0
  58. data/lib/rgeo/{geography/common/helper.rb → impl_helpers/basic_polygon_methods.rb} +62 -53
  59. data/lib/rgeo/{geography/common/polygon_methods.rb → impl_helpers/serialization.rb} +50 -42
  60. data/tests/common/geometry_collection_tests.rb +9 -7
  61. data/tests/common/multi_line_string_tests.rb +16 -13
  62. data/tests/common/multi_point_tests.rb +16 -13
  63. data/tests/common/multi_polygon_tests.rb +8 -6
  64. data/tests/common/point_tests.rb +1 -2
  65. data/tests/common/polygon_tests.rb +9 -9
  66. data/tests/geos/tc_multi_line_string.rb +2 -2
  67. data/tests/simple_cartesian/tc_calculations.rb +138 -0
  68. data/tests/simple_cartesian/tc_geometry_collection.rb +68 -0
  69. data/tests/simple_cartesian/tc_line_string.rb +70 -0
  70. data/{lib/rgeo/geography/simple_spherical/multi_line_string_impl.rb → tests/simple_cartesian/tc_multi_line_string.rb} +19 -19
  71. data/{lib/rgeo/geography/simple_spherical/multi_polygon_impl.rb → tests/simple_cartesian/tc_multi_point.rb} +19 -19
  72. data/{lib/rgeo/geography/common/geometry_methods.rb → tests/simple_cartesian/tc_multi_polygon.rb} +19 -41
  73. data/{lib/rgeo/geography/simple_spherical/point_impl.rb → tests/simple_cartesian/tc_point.rb} +33 -35
  74. data/tests/simple_cartesian/tc_polygon.rb +67 -0
  75. data/tests/simple_spherical/tc_geometry_collection.rb +68 -0
  76. data/tests/simple_spherical/tc_line_string.rb +10 -171
  77. data/tests/simple_spherical/tc_multi_line_string.rb +67 -0
  78. data/{lib/rgeo/geography/simple_spherical/multi_point_impl.rb → tests/simple_spherical/tc_multi_point.rb} +19 -19
  79. data/tests/simple_spherical/tc_multi_polygon.rb +70 -0
  80. data/tests/simple_spherical/tc_point.rb +17 -115
  81. data/tests/simple_spherical/tc_polygon.rb +67 -0
  82. metadata +46 -18
  83. data/ext/geos_c_impl/globals.h +0 -58
  84. data/lib/rgeo/geography/common/geometry_collection_methods.rb +0 -217
  85. data/lib/rgeo/geography/common/line_string_methods.rb +0 -201
  86. data/lib/rgeo/geography/common/point_methods.rb +0 -153
@@ -43,12 +43,7 @@
43
43
 
44
44
  #include "factory.h"
45
45
 
46
- #ifdef __cplusplus
47
- extern "C" {
48
- #if 0
49
- }
50
- #endif
51
- #endif
46
+ RGEO_BEGIN_C
52
47
 
53
48
 
54
49
  /*
@@ -69,11 +64,6 @@ void rgeo_init_geos_geometry_collection(RGeo_Globals* globals);
69
64
  VALUE rgeo_geos_geometry_collections_eql(GEOSContextHandle_t context, const GEOSGeometry* geom1, const GEOSGeometry* geom2);
70
65
 
71
66
 
72
- #ifdef __cplusplus
73
- #if 0
74
- {
75
- #endif
76
- }
77
- #endif
67
+ RGEO_END_C
78
68
 
79
69
  #endif
@@ -48,12 +48,7 @@
48
48
  #include "point.h"
49
49
  #include "line_string.h"
50
50
 
51
- #ifdef __cplusplus
52
- extern "C" {
53
- #if 0
54
- }
55
- #endif
56
- #endif
51
+ RGEO_BEGIN_C
57
52
 
58
53
 
59
54
  static VALUE method_line_string_geometry_type(VALUE self)
@@ -89,47 +84,6 @@ static VALUE method_line_geometry_type(VALUE self)
89
84
  }
90
85
 
91
86
 
92
- static VALUE method_line_string_cast(VALUE self, VALUE type)
93
- {
94
- VALUE result = Qnil;
95
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
96
- if (self_geom) {
97
- VALUE type_name = rb_funcall(type, rb_intern("name"), 0);
98
- char* new_type_str = StringValuePtr(type_name);
99
- VALUE klass = Qnil;
100
- char is_ring = 0;
101
- if (strcmp(new_type_str, "Line") == 0) {
102
- if (GEOSGetNumCoordinates_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom) == 2) {
103
- klass = rb_const_get_at(RGEO_GLOBALS_FROM_GEOMETRY(self)->geos_module, rb_intern("LineImpl"));
104
- }
105
- }
106
- else if (strcmp(new_type_str, "LinearRing") == 0) {
107
- klass = rb_const_get_at(RGEO_GLOBALS_FROM_GEOMETRY(self)->geos_module, rb_intern("LinearRingImpl"));
108
- is_ring = 1;
109
- }
110
- else if (strcmp(new_type_str, "LineString") == 0) {
111
- klass = rb_const_get_at(RGEO_GLOBALS_FROM_GEOMETRY(self)->geos_module, rb_intern("LineStringImpl"));
112
- }
113
- if (!NIL_P(klass)) {
114
- const GEOSCoordSequence* self_coord_seq = GEOSGeom_getCoordSeq_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom);
115
- if (self_coord_seq) {
116
- GEOSCoordSequence* coord_seq = GEOSCoordSeq_clone_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_coord_seq);
117
- if (coord_seq) {
118
- GEOSGeometry* geom = is_ring ? GEOSGeom_createLinearRing_r(RGEO_CONTEXT_FROM_GEOMETRY(self), coord_seq) : GEOSGeom_createLineString_r(RGEO_CONTEXT_FROM_GEOMETRY(self), coord_seq);
119
- if (geom) {
120
- result = rgeo_wrap_geos_geometry(RGEO_FACTORY_FROM_GEOMETRY(self), geom, klass);
121
- }
122
- }
123
- }
124
- }
125
- if (NIL_P(result)) {
126
- result = rb_call_super(1, &type);
127
- }
128
- }
129
- return result;
130
- }
131
-
132
-
133
87
  static VALUE method_line_string_length(VALUE self)
134
88
  {
135
89
  VALUE result = Qnil;
@@ -273,38 +227,49 @@ static VALUE method_line_string_eql(VALUE self, VALUE rhs)
273
227
  }
274
228
 
275
229
 
276
- static GEOSCoordSequence* coord_seq_from_array(GEOSContextHandle_t context, VALUE array)
230
+ static GEOSCoordSequence* coord_seq_from_array(VALUE factory, VALUE array, char close)
277
231
  {
278
232
  Check_Type(array, T_ARRAY);
279
- unsigned int len = (unsigned int)RARRAY_LEN(array);
233
+ VALUE point_type = rb_const_get_at(RGEO_GLOBALS_FROM_FACTORY(factory)->features_module, rb_intern("Point"));
234
+ unsigned int orig_len = (unsigned int)RARRAY_LEN(array);
235
+ const GEOSGeometry** geoms = ALLOC_N(const GEOSGeometry*, orig_len == 0 ? 1 : orig_len);
236
+ if (!geoms) {
237
+ return NULL;
238
+ }
280
239
  char has_z = 0;
281
240
  unsigned int i;
282
- for (i=0; i<len; ++i) {
283
- const GEOSGeometry* entry_geom = rgeo_get_geos_geometry_safe(rb_ary_entry(array, i));
284
- if (!entry_geom || GEOSGeomTypeId_r(context, entry_geom) != GEOS_POINT) {
241
+ for (i=0; i<orig_len; ++i) {
242
+ const GEOSGeometry* entry_geom = rgeo_convert_to_geos_geometry(factory, rb_ary_entry(array, i), point_type);
243
+ if (!entry_geom) {
244
+ free(geoms);
285
245
  return NULL;
286
246
  }
287
- if (GEOSHasZ_r(context, entry_geom) == 1) {
247
+ geoms[i] = entry_geom;
248
+ if (GEOSHasZ_r(RGEO_CONTEXT_FROM_FACTORY(factory), entry_geom) == 1) {
288
249
  has_z = 1;
289
- i = len;
290
250
  }
291
251
  }
292
- GEOSCoordSequence* coord_seq = GEOSCoordSeq_create_r(context, len, has_z ? 3 : 2);
252
+ unsigned int len = orig_len;
253
+ if (orig_len > 0 && close && GEOSEquals_r(RGEO_CONTEXT_FROM_FACTORY(factory), geoms[0], geoms[orig_len-1]) != 1) {
254
+ ++len;
255
+ }
256
+ GEOSCoordSequence* coord_seq = GEOSCoordSeq_create_r(RGEO_CONTEXT_FROM_FACTORY(factory), len, has_z ? 3 : 2);
293
257
  if (coord_seq) {
294
258
  for (i=0; i<len; ++i) {
295
- const GEOSCoordSequence* cs = GEOSGeom_getCoordSeq_r(context, RGEO_GET_GEOS_GEOMETRY(rb_ary_entry(array, i)));
259
+ const GEOSCoordSequence* cs = GEOSGeom_getCoordSeq_r(RGEO_CONTEXT_FROM_FACTORY(factory), geoms[i == orig_len ? 0 : i]);
296
260
  double x;
297
- if (GEOSCoordSeq_getX_r(context, cs, 0, &x)) {
298
- GEOSCoordSeq_setX_r(context, coord_seq, i, x);
261
+ if (GEOSCoordSeq_getX_r(RGEO_CONTEXT_FROM_FACTORY(factory), cs, 0, &x)) {
262
+ GEOSCoordSeq_setX_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq, i, x);
299
263
  }
300
- if (GEOSCoordSeq_getY_r(context, cs, 0, &x)) {
301
- GEOSCoordSeq_setY_r(context, coord_seq, i, x);
264
+ if (GEOSCoordSeq_getY_r(RGEO_CONTEXT_FROM_FACTORY(factory), cs, 0, &x)) {
265
+ GEOSCoordSeq_setY_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq, i, x);
302
266
  }
303
- if (has_z && GEOSCoordSeq_getZ_r(context, cs, 0, &x)) {
304
- GEOSCoordSeq_setZ_r(context, coord_seq, i, x);
267
+ if (has_z && GEOSCoordSeq_getZ_r(RGEO_CONTEXT_FROM_FACTORY(factory), cs, 0, &x)) {
268
+ GEOSCoordSeq_setZ_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq, i, x);
305
269
  }
306
270
  }
307
271
  }
272
+ free(geoms);
308
273
  return coord_seq;
309
274
  }
310
275
 
@@ -312,7 +277,7 @@ static GEOSCoordSequence* coord_seq_from_array(GEOSContextHandle_t context, VALU
312
277
  static VALUE cmethod_create_line_string(VALUE module, VALUE factory, VALUE array)
313
278
  {
314
279
  VALUE result = Qnil;
315
- GEOSCoordSequence* coord_seq = coord_seq_from_array(RGEO_CONTEXT_FROM_FACTORY(factory), array);
280
+ GEOSCoordSequence* coord_seq = coord_seq_from_array(factory, array, 0);
316
281
  if (coord_seq) {
317
282
  GEOSGeometry* geom = GEOSGeom_createLineString_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq);
318
283
  if (geom) {
@@ -326,7 +291,7 @@ static VALUE cmethod_create_line_string(VALUE module, VALUE factory, VALUE array
326
291
  static VALUE cmethod_create_linear_ring(VALUE module, VALUE factory, VALUE array)
327
292
  {
328
293
  VALUE result = Qnil;
329
- GEOSCoordSequence* coord_seq = coord_seq_from_array(RGEO_CONTEXT_FROM_FACTORY(factory), array);
294
+ GEOSCoordSequence* coord_seq = coord_seq_from_array(factory, array, 1);
330
295
  if (coord_seq) {
331
296
  GEOSGeometry* geom = GEOSGeom_createLinearRing_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq);
332
297
  if (geom) {
@@ -341,20 +306,20 @@ static VALUE cmethod_create_line(VALUE module, VALUE factory, VALUE start, VALUE
341
306
  {
342
307
  VALUE result = Qnil;
343
308
  char has_z = 0;
309
+ VALUE point_type = rb_const_get_at(RGEO_GLOBALS_FROM_FACTORY(factory)->features_module, rb_intern("Point"));
344
310
 
345
- const GEOSGeometry* entry_geom;
346
- entry_geom = rgeo_get_geos_geometry_safe(start);
347
- if (!entry_geom || GEOSGeomTypeId_r(RGEO_CONTEXT_FROM_FACTORY(factory), entry_geom) != GEOS_POINT) {
311
+ const GEOSGeometry* start_geom = rgeo_convert_to_geos_geometry(factory, start, point_type);
312
+ if (!start_geom) {
348
313
  return Qnil;
349
314
  }
350
- if (GEOSHasZ_r(RGEO_CONTEXT_FROM_FACTORY(factory), entry_geom) == 1) {
315
+ if (GEOSHasZ_r(RGEO_CONTEXT_FROM_FACTORY(factory), start_geom) == 1) {
351
316
  has_z = 1;
352
317
  }
353
- entry_geom = rgeo_get_geos_geometry_safe(end);
354
- if (!entry_geom || GEOSGeomTypeId_r(RGEO_CONTEXT_FROM_FACTORY(factory), entry_geom) != GEOS_POINT) {
318
+ const GEOSGeometry* end_geom = rgeo_convert_to_geos_geometry(factory, end, point_type);
319
+ if (!end_geom) {
355
320
  return Qnil;
356
321
  }
357
- if (GEOSHasZ_r(RGEO_CONTEXT_FROM_FACTORY(factory), entry_geom) == 1) {
322
+ if (GEOSHasZ_r(RGEO_CONTEXT_FROM_FACTORY(factory), end_geom) == 1) {
358
323
  has_z = 1;
359
324
  }
360
325
 
@@ -362,7 +327,7 @@ static VALUE cmethod_create_line(VALUE module, VALUE factory, VALUE start, VALUE
362
327
  if (coord_seq) {
363
328
  const GEOSCoordSequence* cs;
364
329
  double x;
365
- cs = GEOSGeom_getCoordSeq_r(RGEO_CONTEXT_FROM_FACTORY(factory), RGEO_GET_GEOS_GEOMETRY(start));
330
+ cs = GEOSGeom_getCoordSeq_r(RGEO_CONTEXT_FROM_FACTORY(factory), start_geom);
366
331
  if (GEOSCoordSeq_getX_r(RGEO_CONTEXT_FROM_FACTORY(factory), cs, 0, &x)) {
367
332
  GEOSCoordSeq_setX_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq, 0, x);
368
333
  }
@@ -372,7 +337,7 @@ static VALUE cmethod_create_line(VALUE module, VALUE factory, VALUE start, VALUE
372
337
  if (has_z && GEOSCoordSeq_getZ_r(RGEO_CONTEXT_FROM_FACTORY(factory), cs, 0, &x)) {
373
338
  GEOSCoordSeq_setZ_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq, 0, x);
374
339
  }
375
- cs = GEOSGeom_getCoordSeq_r(RGEO_CONTEXT_FROM_FACTORY(factory), RGEO_GET_GEOS_GEOMETRY(end));
340
+ cs = GEOSGeom_getCoordSeq_r(RGEO_CONTEXT_FROM_FACTORY(factory), end_geom);
376
341
  if (GEOSCoordSeq_getX_r(RGEO_CONTEXT_FROM_FACTORY(factory), cs, 0, &x)) {
377
342
  GEOSCoordSeq_setX_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq, 1, x);
378
343
  }
@@ -391,6 +356,47 @@ static VALUE cmethod_create_line(VALUE module, VALUE factory, VALUE start, VALUE
391
356
  }
392
357
 
393
358
 
359
+ static VALUE impl_copy_from(VALUE klass, VALUE factory, VALUE original, char subtype)
360
+ {
361
+ VALUE result = Qnil;
362
+ const GEOSGeometry* original_geom = RGEO_GET_GEOS_GEOMETRY(original);
363
+ if (original_geom && subtype == 1 && GEOSGetNumCoordinates_r(RGEO_CONTEXT_FROM_FACTORY(factory), original_geom) != 2) {
364
+ original_geom = NULL;
365
+ }
366
+ if (original_geom) {
367
+ const GEOSCoordSequence* original_coord_seq = GEOSGeom_getCoordSeq_r(RGEO_CONTEXT_FROM_FACTORY(factory), original_geom);
368
+ if (original_coord_seq) {
369
+ GEOSCoordSequence* coord_seq = GEOSCoordSeq_clone_r(RGEO_CONTEXT_FROM_FACTORY(factory), original_coord_seq);
370
+ if (coord_seq) {
371
+ GEOSGeometry* geom = subtype == 2 ? GEOSGeom_createLinearRing_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq) : GEOSGeom_createLineString_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq);
372
+ if (geom) {
373
+ result = rgeo_wrap_geos_geometry(factory, geom, klass);
374
+ }
375
+ }
376
+ }
377
+ }
378
+ return result;
379
+ }
380
+
381
+
382
+ static VALUE cmethod_line_string_copy_from(VALUE klass, VALUE factory, VALUE original)
383
+ {
384
+ return impl_copy_from(klass, factory, original, 0);
385
+ }
386
+
387
+
388
+ static VALUE cmethod_line_copy_from(VALUE klass, VALUE factory, VALUE original)
389
+ {
390
+ return impl_copy_from(klass, factory, original, 1);
391
+ }
392
+
393
+
394
+ static VALUE cmethod_linear_ring_copy_from(VALUE klass, VALUE factory, VALUE original)
395
+ {
396
+ return impl_copy_from(klass, factory, original, 2);
397
+ }
398
+
399
+
394
400
  void rgeo_init_geos_line_string(RGeo_Globals* globals)
395
401
  {
396
402
  VALUE geos_line_string_class = rb_define_class_under(globals->geos_module, "LineStringImpl", rb_const_get_at(globals->geos_module, rb_intern("GeometryImpl")));
@@ -398,9 +404,9 @@ void rgeo_init_geos_line_string(RGeo_Globals* globals)
398
404
  VALUE geos_line_class = rb_define_class_under(globals->geos_module, "LineImpl", geos_line_string_class);
399
405
 
400
406
  rb_define_module_function(geos_line_string_class, "create", cmethod_create_line_string, 2);
407
+ rb_define_module_function(geos_line_string_class, "_copy_from", cmethod_line_string_copy_from, 2);
401
408
  rb_define_method(geos_line_string_class, "eql?", method_line_string_eql, 1);
402
409
  rb_define_method(geos_line_string_class, "geometry_type", method_line_string_geometry_type, 0);
403
- rb_define_method(geos_line_string_class, "cast", method_line_string_cast, 1);
404
410
  rb_define_method(geos_line_string_class, "length", method_line_string_length, 0);
405
411
  rb_define_method(geos_line_string_class, "num_points", method_line_string_num_points, 0);
406
412
  rb_define_method(geos_line_string_class, "point_n", method_line_string_point_n, 1);
@@ -411,9 +417,11 @@ void rgeo_init_geos_line_string(RGeo_Globals* globals)
411
417
  rb_define_method(geos_line_string_class, "is_ring?", method_line_string_is_ring, 0);
412
418
 
413
419
  rb_define_module_function(geos_linear_ring_class, "create", cmethod_create_linear_ring, 2);
420
+ rb_define_module_function(geos_linear_ring_class, "_copy_from", cmethod_linear_ring_copy_from, 2);
414
421
  rb_define_method(geos_linear_ring_class, "geometry_type", method_linear_ring_geometry_type, 0);
415
422
 
416
423
  rb_define_module_function(geos_line_class, "create", cmethod_create_line, 3);
424
+ rb_define_module_function(geos_line_class, "_copy_from", cmethod_line_copy_from, 2);
417
425
  rb_define_method(geos_line_class, "geometry_type", method_line_geometry_type, 0);
418
426
  }
419
427
 
@@ -458,11 +466,6 @@ VALUE rgeo_is_geos_line_string_closed(GEOSContextHandle_t context, const GEOSGeo
458
466
  }
459
467
 
460
468
 
461
- #ifdef __cplusplus
462
- #if 0
463
- {
464
- #endif
465
- }
466
- #endif
469
+ RGEO_END_C
467
470
 
468
471
  #endif
@@ -43,12 +43,7 @@
43
43
 
44
44
  #include "factory.h"
45
45
 
46
- #ifdef __cplusplus
47
- extern "C" {
48
- #if 0
49
- }
50
- #endif
51
- #endif
46
+ RGEO_BEGIN_C
52
47
 
53
48
 
54
49
  /*
@@ -64,11 +59,6 @@ void rgeo_init_geos_line_string(RGeo_Globals* globals);
64
59
  VALUE rgeo_is_geos_line_string_closed(GEOSContextHandle_t context, const GEOSGeometry* geom);
65
60
 
66
61
 
67
- #ifdef __cplusplus
68
- #if 0
69
- {
70
- #endif
71
- }
72
- #endif
62
+ RGEO_END_C
73
63
 
74
64
  #endif
@@ -51,6 +51,8 @@
51
51
 
52
52
  #endif
53
53
 
54
+ RGEO_BEGIN_C
55
+
54
56
 
55
57
  void Init_geos_c_impl()
56
58
  {
@@ -63,3 +65,6 @@ void Init_geos_c_impl()
63
65
  rgeo_init_geos_geometry_collection(globals);
64
66
  #endif
65
67
  }
68
+
69
+
70
+ RGEO_END_C
@@ -46,12 +46,7 @@
46
46
  #include "geometry.h"
47
47
  #include "point.h"
48
48
 
49
- #ifdef __cplusplus
50
- extern "C" {
51
- #if 0
52
- }
53
- #endif
54
- #endif
49
+ RGEO_BEGIN_C
55
50
 
56
51
 
57
52
  static VALUE method_point_geometry_type(VALUE self)
@@ -191,11 +186,6 @@ VALUE rgeo_create_geos_point_3d(VALUE factory, double x, double y, double z)
191
186
  }
192
187
 
193
188
 
194
- #ifdef __cplusplus
195
- #if 0
196
- {
197
- #endif
198
- }
199
- #endif
189
+ RGEO_END_C
200
190
 
201
191
  #endif
@@ -42,12 +42,7 @@
42
42
 
43
43
  #include "factory.h"
44
44
 
45
- #ifdef __cplusplus
46
- extern "C" {
47
- #if 0
48
- }
49
- #endif
50
- #endif
45
+ RGEO_BEGIN_C
51
46
 
52
47
 
53
48
  /*
@@ -67,11 +62,6 @@ VALUE rgeo_create_geos_point_2d(VALUE factory, double x, double y);
67
62
  VALUE rgeo_create_geos_point_3d(VALUE factory, double x, double y, double z);
68
63
 
69
64
 
70
- #ifdef __cplusplus
71
- #if 0
72
- {
73
- #endif
74
- }
75
- #endif
65
+ RGEO_END_C
76
66
 
77
67
  #endif
@@ -47,12 +47,7 @@
47
47
  #include "line_string.h"
48
48
  #include "polygon.h"
49
49
 
50
- #ifdef __cplusplus
51
- extern "C" {
52
- #if 0
53
- }
54
- #endif
55
- #endif
50
+ RGEO_BEGIN_C
56
51
 
57
52
 
58
53
  static VALUE method_polygon_eql(VALUE self, VALUE rhs)
@@ -169,7 +164,8 @@ static VALUE method_polygon_interior_rings(VALUE self)
169
164
  static VALUE cmethod_create(VALUE module, VALUE factory, VALUE exterior, VALUE interior_array)
170
165
  {
171
166
  Check_Type(interior_array, T_ARRAY);
172
- GEOSGeometry* exterior_geom = rgeo_convert_to_detached_geos_geometry(RGEO_GLOBALS_FROM_FACTORY(factory), exterior, NULL);
167
+ VALUE linear_ring_type = rb_const_get_at(RGEO_GLOBALS_FROM_FACTORY(factory)->features_module, rb_intern("LinearRing"));
168
+ GEOSGeometry* exterior_geom = rgeo_convert_to_detached_geos_geometry(RGEO_GLOBALS_FROM_FACTORY(factory), exterior, linear_ring_type, NULL);
173
169
  if (exterior_geom) {
174
170
  unsigned int len = (unsigned int)RARRAY_LEN(interior_array);
175
171
  GEOSGeometry** interior_geoms = ALLOC_N(GEOSGeometry*, len == 0 ? 1 : len);
@@ -177,7 +173,7 @@ static VALUE cmethod_create(VALUE module, VALUE factory, VALUE exterior, VALUE i
177
173
  unsigned int actual_len = 0;
178
174
  unsigned int i;
179
175
  for (i=0; i<len; ++i) {
180
- GEOSGeometry* interior_geom = rgeo_convert_to_detached_geos_geometry(RGEO_GLOBALS_FROM_FACTORY(factory), rb_ary_entry(interior_array, i), NULL);
176
+ GEOSGeometry* interior_geom = rgeo_convert_to_detached_geos_geometry(RGEO_GLOBALS_FROM_FACTORY(factory), rb_ary_entry(interior_array, i), linear_ring_type, NULL);
181
177
  if (interior_geom) {
182
178
  interior_geoms[actual_len++] = interior_geom;
183
179
  }
@@ -249,11 +245,6 @@ VALUE rgeo_geos_polygons_eql(GEOSContextHandle_t context, const GEOSGeometry* ge
249
245
  }
250
246
 
251
247
 
252
- #ifdef __cplusplus
253
- #if 0
254
- {
255
- #endif
256
- }
257
- #endif
248
+ RGEO_END_C
258
249
 
259
250
  #endif
@@ -43,12 +43,7 @@
43
43
 
44
44
  #include "factory.h"
45
45
 
46
- #ifdef __cplusplus
47
- extern "C" {
48
- #if 0
49
- }
50
- #endif
51
- #endif
46
+ RGEO_BEGIN_C
52
47
 
53
48
 
54
49
  /*
@@ -66,11 +61,6 @@ void rgeo_init_geos_polygon(RGeo_Globals* globals);
66
61
  VALUE rgeo_geos_polygons_eql(GEOSContextHandle_t context, const GEOSGeometry* geom1, const GEOSGeometry* geom2);
67
62
 
68
63
 
69
- #ifdef __cplusplus
70
- #if 0
71
- {
72
- #endif
73
- }
74
- #endif
64
+ RGEO_END_C
75
65
 
76
66
  #endif