rgeo 2.4.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +6 -0
- data/README.md +21 -11
- data/ext/geos_c_impl/analysis.c +29 -26
- data/ext/geos_c_impl/analysis.h +8 -5
- data/ext/geos_c_impl/coordinates.c +27 -21
- data/ext/geos_c_impl/coordinates.h +5 -2
- data/ext/geos_c_impl/errors.c +19 -10
- data/ext/geos_c_impl/errors.h +11 -4
- data/ext/geos_c_impl/extconf.rb +41 -29
- data/ext/geos_c_impl/factory.c +441 -351
- data/ext/geos_c_impl/factory.h +98 -55
- data/ext/geos_c_impl/geometry.c +563 -384
- data/ext/geos_c_impl/geometry.h +10 -3
- data/ext/geos_c_impl/geometry_collection.c +288 -316
- data/ext/geos_c_impl/geometry_collection.h +6 -18
- data/ext/geos_c_impl/globals.c +99 -21
- data/ext/geos_c_impl/globals.h +3 -2
- data/ext/geos_c_impl/line_string.c +263 -222
- data/ext/geos_c_impl/line_string.h +5 -6
- data/ext/geos_c_impl/main.c +8 -9
- data/ext/geos_c_impl/point.c +62 -65
- data/ext/geos_c_impl/point.h +4 -5
- data/ext/geos_c_impl/polygon.c +134 -132
- data/ext/geos_c_impl/polygon.h +11 -9
- data/ext/geos_c_impl/preface.h +10 -12
- data/ext/geos_c_impl/ruby_more.c +67 -0
- data/ext/geos_c_impl/ruby_more.h +25 -0
- data/lib/rgeo/cartesian/analysis.rb +5 -3
- data/lib/rgeo/cartesian/bounding_box.rb +74 -79
- data/lib/rgeo/cartesian/calculations.rb +64 -33
- data/lib/rgeo/cartesian/factory.rb +57 -102
- data/lib/rgeo/cartesian/feature_classes.rb +68 -46
- data/lib/rgeo/cartesian/feature_methods.rb +67 -25
- data/lib/rgeo/cartesian/interface.rb +6 -41
- data/lib/rgeo/cartesian/planar_graph.rb +373 -0
- data/lib/rgeo/cartesian/sweepline_intersector.rb +147 -0
- data/lib/rgeo/cartesian/valid_op.rb +69 -0
- data/lib/rgeo/cartesian.rb +3 -0
- data/lib/rgeo/coord_sys/cs/entities.rb +299 -99
- data/lib/rgeo/coord_sys/cs/factories.rb +0 -2
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +90 -42
- data/lib/rgeo/coord_sys.rb +1 -20
- data/lib/rgeo/error.rb +15 -0
- data/lib/rgeo/feature/curve.rb +0 -11
- data/lib/rgeo/feature/factory.rb +26 -36
- data/lib/rgeo/feature/factory_generator.rb +6 -14
- data/lib/rgeo/feature/geometry.rb +146 -66
- data/lib/rgeo/feature/geometry_collection.rb +16 -9
- data/lib/rgeo/feature/line_string.rb +4 -5
- data/lib/rgeo/feature/linear_ring.rb +0 -1
- data/lib/rgeo/feature/multi_curve.rb +0 -6
- data/lib/rgeo/feature/multi_surface.rb +3 -4
- data/lib/rgeo/feature/point.rb +4 -5
- data/lib/rgeo/feature/polygon.rb +1 -2
- data/lib/rgeo/feature/surface.rb +3 -4
- data/lib/rgeo/feature/types.rb +73 -83
- data/lib/rgeo/geographic/factory.rb +98 -125
- data/lib/rgeo/geographic/interface.rb +66 -163
- data/lib/rgeo/geographic/projected_feature_classes.rb +21 -9
- data/lib/rgeo/geographic/projected_feature_methods.rb +67 -42
- data/lib/rgeo/geographic/projected_window.rb +36 -22
- data/lib/rgeo/geographic/{proj4_projector.rb → projector.rb} +3 -5
- data/lib/rgeo/geographic/simple_mercator_projector.rb +24 -23
- data/lib/rgeo/geographic/spherical_feature_classes.rb +29 -9
- data/lib/rgeo/geographic/spherical_feature_methods.rb +86 -9
- data/lib/rgeo/geographic/spherical_math.rb +17 -20
- data/lib/rgeo/geographic.rb +1 -1
- data/lib/rgeo/geos/capi_factory.rb +87 -158
- data/lib/rgeo/geos/capi_feature_classes.rb +50 -36
- data/lib/rgeo/geos/ffi_factory.rb +95 -165
- data/lib/rgeo/geos/ffi_feature_classes.rb +34 -10
- data/lib/rgeo/geos/ffi_feature_methods.rb +105 -126
- data/lib/rgeo/geos/interface.rb +20 -59
- data/lib/rgeo/geos/utils.rb +3 -3
- data/lib/rgeo/geos/zm_factory.rb +53 -95
- data/lib/rgeo/geos/zm_feature_methods.rb +30 -32
- data/lib/rgeo/geos.rb +8 -8
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +9 -22
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -2
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +28 -56
- data/lib/rgeo/impl_helper/basic_point_methods.rb +2 -14
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +17 -26
- data/lib/rgeo/impl_helper/utils.rb +21 -0
- data/lib/rgeo/impl_helper/valid_op.rb +350 -0
- data/lib/rgeo/impl_helper/validity_check.rb +139 -0
- data/lib/rgeo/impl_helper.rb +1 -0
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep/wkb_generator.rb +73 -63
- data/lib/rgeo/wkrep/wkb_parser.rb +33 -31
- data/lib/rgeo/wkrep/wkt_generator.rb +52 -45
- data/lib/rgeo/wkrep/wkt_parser.rb +48 -35
- data/lib/rgeo.rb +1 -3
- metadata +51 -16
- data/lib/rgeo/coord_sys/srs_database/entry.rb +0 -107
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +0 -64
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +0 -65
@@ -2,28 +2,27 @@
|
|
2
2
|
Line string methods for GEOS wrapper
|
3
3
|
*/
|
4
4
|
|
5
|
-
|
6
5
|
#ifndef RGEO_GEOS_LINE_STRING_INCLUDED
|
7
6
|
#define RGEO_GEOS_LINE_STRING_INCLUDED
|
8
7
|
|
9
|
-
#include <ruby.h>
|
10
8
|
#include <geos_c.h>
|
9
|
+
#include <ruby.h>
|
11
10
|
|
12
11
|
RGEO_BEGIN_C
|
13
12
|
|
14
|
-
|
15
13
|
/*
|
16
14
|
Initializes the line string module. This should be called after
|
17
15
|
the geometry module is initialized.
|
18
16
|
*/
|
19
|
-
void
|
17
|
+
void
|
18
|
+
rgeo_init_geos_line_string();
|
20
19
|
|
21
20
|
/*
|
22
21
|
Determines whether the given GEOS line string is closed.
|
23
22
|
Returns Qtrue if true, Qfalse if false, or Qnil on an error.
|
24
23
|
*/
|
25
|
-
VALUE
|
26
|
-
|
24
|
+
VALUE
|
25
|
+
rgeo_is_geos_line_string_closed(const GEOSGeometry* geom);
|
27
26
|
|
28
27
|
RGEO_END_C
|
29
28
|
|
data/ext/geos_c_impl/main.c
CHANGED
@@ -6,26 +6,26 @@
|
|
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
|
-
#include "
|
13
|
-
|
12
|
+
#include "analysis.h"
|
14
13
|
#include "errors.h"
|
15
|
-
|
16
14
|
#include "factory.h"
|
17
15
|
#include "geometry.h"
|
18
|
-
#include "
|
16
|
+
#include "geometry_collection.h"
|
17
|
+
#include "globals.h"
|
19
18
|
#include "line_string.h"
|
19
|
+
#include "point.h"
|
20
20
|
#include "polygon.h"
|
21
|
-
#include "
|
22
|
-
#include "analysis.h"
|
21
|
+
#include "ruby_more.h"
|
23
22
|
|
24
23
|
#endif
|
25
24
|
|
26
25
|
RGEO_BEGIN_C
|
27
26
|
|
28
|
-
void
|
27
|
+
void
|
28
|
+
Init_geos_c_impl()
|
29
29
|
{
|
30
30
|
#ifdef RGEO_GEOS_SUPPORTED
|
31
31
|
rgeo_init_geos_globals();
|
@@ -40,5 +40,4 @@ void Init_geos_c_impl()
|
|
40
40
|
#endif
|
41
41
|
}
|
42
42
|
|
43
|
-
|
44
43
|
RGEO_END_C
|
data/ext/geos_c_impl/point.c
CHANGED
@@ -6,21 +6,19 @@
|
|
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
|
-
#include "
|
13
|
-
|
12
|
+
#include "coordinates.h"
|
14
13
|
#include "factory.h"
|
15
14
|
#include "geometry.h"
|
15
|
+
#include "globals.h"
|
16
16
|
#include "point.h"
|
17
17
|
|
18
|
-
#include "coordinates.h"
|
19
|
-
|
20
18
|
RGEO_BEGIN_C
|
21
19
|
|
22
|
-
|
23
|
-
|
20
|
+
static VALUE
|
21
|
+
method_point_geometry_type(VALUE self)
|
24
22
|
{
|
25
23
|
VALUE result;
|
26
24
|
RGeo_GeometryData* self_data;
|
@@ -33,13 +31,12 @@ static VALUE method_point_geometry_type(VALUE self)
|
|
33
31
|
return result;
|
34
32
|
}
|
35
33
|
|
36
|
-
|
37
|
-
|
34
|
+
static VALUE
|
35
|
+
method_point_coordinates(VALUE self)
|
38
36
|
{
|
39
37
|
VALUE result = Qnil;
|
40
38
|
RGeo_GeometryData* self_data;
|
41
39
|
const GEOSGeometry* self_geom;
|
42
|
-
GEOSContextHandle_t context;
|
43
40
|
const GEOSCoordSequence* coord_sequence;
|
44
41
|
int zCoordinate;
|
45
42
|
|
@@ -47,23 +44,23 @@ static VALUE method_point_coordinates(VALUE self)
|
|
47
44
|
self_geom = self_data->geom;
|
48
45
|
|
49
46
|
if (self_geom) {
|
50
|
-
zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
|
51
|
-
|
52
|
-
coord_sequence =
|
53
|
-
if(coord_sequence) {
|
54
|
-
result = rb_ary_pop(
|
47
|
+
zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
|
48
|
+
RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
|
49
|
+
coord_sequence = GEOSGeom_getCoordSeq(self_geom);
|
50
|
+
if (coord_sequence) {
|
51
|
+
result = rb_ary_pop(
|
52
|
+
extract_points_from_coordinate_sequence(coord_sequence, zCoordinate));
|
55
53
|
}
|
56
54
|
}
|
57
55
|
return result;
|
58
56
|
}
|
59
57
|
|
60
|
-
|
61
|
-
|
58
|
+
static VALUE
|
59
|
+
method_point_x(VALUE self)
|
62
60
|
{
|
63
61
|
VALUE result;
|
64
62
|
RGeo_GeometryData* self_data;
|
65
63
|
const GEOSGeometry* self_geom;
|
66
|
-
GEOSContextHandle_t self_context;
|
67
64
|
const GEOSCoordSequence* coord_seq;
|
68
65
|
double val;
|
69
66
|
|
@@ -71,10 +68,9 @@ static VALUE method_point_x(VALUE self)
|
|
71
68
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
72
69
|
self_geom = self_data->geom;
|
73
70
|
if (self_geom) {
|
74
|
-
|
75
|
-
coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
|
71
|
+
coord_seq = GEOSGeom_getCoordSeq(self_geom);
|
76
72
|
if (coord_seq) {
|
77
|
-
if (
|
73
|
+
if (GEOSCoordSeq_getX(coord_seq, 0, &val)) {
|
78
74
|
result = rb_float_new(val);
|
79
75
|
}
|
80
76
|
}
|
@@ -82,13 +78,12 @@ static VALUE method_point_x(VALUE self)
|
|
82
78
|
return result;
|
83
79
|
}
|
84
80
|
|
85
|
-
|
86
|
-
|
81
|
+
static VALUE
|
82
|
+
method_point_y(VALUE self)
|
87
83
|
{
|
88
84
|
VALUE result;
|
89
85
|
RGeo_GeometryData* self_data;
|
90
86
|
const GEOSGeometry* self_geom;
|
91
|
-
GEOSContextHandle_t self_context;
|
92
87
|
const GEOSCoordSequence* coord_seq;
|
93
88
|
double val;
|
94
89
|
|
@@ -96,10 +91,9 @@ static VALUE method_point_y(VALUE self)
|
|
96
91
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
97
92
|
self_geom = self_data->geom;
|
98
93
|
if (self_geom) {
|
99
|
-
|
100
|
-
coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
|
94
|
+
coord_seq = GEOSGeom_getCoordSeq(self_geom);
|
101
95
|
if (coord_seq) {
|
102
|
-
if (
|
96
|
+
if (GEOSCoordSeq_getY(coord_seq, 0, &val)) {
|
103
97
|
result = rb_float_new(val);
|
104
98
|
}
|
105
99
|
}
|
@@ -107,13 +101,12 @@ static VALUE method_point_y(VALUE self)
|
|
107
101
|
return result;
|
108
102
|
}
|
109
103
|
|
110
|
-
|
111
|
-
|
104
|
+
static VALUE
|
105
|
+
get_3d_point(VALUE self, int flag)
|
112
106
|
{
|
113
107
|
VALUE result;
|
114
108
|
RGeo_GeometryData* self_data;
|
115
109
|
const GEOSGeometry* self_geom;
|
116
|
-
GEOSContextHandle_t self_context;
|
117
110
|
const GEOSCoordSequence* coord_seq;
|
118
111
|
double val;
|
119
112
|
|
@@ -122,10 +115,9 @@ static VALUE get_3d_point(VALUE self, int flag)
|
|
122
115
|
self_geom = self_data->geom;
|
123
116
|
if (self_geom) {
|
124
117
|
if (RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & flag) {
|
125
|
-
|
126
|
-
coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
|
118
|
+
coord_seq = GEOSGeom_getCoordSeq(self_geom);
|
127
119
|
if (coord_seq) {
|
128
|
-
if (
|
120
|
+
if (GEOSCoordSeq_getZ(coord_seq, 0, &val)) {
|
129
121
|
result = rb_float_new(val);
|
130
122
|
}
|
131
123
|
}
|
@@ -134,20 +126,20 @@ static VALUE get_3d_point(VALUE self, int flag)
|
|
134
126
|
return result;
|
135
127
|
}
|
136
128
|
|
137
|
-
|
138
|
-
|
129
|
+
static VALUE
|
130
|
+
method_point_z(VALUE self)
|
139
131
|
{
|
140
132
|
return get_3d_point(self, RGEO_FACTORYFLAGS_SUPPORTS_Z);
|
141
133
|
}
|
142
134
|
|
143
|
-
|
144
|
-
|
135
|
+
static VALUE
|
136
|
+
method_point_m(VALUE self)
|
145
137
|
{
|
146
138
|
return get_3d_point(self, RGEO_FACTORYFLAGS_SUPPORTS_M);
|
147
139
|
}
|
148
140
|
|
149
|
-
|
150
|
-
|
141
|
+
static VALUE
|
142
|
+
method_point_eql(VALUE self, VALUE rhs)
|
151
143
|
{
|
152
144
|
VALUE result;
|
153
145
|
RGeo_GeometryData* self_data;
|
@@ -155,13 +147,14 @@ static VALUE method_point_eql(VALUE self, VALUE rhs)
|
|
155
147
|
result = rgeo_geos_klasses_and_factories_eql(self, rhs);
|
156
148
|
if (RTEST(result)) {
|
157
149
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
158
|
-
result =
|
150
|
+
result = rgeo_geos_geometries_strict_eql(self_data->geom,
|
151
|
+
RGEO_GEOMETRY_DATA_PTR(rhs)->geom);
|
159
152
|
}
|
160
153
|
return result;
|
161
154
|
}
|
162
155
|
|
163
|
-
|
164
|
-
|
156
|
+
static VALUE
|
157
|
+
method_point_hash(VALUE self)
|
165
158
|
{
|
166
159
|
st_index_t hash;
|
167
160
|
RGeo_GeometryData* self_data;
|
@@ -171,19 +164,24 @@ static VALUE method_point_hash(VALUE self)
|
|
171
164
|
factory = self_data->factory;
|
172
165
|
hash = rb_hash_start(0);
|
173
166
|
hash = rgeo_geos_objbase_hash(factory, rgeo_feature_point_module, hash);
|
174
|
-
hash = rgeo_geos_coordseq_hash(self_data->
|
167
|
+
hash = rgeo_geos_coordseq_hash(self_data->geom, hash);
|
175
168
|
return LONG2FIX(rb_hash_end(hash));
|
176
169
|
}
|
177
170
|
|
178
|
-
|
179
|
-
|
171
|
+
static VALUE
|
172
|
+
cmethod_create(VALUE module, VALUE factory, VALUE x, VALUE y, VALUE z)
|
180
173
|
{
|
181
|
-
return rgeo_create_geos_point(factory,
|
182
|
-
|
174
|
+
return rgeo_create_geos_point(factory,
|
175
|
+
rb_num2dbl(x),
|
176
|
+
rb_num2dbl(y),
|
177
|
+
RGEO_FACTORY_DATA_PTR(factory)->flags &
|
178
|
+
RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M
|
179
|
+
? rb_num2dbl(z)
|
180
|
+
: 0);
|
183
181
|
}
|
184
182
|
|
185
|
-
|
186
|
-
|
183
|
+
void
|
184
|
+
rgeo_init_geos_point()
|
187
185
|
{
|
188
186
|
VALUE geos_point_methods;
|
189
187
|
|
@@ -191,38 +189,38 @@ void rgeo_init_geos_point()
|
|
191
189
|
rb_define_module_function(rgeo_geos_point_class, "create", cmethod_create, 4);
|
192
190
|
|
193
191
|
// CAPIPointMethods module
|
194
|
-
geos_point_methods =
|
192
|
+
geos_point_methods =
|
193
|
+
rb_define_module_under(rgeo_geos_module, "CAPIPointMethods");
|
195
194
|
rb_define_method(geos_point_methods, "rep_equals?", method_point_eql, 1);
|
196
195
|
rb_define_method(geos_point_methods, "eql?", method_point_eql, 1);
|
197
196
|
rb_define_method(geos_point_methods, "hash", method_point_hash, 0);
|
198
|
-
rb_define_method(
|
197
|
+
rb_define_method(
|
198
|
+
geos_point_methods, "geometry_type", method_point_geometry_type, 0);
|
199
199
|
rb_define_method(geos_point_methods, "x", method_point_x, 0);
|
200
200
|
rb_define_method(geos_point_methods, "y", method_point_y, 0);
|
201
201
|
rb_define_method(geos_point_methods, "z", method_point_z, 0);
|
202
202
|
rb_define_method(geos_point_methods, "m", method_point_m, 0);
|
203
|
-
rb_define_method(
|
203
|
+
rb_define_method(
|
204
|
+
geos_point_methods, "coordinates", method_point_coordinates, 0);
|
204
205
|
}
|
205
206
|
|
206
|
-
|
207
|
-
|
207
|
+
VALUE
|
208
|
+
rgeo_create_geos_point(VALUE factory, double x, double y, double z)
|
208
209
|
{
|
209
210
|
VALUE result;
|
210
|
-
RGeo_FactoryData* factory_data;
|
211
|
-
GEOSContextHandle_t context;
|
212
211
|
GEOSCoordSequence* coord_seq;
|
213
212
|
GEOSGeometry* geom;
|
214
213
|
|
215
214
|
result = Qnil;
|
216
|
-
|
217
|
-
context = factory_data->geos_context;
|
218
|
-
coord_seq = GEOSCoordSeq_create_r(context, 1, 3);
|
215
|
+
coord_seq = GEOSCoordSeq_create(1, 3);
|
219
216
|
if (coord_seq) {
|
220
|
-
if (
|
221
|
-
if (
|
222
|
-
if (
|
223
|
-
geom =
|
217
|
+
if (GEOSCoordSeq_setX(coord_seq, 0, x)) {
|
218
|
+
if (GEOSCoordSeq_setY(coord_seq, 0, y)) {
|
219
|
+
if (GEOSCoordSeq_setZ(coord_seq, 0, z)) {
|
220
|
+
geom = GEOSGeom_createPoint(coord_seq);
|
224
221
|
if (geom) {
|
225
|
-
result =
|
222
|
+
result =
|
223
|
+
rgeo_wrap_geos_geometry(factory, geom, rgeo_geos_point_class);
|
226
224
|
}
|
227
225
|
}
|
228
226
|
}
|
@@ -231,7 +229,6 @@ VALUE rgeo_create_geos_point(VALUE factory, double x, double y, double z)
|
|
231
229
|
return result;
|
232
230
|
}
|
233
231
|
|
234
|
-
|
235
232
|
RGEO_END_C
|
236
233
|
|
237
234
|
#endif
|
data/ext/geos_c_impl/point.h
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
Point methods for GEOS wrapper
|
3
3
|
*/
|
4
4
|
|
5
|
-
|
6
5
|
#ifndef RGEO_GEOS_POINT_INCLUDED
|
7
6
|
#define RGEO_GEOS_POINT_INCLUDED
|
8
7
|
|
@@ -10,18 +9,18 @@
|
|
10
9
|
|
11
10
|
RGEO_BEGIN_C
|
12
11
|
|
13
|
-
|
14
12
|
/*
|
15
13
|
Initializes the point module. This should be called after
|
16
14
|
the geometry module is initialized.
|
17
15
|
*/
|
18
|
-
void
|
16
|
+
void
|
17
|
+
rgeo_init_geos_point();
|
19
18
|
|
20
19
|
/*
|
21
20
|
Creates a 3d point and returns the ruby object.
|
22
21
|
*/
|
23
|
-
VALUE
|
24
|
-
|
22
|
+
VALUE
|
23
|
+
rgeo_create_geos_point(VALUE factory, double x, double y, double z);
|
25
24
|
|
26
25
|
RGEO_END_C
|
27
26
|
|