rgeo 2.3.0 → 3.0.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +6 -0
  3. data/README.md +1 -0
  4. data/ext/geos_c_impl/analysis.c +8 -6
  5. data/ext/geos_c_impl/analysis.h +1 -3
  6. data/ext/geos_c_impl/errors.c +10 -8
  7. data/ext/geos_c_impl/errors.h +7 -3
  8. data/ext/geos_c_impl/extconf.rb +3 -0
  9. data/ext/geos_c_impl/factory.c +251 -182
  10. data/ext/geos_c_impl/factory.h +43 -62
  11. data/ext/geos_c_impl/geometry.c +56 -24
  12. data/ext/geos_c_impl/geometry.h +8 -3
  13. data/ext/geos_c_impl/geometry_collection.c +41 -148
  14. data/ext/geos_c_impl/geometry_collection.h +1 -14
  15. data/ext/geos_c_impl/globals.c +91 -0
  16. data/ext/geos_c_impl/globals.h +45 -0
  17. data/ext/geos_c_impl/line_string.c +28 -29
  18. data/ext/geos_c_impl/line_string.h +1 -3
  19. data/ext/geos_c_impl/main.c +10 -9
  20. data/ext/geos_c_impl/point.c +9 -8
  21. data/ext/geos_c_impl/point.h +1 -3
  22. data/ext/geos_c_impl/polygon.c +15 -51
  23. data/ext/geos_c_impl/polygon.h +1 -3
  24. data/ext/geos_c_impl/preface.h +8 -0
  25. data/lib/rgeo/cartesian/analysis.rb +2 -2
  26. data/lib/rgeo/cartesian/calculations.rb +54 -17
  27. data/lib/rgeo/cartesian/factory.rb +0 -7
  28. data/lib/rgeo/cartesian/feature_classes.rb +66 -46
  29. data/lib/rgeo/cartesian/feature_methods.rb +56 -20
  30. data/lib/rgeo/cartesian/interface.rb +0 -6
  31. data/lib/rgeo/cartesian/planar_graph.rb +379 -0
  32. data/lib/rgeo/cartesian/sweepline_intersector.rb +149 -0
  33. data/lib/rgeo/cartesian/valid_op.rb +71 -0
  34. data/lib/rgeo/cartesian.rb +3 -0
  35. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +6 -6
  36. data/lib/rgeo/error.rb +15 -0
  37. data/lib/rgeo/feature/curve.rb +12 -2
  38. data/lib/rgeo/feature/geometry.rb +38 -28
  39. data/lib/rgeo/feature/geometry_collection.rb +13 -5
  40. data/lib/rgeo/feature/line_string.rb +3 -3
  41. data/lib/rgeo/feature/multi_curve.rb +6 -1
  42. data/lib/rgeo/feature/multi_surface.rb +3 -3
  43. data/lib/rgeo/feature/point.rb +4 -4
  44. data/lib/rgeo/feature/surface.rb +3 -3
  45. data/lib/rgeo/geographic/factory.rb +0 -7
  46. data/lib/rgeo/geographic/interface.rb +4 -18
  47. data/lib/rgeo/geographic/proj4_projector.rb +0 -2
  48. data/lib/rgeo/geographic/projected_feature_classes.rb +21 -9
  49. data/lib/rgeo/geographic/projected_feature_methods.rb +63 -30
  50. data/lib/rgeo/geographic/simple_mercator_projector.rb +0 -2
  51. data/lib/rgeo/geographic/spherical_feature_classes.rb +29 -9
  52. data/lib/rgeo/geographic/spherical_feature_methods.rb +68 -2
  53. data/lib/rgeo/geos/capi_factory.rb +21 -31
  54. data/lib/rgeo/geos/capi_feature_classes.rb +64 -11
  55. data/lib/rgeo/geos/ffi_factory.rb +0 -28
  56. data/lib/rgeo/geos/ffi_feature_classes.rb +34 -10
  57. data/lib/rgeo/geos/ffi_feature_methods.rb +53 -10
  58. data/lib/rgeo/geos/interface.rb +18 -10
  59. data/lib/rgeo/geos/zm_factory.rb +0 -12
  60. data/lib/rgeo/geos/zm_feature_methods.rb +30 -5
  61. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +18 -8
  62. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -1
  63. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +37 -26
  64. data/lib/rgeo/impl_helper/basic_point_methods.rb +13 -3
  65. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +8 -3
  66. data/lib/rgeo/impl_helper/valid_op.rb +354 -0
  67. data/lib/rgeo/impl_helper/validity_check.rb +138 -0
  68. data/lib/rgeo/impl_helper.rb +1 -0
  69. data/lib/rgeo/version.rb +1 -1
  70. data/lib/rgeo/wkrep/wkb_generator.rb +1 -1
  71. data/lib/rgeo/wkrep/wkt_generator.rb +6 -6
  72. metadata +30 -7
@@ -10,10 +10,13 @@
10
10
  #include <ruby.h>
11
11
  #include <geos_c.h>
12
12
 
13
+ #include "globals.h"
14
+
13
15
  #include "factory.h"
14
16
  #include "geometry.h"
15
17
  #include "line_string.h"
16
18
  #include "polygon.h"
19
+ #include "geometry.h"
17
20
  #include "geometry_collection.h"
18
21
 
19
22
  #include "coordinates.h"
@@ -41,9 +44,6 @@ static VALUE create_geometry_collection(VALUE module, int type, VALUE factory, V
41
44
  VALUE cast_type;
42
45
  GEOSGeometry* geom;
43
46
  GEOSGeometry* collection;
44
- char problem;
45
- GEOSGeometry* igeom;
46
- GEOSGeometry* jgeom;
47
47
 
48
48
  result = Qnil;
49
49
  Check_Type(array, T_ARRAY);
@@ -56,13 +56,13 @@ static VALUE create_geometry_collection(VALUE module, int type, VALUE factory, V
56
56
  cast_type = Qnil;
57
57
  switch (type) {
58
58
  case GEOS_MULTIPOINT:
59
- cast_type = factory_data->globals->feature_point;
59
+ cast_type = rgeo_feature_point_module;
60
60
  break;
61
61
  case GEOS_MULTILINESTRING:
62
- cast_type = factory_data->globals->feature_line_string;
62
+ cast_type = rgeo_feature_line_string_module;
63
63
  break;
64
64
  case GEOS_MULTIPOLYGON:
65
- cast_type = factory_data->globals->feature_polygon;
65
+ cast_type = rgeo_feature_polygon_module;
66
66
  break;
67
67
  }
68
68
  for (i=0; i<len; ++i) {
@@ -88,32 +88,6 @@ static VALUE create_geometry_collection(VALUE module, int type, VALUE factory, V
88
88
  }
89
89
  else {
90
90
  collection = GEOSGeom_createCollection_r(geos_context, type, geoms, len);
91
- // Due to a limitation of GEOS, the MultiPolygon assertions are not checked.
92
- // We do that manually here.
93
- if (collection && type == GEOS_MULTIPOLYGON && (factory_data->flags & 1) == 0) {
94
- problem = 0;
95
- for (i=1; i<len; ++i) {
96
- for (j=0; j<i; ++j) {
97
- igeom = geoms[i];
98
- jgeom = geoms[j];
99
- problem = GEOSRelatePattern_r(geos_context, igeom, jgeom, "2********");
100
- if (problem) {
101
- break;
102
- }
103
- problem = GEOSRelatePattern_r(geos_context, igeom, jgeom, "****1****");
104
- if (problem) {
105
- break;
106
- }
107
- }
108
- if (problem) {
109
- break;
110
- }
111
- }
112
- if (problem) {
113
- GEOSGeom_destroy_r(geos_context, collection);
114
- collection = NULL;
115
- }
116
- }
117
91
  if (collection) {
118
92
  result = rgeo_wrap_geos_geometry(factory, collection, module);
119
93
  RGEO_GEOMETRY_DATA_PTR(result)->klasses = klasses;
@@ -141,7 +115,7 @@ static VALUE method_geometry_collection_eql(VALUE self, VALUE rhs)
141
115
  result = rgeo_geos_klasses_and_factories_eql(self, rhs);
142
116
  if (RTEST(result)) {
143
117
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
144
- result = rgeo_geos_geometry_collections_eql(self_data->geos_context, self_data->geom, RGEO_GEOMETRY_DATA_PTR(rhs)->geom, RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
118
+ result = rgeo_geos_geometries_strict_eql(self_data->geos_context, self_data->geom, RGEO_GEOMETRY_DATA_PTR(rhs)->geom);
145
119
  }
146
120
  return result;
147
121
  }
@@ -156,8 +130,7 @@ static VALUE method_geometry_collection_hash(VALUE self)
156
130
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
157
131
  factory = self_data->factory;
158
132
  hash = rb_hash_start(0);
159
- hash = rgeo_geos_objbase_hash(factory,
160
- RGEO_FACTORY_DATA_PTR(factory)->globals->feature_geometry_collection, hash);
133
+ hash = rgeo_geos_objbase_hash(factory, rgeo_feature_geometry_collection_module, hash);
161
134
  hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
162
135
  return LONG2FIX(rb_hash_end(hash));
163
136
  }
@@ -171,7 +144,7 @@ static VALUE method_geometry_collection_geometry_type(VALUE self)
171
144
  result = Qnil;
172
145
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
173
146
  if (self_data->geom) {
174
- result = RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->feature_geometry_collection;
147
+ result = rgeo_feature_geometry_collection_module;
175
148
  }
176
149
  return result;
177
150
  }
@@ -239,6 +212,8 @@ static VALUE method_geometry_collection_brackets(VALUE self, VALUE n)
239
212
 
240
213
  static VALUE method_geometry_collection_each(VALUE self)
241
214
  {
215
+ RETURN_ENUMERATOR(self, 0, 0); /* return enum_for(__callee__) unless block_given? */
216
+
242
217
  RGeo_GeometryData* self_data;
243
218
  const GEOSGeometry* self_geom;
244
219
  int len;
@@ -249,27 +224,22 @@ static VALUE method_geometry_collection_each(VALUE self)
249
224
 
250
225
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
251
226
 
252
- if (rb_block_given_p()) {
253
- self_geom = self_data->geom;
254
- if (self_geom) {
255
- GEOSContextHandle_t self_context = self_data->geos_context;
256
- len = GEOSGetNumGeometries_r(self_context, self_geom);
257
- if (len > 0) {
258
- klasses = self_data->klasses;
259
- for (i=0; i<len; ++i) {
260
- elem_geom = GEOSGetGeometryN_r(self_context, self_geom, i);
261
- elem = rgeo_wrap_geos_geometry_clone(self_data->factory, elem_geom, NIL_P(klasses) ? Qnil : rb_ary_entry(klasses, i));
262
- if (!NIL_P(elem)) {
263
- rb_yield(elem);
264
- }
227
+ self_geom = self_data->geom;
228
+ if (self_geom) {
229
+ GEOSContextHandle_t self_context = self_data->geos_context;
230
+ len = GEOSGetNumGeometries_r(self_context, self_geom);
231
+ if (len > 0) {
232
+ klasses = self_data->klasses;
233
+ for (i=0; i<len; ++i) {
234
+ elem_geom = GEOSGetGeometryN_r(self_context, self_geom, i);
235
+ elem = rgeo_wrap_geos_geometry_clone(self_data->factory, elem_geom, NIL_P(klasses) ? Qnil : rb_ary_entry(klasses, i));
236
+ if (!NIL_P(elem)) {
237
+ rb_yield(elem);
265
238
  }
266
239
  }
267
240
  }
268
- return self;
269
- }
270
- else {
271
- return rb_funcall(self, RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->id_enum_for, 0);
272
241
  }
242
+ return self;
273
243
  }
274
244
 
275
245
  static VALUE method_multi_point_geometry_type(VALUE self)
@@ -280,7 +250,7 @@ static VALUE method_multi_point_geometry_type(VALUE self)
280
250
  result = Qnil;
281
251
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
282
252
  if (self_data->geom) {
283
- result = RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->feature_multi_point;
253
+ result = rgeo_feature_multi_point_module;
284
254
  }
285
255
  return result;
286
256
  }
@@ -295,8 +265,7 @@ static VALUE method_multi_point_hash(VALUE self)
295
265
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
296
266
  factory = self_data->factory;
297
267
  hash = rb_hash_start(0);
298
- hash = rgeo_geos_objbase_hash(factory,
299
- RGEO_FACTORY_DATA_PTR(factory)->globals->feature_multi_point, hash);
268
+ hash = rgeo_geos_objbase_hash(factory, rgeo_feature_multi_point_module, hash);
300
269
  hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
301
270
  return LONG2FIX(rb_hash_end(hash));
302
271
  }
@@ -342,7 +311,7 @@ static VALUE method_multi_line_string_geometry_type(VALUE self)
342
311
  result = Qnil;
343
312
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
344
313
  if (self_data->geom) {
345
- result = RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->feature_multi_line_string;
314
+ result = rgeo_feature_multi_line_string_module;
346
315
  }
347
316
  return result;
348
317
  }
@@ -357,8 +326,7 @@ static VALUE method_multi_line_string_hash(VALUE self)
357
326
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
358
327
  factory = self_data->factory;
359
328
  hash = rb_hash_start(0);
360
- hash = rgeo_geos_objbase_hash(factory,
361
- RGEO_FACTORY_DATA_PTR(factory)->globals->feature_multi_line_string, hash);
329
+ hash = rgeo_geos_objbase_hash(factory, rgeo_feature_multi_line_string_module, hash);
362
330
  hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
363
331
  return LONG2FIX(rb_hash_end(hash));
364
332
  }
@@ -396,7 +364,7 @@ static VALUE method_multi_line_string_coordinates(VALUE self)
396
364
 
397
365
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
398
366
  self_geom = self_data->geom;
399
-
367
+
400
368
  if(self_geom) {
401
369
  zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
402
370
  context = self_data->geos_context;
@@ -472,7 +440,7 @@ static VALUE method_multi_polygon_geometry_type(VALUE self)
472
440
  result = Qnil;
473
441
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
474
442
  if (self_data->geom) {
475
- result = RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->feature_multi_polygon;
443
+ result = rgeo_feature_multi_polygon_module;
476
444
  }
477
445
  return result;
478
446
  }
@@ -487,8 +455,7 @@ static VALUE method_multi_polygon_hash(VALUE self)
487
455
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
488
456
  factory = self_data->factory;
489
457
  hash = rb_hash_start(0);
490
- hash = rgeo_geos_objbase_hash(factory,
491
- RGEO_FACTORY_DATA_PTR(factory)->globals->feature_multi_polygon, hash);
458
+ hash = rgeo_geos_objbase_hash(factory, rgeo_feature_multi_polygon_module, hash);
492
459
  hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
493
460
  return LONG2FIX(rb_hash_end(hash));
494
461
  }
@@ -508,7 +475,7 @@ static VALUE method_multi_polygon_coordinates(VALUE self)
508
475
 
509
476
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
510
477
  self_geom = self_data->geom;
511
-
478
+
512
479
  if(self_geom) {
513
480
  zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
514
481
  context = self_data->geos_context;
@@ -586,7 +553,7 @@ static VALUE cmethod_multi_polygon_create(VALUE module, VALUE factory, VALUE arr
586
553
  /**** INITIALIZATION FUNCTION ****/
587
554
 
588
555
 
589
- void rgeo_init_geos_geometry_collection(RGeo_Globals* globals)
556
+ void rgeo_init_geos_geometry_collection()
590
557
  {
591
558
  VALUE geos_geometry_collection_methods;
592
559
  VALUE geos_multi_point_methods;
@@ -594,13 +561,13 @@ void rgeo_init_geos_geometry_collection(RGeo_Globals* globals)
594
561
  VALUE geos_multi_polygon_methods;
595
562
 
596
563
  // Class methods for geometry collection classes
597
- rb_define_module_function(globals->geos_geometry_collection, "create", cmethod_geometry_collection_create, 2);
598
- rb_define_module_function(globals->geos_multi_point, "create", cmethod_multi_point_create, 2);
599
- rb_define_module_function(globals->geos_multi_line_string, "create", cmethod_multi_line_string_create, 2);
600
- rb_define_module_function(globals->geos_multi_polygon, "create", cmethod_multi_polygon_create, 2);
564
+ rb_define_module_function(rgeo_geos_geometry_collection_class, "create", cmethod_geometry_collection_create, 2);
565
+ rb_define_module_function(rgeo_geos_multi_point_class, "create", cmethod_multi_point_create, 2);
566
+ rb_define_module_function(rgeo_geos_multi_line_string_class, "create", cmethod_multi_line_string_create, 2);
567
+ rb_define_module_function(rgeo_geos_multi_polygon_class, "create", cmethod_multi_polygon_create, 2);
601
568
 
602
569
  // Methods for GeometryCollectionImpl
603
- geos_geometry_collection_methods = rb_define_module_under(globals->geos_module, "CAPIGeometryCollectionMethods");
570
+ geos_geometry_collection_methods = rb_define_module_under(rgeo_geos_module, "CAPIGeometryCollectionMethods");
604
571
  rb_define_method(geos_geometry_collection_methods, "rep_equals?", method_geometry_collection_eql, 1);
605
572
  rb_define_method(geos_geometry_collection_methods, "eql?", method_geometry_collection_eql, 1);
606
573
  rb_define_method(geos_geometry_collection_methods, "hash", method_geometry_collection_hash, 0);
@@ -614,21 +581,21 @@ void rgeo_init_geos_geometry_collection(RGeo_Globals* globals)
614
581
 
615
582
 
616
583
  // Methods for MultiPointImpl
617
- geos_multi_point_methods = rb_define_module_under(globals->geos_module, "CAPIMultiPointMethods");
584
+ geos_multi_point_methods = rb_define_module_under(rgeo_geos_module, "CAPIMultiPointMethods");
618
585
  rb_define_method(geos_multi_point_methods, "geometry_type", method_multi_point_geometry_type, 0);
619
586
  rb_define_method(geos_multi_point_methods, "hash", method_multi_point_hash, 0);
620
587
  rb_define_method(geos_multi_point_methods, "coordinates", method_multi_point_coordinates, 0);
621
588
 
622
589
  // Methods for MultiLineStringImpl
623
- geos_multi_line_string_methods = rb_define_module_under(globals->geos_module, "CAPIMultiLineStringMethods");
590
+ geos_multi_line_string_methods = rb_define_module_under(rgeo_geos_module, "CAPIMultiLineStringMethods");
624
591
  rb_define_method(geos_multi_line_string_methods, "geometry_type", method_multi_line_string_geometry_type, 0);
625
592
  rb_define_method(geos_multi_line_string_methods, "length", method_multi_line_string_length, 0);
626
- rb_define_method(geos_multi_line_string_methods, "is_closed?", method_multi_line_string_is_closed, 0);
593
+ rb_define_method(geos_multi_line_string_methods, "closed?", method_multi_line_string_is_closed, 0);
627
594
  rb_define_method(geos_multi_line_string_methods, "hash", method_multi_line_string_hash, 0);
628
595
  rb_define_method(geos_multi_line_string_methods, "coordinates", method_multi_line_string_coordinates, 0);
629
596
 
630
597
  // Methods for MultiPolygonImpl
631
- geos_multi_polygon_methods = rb_define_module_under(globals->geos_module, "CAPIMultiPolygonMethods");
598
+ geos_multi_polygon_methods = rb_define_module_under(rgeo_geos_module, "CAPIMultiPolygonMethods");
632
599
  rb_define_method(geos_multi_polygon_methods, "geometry_type", method_multi_polygon_geometry_type, 0);
633
600
  rb_define_method(geos_multi_polygon_methods, "area", method_multi_polygon_area, 0);
634
601
  rb_define_method(geos_multi_polygon_methods, "centroid", method_multi_polygon_centroid, 0);
@@ -640,80 +607,6 @@ void rgeo_init_geos_geometry_collection(RGeo_Globals* globals)
640
607
  /**** OTHER PUBLIC FUNCTIONS ****/
641
608
 
642
609
 
643
- VALUE rgeo_geos_geometry_collections_eql(GEOSContextHandle_t context, const GEOSGeometry* geom1, const GEOSGeometry* geom2, char check_z)
644
- {
645
- VALUE result;
646
- int len1;
647
- int len2;
648
- int i;
649
- const GEOSGeometry* sub_geom1;
650
- const GEOSGeometry* sub_geom2;
651
- int type1;
652
- int type2;
653
-
654
- result = Qnil;
655
- if (geom1 && geom2) {
656
- len1 = GEOSGetNumGeometries_r(context, geom1);
657
- len2 = GEOSGetNumGeometries_r(context, geom2);
658
- if (len1 >= 0 && len2 >= 0) {
659
- if (len1 == len2) {
660
- result = Qtrue;
661
- for (i=0; i<len1; ++i) {
662
- sub_geom1 = GEOSGetGeometryN_r(context, geom1, i);
663
- sub_geom2 = GEOSGetGeometryN_r(context, geom2, i);
664
- if (sub_geom1 && sub_geom2) {
665
- type1 = GEOSGeomTypeId_r(context, sub_geom1);
666
- type2 = GEOSGeomTypeId_r(context, sub_geom2);
667
- if (type1 >= 0 && type2 >= 0) {
668
- if (type1 == type2) {
669
- switch (type1) {
670
- case GEOS_POINT:
671
- case GEOS_LINESTRING:
672
- case GEOS_LINEARRING:
673
- result = rgeo_geos_coordseqs_eql(context, sub_geom1, sub_geom2, check_z);
674
- break;
675
- case GEOS_POLYGON:
676
- result = rgeo_geos_polygons_eql(context, sub_geom1, sub_geom2, check_z);
677
- break;
678
- case GEOS_GEOMETRYCOLLECTION:
679
- case GEOS_MULTIPOINT:
680
- case GEOS_MULTILINESTRING:
681
- case GEOS_MULTIPOLYGON:
682
- result = rgeo_geos_geometry_collections_eql(context, sub_geom1, sub_geom2, check_z);
683
- break;
684
- default:
685
- result = Qnil;
686
- break;
687
- }
688
- if (!RTEST(result)) {
689
- break;
690
- }
691
- }
692
- else {
693
- result = Qfalse;
694
- break;
695
- }
696
- }
697
- else {
698
- result = Qnil;
699
- break;
700
- }
701
- }
702
- else {
703
- result = Qnil;
704
- break;
705
- }
706
- }
707
- }
708
- else {
709
- result = Qfalse;
710
- }
711
- }
712
- }
713
- return result;
714
- }
715
-
716
-
717
610
  st_index_t rgeo_geos_geometry_collection_hash(GEOSContextHandle_t context, const GEOSGeometry* geom, st_index_t hash)
718
611
  {
719
612
  const GEOSGeometry* sub_geom;
@@ -9,8 +9,6 @@
9
9
  #include <ruby.h>
10
10
  #include <geos_c.h>
11
11
 
12
- #include "factory.h"
13
-
14
12
  RGEO_BEGIN_C
15
13
 
16
14
 
@@ -18,18 +16,7 @@ RGEO_BEGIN_C
18
16
  Initializes the geometry collection module. This should be called after
19
17
  the geometry module is initialized.
20
18
  */
21
- void rgeo_init_geos_geometry_collection(RGeo_Globals* globals);
22
-
23
- /*
24
- Comopares the contents of two geometry collections. Does not test the
25
- types of the collections themselves, but tests the types, values, and
26
- contents of all the contents. The two given geometries MUST be
27
- collection types-- i.e. GeometryCollection, MultiPoint, MultiLineString,
28
- or MultiPolygon.
29
- Returns Qtrue if the contents of the two geometry collections are equal,
30
- Qfalse if they are inequal, or Qnil if an error occurs.
31
- */
32
- VALUE rgeo_geos_geometry_collections_eql(GEOSContextHandle_t context, const GEOSGeometry* geom1, const GEOSGeometry* geom2, char check_z);
19
+ void rgeo_init_geos_geometry_collection();
33
20
 
34
21
  /*
35
22
  A tool for building up hash values.
@@ -0,0 +1,91 @@
1
+ #include "preface.h"
2
+
3
+ #ifdef RGEO_GEOS_SUPPORTED
4
+
5
+ #include <ruby.h>
6
+
7
+ #include "globals.h"
8
+
9
+ RGEO_BEGIN_C
10
+
11
+ VALUE rgeo_module;
12
+
13
+ VALUE rgeo_feature_module;
14
+ VALUE rgeo_feature_geometry_module;
15
+ VALUE rgeo_feature_point_module;
16
+ VALUE rgeo_feature_line_string_module;
17
+ VALUE rgeo_feature_linear_ring_module;
18
+ VALUE rgeo_feature_line_module;
19
+ VALUE rgeo_feature_polygon_module;
20
+ VALUE rgeo_feature_geometry_collection_module;
21
+ VALUE rgeo_feature_multi_point_module;
22
+ VALUE rgeo_feature_multi_line_string_module;
23
+ VALUE rgeo_feature_multi_polygon_module;
24
+
25
+ VALUE rgeo_geos_module;
26
+ VALUE rgeo_geos_geometry_class;
27
+ VALUE rgeo_geos_point_class;
28
+ VALUE rgeo_geos_line_string_class;
29
+ VALUE rgeo_geos_linear_ring_class;
30
+ VALUE rgeo_geos_line_class;
31
+ VALUE rgeo_geos_polygon_class;
32
+ VALUE rgeo_geos_geometry_collection_class;
33
+ VALUE rgeo_geos_multi_point_class;
34
+ VALUE rgeo_geos_multi_line_string_class;
35
+ VALUE rgeo_geos_multi_polygon_class;
36
+
37
+ void rgeo_init_geos_globals()
38
+ {
39
+ rgeo_module = rb_define_module("RGeo");
40
+ rb_gc_register_mark_object(rgeo_module);
41
+
42
+ rgeo_feature_module = rb_define_module_under(rgeo_module, "Feature");
43
+ rb_gc_register_mark_object(rgeo_feature_module);
44
+ rgeo_feature_geometry_module = rb_const_get_at(rgeo_feature_module, rb_intern("Geometry"));
45
+ rb_gc_register_mark_object(rgeo_feature_geometry_module);
46
+ rgeo_feature_point_module = rb_const_get_at(rgeo_feature_module, rb_intern("Point"));
47
+ rb_gc_register_mark_object(rgeo_feature_point_module);
48
+ rgeo_feature_line_string_module = rb_const_get_at(rgeo_feature_module, rb_intern("LineString"));
49
+ rb_gc_register_mark_object(rgeo_feature_line_string_module);
50
+ rgeo_feature_linear_ring_module = rb_const_get_at(rgeo_feature_module, rb_intern("LinearRing"));
51
+ rb_gc_register_mark_object(rgeo_feature_linear_ring_module);
52
+ rgeo_feature_line_module = rb_const_get_at(rgeo_feature_module, rb_intern("Line"));
53
+ rb_gc_register_mark_object(rgeo_feature_line_module);
54
+ rgeo_feature_polygon_module = rb_const_get_at(rgeo_feature_module, rb_intern("Polygon"));
55
+ rb_gc_register_mark_object(rgeo_feature_polygon_module);
56
+ rgeo_feature_geometry_collection_module = rb_const_get_at(rgeo_feature_module, rb_intern("GeometryCollection"));
57
+ rb_gc_register_mark_object(rgeo_feature_geometry_collection_module);
58
+ rgeo_feature_multi_point_module = rb_const_get_at(rgeo_feature_module, rb_intern("MultiPoint"));
59
+ rb_gc_register_mark_object(rgeo_feature_multi_point_module);
60
+ rgeo_feature_multi_line_string_module = rb_const_get_at(rgeo_feature_module, rb_intern("MultiLineString"));
61
+ rb_gc_register_mark_object(rgeo_feature_multi_line_string_module);
62
+ rgeo_feature_multi_polygon_module = rb_const_get_at(rgeo_feature_module, rb_intern("MultiPolygon"));
63
+ rb_gc_register_mark_object(rgeo_feature_multi_polygon_module);
64
+
65
+ rgeo_geos_module = rb_define_module_under(rgeo_module, "Geos");
66
+ rb_gc_register_mark_object(rgeo_geos_module);
67
+ rgeo_geos_geometry_class = rb_define_class_under(rgeo_geos_module, "CAPIGeometryImpl", rb_cObject);
68
+ rb_gc_register_mark_object(rgeo_geos_geometry_class);
69
+ rgeo_geos_point_class = rb_define_class_under(rgeo_geos_module, "CAPIPointImpl", rb_cObject);
70
+ rb_gc_register_mark_object(rgeo_geos_point_class);
71
+ rgeo_geos_line_string_class = rb_define_class_under(rgeo_geos_module, "CAPILineStringImpl", rb_cObject);
72
+ rb_gc_register_mark_object(rgeo_geos_line_string_class);
73
+ rgeo_geos_linear_ring_class = rb_define_class_under(rgeo_geos_module, "CAPILinearRingImpl", rb_cObject);
74
+ rb_gc_register_mark_object(rgeo_geos_linear_ring_class);
75
+ rgeo_geos_line_class = rb_define_class_under(rgeo_geos_module, "CAPILineImpl", rb_cObject);
76
+ rb_gc_register_mark_object(rgeo_geos_line_class);
77
+ rgeo_geos_polygon_class = rb_define_class_under(rgeo_geos_module, "CAPIPolygonImpl", rb_cObject);
78
+ rb_gc_register_mark_object(rgeo_geos_polygon_class);
79
+ rgeo_geos_geometry_collection_class = rb_define_class_under(rgeo_geos_module, "CAPIGeometryCollectionImpl", rb_cObject);
80
+ rb_gc_register_mark_object(rgeo_geos_geometry_collection_class);
81
+ rgeo_geos_multi_point_class = rb_define_class_under(rgeo_geos_module, "CAPIMultiPointImpl", rb_cObject);
82
+ rb_gc_register_mark_object(rgeo_geos_multi_point_class);
83
+ rgeo_geos_multi_line_string_class = rb_define_class_under(rgeo_geos_module, "CAPIMultiLineStringImpl", rb_cObject);
84
+ rb_gc_register_mark_object(rgeo_geos_multi_line_string_class);
85
+ rgeo_geos_multi_polygon_class = rb_define_class_under(rgeo_geos_module, "CAPIMultiPolygonImpl", rb_cObject);
86
+ rb_gc_register_mark_object(rgeo_geos_multi_polygon_class);
87
+ }
88
+
89
+ RGEO_END_C
90
+
91
+ #endif
@@ -0,0 +1,45 @@
1
+ /*
2
+ Per-interpreter globals.
3
+ Most of these are cached references to commonly used classes, modules,
4
+ and symbols so we don't have to do a lot of constant lookups and calls
5
+ to rb_intern.
6
+ */
7
+
8
+ #ifndef RGEO_GEOS_GLOBALS_INCLUDED
9
+ #define RGEO_GEOS_GLOBALS_INCLUDED
10
+
11
+ #include <ruby.h>
12
+
13
+ RGEO_BEGIN_C
14
+
15
+ extern VALUE rgeo_module;
16
+
17
+ extern VALUE rgeo_feature_module;
18
+ extern VALUE rgeo_feature_geometry_module;
19
+ extern VALUE rgeo_feature_point_module;
20
+ extern VALUE rgeo_feature_line_string_module;
21
+ extern VALUE rgeo_feature_linear_ring_module;
22
+ extern VALUE rgeo_feature_line_module;
23
+ extern VALUE rgeo_feature_polygon_module;
24
+ extern VALUE rgeo_feature_geometry_collection_module;
25
+ extern VALUE rgeo_feature_multi_point_module;
26
+ extern VALUE rgeo_feature_multi_line_string_module;
27
+ extern VALUE rgeo_feature_multi_polygon_module;
28
+
29
+ extern VALUE rgeo_geos_module;
30
+ extern VALUE rgeo_geos_geometry_class;
31
+ extern VALUE rgeo_geos_point_class;
32
+ extern VALUE rgeo_geos_line_string_class;
33
+ extern VALUE rgeo_geos_linear_ring_class;
34
+ extern VALUE rgeo_geos_line_class;
35
+ extern VALUE rgeo_geos_polygon_class;
36
+ extern VALUE rgeo_geos_geometry_collection_class;
37
+ extern VALUE rgeo_geos_multi_point_class;
38
+ extern VALUE rgeo_geos_multi_line_string_class;
39
+ extern VALUE rgeo_geos_multi_polygon_class;
40
+
41
+ void rgeo_init_geos_globals();
42
+
43
+ RGEO_END_C
44
+
45
+ #endif