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.
- checksums.yaml +4 -4
- data/.yardopts +6 -0
- data/README.md +23 -14
- data/ext/geos_c_impl/analysis.c +30 -25
- data/ext/geos_c_impl/analysis.h +8 -7
- 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 +42 -28
- data/ext/geos_c_impl/factory.c +540 -451
- data/ext/geos_c_impl/factory.h +105 -95
- data/ext/geos_c_impl/geometry.c +593 -387
- data/ext/geos_c_impl/geometry.h +10 -5
- data/ext/geos_c_impl/geometry_collection.c +306 -339
- data/ext/geos_c_impl/geometry_collection.h +6 -20
- data/ext/geos_c_impl/globals.c +169 -0
- data/ext/geos_c_impl/globals.h +46 -0
- data/ext/geos_c_impl/line_string.c +271 -231
- data/ext/geos_c_impl/line_string.h +5 -8
- data/ext/geos_c_impl/main.c +16 -16
- data/ext/geos_c_impl/point.c +65 -67
- data/ext/geos_c_impl/point.h +4 -7
- data/ext/geos_c_impl/polygon.c +137 -135
- data/ext/geos_c_impl/polygon.h +11 -11
- data/ext/geos_c_impl/preface.h +16 -10
- 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 +303 -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 +69 -85
- data/lib/rgeo/geographic/factory.rb +98 -125
- data/lib/rgeo/geographic/interface.rb +69 -166
- 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 +26 -25
- 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 +105 -173
- data/lib/rgeo/geos/ffi_feature_classes.rb +34 -10
- data/lib/rgeo/geos/ffi_feature_methods.rb +105 -127
- data/lib/rgeo/geos/interface.rb +20 -59
- data/lib/rgeo/geos/utils.rb +5 -5
- data/lib/rgeo/geos/zm_factory.rb +53 -95
- data/lib/rgeo/geos/zm_feature_methods.rb +30 -33
- 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 +50 -13
- 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,26 +2,25 @@
|
|
2
2
|
Line string methods for GEOS wrapper
|
3
3
|
*/
|
4
4
|
|
5
|
-
|
6
5
|
#include "preface.h"
|
7
6
|
|
8
7
|
#ifdef RGEO_GEOS_SUPPORTED
|
9
8
|
|
10
|
-
#include <string.h>
|
11
|
-
#include <ruby.h>
|
12
9
|
#include <geos_c.h>
|
10
|
+
#include <ruby.h>
|
11
|
+
#include <string.h>
|
13
12
|
|
13
|
+
#include "coordinates.h"
|
14
14
|
#include "factory.h"
|
15
15
|
#include "geometry.h"
|
16
|
-
#include "
|
16
|
+
#include "globals.h"
|
17
17
|
#include "line_string.h"
|
18
|
-
|
19
|
-
#include "coordinates.h"
|
18
|
+
#include "point.h"
|
20
19
|
|
21
20
|
RGEO_BEGIN_C
|
22
21
|
|
23
|
-
|
24
|
-
|
22
|
+
static VALUE
|
23
|
+
method_line_string_geometry_type(VALUE self)
|
25
24
|
{
|
26
25
|
VALUE result;
|
27
26
|
RGeo_GeometryData* self_data;
|
@@ -29,13 +28,13 @@ static VALUE method_line_string_geometry_type(VALUE self)
|
|
29
28
|
result = Qnil;
|
30
29
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
31
30
|
if (self_data->geom) {
|
32
|
-
result =
|
31
|
+
result = rgeo_feature_line_string_module;
|
33
32
|
}
|
34
33
|
return result;
|
35
34
|
}
|
36
35
|
|
37
|
-
|
38
|
-
|
36
|
+
static VALUE
|
37
|
+
method_linear_ring_geometry_type(VALUE self)
|
39
38
|
{
|
40
39
|
VALUE result;
|
41
40
|
RGeo_GeometryData* self_data;
|
@@ -43,13 +42,13 @@ static VALUE method_linear_ring_geometry_type(VALUE self)
|
|
43
42
|
result = Qnil;
|
44
43
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
45
44
|
if (self_data->geom) {
|
46
|
-
result =
|
45
|
+
result = rgeo_feature_linear_ring_module;
|
47
46
|
}
|
48
47
|
return result;
|
49
48
|
}
|
50
49
|
|
51
|
-
|
52
|
-
|
50
|
+
static VALUE
|
51
|
+
method_line_geometry_type(VALUE self)
|
53
52
|
{
|
54
53
|
VALUE result;
|
55
54
|
RGeo_GeometryData* self_data;
|
@@ -57,13 +56,13 @@ static VALUE method_line_geometry_type(VALUE self)
|
|
57
56
|
result = Qnil;
|
58
57
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
59
58
|
if (self_data->geom) {
|
60
|
-
result =
|
59
|
+
result = rgeo_feature_line_module;
|
61
60
|
}
|
62
61
|
return result;
|
63
62
|
}
|
64
63
|
|
65
|
-
|
66
|
-
|
64
|
+
static VALUE
|
65
|
+
method_line_string_length(VALUE self)
|
67
66
|
{
|
68
67
|
VALUE result;
|
69
68
|
RGeo_GeometryData* self_data;
|
@@ -74,15 +73,15 @@ static VALUE method_line_string_length(VALUE self)
|
|
74
73
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
75
74
|
self_geom = self_data->geom;
|
76
75
|
if (self_geom) {
|
77
|
-
if (
|
76
|
+
if (GEOSLength(self_geom, &len)) {
|
78
77
|
result = rb_float_new(len);
|
79
78
|
}
|
80
79
|
}
|
81
80
|
return result;
|
82
81
|
}
|
83
82
|
|
84
|
-
|
85
|
-
|
83
|
+
static VALUE
|
84
|
+
method_line_string_num_points(VALUE self)
|
86
85
|
{
|
87
86
|
VALUE result;
|
88
87
|
RGeo_GeometryData* self_data;
|
@@ -92,13 +91,13 @@ static VALUE method_line_string_num_points(VALUE self)
|
|
92
91
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
93
92
|
self_geom = self_data->geom;
|
94
93
|
if (self_geom) {
|
95
|
-
result = INT2NUM(
|
94
|
+
result = INT2NUM(GEOSGetNumCoordinates(self_geom));
|
96
95
|
}
|
97
96
|
return result;
|
98
97
|
}
|
99
98
|
|
100
|
-
|
101
|
-
|
99
|
+
static VALUE
|
100
|
+
method_line_string_coordinates(VALUE self)
|
102
101
|
{
|
103
102
|
VALUE result;
|
104
103
|
RGeo_GeometryData* self_data;
|
@@ -106,43 +105,41 @@ static VALUE method_line_string_coordinates(VALUE self)
|
|
106
105
|
const GEOSCoordSequence* coord_sequence;
|
107
106
|
int zCoordinate;
|
108
107
|
|
109
|
-
GEOSContextHandle_t context;
|
110
|
-
|
111
108
|
result = Qnil;
|
112
109
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
113
110
|
self_geom = self_data->geom;
|
114
111
|
|
115
112
|
if (self_geom) {
|
116
|
-
zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
|
117
|
-
|
118
|
-
coord_sequence =
|
119
|
-
if(coord_sequence) {
|
120
|
-
result =
|
113
|
+
zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
|
114
|
+
RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
|
115
|
+
coord_sequence = GEOSGeom_getCoordSeq(self_geom);
|
116
|
+
if (coord_sequence) {
|
117
|
+
result =
|
118
|
+
extract_points_from_coordinate_sequence(coord_sequence, zCoordinate);
|
121
119
|
}
|
122
120
|
}
|
123
121
|
return result;
|
124
122
|
}
|
125
123
|
|
126
|
-
|
127
|
-
|
128
|
-
|
124
|
+
static VALUE
|
125
|
+
get_point_from_coordseq(VALUE self,
|
126
|
+
const GEOSCoordSequence* coord_seq,
|
127
|
+
unsigned int i,
|
128
|
+
char has_z)
|
129
129
|
{
|
130
130
|
VALUE result;
|
131
131
|
RGeo_GeometryData* self_data;
|
132
|
-
GEOSContextHandle_t self_context;
|
133
132
|
double x, y, z;
|
134
133
|
|
135
134
|
result = Qnil;
|
136
135
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
137
|
-
|
138
|
-
|
139
|
-
if (GEOSCoordSeq_getY_r(self_context, coord_seq, i, &y)) {
|
136
|
+
if (GEOSCoordSeq_getX(coord_seq, i, &x)) {
|
137
|
+
if (GEOSCoordSeq_getY(coord_seq, i, &y)) {
|
140
138
|
if (has_z) {
|
141
|
-
if (!
|
139
|
+
if (!GEOSCoordSeq_getZ(coord_seq, i, &z)) {
|
142
140
|
z = 0.0;
|
143
141
|
}
|
144
|
-
}
|
145
|
-
else {
|
142
|
+
} else {
|
146
143
|
z = 0.0;
|
147
144
|
}
|
148
145
|
result = rgeo_create_geos_point(self_data->factory, x, y, z);
|
@@ -151,13 +148,12 @@ static VALUE get_point_from_coordseq(VALUE self, const GEOSCoordSequence* coord_
|
|
151
148
|
return result;
|
152
149
|
}
|
153
150
|
|
154
|
-
|
155
|
-
|
151
|
+
static VALUE
|
152
|
+
method_line_string_point_n(VALUE self, VALUE n)
|
156
153
|
{
|
157
154
|
VALUE result;
|
158
155
|
RGeo_GeometryData* self_data;
|
159
156
|
const GEOSGeometry* self_geom;
|
160
|
-
GEOSContextHandle_t self_context;
|
161
157
|
const GEOSCoordSequence* coord_seq;
|
162
158
|
char has_z;
|
163
159
|
int si;
|
@@ -168,14 +164,14 @@ static VALUE method_line_string_point_n(VALUE self, VALUE n)
|
|
168
164
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
169
165
|
self_geom = self_data->geom;
|
170
166
|
if (self_geom) {
|
171
|
-
|
172
|
-
coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
|
167
|
+
coord_seq = GEOSGeom_getCoordSeq(self_geom);
|
173
168
|
if (coord_seq) {
|
174
|
-
has_z = (char)(RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
|
175
|
-
|
169
|
+
has_z = (char)(RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
|
170
|
+
RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
|
171
|
+
si = RB_NUM2INT(n);
|
176
172
|
if (si >= 0) {
|
177
173
|
i = si;
|
178
|
-
if (
|
174
|
+
if (GEOSCoordSeq_getSize(coord_seq, &size)) {
|
179
175
|
if (i < size) {
|
180
176
|
result = get_point_from_coordseq(self, coord_seq, i, has_z);
|
181
177
|
}
|
@@ -186,13 +182,12 @@ static VALUE method_line_string_point_n(VALUE self, VALUE n)
|
|
186
182
|
return result;
|
187
183
|
}
|
188
184
|
|
189
|
-
|
190
|
-
|
185
|
+
static VALUE
|
186
|
+
method_line_string_points(VALUE self)
|
191
187
|
{
|
192
188
|
VALUE result;
|
193
189
|
RGeo_GeometryData* self_data;
|
194
190
|
const GEOSGeometry* self_geom;
|
195
|
-
GEOSContextHandle_t self_context;
|
196
191
|
const GEOSCoordSequence* coord_seq;
|
197
192
|
char has_z;
|
198
193
|
unsigned int size;
|
@@ -203,13 +198,13 @@ static VALUE method_line_string_points(VALUE self)
|
|
203
198
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
204
199
|
self_geom = self_data->geom;
|
205
200
|
if (self_geom) {
|
206
|
-
|
207
|
-
coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
|
201
|
+
coord_seq = GEOSGeom_getCoordSeq(self_geom);
|
208
202
|
if (coord_seq) {
|
209
|
-
has_z = (char)(RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
|
210
|
-
|
203
|
+
has_z = (char)(RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
|
204
|
+
RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
|
205
|
+
if (GEOSCoordSeq_getSize(coord_seq, &size)) {
|
211
206
|
result = rb_ary_new2(size);
|
212
|
-
for (i=0; i<size; ++i) {
|
207
|
+
for (i = 0; i < size; ++i) {
|
213
208
|
point = get_point_from_coordseq(self, coord_seq, i, has_z);
|
214
209
|
if (!NIL_P(point)) {
|
215
210
|
rb_ary_store(result, i, point);
|
@@ -221,14 +216,14 @@ static VALUE method_line_string_points(VALUE self)
|
|
221
216
|
return result;
|
222
217
|
}
|
223
218
|
|
224
|
-
|
225
|
-
|
219
|
+
static VALUE
|
220
|
+
method_line_string_start_point(VALUE self)
|
226
221
|
{
|
227
222
|
return method_line_string_point_n(self, INT2NUM(0));
|
228
223
|
}
|
229
224
|
|
230
|
-
|
231
|
-
|
225
|
+
static VALUE
|
226
|
+
method_line_string_end_point(VALUE self)
|
232
227
|
{
|
233
228
|
VALUE result;
|
234
229
|
RGeo_GeometryData* self_data;
|
@@ -239,41 +234,46 @@ static VALUE method_line_string_end_point(VALUE self)
|
|
239
234
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
240
235
|
self_geom = self_data->geom;
|
241
236
|
if (self_geom) {
|
242
|
-
n =
|
237
|
+
n = GEOSGetNumCoordinates(self_geom);
|
243
238
|
if (n > 0) {
|
244
|
-
result = method_line_string_point_n(self, INT2NUM(n-1));
|
239
|
+
result = method_line_string_point_n(self, INT2NUM(n - 1));
|
245
240
|
}
|
246
241
|
}
|
247
242
|
return result;
|
248
243
|
}
|
249
244
|
|
250
|
-
static VALUE
|
245
|
+
static VALUE
|
246
|
+
method_line_string_project_point(VALUE self, VALUE point)
|
251
247
|
{
|
252
|
-
RGeo_FactoryData* factory_data;
|
253
248
|
VALUE result = Qnil;
|
254
249
|
VALUE factory;
|
255
250
|
RGeo_GeometryData* self_data;
|
256
251
|
const GEOSGeometry* self_geom;
|
257
|
-
const GEOSGeometry
|
252
|
+
const GEOSGeometry* geos_point;
|
253
|
+
int state = 0;
|
258
254
|
|
259
255
|
double location;
|
260
256
|
|
261
257
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
262
258
|
factory = self_data->factory;
|
263
259
|
self_geom = self_data->geom;
|
264
|
-
factory_data = RGEO_FACTORY_DATA_PTR(factory);
|
265
260
|
|
266
|
-
if(self_geom && point) {
|
267
|
-
geos_point = rgeo_convert_to_geos_geometry(
|
268
|
-
|
261
|
+
if (self_geom && point) {
|
262
|
+
geos_point = rgeo_convert_to_geos_geometry(
|
263
|
+
factory, point, rgeo_geos_point_class, &state);
|
264
|
+
if (state) {
|
265
|
+
rb_jump_tag(state);
|
266
|
+
}
|
267
|
+
|
268
|
+
location = GEOSProject(self_geom, geos_point);
|
269
269
|
result = DBL2NUM(location);
|
270
270
|
}
|
271
271
|
return result;
|
272
272
|
}
|
273
273
|
|
274
|
-
static VALUE
|
274
|
+
static VALUE
|
275
|
+
method_line_string_interpolate_point(VALUE self, VALUE loc_num)
|
275
276
|
{
|
276
|
-
RGeo_FactoryData* factory_data;
|
277
277
|
VALUE result = Qnil;
|
278
278
|
VALUE factory;
|
279
279
|
RGeo_GeometryData* self_data;
|
@@ -285,18 +285,19 @@ static VALUE method_line_string_interpolate_point(VALUE self, VALUE loc_num)
|
|
285
285
|
location = NUM2DBL(loc_num);
|
286
286
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
287
287
|
factory = self_data->factory;
|
288
|
-
factory_data = RGEO_FACTORY_DATA_PTR(factory);
|
289
288
|
self_geom = self_data->geom;
|
290
289
|
|
291
|
-
if(self_geom) {
|
292
|
-
geos_point =
|
293
|
-
result =
|
290
|
+
if (self_geom) {
|
291
|
+
geos_point = GEOSInterpolate(self_geom, location);
|
292
|
+
result =
|
293
|
+
rgeo_wrap_geos_geometry(factory, geos_point, rgeo_geos_point_class);
|
294
294
|
}
|
295
295
|
|
296
296
|
return result;
|
297
297
|
}
|
298
298
|
|
299
|
-
static VALUE
|
299
|
+
static VALUE
|
300
|
+
method_line_string_is_closed(VALUE self)
|
300
301
|
{
|
301
302
|
VALUE result;
|
302
303
|
RGeo_GeometryData* self_data;
|
@@ -306,13 +307,13 @@ static VALUE method_line_string_is_closed(VALUE self)
|
|
306
307
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
307
308
|
self_geom = self_data->geom;
|
308
309
|
if (self_geom) {
|
309
|
-
result = rgeo_is_geos_line_string_closed(
|
310
|
+
result = rgeo_is_geos_line_string_closed(self_geom);
|
310
311
|
}
|
311
312
|
return result;
|
312
313
|
}
|
313
314
|
|
314
|
-
|
315
|
-
|
315
|
+
static VALUE
|
316
|
+
method_line_string_is_ring(VALUE self)
|
316
317
|
{
|
317
318
|
VALUE result;
|
318
319
|
RGeo_GeometryData* self_data;
|
@@ -323,19 +324,18 @@ static VALUE method_line_string_is_ring(VALUE self)
|
|
323
324
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
324
325
|
self_geom = self_data->geom;
|
325
326
|
if (self_geom) {
|
326
|
-
val =
|
327
|
+
val = GEOSisRing(self_geom);
|
327
328
|
if (val == 0) {
|
328
329
|
result = Qfalse;
|
329
|
-
}
|
330
|
-
else if (val == 1) {
|
330
|
+
} else if (val == 1) {
|
331
331
|
result = Qtrue;
|
332
332
|
}
|
333
333
|
}
|
334
334
|
return result;
|
335
335
|
}
|
336
336
|
|
337
|
-
|
338
|
-
|
337
|
+
static VALUE
|
338
|
+
method_line_string_eql(VALUE self, VALUE rhs)
|
339
339
|
{
|
340
340
|
VALUE result;
|
341
341
|
RGeo_GeometryData* self_data;
|
@@ -343,13 +343,14 @@ static VALUE method_line_string_eql(VALUE self, VALUE rhs)
|
|
343
343
|
result = rgeo_geos_klasses_and_factories_eql(self, rhs);
|
344
344
|
if (RTEST(result)) {
|
345
345
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
346
|
-
result =
|
346
|
+
result = rgeo_geos_geometries_strict_eql(self_data->geom,
|
347
|
+
RGEO_GEOMETRY_DATA_PTR(rhs)->geom);
|
347
348
|
}
|
348
349
|
return result;
|
349
350
|
}
|
350
351
|
|
351
|
-
|
352
|
-
|
352
|
+
static VALUE
|
353
|
+
method_line_string_hash(VALUE self)
|
353
354
|
{
|
354
355
|
st_index_t hash;
|
355
356
|
RGeo_GeometryData* self_data;
|
@@ -358,14 +359,13 @@ static VALUE method_line_string_hash(VALUE self)
|
|
358
359
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
359
360
|
factory = self_data->factory;
|
360
361
|
hash = rb_hash_start(0);
|
361
|
-
hash = rgeo_geos_objbase_hash(factory,
|
362
|
-
|
363
|
-
hash = rgeo_geos_coordseq_hash(self_data->geos_context, self_data->geom, hash);
|
362
|
+
hash = rgeo_geos_objbase_hash(factory, rgeo_feature_line_string_module, hash);
|
363
|
+
hash = rgeo_geos_coordseq_hash(self_data->geom, hash);
|
364
364
|
return LONG2FIX(rb_hash_end(hash));
|
365
365
|
}
|
366
366
|
|
367
|
-
|
368
|
-
|
367
|
+
static VALUE
|
368
|
+
method_linear_ring_hash(VALUE self)
|
369
369
|
{
|
370
370
|
st_index_t hash;
|
371
371
|
RGeo_GeometryData* self_data;
|
@@ -374,14 +374,13 @@ static VALUE method_linear_ring_hash(VALUE self)
|
|
374
374
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
375
375
|
factory = self_data->factory;
|
376
376
|
hash = rb_hash_start(0);
|
377
|
-
hash = rgeo_geos_objbase_hash(factory,
|
378
|
-
|
379
|
-
hash = rgeo_geos_coordseq_hash(self_data->geos_context, self_data->geom, hash);
|
377
|
+
hash = rgeo_geos_objbase_hash(factory, rgeo_feature_linear_ring_module, hash);
|
378
|
+
hash = rgeo_geos_coordseq_hash(self_data->geom, hash);
|
380
379
|
return LONG2FIX(rb_hash_end(hash));
|
381
380
|
}
|
382
381
|
|
383
|
-
|
384
|
-
|
382
|
+
static VALUE
|
383
|
+
method_line_hash(VALUE self)
|
385
384
|
{
|
386
385
|
st_index_t hash;
|
387
386
|
RGeo_GeometryData* self_data;
|
@@ -390,201 +389,206 @@ static VALUE method_line_hash(VALUE self)
|
|
390
389
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
391
390
|
factory = self_data->factory;
|
392
391
|
hash = rb_hash_start(0);
|
393
|
-
hash = rgeo_geos_objbase_hash(factory,
|
394
|
-
|
395
|
-
hash = rgeo_geos_coordseq_hash(self_data->geos_context, self_data->geom, hash);
|
392
|
+
hash = rgeo_geos_objbase_hash(factory, rgeo_feature_line_module, hash);
|
393
|
+
hash = rgeo_geos_coordseq_hash(self_data->geom, hash);
|
396
394
|
return LONG2FIX(rb_hash_end(hash));
|
397
395
|
}
|
398
396
|
|
399
|
-
|
400
|
-
|
397
|
+
static GEOSCoordSequence*
|
398
|
+
coord_seq_from_array(VALUE factory, VALUE array, char close)
|
401
399
|
{
|
402
|
-
RGeo_FactoryData* factory_data;
|
403
400
|
VALUE point_type;
|
404
401
|
unsigned int len;
|
405
402
|
char has_z;
|
406
403
|
unsigned int dims;
|
407
404
|
double* coords;
|
408
|
-
GEOSContextHandle_t context;
|
409
405
|
unsigned int i;
|
410
406
|
char good;
|
411
407
|
const GEOSGeometry* entry_geom;
|
412
408
|
const GEOSCoordSequence* entry_cs;
|
413
409
|
double x;
|
414
410
|
GEOSCoordSequence* coord_seq;
|
411
|
+
int state = 0;
|
415
412
|
|
416
413
|
Check_Type(array, T_ARRAY);
|
417
|
-
|
418
|
-
point_type = factory_data->globals->feature_point;
|
414
|
+
point_type = rgeo_feature_point_module;
|
419
415
|
len = (unsigned int)RARRAY_LEN(array);
|
420
|
-
has_z = (char)(RGEO_FACTORY_DATA_PTR(factory)->flags &
|
416
|
+
has_z = (char)(RGEO_FACTORY_DATA_PTR(factory)->flags &
|
417
|
+
RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
|
421
418
|
dims = has_z ? 3 : 2;
|
422
419
|
coords = ALLOC_N(double, len == 0 ? 1 : len * dims);
|
423
420
|
if (!coords) {
|
424
421
|
return NULL;
|
425
422
|
}
|
426
|
-
|
427
|
-
for (i=0; i<len; ++i) {
|
423
|
+
for (i = 0; i < len; ++i) {
|
428
424
|
good = 0;
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
425
|
+
|
426
|
+
entry_geom = rgeo_convert_to_geos_geometry(
|
427
|
+
factory, rb_ary_entry(array, i), point_type, &state);
|
428
|
+
if (state) {
|
429
|
+
FREE(coords);
|
430
|
+
rb_jump_tag(state);
|
431
|
+
}
|
432
|
+
|
433
|
+
entry_cs = GEOSGeom_getCoordSeq(entry_geom);
|
434
|
+
if (entry_cs) {
|
435
|
+
if (GEOSCoordSeq_getX(entry_cs, 0, &x)) {
|
436
|
+
coords[i * dims] = x;
|
437
|
+
if (GEOSCoordSeq_getY(entry_cs, 0, &x)) {
|
438
|
+
coords[i * dims + 1] = x;
|
439
|
+
good = 1;
|
440
|
+
if (has_z) {
|
441
|
+
if (GEOSCoordSeq_getZ(entry_cs, 0, &x)) {
|
442
|
+
coords[i * dims + 2] = x;
|
443
|
+
} else {
|
444
|
+
good = 0;
|
445
445
|
}
|
446
446
|
}
|
447
447
|
}
|
448
448
|
}
|
449
449
|
}
|
450
450
|
if (!good) {
|
451
|
-
|
451
|
+
FREE(coords);
|
452
452
|
return NULL;
|
453
453
|
}
|
454
454
|
}
|
455
455
|
if (len > 0 && close) {
|
456
|
-
if (coords[0] == coords[(len-1)*dims] &&
|
456
|
+
if (coords[0] == coords[(len - 1) * dims] &&
|
457
|
+
coords[1] == coords[(len - 1) * dims + 1]) {
|
457
458
|
close = 0;
|
458
459
|
}
|
459
|
-
}
|
460
|
-
else {
|
460
|
+
} else {
|
461
461
|
close = 0;
|
462
462
|
}
|
463
|
-
coord_seq =
|
463
|
+
coord_seq = GEOSCoordSeq_create(len + close, 3);
|
464
464
|
if (coord_seq) {
|
465
|
-
for (i=0; i<len; ++i) {
|
466
|
-
|
467
|
-
|
468
|
-
|
465
|
+
for (i = 0; i < len; ++i) {
|
466
|
+
GEOSCoordSeq_setX(coord_seq, i, coords[i * dims]);
|
467
|
+
GEOSCoordSeq_setY(coord_seq, i, coords[i * dims + 1]);
|
468
|
+
GEOSCoordSeq_setZ(coord_seq, i, has_z ? coords[i * dims + 2] : 0);
|
469
469
|
}
|
470
470
|
if (close) {
|
471
|
-
|
472
|
-
|
473
|
-
|
471
|
+
GEOSCoordSeq_setX(coord_seq, len, coords[0]);
|
472
|
+
GEOSCoordSeq_setY(coord_seq, len, coords[1]);
|
473
|
+
GEOSCoordSeq_setZ(coord_seq, len, has_z ? coords[2] : 0);
|
474
474
|
}
|
475
475
|
}
|
476
|
-
|
476
|
+
FREE(coords);
|
477
477
|
return coord_seq;
|
478
478
|
}
|
479
479
|
|
480
|
-
|
481
|
-
|
480
|
+
static VALUE
|
481
|
+
cmethod_create_line_string(VALUE module, VALUE factory, VALUE array)
|
482
482
|
{
|
483
483
|
VALUE result;
|
484
484
|
GEOSCoordSequence* coord_seq;
|
485
|
-
RGeo_FactoryData* factory_data;
|
486
485
|
GEOSGeometry* geom;
|
487
486
|
|
488
487
|
result = Qnil;
|
489
488
|
coord_seq = coord_seq_from_array(factory, array, 0);
|
490
489
|
if (coord_seq) {
|
491
|
-
|
492
|
-
geom = GEOSGeom_createLineString_r(factory_data->geos_context, coord_seq);
|
490
|
+
geom = GEOSGeom_createLineString(coord_seq);
|
493
491
|
if (geom) {
|
494
|
-
result =
|
492
|
+
result =
|
493
|
+
rgeo_wrap_geos_geometry(factory, geom, rgeo_geos_line_string_class);
|
495
494
|
}
|
496
495
|
}
|
497
496
|
return result;
|
498
497
|
}
|
499
498
|
|
500
|
-
|
501
|
-
|
499
|
+
static VALUE
|
500
|
+
cmethod_create_linear_ring(VALUE module, VALUE factory, VALUE array)
|
502
501
|
{
|
503
502
|
VALUE result;
|
504
503
|
GEOSCoordSequence* coord_seq;
|
505
|
-
RGeo_FactoryData* factory_data;
|
506
504
|
GEOSGeometry* geom;
|
507
505
|
|
508
506
|
result = Qnil;
|
509
507
|
coord_seq = coord_seq_from_array(factory, array, 1);
|
510
508
|
if (coord_seq) {
|
511
|
-
|
512
|
-
geom = GEOSGeom_createLinearRing_r(factory_data->geos_context, coord_seq);
|
509
|
+
geom = GEOSGeom_createLinearRing(coord_seq);
|
513
510
|
if (geom) {
|
514
|
-
result =
|
511
|
+
result =
|
512
|
+
rgeo_wrap_geos_geometry(factory, geom, rgeo_geos_linear_ring_class);
|
515
513
|
}
|
516
514
|
}
|
517
515
|
return result;
|
518
516
|
}
|
519
517
|
|
520
|
-
|
521
|
-
|
518
|
+
static void
|
519
|
+
populate_geom_into_coord_seq(const GEOSGeometry* geom,
|
520
|
+
GEOSCoordSequence* coord_seq,
|
521
|
+
unsigned int i,
|
522
|
+
char has_z)
|
522
523
|
{
|
523
524
|
const GEOSCoordSequence* cs;
|
524
525
|
double x;
|
525
526
|
|
526
|
-
cs =
|
527
|
+
cs = GEOSGeom_getCoordSeq(geom);
|
527
528
|
x = 0;
|
528
529
|
if (cs) {
|
529
|
-
|
530
|
+
GEOSCoordSeq_getX(cs, 0, &x);
|
530
531
|
}
|
531
|
-
|
532
|
+
GEOSCoordSeq_setX(coord_seq, i, x);
|
532
533
|
x = 0;
|
533
534
|
if (cs) {
|
534
|
-
|
535
|
+
GEOSCoordSeq_getY(cs, 0, &x);
|
535
536
|
}
|
536
|
-
|
537
|
+
GEOSCoordSeq_setY(coord_seq, i, x);
|
537
538
|
x = 0;
|
538
539
|
if (has_z && cs) {
|
539
|
-
|
540
|
+
GEOSCoordSeq_getZ(cs, 0, &x);
|
540
541
|
}
|
541
|
-
|
542
|
+
GEOSCoordSeq_setZ(coord_seq, i, x);
|
542
543
|
}
|
543
544
|
|
544
|
-
|
545
|
-
|
545
|
+
static VALUE
|
546
|
+
cmethod_create_line(VALUE module, VALUE factory, VALUE start, VALUE end)
|
546
547
|
{
|
547
548
|
VALUE result;
|
548
549
|
RGeo_FactoryData* factory_data;
|
549
550
|
char has_z;
|
550
551
|
VALUE point_type;
|
551
|
-
GEOSContextHandle_t context;
|
552
552
|
const GEOSGeometry* start_geom;
|
553
553
|
const GEOSGeometry* end_geom;
|
554
554
|
GEOSCoordSequence* coord_seq;
|
555
555
|
GEOSGeometry* geom;
|
556
|
+
int state = 0;
|
556
557
|
|
557
558
|
result = Qnil;
|
558
559
|
factory_data = RGEO_FACTORY_DATA_PTR(factory);
|
559
560
|
has_z = (char)(factory_data->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
|
560
|
-
point_type =
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
if (
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
561
|
+
point_type = rgeo_feature_point_module;
|
562
|
+
|
563
|
+
start_geom =
|
564
|
+
rgeo_convert_to_geos_geometry(factory, start, point_type, &state);
|
565
|
+
if (state) {
|
566
|
+
rb_jump_tag(state);
|
567
|
+
}
|
568
|
+
|
569
|
+
end_geom = rgeo_convert_to_geos_geometry(factory, end, point_type, &state);
|
570
|
+
if (state) {
|
571
|
+
rb_jump_tag(state);
|
572
|
+
}
|
573
|
+
|
574
|
+
coord_seq = GEOSCoordSeq_create(2, 3);
|
575
|
+
if (coord_seq) {
|
576
|
+
populate_geom_into_coord_seq(start_geom, coord_seq, 0, has_z);
|
577
|
+
populate_geom_into_coord_seq(end_geom, coord_seq, 1, has_z);
|
578
|
+
geom = GEOSGeom_createLineString(coord_seq);
|
579
|
+
if (geom) {
|
580
|
+
result = rgeo_wrap_geos_geometry(factory, geom, rgeo_geos_line_class);
|
576
581
|
}
|
577
582
|
}
|
578
583
|
|
579
584
|
return result;
|
580
585
|
}
|
581
586
|
|
582
|
-
|
583
|
-
|
587
|
+
static VALUE
|
588
|
+
impl_copy_from(VALUE klass, VALUE factory, VALUE original, char subtype)
|
584
589
|
{
|
585
590
|
VALUE result;
|
586
591
|
const GEOSGeometry* original_geom;
|
587
|
-
GEOSContextHandle_t context;
|
588
592
|
const GEOSCoordSequence* original_coord_seq;
|
589
593
|
GEOSCoordSequence* coord_seq;
|
590
594
|
GEOSGeometry* geom;
|
@@ -592,16 +596,16 @@ static VALUE impl_copy_from(VALUE klass, VALUE factory, VALUE original, char sub
|
|
592
596
|
result = Qnil;
|
593
597
|
original_geom = RGEO_GEOMETRY_DATA_PTR(original)->geom;
|
594
598
|
if (original_geom) {
|
595
|
-
|
596
|
-
if (subtype == 1 && GEOSGetNumCoordinates_r(context, original_geom) != 2) {
|
599
|
+
if (subtype == 1 && GEOSGetNumCoordinates(original_geom) != 2) {
|
597
600
|
original_geom = NULL;
|
598
601
|
}
|
599
602
|
if (original_geom) {
|
600
|
-
original_coord_seq =
|
603
|
+
original_coord_seq = GEOSGeom_getCoordSeq(original_geom);
|
601
604
|
if (original_coord_seq) {
|
602
|
-
coord_seq =
|
605
|
+
coord_seq = GEOSCoordSeq_clone(original_coord_seq);
|
603
606
|
if (coord_seq) {
|
604
|
-
geom = subtype == 2 ?
|
607
|
+
geom = subtype == 2 ? GEOSGeom_createLinearRing(coord_seq)
|
608
|
+
: GEOSGeom_createLineString(coord_seq);
|
605
609
|
if (geom) {
|
606
610
|
result = rgeo_wrap_geos_geometry(factory, geom, klass);
|
607
611
|
}
|
@@ -612,74 +616,112 @@ static VALUE impl_copy_from(VALUE klass, VALUE factory, VALUE original, char sub
|
|
612
616
|
return result;
|
613
617
|
}
|
614
618
|
|
615
|
-
|
616
|
-
|
619
|
+
static VALUE
|
620
|
+
cmethod_line_string_copy_from(VALUE klass, VALUE factory, VALUE original)
|
617
621
|
{
|
618
622
|
return impl_copy_from(klass, factory, original, 0);
|
619
623
|
}
|
620
624
|
|
621
|
-
|
622
|
-
|
625
|
+
static VALUE
|
626
|
+
cmethod_line_copy_from(VALUE klass, VALUE factory, VALUE original)
|
623
627
|
{
|
624
628
|
return impl_copy_from(klass, factory, original, 1);
|
625
629
|
}
|
626
630
|
|
627
|
-
|
628
|
-
|
631
|
+
static VALUE
|
632
|
+
cmethod_linear_ring_copy_from(VALUE klass, VALUE factory, VALUE original)
|
629
633
|
{
|
630
634
|
return impl_copy_from(klass, factory, original, 2);
|
631
635
|
}
|
632
636
|
|
633
|
-
|
634
|
-
|
637
|
+
void
|
638
|
+
rgeo_init_geos_line_string()
|
635
639
|
{
|
636
640
|
VALUE geos_line_string_methods;
|
637
641
|
VALUE geos_linear_ring_methods;
|
638
642
|
VALUE geos_line_methods;
|
639
643
|
|
640
644
|
// Class methods for CAPILineStringImpl
|
641
|
-
rb_define_module_function(
|
642
|
-
|
645
|
+
rb_define_module_function(
|
646
|
+
rgeo_geos_line_string_class, "create", cmethod_create_line_string, 2);
|
647
|
+
rb_define_module_function(rgeo_geos_line_string_class,
|
648
|
+
"_copy_from",
|
649
|
+
cmethod_line_string_copy_from,
|
650
|
+
2);
|
643
651
|
|
644
652
|
// Class methods for CAPILinearRingImpl
|
645
|
-
rb_define_module_function(
|
646
|
-
|
653
|
+
rb_define_module_function(
|
654
|
+
rgeo_geos_linear_ring_class, "create", cmethod_create_linear_ring, 2);
|
655
|
+
rb_define_module_function(rgeo_geos_linear_ring_class,
|
656
|
+
"_copy_from",
|
657
|
+
cmethod_linear_ring_copy_from,
|
658
|
+
2);
|
647
659
|
|
648
660
|
// Class methods for CAPILineImpl
|
649
|
-
rb_define_module_function(
|
650
|
-
|
661
|
+
rb_define_module_function(
|
662
|
+
rgeo_geos_line_class, "create", cmethod_create_line, 3);
|
663
|
+
rb_define_module_function(
|
664
|
+
rgeo_geos_line_class, "_copy_from", cmethod_line_copy_from, 2);
|
651
665
|
|
652
666
|
// CAPILineStringMethods module
|
653
|
-
geos_line_string_methods =
|
654
|
-
|
667
|
+
geos_line_string_methods =
|
668
|
+
rb_define_module_under(rgeo_geos_module, "CAPILineStringMethods");
|
669
|
+
rb_define_method(
|
670
|
+
geos_line_string_methods, "rep_equals?", method_line_string_eql, 1);
|
655
671
|
rb_define_method(geos_line_string_methods, "eql?", method_line_string_eql, 1);
|
656
|
-
rb_define_method(
|
657
|
-
|
658
|
-
rb_define_method(geos_line_string_methods,
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
rb_define_method(
|
663
|
-
|
664
|
-
rb_define_method(
|
665
|
-
|
666
|
-
rb_define_method(
|
667
|
-
|
668
|
-
rb_define_method(
|
672
|
+
rb_define_method(
|
673
|
+
geos_line_string_methods, "hash", method_line_string_hash, 0);
|
674
|
+
rb_define_method(geos_line_string_methods,
|
675
|
+
"geometry_type",
|
676
|
+
method_line_string_geometry_type,
|
677
|
+
0);
|
678
|
+
rb_define_method(
|
679
|
+
geos_line_string_methods, "length", method_line_string_length, 0);
|
680
|
+
rb_define_method(
|
681
|
+
geos_line_string_methods, "num_points", method_line_string_num_points, 0);
|
682
|
+
rb_define_method(
|
683
|
+
geos_line_string_methods, "point_n", method_line_string_point_n, 1);
|
684
|
+
rb_define_method(
|
685
|
+
geos_line_string_methods, "points", method_line_string_points, 0);
|
686
|
+
rb_define_method(
|
687
|
+
geos_line_string_methods, "start_point", method_line_string_start_point, 0);
|
688
|
+
rb_define_method(
|
689
|
+
geos_line_string_methods, "end_point", method_line_string_end_point, 0);
|
690
|
+
rb_define_method(geos_line_string_methods,
|
691
|
+
"project_point",
|
692
|
+
method_line_string_project_point,
|
693
|
+
1);
|
694
|
+
rb_define_method(geos_line_string_methods,
|
695
|
+
"interpolate_point",
|
696
|
+
method_line_string_interpolate_point,
|
697
|
+
1);
|
698
|
+
rb_define_method(
|
699
|
+
geos_line_string_methods, "closed?", method_line_string_is_closed, 0);
|
700
|
+
rb_define_method(
|
701
|
+
geos_line_string_methods, "ring?", method_line_string_is_ring, 0);
|
702
|
+
rb_define_method(
|
703
|
+
geos_line_string_methods, "coordinates", method_line_string_coordinates, 0);
|
669
704
|
|
670
705
|
// CAPILinearRingMethods module
|
671
|
-
geos_linear_ring_methods =
|
672
|
-
|
673
|
-
rb_define_method(geos_linear_ring_methods,
|
706
|
+
geos_linear_ring_methods =
|
707
|
+
rb_define_module_under(rgeo_geos_module, "CAPILinearRingMethods");
|
708
|
+
rb_define_method(geos_linear_ring_methods,
|
709
|
+
"geometry_type",
|
710
|
+
method_linear_ring_geometry_type,
|
711
|
+
0);
|
712
|
+
rb_define_method(
|
713
|
+
geos_linear_ring_methods, "hash", method_linear_ring_hash, 0);
|
674
714
|
|
675
715
|
// CAPILineMethods module
|
676
|
-
geos_line_methods =
|
677
|
-
|
716
|
+
geos_line_methods =
|
717
|
+
rb_define_module_under(rgeo_geos_module, "CAPILineMethods");
|
718
|
+
rb_define_method(
|
719
|
+
geos_line_methods, "geometry_type", method_line_geometry_type, 0);
|
678
720
|
rb_define_method(geos_line_methods, "hash", method_line_hash, 0);
|
679
721
|
}
|
680
722
|
|
681
|
-
|
682
|
-
|
723
|
+
VALUE
|
724
|
+
rgeo_is_geos_line_string_closed(const GEOSGeometry* geom)
|
683
725
|
{
|
684
726
|
VALUE result;
|
685
727
|
unsigned int n;
|
@@ -687,19 +729,18 @@ VALUE rgeo_is_geos_line_string_closed(GEOSContextHandle_t context, const GEOSGeo
|
|
687
729
|
const GEOSCoordSequence* coord_seq;
|
688
730
|
|
689
731
|
result = Qnil;
|
690
|
-
n =
|
732
|
+
n = GEOSGetNumCoordinates(geom);
|
691
733
|
if (n > 0) {
|
692
|
-
coord_seq =
|
693
|
-
if (
|
694
|
-
if (
|
734
|
+
coord_seq = GEOSGeom_getCoordSeq(geom);
|
735
|
+
if (GEOSCoordSeq_getX(coord_seq, 0, &x1)) {
|
736
|
+
if (GEOSCoordSeq_getX(coord_seq, n - 1, &x2)) {
|
695
737
|
if (x1 == x2) {
|
696
|
-
if (
|
697
|
-
if (
|
738
|
+
if (GEOSCoordSeq_getY(coord_seq, 0, &y1)) {
|
739
|
+
if (GEOSCoordSeq_getY(coord_seq, n - 1, &y2)) {
|
698
740
|
result = y1 == y2 ? Qtrue : Qfalse;
|
699
741
|
}
|
700
742
|
}
|
701
|
-
}
|
702
|
-
else {
|
743
|
+
} else {
|
703
744
|
result = Qfalse;
|
704
745
|
}
|
705
746
|
}
|
@@ -708,7 +749,6 @@ VALUE rgeo_is_geos_line_string_closed(GEOSContextHandle_t context, const GEOSGeo
|
|
708
749
|
return result;
|
709
750
|
}
|
710
751
|
|
711
|
-
|
712
752
|
RGEO_END_C
|
713
753
|
|
714
754
|
#endif
|