rgeo 3.0.0.pre.rc.2 → 3.0.0.pre.rc.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/geos_c_impl/analysis.c +26 -23
- 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 +15 -8
- data/ext/geos_c_impl/errors.h +4 -1
- data/ext/geos_c_impl/extconf.rb +40 -30
- data/ext/geos_c_impl/factory.c +367 -387
- data/ext/geos_c_impl/factory.h +59 -48
- data/ext/geos_c_impl/geometry.c +368 -320
- data/ext/geos_c_impl/geometry.h +5 -5
- data/ext/geos_c_impl/geometry_collection.c +256 -183
- data/ext/geos_c_impl/geometry_collection.h +6 -7
- 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 +229 -198
- 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 -63
- data/ext/geos_c_impl/point.h +4 -5
- data/ext/geos_c_impl/polygon.c +116 -84
- data/ext/geos_c_impl/polygon.h +10 -8
- data/ext/geos_c_impl/preface.h +4 -13
- data/ext/geos_c_impl/ruby_more.c +35 -40
- data/ext/geos_c_impl/ruby_more.h +3 -2
- data/lib/rgeo/cartesian/bounding_box.rb +1 -1
- data/lib/rgeo/cartesian/factory.rb +8 -43
- data/lib/rgeo/cartesian/feature_methods.rb +0 -5
- data/lib/rgeo/cartesian/interface.rb +6 -5
- data/lib/rgeo/coord_sys/cs/entities.rb +214 -0
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +15 -8
- data/lib/rgeo/coord_sys.rb +1 -9
- data/lib/rgeo/feature/curve.rb +0 -10
- data/lib/rgeo/feature/factory.rb +1 -9
- data/lib/rgeo/feature/factory_generator.rb +3 -7
- data/lib/rgeo/feature/geometry.rb +0 -10
- data/lib/rgeo/feature/multi_curve.rb +0 -5
- data/lib/rgeo/feature/types.rb +5 -5
- data/lib/rgeo/geographic/factory.rb +9 -42
- data/lib/rgeo/geographic/interface.rb +28 -99
- data/lib/rgeo/geographic/projected_feature_methods.rb +0 -10
- data/lib/rgeo/geographic/projected_window.rb +1 -1
- data/lib/rgeo/geographic/{proj4_projector.rb → projector.rb} +3 -3
- data/lib/rgeo/geographic/simple_mercator_projector.rb +1 -10
- data/lib/rgeo/geographic/spherical_feature_methods.rb +0 -5
- data/lib/rgeo/geographic.rb +1 -1
- data/lib/rgeo/geos/capi_factory.rb +37 -91
- data/lib/rgeo/geos/capi_feature_classes.rb +0 -29
- data/lib/rgeo/geos/ffi_factory.rb +52 -92
- data/lib/rgeo/geos/ffi_feature_methods.rb +1 -31
- data/lib/rgeo/geos/interface.rb +5 -20
- data/lib/rgeo/geos/zm_factory.rb +5 -36
- data/lib/rgeo/geos/zm_feature_methods.rb +1 -26
- data/lib/rgeo/geos.rb +2 -5
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +1 -14
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +1 -19
- data/lib/rgeo/impl_helper/basic_point_methods.rb +0 -10
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +1 -9
- data/lib/rgeo/impl_helper/utils.rb +27 -0
- data/lib/rgeo/impl_helper/validity_check.rb +3 -3
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep/wkb_generator.rb +68 -53
- data/lib/rgeo/wkrep/wkb_parser.rb +19 -16
- data/lib/rgeo/wkrep/wkt_generator.rb +34 -34
- data/lib/rgeo/wkrep/wkt_parser.rb +26 -23
- data/lib/rgeo.rb +1 -3
- metadata +7 -6
@@ -2,31 +2,30 @@
|
|
2
2
|
Geometry collection methods for GEOS wrapper
|
3
3
|
*/
|
4
4
|
|
5
|
-
|
6
5
|
#ifndef RGEO_GEOS_GEOMETRY_COLLECTION_INCLUDED
|
7
6
|
#define RGEO_GEOS_GEOMETRY_COLLECTION_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 geometry collection module. This should be called after
|
17
15
|
the geometry module is initialized.
|
18
16
|
*/
|
19
|
-
void
|
17
|
+
void
|
18
|
+
rgeo_init_geos_geometry_collection();
|
20
19
|
|
21
20
|
/*
|
22
21
|
A tool for building up hash values.
|
23
|
-
You must pass in
|
22
|
+
You must pass in a geos geometry and a seed hash.
|
24
23
|
Returns an updated hash.
|
25
24
|
This call is useful in sequence, and should be bracketed by calls to
|
26
25
|
rb_hash_start and rb_hash_end.
|
27
26
|
*/
|
28
|
-
st_index_t
|
29
|
-
|
27
|
+
st_index_t
|
28
|
+
rgeo_geos_geometry_collection_hash(const GEOSGeometry* geom, st_index_t hash);
|
30
29
|
|
31
30
|
RGEO_END_C
|
32
31
|
|
data/ext/geos_c_impl/globals.c
CHANGED
@@ -2,8 +2,13 @@
|
|
2
2
|
|
3
3
|
#ifdef RGEO_GEOS_SUPPORTED
|
4
4
|
|
5
|
+
#include <ctype.h>
|
6
|
+
#include <geos_c.h>
|
5
7
|
#include <ruby.h>
|
8
|
+
#include <stdarg.h>
|
9
|
+
#include <stdio.h>
|
6
10
|
|
11
|
+
#include "errors.h"
|
7
12
|
#include "globals.h"
|
8
13
|
|
9
14
|
RGEO_BEGIN_C
|
@@ -34,55 +39,128 @@ VALUE rgeo_geos_multi_point_class;
|
|
34
39
|
VALUE rgeo_geos_multi_line_string_class;
|
35
40
|
VALUE rgeo_geos_multi_polygon_class;
|
36
41
|
|
37
|
-
|
42
|
+
// The notice handler is very rarely used by GEOS, only in
|
43
|
+
// GEOSIsValid_r (check for NOTICE_MESSAGE in GEOS codebase).
|
44
|
+
// We still set it to make sure we do not miss any implementation
|
45
|
+
// change. Use `DEBUG=1 rake` to show notice.
|
46
|
+
static void
|
47
|
+
notice_handler(const char* fmt, ...)
|
38
48
|
{
|
49
|
+
#ifdef DEBUG
|
50
|
+
va_list args;
|
51
|
+
va_start(args, fmt);
|
52
|
+
fprintf(stderr, "GEOS Notice -- ");
|
53
|
+
vfprintf(stderr, fmt, args);
|
54
|
+
fprintf(stderr, "\n");
|
55
|
+
va_end(args);
|
56
|
+
#endif
|
57
|
+
}
|
58
|
+
|
59
|
+
static void
|
60
|
+
error_handler(const char* fmt, ...)
|
61
|
+
{
|
62
|
+
// See https://en.cppreference.com/w/c/io/vfprintf
|
63
|
+
va_list args1;
|
64
|
+
va_start(args1, fmt);
|
65
|
+
va_list args2;
|
66
|
+
va_copy(args2, args1);
|
67
|
+
int size = 1 + vsnprintf(NULL, 0, fmt, args1);
|
68
|
+
va_end(args1);
|
69
|
+
char geos_full_error[size];
|
70
|
+
vsnprintf(geos_full_error, sizeof geos_full_error, fmt, args2);
|
71
|
+
va_end(args2);
|
72
|
+
|
73
|
+
// NOTE: strtok is destructive, geos_full_error is not to be used afterwards.
|
74
|
+
char* geos_error = strtok(geos_full_error, ":");
|
75
|
+
char* geos_message = strtok(NULL, ":");
|
76
|
+
while (isspace(*geos_message))
|
77
|
+
geos_message++;
|
78
|
+
|
79
|
+
if (streq(geos_error, "UnsupportedOperationException")) {
|
80
|
+
rb_raise(rb_eRGeoUnsupportedOperation, "%s", geos_message);
|
81
|
+
} else if (streq(geos_error, "IllegalArgumentException")) {
|
82
|
+
rb_raise(rb_eRGeoInvalidGeometry, "%s", geos_message);
|
83
|
+
} else if (streq(geos_error, "ParseException")) {
|
84
|
+
rb_raise(rb_eRGeoParseError, "%s", geos_message);
|
85
|
+
} else if (geos_message) {
|
86
|
+
rb_raise(rb_eGeosError, "%s: %s", geos_error, geos_message);
|
87
|
+
} else {
|
88
|
+
rb_raise(rb_eGeosError, "%s", geos_error);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
void
|
93
|
+
rgeo_init_geos_globals()
|
94
|
+
{
|
95
|
+
initGEOS(notice_handler, error_handler);
|
96
|
+
|
39
97
|
rgeo_module = rb_define_module("RGeo");
|
40
98
|
rb_gc_register_mark_object(rgeo_module);
|
41
99
|
|
42
100
|
rgeo_feature_module = rb_define_module_under(rgeo_module, "Feature");
|
43
101
|
rb_gc_register_mark_object(rgeo_feature_module);
|
44
|
-
rgeo_feature_geometry_module =
|
102
|
+
rgeo_feature_geometry_module =
|
103
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("Geometry"));
|
45
104
|
rb_gc_register_mark_object(rgeo_feature_geometry_module);
|
46
|
-
rgeo_feature_point_module =
|
105
|
+
rgeo_feature_point_module =
|
106
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("Point"));
|
47
107
|
rb_gc_register_mark_object(rgeo_feature_point_module);
|
48
|
-
rgeo_feature_line_string_module =
|
108
|
+
rgeo_feature_line_string_module =
|
109
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("LineString"));
|
49
110
|
rb_gc_register_mark_object(rgeo_feature_line_string_module);
|
50
|
-
rgeo_feature_linear_ring_module =
|
111
|
+
rgeo_feature_linear_ring_module =
|
112
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("LinearRing"));
|
51
113
|
rb_gc_register_mark_object(rgeo_feature_linear_ring_module);
|
52
|
-
rgeo_feature_line_module =
|
114
|
+
rgeo_feature_line_module =
|
115
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("Line"));
|
53
116
|
rb_gc_register_mark_object(rgeo_feature_line_module);
|
54
|
-
rgeo_feature_polygon_module =
|
117
|
+
rgeo_feature_polygon_module =
|
118
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("Polygon"));
|
55
119
|
rb_gc_register_mark_object(rgeo_feature_polygon_module);
|
56
|
-
rgeo_feature_geometry_collection_module =
|
120
|
+
rgeo_feature_geometry_collection_module =
|
121
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("GeometryCollection"));
|
57
122
|
rb_gc_register_mark_object(rgeo_feature_geometry_collection_module);
|
58
|
-
rgeo_feature_multi_point_module =
|
123
|
+
rgeo_feature_multi_point_module =
|
124
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("MultiPoint"));
|
59
125
|
rb_gc_register_mark_object(rgeo_feature_multi_point_module);
|
60
|
-
rgeo_feature_multi_line_string_module =
|
126
|
+
rgeo_feature_multi_line_string_module =
|
127
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("MultiLineString"));
|
61
128
|
rb_gc_register_mark_object(rgeo_feature_multi_line_string_module);
|
62
|
-
rgeo_feature_multi_polygon_module =
|
129
|
+
rgeo_feature_multi_polygon_module =
|
130
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("MultiPolygon"));
|
63
131
|
rb_gc_register_mark_object(rgeo_feature_multi_polygon_module);
|
64
132
|
|
65
133
|
rgeo_geos_module = rb_define_module_under(rgeo_module, "Geos");
|
66
134
|
rb_gc_register_mark_object(rgeo_geos_module);
|
67
|
-
rgeo_geos_geometry_class =
|
135
|
+
rgeo_geos_geometry_class =
|
136
|
+
rb_define_class_under(rgeo_geos_module, "CAPIGeometryImpl", rb_cObject);
|
68
137
|
rb_gc_register_mark_object(rgeo_geos_geometry_class);
|
69
|
-
rgeo_geos_point_class =
|
138
|
+
rgeo_geos_point_class =
|
139
|
+
rb_define_class_under(rgeo_geos_module, "CAPIPointImpl", rb_cObject);
|
70
140
|
rb_gc_register_mark_object(rgeo_geos_point_class);
|
71
|
-
rgeo_geos_line_string_class =
|
141
|
+
rgeo_geos_line_string_class =
|
142
|
+
rb_define_class_under(rgeo_geos_module, "CAPILineStringImpl", rb_cObject);
|
72
143
|
rb_gc_register_mark_object(rgeo_geos_line_string_class);
|
73
|
-
rgeo_geos_linear_ring_class =
|
144
|
+
rgeo_geos_linear_ring_class =
|
145
|
+
rb_define_class_under(rgeo_geos_module, "CAPILinearRingImpl", rb_cObject);
|
74
146
|
rb_gc_register_mark_object(rgeo_geos_linear_ring_class);
|
75
|
-
rgeo_geos_line_class =
|
147
|
+
rgeo_geos_line_class =
|
148
|
+
rb_define_class_under(rgeo_geos_module, "CAPILineImpl", rb_cObject);
|
76
149
|
rb_gc_register_mark_object(rgeo_geos_line_class);
|
77
|
-
rgeo_geos_polygon_class =
|
150
|
+
rgeo_geos_polygon_class =
|
151
|
+
rb_define_class_under(rgeo_geos_module, "CAPIPolygonImpl", rb_cObject);
|
78
152
|
rb_gc_register_mark_object(rgeo_geos_polygon_class);
|
79
|
-
rgeo_geos_geometry_collection_class = rb_define_class_under(
|
153
|
+
rgeo_geos_geometry_collection_class = rb_define_class_under(
|
154
|
+
rgeo_geos_module, "CAPIGeometryCollectionImpl", rb_cObject);
|
80
155
|
rb_gc_register_mark_object(rgeo_geos_geometry_collection_class);
|
81
|
-
rgeo_geos_multi_point_class =
|
156
|
+
rgeo_geos_multi_point_class =
|
157
|
+
rb_define_class_under(rgeo_geos_module, "CAPIMultiPointImpl", rb_cObject);
|
82
158
|
rb_gc_register_mark_object(rgeo_geos_multi_point_class);
|
83
|
-
rgeo_geos_multi_line_string_class = rb_define_class_under(
|
159
|
+
rgeo_geos_multi_line_string_class = rb_define_class_under(
|
160
|
+
rgeo_geos_module, "CAPIMultiLineStringImpl", rb_cObject);
|
84
161
|
rb_gc_register_mark_object(rgeo_geos_multi_line_string_class);
|
85
|
-
rgeo_geos_multi_polygon_class =
|
162
|
+
rgeo_geos_multi_polygon_class =
|
163
|
+
rb_define_class_under(rgeo_geos_module, "CAPIMultiPolygonImpl", rb_cObject);
|
86
164
|
rb_gc_register_mark_object(rgeo_geos_multi_polygon_class);
|
87
165
|
}
|
88
166
|
|
data/ext/geos_c_impl/globals.h
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
#ifndef RGEO_GEOS_GLOBALS_INCLUDED
|
9
9
|
#define RGEO_GEOS_GLOBALS_INCLUDED
|
10
10
|
|
11
|
-
#include <
|
11
|
+
#include <geos_c.h>
|
12
12
|
|
13
13
|
RGEO_BEGIN_C
|
14
14
|
|
@@ -38,7 +38,8 @@ extern VALUE rgeo_geos_multi_point_class;
|
|
38
38
|
extern VALUE rgeo_geos_multi_line_string_class;
|
39
39
|
extern VALUE rgeo_geos_multi_polygon_class;
|
40
40
|
|
41
|
-
void
|
41
|
+
void
|
42
|
+
rgeo_init_geos_globals();
|
42
43
|
|
43
44
|
RGEO_END_C
|
44
45
|
|