rgeo 2.3.1 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +6 -0
  3. data/README.md +23 -14
  4. data/ext/geos_c_impl/analysis.c +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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b93de3431a81612631cfa612d589bc0e1026f16276d3c1e848b71f1a3e682731
4
- data.tar.gz: 992a46705454a1fe1c77405e9b6f753739af0c80b9e6f58d8e60da07b75eea93
3
+ metadata.gz: 792e1494e9ef340bb740e8675b2ce67e4d02fa6c4333ad93c523e348e5153812
4
+ data.tar.gz: a4051c1728401caca45807c9e786a5e5130761c95a95ff6bdb60265130aa2049
5
5
  SHA512:
6
- metadata.gz: aca5ecae4e1c3ee2d022591ccf612aae3e4f8539543cc740ba3875b15ae156da6e1e13180a305e0c2a41a9bcf3a60e3eafb5c87eb737f95ef194e08fe66c39f9
7
- data.tar.gz: 94ae519f52c0a6deada3e560722256e99fc482528be8ceea67496cf0dbc7488da9bf643ab2905a28294aaa68ac3f532e913c3afb7fea2877b438ecf282911153
6
+ metadata.gz: 3a6ee8000fd92f7bef89915d9d7e11aea0fb413248778d0f5e5218516d98cc6d16afba66d92c670c9f0539d37a6c7e934a5fcc3ad839626d7299b7c5ae8ffc57
7
+ data.tar.gz: 580f0a56261c8ab5698e14a78e7f61bcdb8fa362160db4ed1662dbb792d1d8ec7272a1e3387568b00c6b8403547aae128363ad230cf622ec5b5908a0e17b8d6f
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ --markup rdoc
2
+ --output-dir ./yardoc
3
+ lib/**/*.rb
4
+ ext/**/*.{c,h}
5
+ -
6
+ doc/*.md
data/README.md CHANGED
@@ -1,15 +1,14 @@
1
1
  ## RGeo
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/rgeo.svg)](http://badge.fury.io/rb/rgeo)
4
- [![CI](https://github.com/rgeo/rgeo/workflows/CI/badge.svg)](https://github.com/rgeo/rgeo/actions?query=workflow%3ACI+branch%3Amaster+event%3Apush)
4
+ [![CI](https://github.com/rgeo/rgeo/workflows/CI/badge.svg)](https://github.com/rgeo/rgeo/actions?query=workflow%3ACI+branch%3Amain+event%3Apush)
5
5
 
6
6
  RGeo is a geospatial data library for Ruby.
7
7
 
8
- :warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning:
8
+ ***Contributors Wanted!***
9
9
 
10
- This organization is looking for maintainers, see [this issue](https://github.com/rgeo/rgeo/issues/216) for more information.
10
+ If you use RGeo and are interested in contributing, please check out our [open issues](https://github.com/rgeo/rgeo/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22%2C%22help+wanted%22) to see if there's anything you're able to help with.
11
11
 
12
- :warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning:
13
12
 
14
13
  ### Summary
15
14
 
@@ -37,7 +36,7 @@ Use the core **rgeo** gem to:
37
36
 
38
37
  RGeo works with the following Ruby implementations:
39
38
 
40
- * MRI Ruby 2.3.0 or later.
39
+ * MRI Ruby 2.6.0 or later.
41
40
  * Partial support for JRuby 9.0 or later. The FFI implementation of GEOS
42
41
  is available (ffi-geos gem required) but CAPI is not.
43
42
  * See earlier versions for support for older ruby versions.
@@ -74,6 +73,14 @@ If you are using proj.4 extensions, include
74
73
  gem "rgeo-proj4"
75
74
  ```
76
75
 
76
+ ### Upgrading to Version 3.0
77
+
78
+ See [doc/Upgrading-to-v3.md](doc/Upgrading-to-v3.md) for a checklist of changes to make before upgrading to RGeo 3.0.
79
+
80
+ For a brief overview of the changes, see [NEWS.md](NEWS.md).
81
+
82
+ For a comprehensive list of all changes, see [History.md](History.md).
83
+
77
84
 
78
85
  ### Extensions
79
86
 
@@ -109,7 +116,7 @@ ActiveRecord connection adapter for SpatiaLite, based on sqlite3 (*not maintaine
109
116
  RDoc Documentation is available at https://www.rubydoc.info/gems/rgeo
110
117
 
111
118
  Contributions are welcome. Please read the
112
- [Contributing guidelines](https://github.com/rgeo/rgeo/blob/master/CONTRIBUTING.md).
119
+ [Contributing guidelines](https://github.com/rgeo/rgeo/blob/main/CONTRIBUTING.md).
113
120
 
114
121
  Support may be available on the
115
122
  [rgeo-users google group](https://groups.google.com/forum/#!forum/rgeo-users)
@@ -124,13 +131,15 @@ generate documentation locally if you're working on RGeo: `yardoc server`.
124
131
 
125
132
  Here's the current list of available topics:
126
133
 
127
- - [An introduction to Spatial Programming With RGeo](https://github.com/rgeo/rgeo/blob/master/doc/An-Introduction-to-Spatial-Programming-With-RGeo.md)
128
- - [Enable GEOS and Proj4 on Heroku](https://github.com/rgeo/rgeo/blob/master/doc/Enable-GEOS-and-Proj4-on-Heroku.md)
129
- - [Installing GEOS](https://github.com/rgeo/rgeo/blob/master/doc/Installing-GEOS.md)
130
- - [Factory Compatibility](https://github.com/rgeo/rgeo/blob/master/doc/Factory-Compatibility.md)
131
- - [Which factory should I use?](https://github.com/rgeo/rgeo/blob/master/doc/Which-factory-should-I-use.md)
132
- - [Examples](https://github.com/rgeo/rgeo/blob/master/doc/Examples.md)
133
- - [Who uses `rgeo`?](https://github.com/rgeo/rgeo/blob/master/doc/Gallery.md)
134
+ - [An introduction to Spatial Programming With RGeo](https://github.com/rgeo/rgeo/blob/main/doc/An-Introduction-to-Spatial-Programming-With-RGeo.md)
135
+ - [Enable GEOS and Proj4 on Heroku](https://github.com/rgeo/rgeo/blob/main/doc/Enable-GEOS-and-Proj4-on-Heroku.md)
136
+ - [Installing GEOS](https://github.com/rgeo/rgeo/blob/main/doc/Installing-GEOS.md)
137
+ - [Factory Compatibility](https://github.com/rgeo/rgeo/blob/main/doc/Factory-Compatibility.md)
138
+ - [Which factory should I use?](https://github.com/rgeo/rgeo/blob/main/doc/Which-factory-should-I-use.md)
139
+ - [Geometry validity handling](https://github.com/rgeo/rgeo/blob/main/doc/Geometry-Validity.md)
140
+ - [Upgrading to Version 3](https://github.com/rgeo/rgeo/blob/main/doc/Upgrading-to-v3.md)
141
+ - [Examples](https://github.com/rgeo/rgeo/blob/main/doc/Examples.md)
142
+ - [Who uses `rgeo`?](https://github.com/rgeo/rgeo/blob/main/doc/Gallery.md)
134
143
 
135
144
  You can see an exhaustive and up to date list at https://rubydoc.info/gems/rgeo/index.
136
145
  ### Acknowledgments
@@ -157,4 +166,4 @@ by [J Smith](https://github.com/dark-panda).
157
166
 
158
167
  Copyright (c) Daniel Azuma, Tee Parham
159
168
 
160
- [License](https://github.com/rgeo/rgeo/blob/master/LICENSE.txt)
169
+ [License](https://github.com/rgeo/rgeo/blob/main/LICENSE.txt)
@@ -6,12 +6,13 @@
6
6
 
7
7
  #ifdef RGEO_GEOS_SUPPORTED
8
8
 
9
- #include <ruby.h>
10
9
  #include <geos_c.h>
10
+ #include <ruby.h>
11
11
 
12
12
  #include "analysis.h"
13
- #include "factory.h"
14
13
  #include "errors.h"
14
+ #include "factory.h"
15
+ #include "globals.h"
15
16
 
16
17
  RGEO_BEGIN_C
17
18
 
@@ -23,9 +24,9 @@ RGEO_BEGIN_C
23
24
  * otherwise.
24
25
  */
25
26
  #ifdef RGEO_GEOS_SUPPORTS_ISCCW
26
- VALUE rgeo_geos_analysis_ccw_p(VALUE self, VALUE ring)
27
+ VALUE
28
+ rgeo_geos_analysis_ccw_p(VALUE self, VALUE ring)
27
29
  {
28
-
29
30
  const RGeo_GeometryData* ring_data;
30
31
  const GEOSCoordSequence* coord_seq;
31
32
  char is_ccw;
@@ -34,43 +35,47 @@ VALUE rgeo_geos_analysis_ccw_p(VALUE self, VALUE ring)
34
35
 
35
36
  ring_data = RGEO_GEOMETRY_DATA_PTR(ring);
36
37
 
37
- coord_seq = GEOSGeom_getCoordSeq_r(ring_data->geos_context, ring_data->geom);
38
- if (!coord_seq) { rb_raise(geos_error, "Could not retrieve CoordSeq from given ring."); }
39
- if (!GEOSCoordSeq_isCCW_r(ring_data->geos_context, coord_seq, &is_ccw)) {
40
- rb_raise(geos_error, "Could not determine if the CoordSeq is CCW.");
38
+ coord_seq = GEOSGeom_getCoordSeq(ring_data->geom);
39
+ if (!coord_seq) {
40
+ rb_raise(rb_eGeosError, "Could not retrieve CoordSeq from given ring.");
41
+ }
42
+ if (!GEOSCoordSeq_isCCW(coord_seq, &is_ccw)) {
43
+ rb_raise(rb_eGeosError, "Could not determine if the CoordSeq is CCW.");
41
44
  }
42
45
 
43
46
  return is_ccw ? Qtrue : Qfalse;
44
- };
47
+ }
45
48
  #endif // RGEO_GEOS_SUPPORTS_ISCCW
46
49
 
47
-
48
50
  /**
49
51
  * call-seq:
50
- * RGeo::Geos::Analysis.ccw_supported? -> true or false
51
- *
52
+ * RGeo::Geos::Analysis.ccw_supported? -> true or false
53
+ *
52
54
  * Checks if the RGEO_GEOS_SUPPORTS_ISCCW macro is defined, returns +true+
53
55
  * if it is, +false+ otherwise
54
56
  */
55
- VALUE rgeo_geos_analysis_supports_ccw(VALUE self)
57
+ VALUE
58
+ rgeo_geos_analysis_supports_ccw(VALUE self)
56
59
  {
57
- #ifdef RGEO_GEOS_SUPPORTS_ISCCW
58
- return Qtrue;
59
- #else
60
- return Qfalse;
61
- #endif
60
+ #ifdef RGEO_GEOS_SUPPORTS_ISCCW
61
+ return Qtrue;
62
+ #else
63
+ return Qfalse;
64
+ #endif
62
65
  }
63
66
 
64
-
65
- void rgeo_init_geos_analysis(RGeo_Globals* globals)
67
+ void
68
+ rgeo_init_geos_analysis()
66
69
  {
67
70
  VALUE geos_analysis_module;
68
71
 
69
- geos_analysis_module = rb_define_module_under(globals->geos_module, "Analysis");
70
- rb_define_singleton_method(geos_analysis_module, "ccw_supported?", rgeo_geos_analysis_supports_ccw, 0);
71
- #ifdef RGEO_GEOS_SUPPORTS_ISCCW
72
- rb_define_singleton_method(geos_analysis_module, "ccw?", rgeo_geos_analysis_ccw_p, 1);
73
- #endif // RGEO_GEOS_SUPPORTS_ISCCW
72
+ geos_analysis_module = rb_define_module_under(rgeo_geos_module, "Analysis");
73
+ rb_define_singleton_method(
74
+ geos_analysis_module, "ccw_supported?", rgeo_geos_analysis_supports_ccw, 0);
75
+ #ifdef RGEO_GEOS_SUPPORTS_ISCCW
76
+ rb_define_singleton_method(
77
+ geos_analysis_module, "ccw?", rgeo_geos_analysis_ccw_p, 1);
78
+ #endif // RGEO_GEOS_SUPPORTS_ISCCW
74
79
  }
75
80
 
76
81
  RGEO_END_C
@@ -9,8 +9,6 @@
9
9
 
10
10
  #ifdef RGEO_GEOS_SUPPORTED
11
11
 
12
- #include "factory.h"
13
-
14
12
  RGEO_BEGIN_C
15
13
 
16
14
  /*
@@ -21,19 +19,22 @@ RGEO_BEGIN_C
21
19
  * otherwise.
22
20
  */
23
21
  #ifdef RGEO_GEOS_SUPPORTS_CCW
24
- VALUE rgeo_geos_analysis_ccw_p(VALUE self, VALUE ring);
22
+ VALUE
23
+ rgeo_geos_analysis_ccw_p(VALUE self, VALUE ring);
25
24
  #endif // RGEO_GEOS_SUPPORTS_CCW
26
25
 
27
26
  /**
28
27
  * call-seq:
29
- * RGeo::Geos::Analysis.ccw_supported? -> true or false
30
- *
28
+ * RGeo::Geos::Analysis.ccw_supported? -> true or false
29
+ *
31
30
  * Checks if the RGEO_GEOS_SUPPORTS_ISCCW macro is defined, returns +true+
32
31
  * if it is, +false+ otherwise
33
32
  */
34
- VALUE rgeo_geos_analysis_supports_ccw(VALUE self);
33
+ VALUE
34
+ rgeo_geos_analysis_supports_ccw(VALUE self);
35
35
 
36
- void rgeo_init_geos_analysis(RGeo_Globals* globals);
36
+ void
37
+ rgeo_init_geos_analysis();
37
38
 
38
39
  RGEO_END_C
39
40
 
@@ -1,8 +1,9 @@
1
- #include <ruby.h>
2
1
  #include <geos_c.h>
2
+ #include <ruby.h>
3
3
 
4
-
5
- VALUE extract_points_from_coordinate_sequence(GEOSContextHandle_t context, const GEOSCoordSequence* coord_sequence, int zCoordinate)
4
+ VALUE
5
+ extract_points_from_coordinate_sequence(const GEOSCoordSequence* coord_sequence,
6
+ int zCoordinate)
6
7
  {
7
8
  VALUE result = Qnil;
8
9
  VALUE point;
@@ -10,20 +11,20 @@ VALUE extract_points_from_coordinate_sequence(GEOSContextHandle_t context, const
10
11
  unsigned int i;
11
12
  double val;
12
13
 
13
- if(GEOSCoordSeq_getSize_r(context, coord_sequence, &count)) {
14
+ if (GEOSCoordSeq_getSize(coord_sequence, &count)) {
14
15
  result = rb_ary_new2(count);
15
- for(i = 0; i < count; ++i) {
16
- if(zCoordinate) {
16
+ for (i = 0; i < count; ++i) {
17
+ if (zCoordinate) {
17
18
  point = rb_ary_new2(3);
18
19
  } else {
19
20
  point = rb_ary_new2(2);
20
21
  }
21
- GEOSCoordSeq_getX_r(context, coord_sequence, i, &val);
22
+ GEOSCoordSeq_getX(coord_sequence, i, &val);
22
23
  rb_ary_push(point, rb_float_new(val));
23
- GEOSCoordSeq_getY_r(context, coord_sequence, i, &val);
24
+ GEOSCoordSeq_getY(coord_sequence, i, &val);
24
25
  rb_ary_push(point, rb_float_new(val));
25
- if(zCoordinate) {
26
- GEOSCoordSeq_getZ_r(context, coord_sequence, i, &val);
26
+ if (zCoordinate) {
27
+ GEOSCoordSeq_getZ(coord_sequence, i, &val);
27
28
  rb_ary_push(point, rb_float_new(val));
28
29
  }
29
30
  rb_ary_push(result, point);
@@ -33,7 +34,8 @@ VALUE extract_points_from_coordinate_sequence(GEOSContextHandle_t context, const
33
34
  return result;
34
35
  }
35
36
 
36
- VALUE extract_points_from_polygon(GEOSContextHandle_t context, const GEOSGeometry* polygon, int zCoordinate)
37
+ VALUE
38
+ extract_points_from_polygon(const GEOSGeometry* polygon, int zCoordinate)
37
39
  {
38
40
  VALUE result = Qnil;
39
41
 
@@ -43,20 +45,24 @@ VALUE extract_points_from_polygon(GEOSContextHandle_t context, const GEOSGeometr
43
45
  unsigned int i;
44
46
 
45
47
  if (polygon) {
46
- ring = GEOSGetExteriorRing_r(context, polygon);
47
- coord_sequence = GEOSGeom_getCoordSeq_r(context, ring);
48
+ ring = GEOSGetExteriorRing(polygon);
49
+ coord_sequence = GEOSGeom_getCoordSeq(ring);
48
50
 
49
- if(coord_sequence) {
50
- interior_ring_count = GEOSGetNumInteriorRings_r(context, polygon);
51
+ if (coord_sequence) {
52
+ interior_ring_count = GEOSGetNumInteriorRings(polygon);
51
53
  result = rb_ary_new2(interior_ring_count + 1); // exterior + inner rings
52
54
 
53
- rb_ary_push(result, extract_points_from_coordinate_sequence(context, coord_sequence, zCoordinate));
55
+ rb_ary_push(
56
+ result,
57
+ extract_points_from_coordinate_sequence(coord_sequence, zCoordinate));
54
58
 
55
- for(i = 0; i < interior_ring_count; ++i) {
56
- ring = GEOSGetInteriorRingN_r(context, polygon, i);
57
- coord_sequence = GEOSGeom_getCoordSeq_r(context, ring);
58
- if(coord_sequence) {
59
- rb_ary_push(result, extract_points_from_coordinate_sequence(context, coord_sequence, zCoordinate));
59
+ for (i = 0; i < interior_ring_count; ++i) {
60
+ ring = GEOSGetInteriorRingN(polygon, i);
61
+ coord_sequence = GEOSGeom_getCoordSeq(ring);
62
+ if (coord_sequence) {
63
+ rb_ary_push(result,
64
+ extract_points_from_coordinate_sequence(coord_sequence,
65
+ zCoordinate));
60
66
  }
61
67
  }
62
68
  }
@@ -1,2 +1,5 @@
1
- VALUE extract_points_from_coordinate_sequence(GEOSContextHandle_t context, const GEOSCoordSequence* coord_sequence, int zCoordinate);
2
- VALUE extract_points_from_polygon(GEOSContextHandle_t context, const GEOSGeometry* polygon, int zCoordinate);
1
+ VALUE
2
+ extract_points_from_coordinate_sequence(const GEOSCoordSequence* coord_sequence,
3
+ int zCoordinate);
4
+ VALUE
5
+ extract_points_from_polygon(const GEOSGeometry* polygon, int zCoordinate);
@@ -9,23 +9,32 @@
9
9
  #ifdef RGEO_GEOS_SUPPORTED
10
10
 
11
11
  #include "errors.h"
12
+ #include "globals.h"
12
13
 
13
14
  RGEO_BEGIN_C
14
15
 
15
- // Any error relative to RGeo.
16
- VALUE rgeo_error;
17
- // RGeo error specific to the GEOS implementation.
18
- VALUE geos_error;
16
+ VALUE rb_eRGeoError;
17
+ VALUE rb_eRGeoInvalidGeometry;
18
+ VALUE rb_eRGeoParseError;
19
+ VALUE rb_eRGeoUnsupportedOperation;
20
+ VALUE rb_eGeosError;
19
21
 
20
-
21
- void rgeo_init_geos_errors() {
22
- VALUE rgeo_module;
22
+ void
23
+ rgeo_init_geos_errors()
24
+ {
23
25
  VALUE error_module;
24
26
 
25
- rgeo_module = rb_define_module("RGeo");
26
27
  error_module = rb_define_module_under(rgeo_module, "Error");
27
- rgeo_error = rb_define_class_under(error_module, "RGeoError", rb_eRuntimeError);
28
- geos_error = rb_define_class_under(error_module, "GeosError", rgeo_error);
28
+ rb_eRGeoError =
29
+ rb_define_class_under(error_module, "RGeoError", rb_eRuntimeError);
30
+ rb_eRGeoInvalidGeometry =
31
+ rb_define_class_under(error_module, "InvalidGeometry", rb_eRGeoError);
32
+ rb_eRGeoUnsupportedOperation =
33
+ rb_define_class_under(error_module, "UnsupportedOperation", rb_eRGeoError);
34
+ rb_eRGeoParseError =
35
+ rb_define_class_under(error_module, "ParseError", rb_eRGeoError);
36
+ rb_eGeosError =
37
+ rb_define_class_under(error_module, "GeosError", rb_eRGeoError);
29
38
  }
30
39
 
31
40
  RGEO_END_C
@@ -8,12 +8,19 @@
8
8
 
9
9
  RGEO_BEGIN_C
10
10
 
11
- // Any error relative to RGeo.
12
- extern VALUE rgeo_error;
11
+ // Main rgeo error type
12
+ extern VALUE rb_eRGeoError;
13
+ // RGeo::Error::InvalidGeometry
14
+ extern VALUE rb_eRGeoInvalidGeometry;
15
+ // RGeo::Error::ParseError
16
+ extern VALUE rb_eRGeoParseError;
17
+ // RGeo::Error::UnsupportedOperation
18
+ extern VALUE rb_eRGeoUnsupportedOperation;
13
19
  // RGeo error specific to the GEOS implementation.
14
- extern VALUE geos_error;
20
+ extern VALUE rb_eGeosError;
15
21
 
16
- void rgeo_init_geos_errors();
22
+ void
23
+ rgeo_init_geos_errors();
17
24
 
18
25
  RGEO_END_C
19
26
 
@@ -6,42 +6,56 @@
6
6
  #
7
7
  # -----------------------------------------------------------------------------
8
8
  def create_dummy_makefile
9
- File.open("Makefile", "w") { |f_| f_.write(".PHONY: install\ninstall:\n") }
9
+ File.write("Makefile", ".PHONY: install\ninstall:\n")
10
10
  end
11
11
 
12
12
  if RUBY_DESCRIPTION =~ /^jruby\s/
13
13
  create_dummy_makefile
14
- else
15
- require "mkmf"
14
+ exit
15
+ end
16
16
 
17
- geosconfig = with_config("geos-config") || find_executable("geos-config")
17
+ require "mkmf"
18
18
 
19
- if geosconfig
20
- puts "Using GEOS compile configuration from #{geosconfig}"
21
- $INCFLAGS << " " << `#{geosconfig} --cflags`.strip
22
- geos_libs = `#{geosconfig} --clibs`.tr("\n", " ")
23
- geos_libs.split(/\s+/).each do |flag|
24
- $libs << " " + flag unless $libs.include?(flag)
25
- end
26
- end
19
+ if ENV.key?("DEBUG") || ENV.key?("MAINTAINER_MODE")
20
+ $CFLAGS << " -DDEBUG" \
21
+ " -Wall" \
22
+ " -ggdb" \
23
+ " -pedantic" \
24
+ " -std=c17"
27
25
 
28
- found_geos_ = false
29
- if have_header("geos_c.h")
30
- found_geos_ = true if have_func("GEOSSetSRID_r", "geos_c.h")
31
- have_func("GEOSPreparedContains_r", "geos_c.h")
32
- have_func("GEOSPreparedDisjoint_r", "geos_c.h")
33
- have_func("GEOSUnaryUnion_r", "geos_c.h")
34
- have_func("GEOSCoordSeq_isCCW_r", "geos_c.h")
35
- have_func("rb_memhash", "ruby.h")
36
- end
26
+ extra_flags = ENV.fetch("MAINTAINER_MODE", ENV.fetch("DEBUG", ""))
27
+ $CFLAGS << " " << extra_flags if extra_flags.strip.start_with?("-")
28
+ end
37
29
 
38
- if found_geos_
39
- create_makefile("rgeo/geos/geos_c_impl")
40
- else
41
- puts "**** WARNING: Unable to find GEOS headers or libraries."
42
- puts "**** Ensure that 'geos-config' is in your PATH or provide that full path via --with-geos-config"
43
- puts "**** Compiling without GEOS support."
30
+ geosconfig = with_config("geos-config") || find_executable("geos-config")
44
31
 
45
- create_dummy_makefile
32
+ if geosconfig
33
+ puts "Using GEOS compile configuration from #{geosconfig}"
34
+ $INCFLAGS << " " << IO.popen([geosconfig, "--cflags"], &:read).strip
35
+ geos_libs = IO.popen([geosconfig, "--clibs"], &:read)
36
+ geos_libs.split.each do |flag|
37
+ $libs << " " << flag unless $libs.include?(flag)
46
38
  end
47
39
  end
40
+
41
+ found_geos = false
42
+ if have_header("geos_c.h")
43
+ found_geos = true if have_func("GEOSSetSRID_r", "geos_c.h")
44
+ have_func("GEOSPreparedContains_r", "geos_c.h")
45
+ have_func("GEOSPreparedDisjoint_r", "geos_c.h")
46
+ have_func("GEOSUnaryUnion_r", "geos_c.h")
47
+ have_func("GEOSCoordSeq_isCCW_r", "geos_c.h")
48
+ have_func("GEOSDensify", "geos_c.h")
49
+ have_func("rb_memhash", "ruby.h")
50
+ have_func("rb_gc_mark_movable", "ruby.h")
51
+ end
52
+
53
+ if found_geos
54
+ create_makefile("rgeo/geos/geos_c_impl")
55
+ else
56
+ puts "**** WARNING: Unable to find GEOS headers or libraries."
57
+ puts "**** Ensure that 'geos-config' is in your PATH or provide that full path via --with-geos-config"
58
+ puts "**** Compiling without GEOS support."
59
+
60
+ create_dummy_makefile
61
+ end