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,44 +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>
|
11
|
-
|
12
|
-
#include "factory.h"
|
9
|
+
#include <ruby.h>
|
13
10
|
|
14
11
|
RGEO_BEGIN_C
|
15
12
|
|
16
|
-
|
17
13
|
/*
|
18
14
|
Initializes the geometry collection module. This should be called after
|
19
15
|
the geometry module is initialized.
|
20
16
|
*/
|
21
|
-
void
|
22
|
-
|
23
|
-
/*
|
24
|
-
Comopares the contents of two geometry collections. Does not test the
|
25
|
-
types of the collections themselves, but tests the types, values, and
|
26
|
-
contents of all the contents. The two given geometries MUST be
|
27
|
-
collection types-- i.e. GeometryCollection, MultiPoint, MultiLineString,
|
28
|
-
or MultiPolygon.
|
29
|
-
Returns Qtrue if the contents of the two geometry collections are equal,
|
30
|
-
Qfalse if they are inequal, or Qnil if an error occurs.
|
31
|
-
*/
|
32
|
-
VALUE rgeo_geos_geometry_collections_eql(GEOSContextHandle_t context, const GEOSGeometry* geom1, const GEOSGeometry* geom2, char check_z);
|
17
|
+
void
|
18
|
+
rgeo_init_geos_geometry_collection();
|
33
19
|
|
34
20
|
/*
|
35
21
|
A tool for building up hash values.
|
36
|
-
You must pass in
|
22
|
+
You must pass in a geos geometry and a seed hash.
|
37
23
|
Returns an updated hash.
|
38
24
|
This call is useful in sequence, and should be bracketed by calls to
|
39
25
|
rb_hash_start and rb_hash_end.
|
40
26
|
*/
|
41
|
-
st_index_t
|
42
|
-
|
27
|
+
st_index_t
|
28
|
+
rgeo_geos_geometry_collection_hash(const GEOSGeometry* geom, st_index_t hash);
|
43
29
|
|
44
30
|
RGEO_END_C
|
45
31
|
|
@@ -0,0 +1,169 @@
|
|
1
|
+
#include "preface.h"
|
2
|
+
|
3
|
+
#ifdef RGEO_GEOS_SUPPORTED
|
4
|
+
|
5
|
+
#include <ctype.h>
|
6
|
+
#include <geos_c.h>
|
7
|
+
#include <ruby.h>
|
8
|
+
#include <stdarg.h>
|
9
|
+
#include <stdio.h>
|
10
|
+
|
11
|
+
#include "errors.h"
|
12
|
+
#include "globals.h"
|
13
|
+
|
14
|
+
RGEO_BEGIN_C
|
15
|
+
|
16
|
+
VALUE rgeo_module;
|
17
|
+
|
18
|
+
VALUE rgeo_feature_module;
|
19
|
+
VALUE rgeo_feature_geometry_module;
|
20
|
+
VALUE rgeo_feature_point_module;
|
21
|
+
VALUE rgeo_feature_line_string_module;
|
22
|
+
VALUE rgeo_feature_linear_ring_module;
|
23
|
+
VALUE rgeo_feature_line_module;
|
24
|
+
VALUE rgeo_feature_polygon_module;
|
25
|
+
VALUE rgeo_feature_geometry_collection_module;
|
26
|
+
VALUE rgeo_feature_multi_point_module;
|
27
|
+
VALUE rgeo_feature_multi_line_string_module;
|
28
|
+
VALUE rgeo_feature_multi_polygon_module;
|
29
|
+
|
30
|
+
VALUE rgeo_geos_module;
|
31
|
+
VALUE rgeo_geos_geometry_class;
|
32
|
+
VALUE rgeo_geos_point_class;
|
33
|
+
VALUE rgeo_geos_line_string_class;
|
34
|
+
VALUE rgeo_geos_linear_ring_class;
|
35
|
+
VALUE rgeo_geos_line_class;
|
36
|
+
VALUE rgeo_geos_polygon_class;
|
37
|
+
VALUE rgeo_geos_geometry_collection_class;
|
38
|
+
VALUE rgeo_geos_multi_point_class;
|
39
|
+
VALUE rgeo_geos_multi_line_string_class;
|
40
|
+
VALUE rgeo_geos_multi_polygon_class;
|
41
|
+
|
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, ...)
|
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
|
+
|
97
|
+
rgeo_module = rb_define_module("RGeo");
|
98
|
+
rb_gc_register_mark_object(rgeo_module);
|
99
|
+
|
100
|
+
rgeo_feature_module = rb_define_module_under(rgeo_module, "Feature");
|
101
|
+
rb_gc_register_mark_object(rgeo_feature_module);
|
102
|
+
rgeo_feature_geometry_module =
|
103
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("Geometry"));
|
104
|
+
rb_gc_register_mark_object(rgeo_feature_geometry_module);
|
105
|
+
rgeo_feature_point_module =
|
106
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("Point"));
|
107
|
+
rb_gc_register_mark_object(rgeo_feature_point_module);
|
108
|
+
rgeo_feature_line_string_module =
|
109
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("LineString"));
|
110
|
+
rb_gc_register_mark_object(rgeo_feature_line_string_module);
|
111
|
+
rgeo_feature_linear_ring_module =
|
112
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("LinearRing"));
|
113
|
+
rb_gc_register_mark_object(rgeo_feature_linear_ring_module);
|
114
|
+
rgeo_feature_line_module =
|
115
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("Line"));
|
116
|
+
rb_gc_register_mark_object(rgeo_feature_line_module);
|
117
|
+
rgeo_feature_polygon_module =
|
118
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("Polygon"));
|
119
|
+
rb_gc_register_mark_object(rgeo_feature_polygon_module);
|
120
|
+
rgeo_feature_geometry_collection_module =
|
121
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("GeometryCollection"));
|
122
|
+
rb_gc_register_mark_object(rgeo_feature_geometry_collection_module);
|
123
|
+
rgeo_feature_multi_point_module =
|
124
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("MultiPoint"));
|
125
|
+
rb_gc_register_mark_object(rgeo_feature_multi_point_module);
|
126
|
+
rgeo_feature_multi_line_string_module =
|
127
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("MultiLineString"));
|
128
|
+
rb_gc_register_mark_object(rgeo_feature_multi_line_string_module);
|
129
|
+
rgeo_feature_multi_polygon_module =
|
130
|
+
rb_const_get_at(rgeo_feature_module, rb_intern("MultiPolygon"));
|
131
|
+
rb_gc_register_mark_object(rgeo_feature_multi_polygon_module);
|
132
|
+
|
133
|
+
rgeo_geos_module = rb_define_module_under(rgeo_module, "Geos");
|
134
|
+
rb_gc_register_mark_object(rgeo_geos_module);
|
135
|
+
rgeo_geos_geometry_class =
|
136
|
+
rb_define_class_under(rgeo_geos_module, "CAPIGeometryImpl", rb_cObject);
|
137
|
+
rb_gc_register_mark_object(rgeo_geos_geometry_class);
|
138
|
+
rgeo_geos_point_class =
|
139
|
+
rb_define_class_under(rgeo_geos_module, "CAPIPointImpl", rb_cObject);
|
140
|
+
rb_gc_register_mark_object(rgeo_geos_point_class);
|
141
|
+
rgeo_geos_line_string_class =
|
142
|
+
rb_define_class_under(rgeo_geos_module, "CAPILineStringImpl", rb_cObject);
|
143
|
+
rb_gc_register_mark_object(rgeo_geos_line_string_class);
|
144
|
+
rgeo_geos_linear_ring_class =
|
145
|
+
rb_define_class_under(rgeo_geos_module, "CAPILinearRingImpl", rb_cObject);
|
146
|
+
rb_gc_register_mark_object(rgeo_geos_linear_ring_class);
|
147
|
+
rgeo_geos_line_class =
|
148
|
+
rb_define_class_under(rgeo_geos_module, "CAPILineImpl", rb_cObject);
|
149
|
+
rb_gc_register_mark_object(rgeo_geos_line_class);
|
150
|
+
rgeo_geos_polygon_class =
|
151
|
+
rb_define_class_under(rgeo_geos_module, "CAPIPolygonImpl", rb_cObject);
|
152
|
+
rb_gc_register_mark_object(rgeo_geos_polygon_class);
|
153
|
+
rgeo_geos_geometry_collection_class = rb_define_class_under(
|
154
|
+
rgeo_geos_module, "CAPIGeometryCollectionImpl", rb_cObject);
|
155
|
+
rb_gc_register_mark_object(rgeo_geos_geometry_collection_class);
|
156
|
+
rgeo_geos_multi_point_class =
|
157
|
+
rb_define_class_under(rgeo_geos_module, "CAPIMultiPointImpl", rb_cObject);
|
158
|
+
rb_gc_register_mark_object(rgeo_geos_multi_point_class);
|
159
|
+
rgeo_geos_multi_line_string_class = rb_define_class_under(
|
160
|
+
rgeo_geos_module, "CAPIMultiLineStringImpl", rb_cObject);
|
161
|
+
rb_gc_register_mark_object(rgeo_geos_multi_line_string_class);
|
162
|
+
rgeo_geos_multi_polygon_class =
|
163
|
+
rb_define_class_under(rgeo_geos_module, "CAPIMultiPolygonImpl", rb_cObject);
|
164
|
+
rb_gc_register_mark_object(rgeo_geos_multi_polygon_class);
|
165
|
+
}
|
166
|
+
|
167
|
+
RGEO_END_C
|
168
|
+
|
169
|
+
#endif
|
@@ -0,0 +1,46 @@
|
|
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 <geos_c.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
|
42
|
+
rgeo_init_geos_globals();
|
43
|
+
|
44
|
+
RGEO_END_C
|
45
|
+
|
46
|
+
#endif
|