rgeo 3.0.0.pre.rc.1 → 3.0.0.pre.rc.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -12
  3. data/ext/geos_c_impl/analysis.c +26 -23
  4. data/ext/geos_c_impl/analysis.h +8 -5
  5. data/ext/geos_c_impl/coordinates.c +27 -21
  6. data/ext/geos_c_impl/coordinates.h +5 -2
  7. data/ext/geos_c_impl/errors.c +15 -8
  8. data/ext/geos_c_impl/errors.h +4 -1
  9. data/ext/geos_c_impl/extconf.rb +40 -30
  10. data/ext/geos_c_impl/factory.c +391 -410
  11. data/ext/geos_c_impl/factory.h +66 -48
  12. data/ext/geos_c_impl/geometry.c +417 -299
  13. data/ext/geos_c_impl/geometry.h +5 -5
  14. data/ext/geos_c_impl/geometry_collection.c +289 -213
  15. data/ext/geos_c_impl/geometry_collection.h +6 -7
  16. data/ext/geos_c_impl/globals.c +99 -21
  17. data/ext/geos_c_impl/globals.h +3 -2
  18. data/ext/geos_c_impl/line_string.c +231 -200
  19. data/ext/geos_c_impl/line_string.h +5 -6
  20. data/ext/geos_c_impl/main.c +8 -9
  21. data/ext/geos_c_impl/point.c +62 -63
  22. data/ext/geos_c_impl/point.h +4 -5
  23. data/ext/geos_c_impl/polygon.c +133 -94
  24. data/ext/geos_c_impl/polygon.h +10 -8
  25. data/ext/geos_c_impl/preface.h +8 -13
  26. data/ext/geos_c_impl/ruby_more.c +60 -0
  27. data/ext/geos_c_impl/ruby_more.h +17 -0
  28. data/lib/rgeo/cartesian/bounding_box.rb +1 -1
  29. data/lib/rgeo/cartesian/factory.rb +14 -50
  30. data/lib/rgeo/cartesian/feature_classes.rb +2 -0
  31. data/lib/rgeo/cartesian/feature_methods.rb +16 -5
  32. data/lib/rgeo/cartesian/interface.rb +6 -35
  33. data/lib/rgeo/coord_sys/cs/entities.rb +214 -0
  34. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +15 -8
  35. data/lib/rgeo/coord_sys.rb +1 -20
  36. data/lib/rgeo/feature/curve.rb +0 -10
  37. data/lib/rgeo/feature/factory.rb +1 -9
  38. data/lib/rgeo/feature/factory_generator.rb +3 -10
  39. data/lib/rgeo/feature/geometry.rb +77 -8
  40. data/lib/rgeo/feature/multi_curve.rb +0 -5
  41. data/lib/rgeo/feature/types.rb +5 -5
  42. data/lib/rgeo/geographic/factory.rb +15 -42
  43. data/lib/rgeo/geographic/interface.rb +28 -127
  44. data/lib/rgeo/geographic/projected_feature_methods.rb +16 -10
  45. data/lib/rgeo/geographic/projected_window.rb +1 -1
  46. data/lib/rgeo/geographic/{proj4_projector.rb → projector.rb} +3 -3
  47. data/lib/rgeo/geographic/simple_mercator_projector.rb +1 -10
  48. data/lib/rgeo/geographic/spherical_feature_methods.rb +17 -6
  49. data/lib/rgeo/geographic.rb +1 -1
  50. data/lib/rgeo/geos/capi_factory.rb +37 -98
  51. data/lib/rgeo/geos/capi_feature_classes.rb +15 -25
  52. data/lib/rgeo/geos/ffi_factory.rb +58 -99
  53. data/lib/rgeo/geos/ffi_feature_methods.rb +15 -29
  54. data/lib/rgeo/geos/interface.rb +5 -37
  55. data/lib/rgeo/geos/zm_factory.rb +5 -43
  56. data/lib/rgeo/geos/zm_feature_methods.rb +15 -24
  57. data/lib/rgeo/geos.rb +8 -8
  58. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +1 -14
  59. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +1 -19
  60. data/lib/rgeo/impl_helper/basic_point_methods.rb +0 -10
  61. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +1 -9
  62. data/lib/rgeo/impl_helper/utils.rb +27 -0
  63. data/lib/rgeo/impl_helper/validity_check.rb +6 -5
  64. data/lib/rgeo/version.rb +1 -1
  65. data/lib/rgeo/wkrep/wkb_generator.rb +68 -53
  66. data/lib/rgeo/wkrep/wkb_parser.rb +19 -16
  67. data/lib/rgeo/wkrep/wkt_generator.rb +34 -34
  68. data/lib/rgeo/wkrep/wkt_parser.rb +26 -23
  69. data/lib/rgeo.rb +1 -3
  70. metadata +23 -9
  71. data/lib/rgeo/coord_sys/srs_database/entry.rb +0 -107
  72. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +0 -64
  73. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +0 -65
@@ -5,19 +5,19 @@
5
5
  #ifndef RGEO_GEOS_FACTORY_INCLUDED
6
6
  #define RGEO_GEOS_FACTORY_INCLUDED
7
7
 
8
- #include <ruby.h>
9
8
  #include <geos_c.h>
9
+ #include <ruby.h>
10
10
 
11
11
  RGEO_BEGIN_C
12
12
 
13
13
  /*
14
14
  Wrapped structure for Factory objects.
15
- A factory encapsulates the GEOS context, and GEOS serializer settings.
15
+ A factory encapsulates GEOS serializer settings.
16
16
  It also stores the SRID for all geometries created by this factory,
17
17
  and the resolution for buffers created for this factory's geometries.
18
18
  */
19
- typedef struct {
20
- GEOSContextHandle_t geos_context;
19
+ typedef struct
20
+ {
21
21
  GEOSWKTReader* wkt_reader;
22
22
  GEOSWKBReader* wkb_reader;
23
23
  GEOSWKTWriter* wkt_writer;
@@ -30,7 +30,6 @@ typedef struct {
30
30
  GEOSWKBReader* marshal_wkb_reader;
31
31
  GEOSWKTWriter* psych_wkt_writer;
32
32
  GEOSWKBWriter* marshal_wkb_writer;
33
- VALUE proj4_obj;
34
33
  VALUE coord_sys_obj;
35
34
  int flags;
36
35
  int srid;
@@ -42,30 +41,35 @@ typedef struct {
42
41
  They are available in ruby under RGeo::Geos::CAPIFactory::FLAG_name
43
42
  where name is the name below without the RGEO_FACTORYFLAGS_ prefix.
44
43
  */
45
- #define RGEO_FACTORYFLAGS_SUPPORTS_Z 0b0010
46
- #define RGEO_FACTORYFLAGS_SUPPORTS_M 0b0100
47
- #define RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M (RGEO_FACTORYFLAGS_SUPPORTS_Z | RGEO_FACTORYFLAGS_SUPPORTS_M)
48
- #define RGEO_FACTORYFLAGS_PREPARE_HEURISTIC 0b1000
44
+ #define RGEO_FACTORYFLAGS_SUPPORTS_Z 0b0010
45
+ #define RGEO_FACTORYFLAGS_SUPPORTS_M 0b0100
46
+ #define RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M \
47
+ (RGEO_FACTORYFLAGS_SUPPORTS_Z | RGEO_FACTORYFLAGS_SUPPORTS_M)
48
+ #define RGEO_FACTORYFLAGS_PREPARE_HEURISTIC 0b1000
49
49
 
50
50
  /* call-seq:
51
51
  * RGeo::Geos::CAPIFactory.supports_z? -> true or false
52
52
  */
53
- VALUE method_factory_supports_z_p(VALUE self);
53
+ VALUE
54
+ method_factory_supports_z_p(VALUE self);
54
55
 
55
56
  /* call-seq:
56
57
  * RGeo::Geos::CAPIFactory.supports_m? -> true or false
57
58
  */
58
- VALUE method_factory_supports_m_p(VALUE self);
59
+ VALUE
60
+ method_factory_supports_m_p(VALUE self);
59
61
 
60
62
  /* call-seq:
61
63
  * RGeo::Geos::CAPIFactory.supports_z_or_m? -> true or false
62
64
  */
63
- VALUE method_factory_supports_z_or_m_p(VALUE self);
65
+ VALUE
66
+ method_factory_supports_z_or_m_p(VALUE self);
64
67
 
65
68
  /* call-seq:
66
69
  * RGeo::Geos::CAPIFactory.prepare_heuristic? -> true or false
67
70
  */
68
- VALUE method_factory_prepare_heuristic_p(VALUE self);
71
+ VALUE
72
+ method_factory_prepare_heuristic_p(VALUE self);
69
73
 
70
74
  /*
71
75
  Wrapped structure for Geometry objects.
@@ -80,47 +84,44 @@ VALUE method_factory_prepare_heuristic_p(VALUE self);
80
84
  in Line objects, which have no GEOS type). Any array element, or the
81
85
  array itself, could be Qnil, indicating fall back to the default
82
86
  inferred from the GEOS type.
83
-
84
- The GEOS context handle is also included here. Ideally, it would be
85
- available by following the factory reference and getting it from the
86
- factory data. However, one use case is in the destroy_geometry_func
87
- in factory.c, and Rubinius 1.1.1 seems to crash when you try to
88
- evaluate a DATA_PTR from that function, so we copy the context handle
89
- here so the destroy_geometry_func can get to it.
90
87
  */
91
- typedef struct {
92
- GEOSContextHandle_t geos_context;
88
+ typedef struct
89
+ {
93
90
  GEOSGeometry* geom;
94
91
  const GEOSPreparedGeometry* prep;
95
92
  VALUE factory;
96
93
  VALUE klasses;
97
94
  } RGeo_GeometryData;
98
95
 
99
-
100
96
  // Data types which indicate how RGeo types should be managed by Ruby.
101
97
  extern const rb_data_type_t rgeo_factory_type;
102
98
 
103
99
  extern const rb_data_type_t rgeo_geometry_type;
104
100
 
105
-
106
101
  // Convenient macros for checking the type of data from Ruby
107
- #define RGEO_FACTORY_TYPEDDATA_P(object) (_RGEO_TYPEDDATA_P(object, &rgeo_factory_type))
108
- #define RGEO_GEOMETRY_TYPEDDATA_P(object) (_RGEO_TYPEDDATA_P(object, &rgeo_geometry_type))
102
+ #define RGEO_FACTORY_TYPEDDATA_P(object) \
103
+ (_RGEO_TYPEDDATA_P(object, &rgeo_factory_type))
104
+ #define RGEO_GEOMETRY_TYPEDDATA_P(object) \
105
+ (_RGEO_TYPEDDATA_P(object, &rgeo_geometry_type))
109
106
 
110
- #define _RGEO_TYPEDDATA_P(object, data_type) (TYPE(object) == T_DATA && RTYPEDDATA(object)->typed_flag == 1 && RTYPEDDATA(object)->type == data_type)
107
+ #define _RGEO_TYPEDDATA_P(object, data_type) \
108
+ (TYPE(object) == T_DATA && RTYPEDDATA(object)->typed_flag == 1 && \
109
+ RTYPEDDATA(object)->type == data_type)
111
110
 
112
111
  // Returns the RGeo_FactoryData* given a ruby Factory object
113
- #define RGEO_FACTORY_DATA_PTR(factory) ((RGeo_FactoryData*)RTYPEDDATA_DATA(factory))
112
+ #define RGEO_FACTORY_DATA_PTR(factory) \
113
+ ((RGeo_FactoryData*)RTYPEDDATA_DATA(factory))
114
114
 
115
115
  // Returns the RGeo_GeometryData* given a ruby Geometry object
116
- #define RGEO_GEOMETRY_DATA_PTR(geometry) ((RGeo_GeometryData*)RTYPEDDATA_DATA(geometry))
117
-
116
+ #define RGEO_GEOMETRY_DATA_PTR(geometry) \
117
+ ((RGeo_GeometryData*)RTYPEDDATA_DATA(geometry))
118
118
 
119
119
  /*
120
120
  Initializes the factory module. This should be called first in the
121
121
  initialization process.
122
122
  */
123
- void rgeo_init_geos_factory();
123
+ void
124
+ rgeo_init_geos_factory();
124
125
 
125
126
  /*
126
127
  Given a GEOS geometry handle, wraps it in a ruby Geometry object of the
@@ -134,13 +135,17 @@ void rgeo_init_geos_factory();
134
135
  classes for the elements of the collection.
135
136
  Returns Qnil if the wrapping failed for any reason.
136
137
  */
137
- VALUE rgeo_wrap_geos_geometry(VALUE factory, GEOSGeometry* geom, VALUE klass);
138
+ VALUE
139
+ rgeo_wrap_geos_geometry(VALUE factory, GEOSGeometry* geom, VALUE klass);
138
140
 
139
141
  /*
140
142
  Same as rgeo_wrap_geos_geometry except that it wraps a clone of the
141
143
  given geom, so the original geom doesn't change ownership.
142
144
  */
143
- VALUE rgeo_wrap_geos_geometry_clone(VALUE factory, const GEOSGeometry* geom, VALUE klass);
145
+ VALUE
146
+ rgeo_wrap_geos_geometry_clone(VALUE factory,
147
+ const GEOSGeometry* geom,
148
+ VALUE klass);
144
149
 
145
150
  /*
146
151
  Gets the GEOS geometry for a given ruby Geometry object. If the given
@@ -150,7 +155,8 @@ VALUE rgeo_wrap_geos_geometry_clone(VALUE factory, const GEOSGeometry* geom, VAL
150
155
  disables this auto-cast. The returned GEOS geometry is owned by rgeo,
151
156
  and you should not dispose it or take ownership of it yourself.
152
157
  */
153
- const GEOSGeometry* rgeo_convert_to_geos_geometry(VALUE factory, VALUE obj, VALUE type);
158
+ const GEOSGeometry*
159
+ rgeo_convert_to_geos_geometry(VALUE factory, VALUE obj, VALUE type);
154
160
 
155
161
  /*
156
162
  Gets a GEOS geometry for a given ruby Geometry object. You must provide
@@ -167,41 +173,58 @@ const GEOSGeometry* rgeo_convert_to_geos_geometry(VALUE factory, VALUE obj, VALU
167
173
  result of this function to build a GEOS-backed clone of the original
168
174
  geometry, or to include the given geometry in a collection while keeping
169
175
  the klasses intact.
176
+
177
+ The state parameter is given to follow `rb_protect*` ruby methods: this
178
+ method calls `#cast`, and this call may raise. if it does raise, state
179
+ will be set to a non-zero value, and you'll have access to the error
180
+ in `rb_errinfo()`. IT IS THE CALLER'S RESPONSIBILITY TO PROPAGATE THE
181
+ ERROR. You could also discard the error with `rb_set_errinfo(Qnil)`,
182
+ this will just ignore the error altogether.
170
183
  */
171
- GEOSGeometry* rgeo_convert_to_detached_geos_geometry(VALUE obj, VALUE factory, VALUE type, VALUE* klasses);
184
+ GEOSGeometry*
185
+ rgeo_convert_to_detached_geos_geometry(VALUE obj,
186
+ VALUE factory,
187
+ VALUE type,
188
+ VALUE* klasses,
189
+ int* state);
172
190
 
173
191
  /*
174
192
  Returns 1 if the given ruby object is a GEOS Geometry implementation,
175
193
  or 0 if not.
176
194
  */
177
- char rgeo_is_geos_object(VALUE obj);
195
+ char
196
+ rgeo_is_geos_object(VALUE obj);
178
197
 
179
198
  /*
180
199
  Raises a rgeo error if the object is not a GEOS Geometry implementation.
181
200
  */
182
- void rgeo_check_geos_object(VALUE obj);
201
+ void
202
+ rgeo_check_geos_object(VALUE obj);
183
203
 
184
204
  /*
185
205
  Gets the underlying GEOS geometry for a given ruby object. Returns NULL
186
206
  if the given ruby object is not a GEOS geometry wrapper.
187
207
  */
188
- const GEOSGeometry* rgeo_get_geos_geometry_safe(VALUE obj);
208
+ const GEOSGeometry*
209
+ rgeo_get_geos_geometry_safe(VALUE obj);
189
210
 
190
211
  /*
191
212
  Compares the ruby classes and geometry factories of the two given ruby
192
213
  objects. Returns Qtrue if everything is equal (that is, the two objects
193
214
  are of the same type and factory), or Qfalse otherwise.
194
215
  */
195
- VALUE rgeo_geos_klasses_and_factories_eql(VALUE obj1, VALUE obj2);
216
+ VALUE
217
+ rgeo_geos_klasses_and_factories_eql(VALUE obj1, VALUE obj2);
196
218
 
197
219
  /*
198
220
  A tool for building up hash values.
199
- You must pass in the context, a geos geometry, and a seed hash.
221
+ You must pass a geos geometry and a seed hash.
200
222
  Returns an updated hash.
201
223
  This call is useful in sequence, and should be bracketed by calls to
202
224
  rb_hash_start and rb_hash_end.
203
225
  */
204
- st_index_t rgeo_geos_coordseq_hash(GEOSContextHandle_t context, const GEOSGeometry* geom, st_index_t hash);
226
+ st_index_t
227
+ rgeo_geos_coordseq_hash(const GEOSGeometry* geom, st_index_t hash);
205
228
 
206
229
  /*
207
230
  A tool for building up hash values.
@@ -210,13 +233,8 @@ st_index_t rgeo_geos_coordseq_hash(GEOSContextHandle_t context, const GEOSGeomet
210
233
  This call is useful in sequence, and should be bracketed by calls to
211
234
  rb_hash_start and rb_hash_end.
212
235
  */
213
- st_index_t rgeo_geos_objbase_hash(VALUE factory, VALUE type_module, st_index_t hash);
214
-
215
- /*
216
- Internal tool for creating simple (FNV-1A 32 bit) hashes.
217
- */
218
- st_index_t rgeo_internal_memhash(const void* ptr, long len);
219
-
236
+ st_index_t
237
+ rgeo_geos_objbase_hash(VALUE factory, VALUE type_module, st_index_t hash);
220
238
 
221
239
  RGEO_END_C
222
240