rgeo 2.3.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.
- checksums.yaml +4 -4
- data/ext/geos_c_impl/analysis.c +4 -2
- data/ext/geos_c_impl/analysis.h +1 -3
- data/ext/geos_c_impl/errors.c +2 -2
- data/ext/geos_c_impl/extconf.rb +1 -0
- data/ext/geos_c_impl/factory.c +167 -170
- data/ext/geos_c_impl/factory.h +15 -48
- data/ext/geos_c_impl/geometry.c +8 -8
- data/ext/geos_c_impl/geometry.h +1 -3
- data/ext/geos_c_impl/geometry_collection.c +38 -43
- data/ext/geos_c_impl/geometry_collection.h +1 -3
- data/ext/geos_c_impl/globals.c +91 -0
- data/ext/geos_c_impl/globals.h +45 -0
- data/ext/geos_c_impl/line_string.c +25 -26
- data/ext/geos_c_impl/line_string.h +1 -3
- data/ext/geos_c_impl/main.c +10 -9
- data/ext/geos_c_impl/point.c +8 -7
- data/ext/geos_c_impl/point.h +1 -3
- data/ext/geos_c_impl/polygon.c +14 -14
- data/ext/geos_c_impl/polygon.h +1 -3
- data/ext/geos_c_impl/preface.h +5 -0
- data/lib/rgeo/version.rb +1 -1
- metadata +8 -6
data/ext/geos_c_impl/factory.h
CHANGED
@@ -10,58 +10,13 @@
|
|
10
10
|
|
11
11
|
RGEO_BEGIN_C
|
12
12
|
|
13
|
-
/*
|
14
|
-
Per-interpreter globals.
|
15
|
-
Most of these are cached references to commonly used classes, modules,
|
16
|
-
and symbols so we don't have to do a lot of constant lookups and calls
|
17
|
-
to rb_intern.
|
18
|
-
*/
|
19
|
-
typedef struct {
|
20
|
-
VALUE feature_module;
|
21
|
-
VALUE feature_geometry;
|
22
|
-
VALUE feature_point;
|
23
|
-
VALUE feature_line_string;
|
24
|
-
VALUE feature_linear_ring;
|
25
|
-
VALUE feature_line;
|
26
|
-
VALUE feature_polygon;
|
27
|
-
VALUE feature_geometry_collection;
|
28
|
-
VALUE feature_multi_point;
|
29
|
-
VALUE feature_multi_line_string;
|
30
|
-
VALUE feature_multi_polygon;
|
31
|
-
VALUE geos_module;
|
32
|
-
VALUE geos_geometry;
|
33
|
-
VALUE geos_point;
|
34
|
-
VALUE geos_line_string;
|
35
|
-
VALUE geos_linear_ring;
|
36
|
-
VALUE geos_line;
|
37
|
-
VALUE geos_polygon;
|
38
|
-
VALUE geos_geometry_collection;
|
39
|
-
VALUE geos_multi_point;
|
40
|
-
VALUE geos_multi_line_string;
|
41
|
-
VALUE geos_multi_polygon;
|
42
|
-
ID id_cast;
|
43
|
-
ID id_eql;
|
44
|
-
ID id_generate;
|
45
|
-
ID id_enum_for;
|
46
|
-
ID id_hash;
|
47
|
-
VALUE sym_force_new;
|
48
|
-
VALUE sym_keep_subtype;
|
49
|
-
#ifndef RGEO_GEOS_SUPPORTS_SETOUTPUTDIMENSION
|
50
|
-
VALUE psych_wkt_generator;
|
51
|
-
VALUE marshal_wkb_generator;
|
52
|
-
#endif
|
53
|
-
} RGeo_Globals;
|
54
|
-
|
55
|
-
|
56
13
|
/*
|
57
14
|
Wrapped structure for Factory objects.
|
58
15
|
A factory encapsulates the GEOS context, and GEOS serializer settings.
|
59
16
|
It also stores the SRID for all geometries created by this factory,
|
60
17
|
and the resolution for buffers created for this factory's geometries.
|
61
|
-
Finally, it provides easy access to the globals.
|
62
18
|
*/
|
63
19
|
typedef struct {
|
64
|
-
RGeo_Globals* globals;
|
65
20
|
GEOSContextHandle_t geos_context;
|
66
21
|
GEOSWKTReader* wkt_reader;
|
67
22
|
GEOSWKBReader* wkb_reader;
|
@@ -119,18 +74,30 @@ typedef struct {
|
|
119
74
|
} RGeo_GeometryData;
|
120
75
|
|
121
76
|
|
77
|
+
// Data types which indicate how RGeo types should be managed by Ruby.
|
78
|
+
extern const rb_data_type_t rgeo_factory_type;
|
79
|
+
|
80
|
+
extern const rb_data_type_t rgeo_geometry_type;
|
81
|
+
|
82
|
+
|
83
|
+
// Convenient macros for checking the type of data from Ruby
|
84
|
+
#define RGEO_FACTORY_TYPEDDATA_P(object) (_RGEO_TYPEDDATA_P(object, &rgeo_factory_type))
|
85
|
+
#define RGEO_GEOMETRY_TYPEDDATA_P(object) (_RGEO_TYPEDDATA_P(object, &rgeo_geometry_type))
|
86
|
+
|
87
|
+
#define _RGEO_TYPEDDATA_P(object, data_type) (TYPE(object) == T_DATA && RTYPEDDATA(object)->typed_flag == 1 && RTYPEDDATA(object)->type == data_type)
|
88
|
+
|
122
89
|
// Returns the RGeo_FactoryData* given a ruby Factory object
|
123
|
-
#define RGEO_FACTORY_DATA_PTR(factory) ((RGeo_FactoryData*)
|
90
|
+
#define RGEO_FACTORY_DATA_PTR(factory) ((RGeo_FactoryData*)RTYPEDDATA_DATA(factory))
|
124
91
|
|
125
92
|
// Returns the RGeo_GeometryData* given a ruby Geometry object
|
126
|
-
#define RGEO_GEOMETRY_DATA_PTR(geometry) ((RGeo_GeometryData*)
|
93
|
+
#define RGEO_GEOMETRY_DATA_PTR(geometry) ((RGeo_GeometryData*)RTYPEDDATA_DATA(geometry))
|
127
94
|
|
128
95
|
|
129
96
|
/*
|
130
97
|
Initializes the factory module. This should be called first in the
|
131
98
|
initialization process.
|
132
99
|
*/
|
133
|
-
|
100
|
+
void rgeo_init_geos_factory();
|
134
101
|
|
135
102
|
/*
|
136
103
|
Given a GEOS geometry handle, wraps it in a ruby Geometry object of the
|
data/ext/geos_c_impl/geometry.c
CHANGED
@@ -11,6 +11,8 @@
|
|
11
11
|
#include <ruby.h>
|
12
12
|
#include <geos_c.h>
|
13
13
|
|
14
|
+
#include "globals.h"
|
15
|
+
|
14
16
|
#include "factory.h"
|
15
17
|
#include "geometry.h"
|
16
18
|
|
@@ -180,13 +182,11 @@ static VALUE method_geometry_geometry_type(VALUE self)
|
|
180
182
|
{
|
181
183
|
VALUE result;
|
182
184
|
RGeo_GeometryData* self_data;
|
183
|
-
const GEOSGeometry* self_geom;
|
184
185
|
|
185
186
|
result = Qnil;
|
186
187
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
187
|
-
|
188
|
-
|
189
|
-
result = RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->feature_geometry;
|
188
|
+
if (self_data->geom) {
|
189
|
+
result = rgeo_feature_geometry_module;
|
190
190
|
}
|
191
191
|
return result;
|
192
192
|
}
|
@@ -271,7 +271,7 @@ static VALUE method_geometry_as_text(VALUE self)
|
|
271
271
|
factory_data = RGEO_FACTORY_DATA_PTR(self_data->factory);
|
272
272
|
wkt_generator = factory_data->wkrep_wkt_generator;
|
273
273
|
if (!NIL_P(wkt_generator)) {
|
274
|
-
result = rb_funcall(wkt_generator,
|
274
|
+
result = rb_funcall(wkt_generator, rb_intern("generate"), 1, self);
|
275
275
|
}
|
276
276
|
else {
|
277
277
|
wkt_writer = factory_data->wkt_writer;
|
@@ -310,7 +310,7 @@ static VALUE method_geometry_as_binary(VALUE self)
|
|
310
310
|
factory_data = RGEO_FACTORY_DATA_PTR(self_data->factory);
|
311
311
|
wkb_generator = factory_data->wkrep_wkb_generator;
|
312
312
|
if (!NIL_P(wkb_generator)) {
|
313
|
-
result = rb_funcall(wkb_generator,
|
313
|
+
result = rb_funcall(wkb_generator, rb_intern("generate"), 1, self);
|
314
314
|
}
|
315
315
|
else {
|
316
316
|
wkb_writer = factory_data->wkb_writer;
|
@@ -1075,11 +1075,11 @@ static VALUE method_geometry_point_on_surface(VALUE self)
|
|
1075
1075
|
/**** INITIALIZATION FUNCTION ****/
|
1076
1076
|
|
1077
1077
|
|
1078
|
-
void rgeo_init_geos_geometry(
|
1078
|
+
void rgeo_init_geos_geometry()
|
1079
1079
|
{
|
1080
1080
|
VALUE geos_geometry_methods;
|
1081
1081
|
|
1082
|
-
geos_geometry_methods = rb_define_module_under(
|
1082
|
+
geos_geometry_methods = rb_define_module_under(rgeo_geos_module, "CAPIGeometryMethods");
|
1083
1083
|
|
1084
1084
|
rb_define_method(geos_geometry_methods, "factory=", method_geometry_set_factory, 1);
|
1085
1085
|
rb_define_method(geos_geometry_methods, "initialize_copy", method_geometry_initialize_copy, 1);
|
data/ext/geos_c_impl/geometry.h
CHANGED
@@ -6,8 +6,6 @@
|
|
6
6
|
#ifndef RGEO_GEOS_GEOMETRY_INCLUDED
|
7
7
|
#define RGEO_GEOS_GEOMETRY_INCLUDED
|
8
8
|
|
9
|
-
#include "factory.h"
|
10
|
-
|
11
9
|
RGEO_BEGIN_C
|
12
10
|
|
13
11
|
|
@@ -15,7 +13,7 @@ RGEO_BEGIN_C
|
|
15
13
|
Initializes the geometry module. This should be called after the factory
|
16
14
|
module is initialized, but before any of the other modules.
|
17
15
|
*/
|
18
|
-
void rgeo_init_geos_geometry(
|
16
|
+
void rgeo_init_geos_geometry();
|
19
17
|
|
20
18
|
|
21
19
|
RGEO_END_C
|
@@ -10,6 +10,8 @@
|
|
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"
|
@@ -56,13 +58,13 @@ static VALUE create_geometry_collection(VALUE module, int type, VALUE factory, V
|
|
56
58
|
cast_type = Qnil;
|
57
59
|
switch (type) {
|
58
60
|
case GEOS_MULTIPOINT:
|
59
|
-
cast_type =
|
61
|
+
cast_type = rgeo_feature_point_module;
|
60
62
|
break;
|
61
63
|
case GEOS_MULTILINESTRING:
|
62
|
-
cast_type =
|
64
|
+
cast_type = rgeo_feature_line_string_module;
|
63
65
|
break;
|
64
66
|
case GEOS_MULTIPOLYGON:
|
65
|
-
cast_type =
|
67
|
+
cast_type = rgeo_feature_polygon_module;
|
66
68
|
break;
|
67
69
|
}
|
68
70
|
for (i=0; i<len; ++i) {
|
@@ -156,8 +158,7 @@ static VALUE method_geometry_collection_hash(VALUE self)
|
|
156
158
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
157
159
|
factory = self_data->factory;
|
158
160
|
hash = rb_hash_start(0);
|
159
|
-
hash = rgeo_geos_objbase_hash(factory,
|
160
|
-
RGEO_FACTORY_DATA_PTR(factory)->globals->feature_geometry_collection, hash);
|
161
|
+
hash = rgeo_geos_objbase_hash(factory, rgeo_feature_geometry_collection_module, hash);
|
161
162
|
hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
|
162
163
|
return LONG2FIX(rb_hash_end(hash));
|
163
164
|
}
|
@@ -171,7 +172,7 @@ static VALUE method_geometry_collection_geometry_type(VALUE self)
|
|
171
172
|
result = Qnil;
|
172
173
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
173
174
|
if (self_data->geom) {
|
174
|
-
result =
|
175
|
+
result = rgeo_feature_geometry_collection_module;
|
175
176
|
}
|
176
177
|
return result;
|
177
178
|
}
|
@@ -239,6 +240,8 @@ static VALUE method_geometry_collection_brackets(VALUE self, VALUE n)
|
|
239
240
|
|
240
241
|
static VALUE method_geometry_collection_each(VALUE self)
|
241
242
|
{
|
243
|
+
RETURN_ENUMERATOR(self, 0, 0); /* return enum_for(__callee__) unless block_given? */
|
244
|
+
|
242
245
|
RGeo_GeometryData* self_data;
|
243
246
|
const GEOSGeometry* self_geom;
|
244
247
|
int len;
|
@@ -249,27 +252,22 @@ static VALUE method_geometry_collection_each(VALUE self)
|
|
249
252
|
|
250
253
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
251
254
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
rb_yield(elem);
|
264
|
-
}
|
255
|
+
self_geom = self_data->geom;
|
256
|
+
if (self_geom) {
|
257
|
+
GEOSContextHandle_t self_context = self_data->geos_context;
|
258
|
+
len = GEOSGetNumGeometries_r(self_context, self_geom);
|
259
|
+
if (len > 0) {
|
260
|
+
klasses = self_data->klasses;
|
261
|
+
for (i=0; i<len; ++i) {
|
262
|
+
elem_geom = GEOSGetGeometryN_r(self_context, self_geom, i);
|
263
|
+
elem = rgeo_wrap_geos_geometry_clone(self_data->factory, elem_geom, NIL_P(klasses) ? Qnil : rb_ary_entry(klasses, i));
|
264
|
+
if (!NIL_P(elem)) {
|
265
|
+
rb_yield(elem);
|
265
266
|
}
|
266
267
|
}
|
267
268
|
}
|
268
|
-
return self;
|
269
|
-
}
|
270
|
-
else {
|
271
|
-
return rb_funcall(self, RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->id_enum_for, 0);
|
272
269
|
}
|
270
|
+
return self;
|
273
271
|
}
|
274
272
|
|
275
273
|
static VALUE method_multi_point_geometry_type(VALUE self)
|
@@ -280,7 +278,7 @@ static VALUE method_multi_point_geometry_type(VALUE self)
|
|
280
278
|
result = Qnil;
|
281
279
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
282
280
|
if (self_data->geom) {
|
283
|
-
result =
|
281
|
+
result = rgeo_feature_multi_point_module;
|
284
282
|
}
|
285
283
|
return result;
|
286
284
|
}
|
@@ -295,8 +293,7 @@ static VALUE method_multi_point_hash(VALUE self)
|
|
295
293
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
296
294
|
factory = self_data->factory;
|
297
295
|
hash = rb_hash_start(0);
|
298
|
-
hash = rgeo_geos_objbase_hash(factory,
|
299
|
-
RGEO_FACTORY_DATA_PTR(factory)->globals->feature_multi_point, hash);
|
296
|
+
hash = rgeo_geos_objbase_hash(factory, rgeo_feature_multi_point_module, hash);
|
300
297
|
hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
|
301
298
|
return LONG2FIX(rb_hash_end(hash));
|
302
299
|
}
|
@@ -342,7 +339,7 @@ static VALUE method_multi_line_string_geometry_type(VALUE self)
|
|
342
339
|
result = Qnil;
|
343
340
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
344
341
|
if (self_data->geom) {
|
345
|
-
result =
|
342
|
+
result = rgeo_feature_multi_line_string_module;
|
346
343
|
}
|
347
344
|
return result;
|
348
345
|
}
|
@@ -357,8 +354,7 @@ static VALUE method_multi_line_string_hash(VALUE self)
|
|
357
354
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
358
355
|
factory = self_data->factory;
|
359
356
|
hash = rb_hash_start(0);
|
360
|
-
hash = rgeo_geos_objbase_hash(factory,
|
361
|
-
RGEO_FACTORY_DATA_PTR(factory)->globals->feature_multi_line_string, hash);
|
357
|
+
hash = rgeo_geos_objbase_hash(factory, rgeo_feature_multi_line_string_module, hash);
|
362
358
|
hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
|
363
359
|
return LONG2FIX(rb_hash_end(hash));
|
364
360
|
}
|
@@ -396,7 +392,7 @@ static VALUE method_multi_line_string_coordinates(VALUE self)
|
|
396
392
|
|
397
393
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
398
394
|
self_geom = self_data->geom;
|
399
|
-
|
395
|
+
|
400
396
|
if(self_geom) {
|
401
397
|
zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
|
402
398
|
context = self_data->geos_context;
|
@@ -472,7 +468,7 @@ static VALUE method_multi_polygon_geometry_type(VALUE self)
|
|
472
468
|
result = Qnil;
|
473
469
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
474
470
|
if (self_data->geom) {
|
475
|
-
result =
|
471
|
+
result = rgeo_feature_multi_polygon_module;
|
476
472
|
}
|
477
473
|
return result;
|
478
474
|
}
|
@@ -487,8 +483,7 @@ static VALUE method_multi_polygon_hash(VALUE self)
|
|
487
483
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
488
484
|
factory = self_data->factory;
|
489
485
|
hash = rb_hash_start(0);
|
490
|
-
hash = rgeo_geos_objbase_hash(factory,
|
491
|
-
RGEO_FACTORY_DATA_PTR(factory)->globals->feature_multi_polygon, hash);
|
486
|
+
hash = rgeo_geos_objbase_hash(factory, rgeo_feature_multi_polygon_module, hash);
|
492
487
|
hash = rgeo_geos_geometry_collection_hash(self_data->geos_context, self_data->geom, hash);
|
493
488
|
return LONG2FIX(rb_hash_end(hash));
|
494
489
|
}
|
@@ -508,7 +503,7 @@ static VALUE method_multi_polygon_coordinates(VALUE self)
|
|
508
503
|
|
509
504
|
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
510
505
|
self_geom = self_data->geom;
|
511
|
-
|
506
|
+
|
512
507
|
if(self_geom) {
|
513
508
|
zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
|
514
509
|
context = self_data->geos_context;
|
@@ -586,7 +581,7 @@ static VALUE cmethod_multi_polygon_create(VALUE module, VALUE factory, VALUE arr
|
|
586
581
|
/**** INITIALIZATION FUNCTION ****/
|
587
582
|
|
588
583
|
|
589
|
-
void rgeo_init_geos_geometry_collection(
|
584
|
+
void rgeo_init_geos_geometry_collection()
|
590
585
|
{
|
591
586
|
VALUE geos_geometry_collection_methods;
|
592
587
|
VALUE geos_multi_point_methods;
|
@@ -594,13 +589,13 @@ void rgeo_init_geos_geometry_collection(RGeo_Globals* globals)
|
|
594
589
|
VALUE geos_multi_polygon_methods;
|
595
590
|
|
596
591
|
// Class methods for geometry collection classes
|
597
|
-
rb_define_module_function(
|
598
|
-
rb_define_module_function(
|
599
|
-
rb_define_module_function(
|
600
|
-
rb_define_module_function(
|
592
|
+
rb_define_module_function(rgeo_geos_geometry_collection_class, "create", cmethod_geometry_collection_create, 2);
|
593
|
+
rb_define_module_function(rgeo_geos_multi_point_class, "create", cmethod_multi_point_create, 2);
|
594
|
+
rb_define_module_function(rgeo_geos_multi_line_string_class, "create", cmethod_multi_line_string_create, 2);
|
595
|
+
rb_define_module_function(rgeo_geos_multi_polygon_class, "create", cmethod_multi_polygon_create, 2);
|
601
596
|
|
602
597
|
// Methods for GeometryCollectionImpl
|
603
|
-
geos_geometry_collection_methods = rb_define_module_under(
|
598
|
+
geos_geometry_collection_methods = rb_define_module_under(rgeo_geos_module, "CAPIGeometryCollectionMethods");
|
604
599
|
rb_define_method(geos_geometry_collection_methods, "rep_equals?", method_geometry_collection_eql, 1);
|
605
600
|
rb_define_method(geos_geometry_collection_methods, "eql?", method_geometry_collection_eql, 1);
|
606
601
|
rb_define_method(geos_geometry_collection_methods, "hash", method_geometry_collection_hash, 0);
|
@@ -614,13 +609,13 @@ void rgeo_init_geos_geometry_collection(RGeo_Globals* globals)
|
|
614
609
|
|
615
610
|
|
616
611
|
// Methods for MultiPointImpl
|
617
|
-
geos_multi_point_methods = rb_define_module_under(
|
612
|
+
geos_multi_point_methods = rb_define_module_under(rgeo_geos_module, "CAPIMultiPointMethods");
|
618
613
|
rb_define_method(geos_multi_point_methods, "geometry_type", method_multi_point_geometry_type, 0);
|
619
614
|
rb_define_method(geos_multi_point_methods, "hash", method_multi_point_hash, 0);
|
620
615
|
rb_define_method(geos_multi_point_methods, "coordinates", method_multi_point_coordinates, 0);
|
621
616
|
|
622
617
|
// Methods for MultiLineStringImpl
|
623
|
-
geos_multi_line_string_methods = rb_define_module_under(
|
618
|
+
geos_multi_line_string_methods = rb_define_module_under(rgeo_geos_module, "CAPIMultiLineStringMethods");
|
624
619
|
rb_define_method(geos_multi_line_string_methods, "geometry_type", method_multi_line_string_geometry_type, 0);
|
625
620
|
rb_define_method(geos_multi_line_string_methods, "length", method_multi_line_string_length, 0);
|
626
621
|
rb_define_method(geos_multi_line_string_methods, "closed?", method_multi_line_string_is_closed, 0);
|
@@ -628,7 +623,7 @@ void rgeo_init_geos_geometry_collection(RGeo_Globals* globals)
|
|
628
623
|
rb_define_method(geos_multi_line_string_methods, "coordinates", method_multi_line_string_coordinates, 0);
|
629
624
|
|
630
625
|
// Methods for MultiPolygonImpl
|
631
|
-
geos_multi_polygon_methods = rb_define_module_under(
|
626
|
+
geos_multi_polygon_methods = rb_define_module_under(rgeo_geos_module, "CAPIMultiPolygonMethods");
|
632
627
|
rb_define_method(geos_multi_polygon_methods, "geometry_type", method_multi_polygon_geometry_type, 0);
|
633
628
|
rb_define_method(geos_multi_polygon_methods, "area", method_multi_polygon_area, 0);
|
634
629
|
rb_define_method(geos_multi_polygon_methods, "centroid", method_multi_polygon_centroid, 0);
|
@@ -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,7 +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(
|
19
|
+
void rgeo_init_geos_geometry_collection();
|
22
20
|
|
23
21
|
/*
|
24
22
|
Comopares the contents of two geometry collections. Does not test the
|
@@ -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
|