rgeo 2.1.1 → 2.4.0

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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +160 -0
  3. data/ext/geos_c_impl/analysis.c +80 -0
  4. data/ext/geos_c_impl/analysis.h +40 -0
  5. data/ext/geos_c_impl/errors.c +35 -0
  6. data/ext/geos_c_impl/errors.h +22 -0
  7. data/ext/geos_c_impl/extconf.rb +2 -0
  8. data/ext/geos_c_impl/factory.c +179 -174
  9. data/ext/geos_c_impl/factory.h +20 -49
  10. data/ext/geos_c_impl/geometry.c +17 -16
  11. data/ext/geos_c_impl/geometry.h +1 -3
  12. data/ext/geos_c_impl/geometry_collection.c +39 -44
  13. data/ext/geos_c_impl/geometry_collection.h +1 -3
  14. data/ext/geos_c_impl/globals.c +91 -0
  15. data/ext/geos_c_impl/globals.h +45 -0
  16. data/ext/geos_c_impl/line_string.c +27 -28
  17. data/ext/geos_c_impl/line_string.h +1 -3
  18. data/ext/geos_c_impl/main.c +14 -10
  19. data/ext/geos_c_impl/point.c +8 -7
  20. data/ext/geos_c_impl/point.h +1 -3
  21. data/ext/geos_c_impl/polygon.c +14 -14
  22. data/ext/geos_c_impl/polygon.h +1 -3
  23. data/ext/geos_c_impl/preface.h +8 -0
  24. data/lib/rgeo/cartesian/analysis.rb +22 -0
  25. data/lib/rgeo/cartesian/feature_methods.rb +6 -1
  26. data/lib/rgeo/cartesian.rb +7 -7
  27. data/lib/rgeo/coord_sys.rb +6 -6
  28. data/lib/rgeo/error.rb +4 -0
  29. data/lib/rgeo/feature/curve.rb +12 -2
  30. data/lib/rgeo/feature/geometry.rb +12 -2
  31. data/lib/rgeo/feature/linear_ring.rb +10 -0
  32. data/lib/rgeo/feature/multi_curve.rb +6 -1
  33. data/lib/rgeo/feature.rb +17 -17
  34. data/lib/rgeo/geographic/interface.rb +2 -1
  35. data/lib/rgeo/geographic/projected_feature_methods.rb +12 -2
  36. data/lib/rgeo/geographic/spherical_feature_classes.rb +1 -0
  37. data/lib/rgeo/geographic/spherical_feature_methods.rb +29 -1
  38. data/lib/rgeo/geographic.rb +10 -10
  39. data/lib/rgeo/geos/capi_factory.rb +3 -3
  40. data/lib/rgeo/geos/capi_feature_classes.rb +33 -0
  41. data/lib/rgeo/geos/ffi_feature_methods.rb +34 -5
  42. data/lib/rgeo/geos/interface.rb +18 -4
  43. data/lib/rgeo/geos/zm_feature_methods.rb +30 -5
  44. data/lib/rgeo/geos.rb +11 -11
  45. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +33 -5
  46. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +62 -8
  47. data/lib/rgeo/impl_helper/basic_point_methods.rb +12 -2
  48. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +44 -2
  49. data/lib/rgeo/impl_helper.rb +7 -7
  50. data/lib/rgeo/version.rb +1 -1
  51. data/lib/rgeo/wkrep/wkb_generator.rb +1 -1
  52. data/lib/rgeo/wkrep/wkt_generator.rb +6 -6
  53. data/lib/rgeo/wkrep.rb +4 -4
  54. data/lib/rgeo.rb +9 -9
  55. metadata +26 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 65bbadb93580fd02234007e3ddfb888b4a38b4a7dfaa2d2b0d072d313b98adfb
4
- data.tar.gz: b45a6f33bba7543ee86e0211a8b9d976cfef470222ab2adb9107f98b06818fff
3
+ metadata.gz: abb42ec2fb37f915e49d13c7e802279560588d75f376d06d37f3a4e4f0e1ab61
4
+ data.tar.gz: 6606d1fe12f30d645fb66edf95e694708ffb24ba81afa78ce03a961456f67686
5
5
  SHA512:
6
- metadata.gz: 33d2c278eb28f697047c98091676fae7161f3b410375ba8b5042f51cb5e10158c69617d044a19d1c68b86c399439fc6a22e3bf39d8767b303194f1d64b191d41
7
- data.tar.gz: 5e77a71cc569f9826fbac6d97ccd2aac46d2b7e37284cba950b6d8621ae04b52ed60c9a63bec7c5d227b3656e2015b1d3062eb1eaf15438de383209f1d6b291e
6
+ metadata.gz: 807c3f239731755e4afe348d70b2ebf0c81f29754a5677a4123dce474c0a18e7a6e63df5ee36fb244a05b04a9ef70356a3e966fab336a0925365afc05e331d5a
7
+ data.tar.gz: c940601cc0c30944b5bc4e5f8d9ed632704295b28cb8115973a1856c823f01a7a0b655bc2e277ebe09268a08cf4fe9e1b0abbb4c192a598d2f06c95baef58901
data/README.md ADDED
@@ -0,0 +1,160 @@
1
+ ## RGeo
2
+
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)
5
+
6
+ RGeo is a geospatial data library for Ruby.
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:
9
+
10
+ This organization is looking for maintainers, see [this issue](https://github.com/rgeo/rgeo/issues/216) for more information.
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
+
14
+ ### Summary
15
+
16
+ RGeo is a key component for writing location-aware applications in the Ruby
17
+ programming language. At its core is an implementation of the industry
18
+ standard OGC Simple Features Specification, which provides data
19
+ representations of geometric objects such as points, lines, and polygons,
20
+ along with a set of geometric analysis operations. This makes it ideal for
21
+ modeling geolocation data. It also supports a suite of optional add-on modules
22
+ that provide various geolocation-related services.
23
+
24
+ Use the core **rgeo** gem to:
25
+
26
+ * Represent spatial and geolocation data objects such as points, lines, and
27
+ polygons in your Ruby application.
28
+ * Perform standard spatial analysis operations such as finding
29
+ intersections, creating buffers, and computing lengths and areas.
30
+ * Correctly handle spherical geometry, and compute geographic projections
31
+ for map display and data analysis.
32
+ * Read and write location data in the WKT and WKB representations used by
33
+ spatial databases.
34
+
35
+
36
+ ### Dependencies
37
+
38
+ RGeo works with the following Ruby implementations:
39
+
40
+ * MRI Ruby 2.3.0 or later.
41
+ * Partial support for JRuby 9.0 or later. The FFI implementation of GEOS
42
+ is available (ffi-geos gem required) but CAPI is not.
43
+ * See earlier versions for support for older ruby versions.
44
+
45
+ Some features also require the following:
46
+
47
+ * GEOS 3.2 or later is highly recommended. (3.3.3 or later preferred.) Some
48
+ functions will not be available without it. This C/C++ library may be
49
+ available via your operating system's package manager (`sudo aptitude
50
+ install libgeos-dev` for debian based Linux distributions, `yum install geos geos-devel` for redhat based Linux distributions), or you can
51
+ download it from http://trac.osgeo.org/geos
52
+ * On some platforms, you should install the ffi-geos gem (version 1.2.0 or
53
+ later recommended.) JRuby requires this gem to link properly with Geos,
54
+ and Windows builds probably do as well.
55
+
56
+ ### Installation
57
+
58
+ Install the RGeo gem:
59
+
60
+ ```sh
61
+ gem install rgeo
62
+ ```
63
+
64
+ or include it in your Gemfile:
65
+
66
+ ```ruby
67
+ gem "rgeo"
68
+ ```
69
+
70
+ If you are using proj.4 extensions, include
71
+ [`rgeo-proj4`](https://github.com/rgeo/rgeo-proj4):
72
+
73
+ ```ruby
74
+ gem "rgeo-proj4"
75
+ ```
76
+
77
+
78
+ ### Extensions
79
+
80
+ The [RGeo organization](https://github.com/rgeo) provides several gems that extend RGeo:
81
+
82
+ #### [`rgeo-proj4`](https://github.com/rgeo/rgeo-proj4)
83
+
84
+ Proj4 extensions
85
+
86
+ #### [`rgeo-geojson`](https://github.com/rgeo/rgeo-geojson)
87
+
88
+ Read and write GeoJSON
89
+
90
+ #### [`rgeo-shapefile`](https://github.com/rgeo/rgeo-shapefile)
91
+
92
+ Read ESRI shapefiles
93
+
94
+ #### [`activerecord-postgis-adapter`](https://github.com/rgeo/activerecord-postgis-adapter)
95
+
96
+ ActiveRecord connection adapter for PostGIS, based on postgresql (pg gem)
97
+
98
+ #### [`activerecord-mysql2spatial-adapter`](https://github.com/rgeo/activerecord-mysql2spatial-adapter)
99
+
100
+ ActiveRecord connection adapter for MySQL Spatial Extensions, based on mysql2
101
+
102
+ #### [`activerecord-spatialite-adapter`](https://github.com/rgeo/activerecord-spatialite-adapter)
103
+
104
+ ActiveRecord connection adapter for SpatiaLite, based on sqlite3 (*not maintained)
105
+
106
+
107
+ ### Development and support
108
+
109
+ RDoc Documentation is available at https://www.rubydoc.info/gems/rgeo
110
+
111
+ Contributions are welcome. Please read the
112
+ [Contributing guidelines](https://github.com/rgeo/rgeo/blob/master/CONTRIBUTING.md).
113
+
114
+ Support may be available on the
115
+ [rgeo-users google group](https://groups.google.com/forum/#!forum/rgeo-users)
116
+ or on [Stack Overflow](https://stackoverflow.com/questions/tagged/rgeo).
117
+
118
+ ### Documentation
119
+
120
+ You can see more in-depth documentation in the `doc` folder. Factories and
121
+ methods are documented inline, you should consider checking
122
+ https://rubydoc.info/gems/rgeo with the version you are currently using. Or
123
+ generate documentation locally if you're working on RGeo: `yardoc server`.
124
+
125
+ Here's the current list of available topics:
126
+
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
+
135
+ You can see an exhaustive and up to date list at https://rubydoc.info/gems/rgeo/index.
136
+ ### Acknowledgments
137
+
138
+ [Daniel Azuma](http://www.daniel-azuma.com) created RGeo.
139
+ [Tee Parham](http://twitter.com/teeparham) is a former maintainer.
140
+ [Keith Doggett](http://www.github.com/keithdoggett), [Ulysse Buonomo](http://www.github.com/BuonOmo) are current maintainers.
141
+
142
+ Development is supported by:
143
+
144
+ - [Klaxit](https://www.github.com/klaxit)
145
+ - Goldfish Ads
146
+
147
+ RGeo calls the GEOS library to handle most Cartesian geometric calculations,
148
+ and the Proj4 library to handle projections and coordinate transformations.
149
+ These libraries are maintained by the Open Source Geospatial Foundation; more
150
+ information is available on [OSGeo's web site](http://www.osgeo.org).
151
+
152
+ JRuby support is made possible by the ffi-geos (and upcoming ffi-proj4) gems,
153
+ by [J Smith](https://github.com/dark-panda).
154
+
155
+
156
+ ### License
157
+
158
+ Copyright (c) Daniel Azuma, Tee Parham
159
+
160
+ [License](https://github.com/rgeo/rgeo/blob/master/LICENSE.txt)
@@ -0,0 +1,80 @@
1
+ /*
2
+ Analysis methos for GEOS wrapper
3
+ */
4
+
5
+ #include "preface.h"
6
+
7
+ #ifdef RGEO_GEOS_SUPPORTED
8
+
9
+ #include <ruby.h>
10
+ #include <geos_c.h>
11
+
12
+ #include "globals.h"
13
+
14
+ #include "analysis.h"
15
+ #include "factory.h"
16
+ #include "errors.h"
17
+
18
+ RGEO_BEGIN_C
19
+
20
+ /*
21
+ * call-seq:
22
+ * RGeo::Geos::Analysis.ccw? -> true or false
23
+ *
24
+ * Checks direction for a ring, returns +true+ if counter-clockwise, +false+
25
+ * otherwise.
26
+ */
27
+ #ifdef RGEO_GEOS_SUPPORTS_ISCCW
28
+ VALUE rgeo_geos_analysis_ccw_p(VALUE self, VALUE ring)
29
+ {
30
+
31
+ const RGeo_GeometryData* ring_data;
32
+ const GEOSCoordSequence* coord_seq;
33
+ char is_ccw;
34
+
35
+ rgeo_check_geos_object(ring);
36
+
37
+ ring_data = RGEO_GEOMETRY_DATA_PTR(ring);
38
+
39
+ coord_seq = GEOSGeom_getCoordSeq_r(ring_data->geos_context, ring_data->geom);
40
+ if (!coord_seq) { rb_raise(geos_error, "Could not retrieve CoordSeq from given ring."); }
41
+ if (!GEOSCoordSeq_isCCW_r(ring_data->geos_context, coord_seq, &is_ccw)) {
42
+ rb_raise(geos_error, "Could not determine if the CoordSeq is CCW.");
43
+ }
44
+
45
+ return is_ccw ? Qtrue : Qfalse;
46
+ };
47
+ #endif // RGEO_GEOS_SUPPORTS_ISCCW
48
+
49
+
50
+ /**
51
+ * call-seq:
52
+ * RGeo::Geos::Analysis.ccw_supported? -> true or false
53
+ *
54
+ * Checks if the RGEO_GEOS_SUPPORTS_ISCCW macro is defined, returns +true+
55
+ * if it is, +false+ otherwise
56
+ */
57
+ VALUE rgeo_geos_analysis_supports_ccw(VALUE self)
58
+ {
59
+ #ifdef RGEO_GEOS_SUPPORTS_ISCCW
60
+ return Qtrue;
61
+ #else
62
+ return Qfalse;
63
+ #endif
64
+ }
65
+
66
+
67
+ void rgeo_init_geos_analysis()
68
+ {
69
+ VALUE geos_analysis_module;
70
+
71
+ geos_analysis_module = rb_define_module_under(rgeo_geos_module, "Analysis");
72
+ rb_define_singleton_method(geos_analysis_module, "ccw_supported?", rgeo_geos_analysis_supports_ccw, 0);
73
+ #ifdef RGEO_GEOS_SUPPORTS_ISCCW
74
+ rb_define_singleton_method(geos_analysis_module, "ccw?", rgeo_geos_analysis_ccw_p, 1);
75
+ #endif // RGEO_GEOS_SUPPORTS_ISCCW
76
+ }
77
+
78
+ RGEO_END_C
79
+
80
+ #endif
@@ -0,0 +1,40 @@
1
+ /*
2
+ Analysis methos for GEOS wrapper
3
+ */
4
+
5
+ #ifndef RGEO_GEOS_ANALYSIS_INCLUDED
6
+ #define RGEO_GEOS_ANALYSIS_INCLUDED
7
+
8
+ #include <ruby.h>
9
+
10
+ #ifdef RGEO_GEOS_SUPPORTED
11
+
12
+ RGEO_BEGIN_C
13
+
14
+ /*
15
+ * call-seq:
16
+ * RGeo::Geos::Analysis.ccw? -> true or false
17
+ *
18
+ * Checks direction for a ring, returns +true+ if counter-clockwise, +false+
19
+ * otherwise.
20
+ */
21
+ #ifdef RGEO_GEOS_SUPPORTS_CCW
22
+ VALUE rgeo_geos_analysis_ccw_p(VALUE self, VALUE ring);
23
+ #endif // RGEO_GEOS_SUPPORTS_CCW
24
+
25
+ /**
26
+ * call-seq:
27
+ * RGeo::Geos::Analysis.ccw_supported? -> true or false
28
+ *
29
+ * Checks if the RGEO_GEOS_SUPPORTS_ISCCW macro is defined, returns +true+
30
+ * if it is, +false+ otherwise
31
+ */
32
+ VALUE rgeo_geos_analysis_supports_ccw(VALUE self);
33
+
34
+ void rgeo_init_geos_analysis();
35
+
36
+ RGEO_END_C
37
+
38
+ #endif // RGEO_GEOS_SUPPORTED
39
+
40
+ #endif // RGEO_GEOS_ANALYSIS_INCLUDED
@@ -0,0 +1,35 @@
1
+
2
+ #ifndef RGEO_GEOS_ERROS_INCLUDED
3
+ #define RGEO_GEOS_ERROS_INCLUDED
4
+
5
+ #include <ruby.h>
6
+
7
+ #include "preface.h"
8
+
9
+ #ifdef RGEO_GEOS_SUPPORTED
10
+
11
+ #include "globals.h"
12
+
13
+ #include "errors.h"
14
+
15
+ RGEO_BEGIN_C
16
+
17
+ // Any error relative to RGeo.
18
+ VALUE rgeo_error;
19
+ // RGeo error specific to the GEOS implementation.
20
+ VALUE geos_error;
21
+
22
+
23
+ void rgeo_init_geos_errors() {
24
+ VALUE error_module;
25
+
26
+ 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);
29
+ }
30
+
31
+ RGEO_END_C
32
+
33
+ #endif // RGEO_GEOS_SUPPORTED
34
+
35
+ #endif // RGEO_GEOS_ERROS_INCLUDED
@@ -0,0 +1,22 @@
1
+
2
+ #ifndef RGEO_GEOS_ERROS_INCLUDED
3
+ #define RGEO_GEOS_ERROS_INCLUDED
4
+
5
+ #include <ruby.h>
6
+
7
+ #ifdef RGEO_GEOS_SUPPORTED
8
+
9
+ RGEO_BEGIN_C
10
+
11
+ // Any error relative to RGeo.
12
+ extern VALUE rgeo_error;
13
+ // RGeo error specific to the GEOS implementation.
14
+ extern VALUE geos_error;
15
+
16
+ void rgeo_init_geos_errors();
17
+
18
+ RGEO_END_C
19
+
20
+ #endif // RGEO_GEOS_SUPPORTED
21
+
22
+ #endif // RGEO_GEOS_ERROS_INCLUDED
@@ -31,7 +31,9 @@ else
31
31
  have_func("GEOSPreparedContains_r", "geos_c.h")
32
32
  have_func("GEOSPreparedDisjoint_r", "geos_c.h")
33
33
  have_func("GEOSUnaryUnion_r", "geos_c.h")
34
+ have_func("GEOSCoordSeq_isCCW_r", "geos_c.h")
34
35
  have_func("rb_memhash", "ruby.h")
36
+ have_func("rb_gc_mark_movable", "ruby.h")
35
37
  end
36
38
 
37
39
  if found_geos_