rgeo-proj4 4.0.0.pre.rc.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0a179679b6f6471a9626bf6fbc08758a52b0d60f5ba81fa4ab5119456680470
4
- data.tar.gz: 2a58dfbbf870d24ea9d4b2880444c1f331ba184dc38862af6b4347fb9cc96366
3
+ metadata.gz: 62f388f5389751fb4be6fd44e37b436c2a3465dc407346cb8c311c839af0e35f
4
+ data.tar.gz: 259d631dcf07572b4a99de70cef87156ea880bc2db54aeaea9cf6db4530772ed
5
5
  SHA512:
6
- metadata.gz: a3f86ad3fd2ef994a74ebf0df1f6f4d87446f7a28055417d551822ed88384893f74e20d6803200083f129fe152170ae3d887b50769a5861391b3c0447d83c7a5
7
- data.tar.gz: b41045b6502bd6172632021e942da3214b9de534ffd1461bb4969813c3fbcd60a8c0c7f3074c692609380f1179a1c9b600b99bba9a0c3a3f620ad99a8226b618
6
+ metadata.gz: c48f8cb2676bbc08309a6c103b7df1c7f121e586b300357bc278bccc3dcdfb72f597b9e89bf11603a749a329910685ee93adf719ab4f47db7b3676a9290911ac
7
+ data.tar.gz: 623d1af171edc6e69bc1d8967d9b9262f2a96dd560fcaa6cc5982be75d1e4d4177957255fd28895230c4645cc1ed778a0f77354d3b0b30d031cda8d9bc984687
@@ -20,8 +20,10 @@ void rgeo_init_proj_errors() {
20
20
 
21
21
  rgeo_module = rb_define_module("RGeo");
22
22
  error_module = rb_define_module_under(rgeo_module, "Error");
23
- rb_eRGeoError = rb_define_class_under(error_module, "RGeoError", rb_eRuntimeError);
24
- rb_eRGeoInvalidProjectionError = rb_define_class_under(error_module, "InvalidProjection", rb_eRGeoError);
23
+ rb_eRGeoError =
24
+ rb_define_class_under(error_module, "RGeoError", rb_eRuntimeError);
25
+ rb_eRGeoInvalidProjectionError =
26
+ rb_define_class_under(error_module, "InvalidProjection", rb_eRGeoError);
25
27
  }
26
28
 
27
29
  RGEO_END_C
@@ -12,6 +12,17 @@ else
12
12
 
13
13
  require "mkmf"
14
14
 
15
+ if ENV.key?("DEBUG") || ENV.key?("MAINTAINER_MODE")
16
+ $CFLAGS << " -DDEBUG" \
17
+ " -Wall" \
18
+ " -ggdb" \
19
+ " -pedantic" \
20
+ " -std=c17"
21
+
22
+ extra_flags = ENV.fetch("MAINTAINER_MODE", ENV.fetch("DEBUG", ""))
23
+ $CFLAGS << " " << extra_flags if extra_flags.strip.start_with?("-")
24
+ end
25
+
15
26
  header_dirs =
16
27
  [
17
28
  ::RbConfig::CONFIG["includedir"],
@@ -6,16 +6,14 @@
6
6
 
7
7
  #ifdef RGEO_PROJ4_SUPPORTED
8
8
 
9
- #include <ruby.h>
10
- #include <proj.h>
11
9
  #include "errors.h"
10
+ #include <proj.h>
11
+ #include <ruby.h>
12
12
 
13
13
  #endif
14
14
 
15
-
16
15
  RGEO_BEGIN_C
17
16
 
18
-
19
17
  #ifdef RGEO_PROJ4_SUPPORTED
20
18
 
21
19
  #if PROJ_VERSION_MAJOR == 6 && PROJ_VERSION_MINOR < 3
@@ -34,72 +32,63 @@ typedef struct {
34
32
  PJ *crs_to_crs;
35
33
  } RGeo_CRSToCRSData;
36
34
 
37
-
38
35
  // Destroy function for proj data.
39
- static void rgeo_proj4_free(void *ptr)
40
- {
36
+ static void rgeo_proj4_free(void *ptr) {
41
37
  RGeo_Proj4Data *data = (RGeo_Proj4Data *)ptr;
42
- if (data->pj){
38
+ if (data->pj) {
43
39
  proj_destroy(data->pj);
44
40
  }
45
- free(data);
41
+ FREE(data);
46
42
  }
47
43
 
48
44
  // Destroy function for crs_to_crs data.
49
- static void rgeo_crs_to_crs_free(void *ptr)
50
- {
45
+ static void rgeo_crs_to_crs_free(void *ptr) {
51
46
  RGeo_CRSToCRSData *data = (RGeo_CRSToCRSData *)ptr;
52
- if (data->crs_to_crs){
47
+ if (data->crs_to_crs) {
53
48
  proj_destroy(data->crs_to_crs);
54
49
  }
55
- free(data);
50
+ FREE(data);
56
51
  }
57
52
 
58
-
59
- static size_t rgeo_proj4_memsize(const void *ptr)
60
- {
53
+ static size_t rgeo_proj4_memsize(const void *ptr) {
61
54
  size_t size = 0;
62
55
  const RGeo_Proj4Data *data = (const RGeo_Proj4Data *)ptr;
63
56
 
64
57
  size += sizeof(*data);
65
- if (data->pj){
58
+ if (data->pj) {
66
59
  size += sizeof(data->pj);
67
60
  }
68
61
  return size;
69
62
  }
70
63
 
71
- static size_t rgeo_crs_to_crs_memsize(const void *ptr)
72
- {
64
+ static size_t rgeo_crs_to_crs_memsize(const void *ptr) {
73
65
  size_t size = 0;
74
66
  const RGeo_CRSToCRSData *data = (const RGeo_CRSToCRSData *)ptr;
75
67
  size += sizeof(*data);
76
- if (data->crs_to_crs){
68
+ if (data->crs_to_crs) {
77
69
  size += sizeof(data->crs_to_crs);
78
70
  }
79
71
  return size;
80
72
  }
81
73
 
82
- static void rgeo_proj4_mark(void *ptr)
83
- {
74
+ static void rgeo_proj4_mark(void *ptr) {
84
75
  RGeo_Proj4Data *data = (RGeo_Proj4Data *)ptr;
85
- if (!NIL_P(data->original_str)){
76
+ if (!NIL_P(data->original_str)) {
86
77
  mark(data->original_str);
87
78
  }
88
79
  }
89
80
 
90
81
  #ifdef HAVE_RB_GC_MARK_MOVABLE
91
- static void rgeo_proj4_compact(void *ptr)
92
- {
82
+ static void rgeo_proj4_compact(void *ptr) {
93
83
  RGeo_Proj4Data *data = (RGeo_Proj4Data *)ptr;
94
- if (data && !NIL_P(data->original_str)){
84
+ if (data && !NIL_P(data->original_str)) {
95
85
  data->original_str = rb_gc_location(data->original_str);
96
86
  }
97
87
  }
98
88
  #endif
99
89
 
100
- static void rgeo_proj4_clear_struct(RGeo_Proj4Data *data)
101
- {
102
- if (data->pj){
90
+ static void rgeo_proj4_clear_struct(RGeo_Proj4Data *data) {
91
+ if (data->pj) {
103
92
  proj_destroy(data->pj);
104
93
  data->pj = NULL;
105
94
  data->original_str = Qnil;
@@ -110,26 +99,27 @@ static const rb_data_type_t rgeo_proj4_data_type = {
110
99
  "RGeo::CoordSys::Proj4",
111
100
  {rgeo_proj4_mark, rgeo_proj4_free, rgeo_proj4_memsize,
112
101
  #ifdef HAVE_RB_GC_MARK_MOVABLE
113
- rgeo_proj4_compact
102
+ rgeo_proj4_compact
114
103
  #endif
115
104
  },
116
- 0, 0,
105
+ 0,
106
+ 0,
117
107
  RUBY_TYPED_FREE_IMMEDIATELY};
118
108
 
119
109
  static const rb_data_type_t rgeo_crs_to_crs_data_type = {
120
110
  "RGeo::CoordSys::CRSToCRS",
121
111
  {0, rgeo_crs_to_crs_free, rgeo_crs_to_crs_memsize},
122
- 0, 0,
112
+ 0,
113
+ 0,
123
114
  RUBY_TYPED_FREE_IMMEDIATELY};
124
115
 
125
- static VALUE rgeo_proj4_data_alloc(VALUE self)
126
- {
116
+ static VALUE rgeo_proj4_data_alloc(VALUE self) {
127
117
  VALUE result;
128
118
  RGeo_Proj4Data *data = ALLOC(RGeo_Proj4Data);
129
119
 
130
120
  result = Qnil;
131
121
 
132
- if (data){
122
+ if (data) {
133
123
  data->pj = NULL;
134
124
  data->original_str = Qnil;
135
125
  data->uses_radians = 0;
@@ -138,26 +128,23 @@ static VALUE rgeo_proj4_data_alloc(VALUE self)
138
128
  return result;
139
129
  }
140
130
 
141
-
142
- static VALUE rgeo_crs_to_crs_data_alloc(VALUE self)
143
- {
131
+ static VALUE rgeo_crs_to_crs_data_alloc(VALUE self) {
144
132
  VALUE result;
145
133
  RGeo_CRSToCRSData *data = ALLOC(RGeo_CRSToCRSData);
146
134
 
147
135
  result = Qnil;
148
136
 
149
- if (data){
137
+ if (data) {
150
138
  data->crs_to_crs = NULL;
151
139
  result = TypedData_Wrap_Struct(self, &rgeo_crs_to_crs_data_type, data);
152
140
  }
153
141
  return result;
154
142
  }
155
143
 
156
- static VALUE method_proj4_initialize_copy(VALUE self, VALUE orig)
157
- {
144
+ static VALUE method_proj4_initialize_copy(VALUE self, VALUE orig) {
158
145
  RGeo_Proj4Data *self_data;
159
146
  RGeo_Proj4Data *orig_data;
160
- const char* str;
147
+ const char *str;
161
148
 
162
149
  // Clear out any existing value
163
150
  TypedData_Get_Struct(self, RGeo_Proj4Data, &rgeo_proj4_data_type, self_data);
@@ -166,9 +153,9 @@ static VALUE method_proj4_initialize_copy(VALUE self, VALUE orig)
166
153
  // Copy value from orig
167
154
  TypedData_Get_Struct(orig, RGeo_Proj4Data, &rgeo_proj4_data_type, orig_data);
168
155
  if (!NIL_P(orig_data->original_str)) {
169
- self_data->pj = proj_create(PJ_DEFAULT_CTX, StringValuePtr(orig_data->original_str));
170
- }
171
- else {
156
+ self_data->pj =
157
+ proj_create(PJ_DEFAULT_CTX, StringValuePtr(orig_data->original_str));
158
+ } else {
172
159
  str = proj_as_proj_string(PJ_DEFAULT_CTX, orig_data->pj, PJ_PROJ_4, NULL);
173
160
  self_data->pj = proj_create(PJ_DEFAULT_CTX, str);
174
161
  }
@@ -178,9 +165,7 @@ static VALUE method_proj4_initialize_copy(VALUE self, VALUE orig)
178
165
  return self;
179
166
  }
180
167
 
181
-
182
- static VALUE method_proj4_set_value(VALUE self, VALUE str, VALUE uses_radians)
183
- {
168
+ static VALUE method_proj4_set_value(VALUE self, VALUE str, VALUE uses_radians) {
184
169
  RGeo_Proj4Data *self_data;
185
170
 
186
171
  Check_Type(str, T_STRING);
@@ -197,9 +182,7 @@ static VALUE method_proj4_set_value(VALUE self, VALUE str, VALUE uses_radians)
197
182
  return self;
198
183
  }
199
184
 
200
-
201
- static VALUE method_proj4_get_geographic(VALUE self)
202
- {
185
+ static VALUE method_proj4_get_geographic(VALUE self) {
203
186
  VALUE result;
204
187
  RGeo_Proj4Data *new_data;
205
188
  RGeo_Proj4Data *self_data;
@@ -208,41 +191,39 @@ static VALUE method_proj4_get_geographic(VALUE self)
208
191
  result = Qnil;
209
192
  new_data = ALLOC(RGeo_Proj4Data);
210
193
  if (new_data) {
211
- TypedData_Get_Struct(self, RGeo_Proj4Data, &rgeo_proj4_data_type, self_data);
194
+ TypedData_Get_Struct(self, RGeo_Proj4Data, &rgeo_proj4_data_type,
195
+ self_data);
212
196
 
213
197
  geographic_proj = proj_crs_get_geodetic_crs(PJ_DEFAULT_CTX, self_data->pj);
214
198
  if (geographic_proj == 0) {
215
- xfree(new_data);
216
- rb_raise(rb_eRGeoInvalidProjectionError, "Geographic CRS could not be created because the source projection is not a CRS");
199
+ FREE(new_data);
200
+ rb_raise(rb_eRGeoInvalidProjectionError,
201
+ "Geographic CRS could not be created because the source "
202
+ "projection is not a CRS");
217
203
  }
218
204
 
219
205
  new_data->pj = geographic_proj;
220
206
  new_data->original_str = Qnil;
221
207
  new_data->uses_radians = self_data->uses_radians;
222
- result = TypedData_Wrap_Struct(CLASS_OF(self), &rgeo_proj4_data_type, new_data);
208
+ result =
209
+ TypedData_Wrap_Struct(CLASS_OF(self), &rgeo_proj4_data_type, new_data);
223
210
  }
224
211
  return result;
225
212
  }
226
213
 
227
-
228
- static VALUE method_proj4_original_str(VALUE self)
229
- {
214
+ static VALUE method_proj4_original_str(VALUE self) {
230
215
  RGeo_Proj4Data *data;
231
216
  TypedData_Get_Struct(self, RGeo_Proj4Data, &rgeo_proj4_data_type, data);
232
217
  return data->original_str;
233
218
  }
234
219
 
235
-
236
- static VALUE method_proj4_uses_radians(VALUE self)
237
- {
220
+ static VALUE method_proj4_uses_radians(VALUE self) {
238
221
  RGeo_Proj4Data *data;
239
222
  TypedData_Get_Struct(self, RGeo_Proj4Data, &rgeo_proj4_data_type, data);
240
223
  return data->uses_radians ? Qtrue : Qfalse;
241
224
  }
242
225
 
243
-
244
- static VALUE method_proj4_canonical_str(VALUE self)
245
- {
226
+ static VALUE method_proj4_canonical_str(VALUE self) {
246
227
  VALUE result;
247
228
  PJ *pj;
248
229
  const char *str;
@@ -260,8 +241,7 @@ static VALUE method_proj4_canonical_str(VALUE self)
260
241
  return result;
261
242
  }
262
243
 
263
- static VALUE method_proj4_wkt_str(VALUE self)
264
- {
244
+ static VALUE method_proj4_wkt_str(VALUE self) {
265
245
  VALUE result;
266
246
  PJ *pj;
267
247
  const char *str;
@@ -273,15 +253,14 @@ static VALUE method_proj4_wkt_str(VALUE self)
273
253
  if (pj) {
274
254
  const char *const options[] = {"MULTILINE=NO", NULL};
275
255
  str = proj_as_wkt(PJ_DEFAULT_CTX, pj, WKT_TYPE, options);
276
- if (str){
256
+ if (str) {
277
257
  result = rb_str_new2(str);
278
258
  }
279
259
  }
280
260
  return result;
281
261
  }
282
262
 
283
- static VALUE method_proj4_auth_name_str(VALUE self)
284
- {
263
+ static VALUE method_proj4_auth_name_str(VALUE self) {
285
264
  VALUE result;
286
265
  PJ *pj;
287
266
  const char *id;
@@ -294,15 +273,14 @@ static VALUE method_proj4_auth_name_str(VALUE self)
294
273
  if (pj) {
295
274
  auth = proj_get_id_auth_name(pj, 0);
296
275
  id = proj_get_id_code(pj, 0);
297
- if (id && auth){
276
+ if (id && auth) {
298
277
  result = rb_sprintf("%s:%s", auth, id);
299
278
  }
300
279
  }
301
280
  return result;
302
281
  }
303
282
 
304
- static VALUE method_proj4_axis_and_unit_info_str(VALUE self, VALUE dimension)
305
- {
283
+ static VALUE method_proj4_axis_and_unit_info_str(VALUE self, VALUE dimension) {
306
284
  VALUE result;
307
285
  int dimension_index;
308
286
  PJ *pj;
@@ -318,10 +296,12 @@ static VALUE method_proj4_axis_and_unit_info_str(VALUE self, VALUE dimension)
318
296
 
319
297
  TypedData_Get_Struct(self, RGeo_Proj4Data, &rgeo_proj4_data_type, data);
320
298
  pj = data->pj;
321
- if (pj){
299
+ if (pj) {
322
300
  pj_cs = proj_crs_get_coordinate_system(PJ_DEFAULT_CTX, pj);
323
301
  if (pj_cs) {
324
- if (proj_cs_get_axis_info(PJ_DEFAULT_CTX, pj_cs, dimension_index, &axis_info, NULL, NULL, NULL, &unit_name, NULL, NULL)) {
302
+ if (proj_cs_get_axis_info(PJ_DEFAULT_CTX, pj_cs, dimension_index,
303
+ &axis_info, NULL, NULL, NULL, &unit_name, NULL,
304
+ NULL)) {
325
305
  result = rb_sprintf("%s:%s", axis_info, unit_name);
326
306
  }
327
307
 
@@ -331,8 +311,7 @@ static VALUE method_proj4_axis_and_unit_info_str(VALUE self, VALUE dimension)
331
311
  return result;
332
312
  }
333
313
 
334
- static VALUE method_proj4_axis_count(VALUE self)
335
- {
314
+ static VALUE method_proj4_axis_count(VALUE self) {
336
315
  VALUE result;
337
316
  PJ *pj;
338
317
  PJ *pj_cs;
@@ -342,7 +321,7 @@ static VALUE method_proj4_axis_count(VALUE self)
342
321
  result = Qnil;
343
322
  TypedData_Get_Struct(self, RGeo_Proj4Data, &rgeo_proj4_data_type, data);
344
323
  pj = data->pj;
345
- if (pj){
324
+ if (pj) {
346
325
  pj_cs = proj_crs_get_coordinate_system(PJ_DEFAULT_CTX, pj);
347
326
  if (pj_cs) {
348
327
  count = proj_cs_get_axis_count(PJ_DEFAULT_CTX, pj_cs);
@@ -354,9 +333,7 @@ static VALUE method_proj4_axis_count(VALUE self)
354
333
  return result;
355
334
  }
356
335
 
357
-
358
- static VALUE method_proj4_is_geographic(VALUE self)
359
- {
336
+ static VALUE method_proj4_is_geographic(VALUE self) {
360
337
  VALUE result;
361
338
  PJ *pj;
362
339
  PJ_TYPE proj_type;
@@ -367,7 +344,8 @@ static VALUE method_proj4_is_geographic(VALUE self)
367
344
  pj = data->pj;
368
345
  if (pj) {
369
346
  proj_type = proj_get_type(pj);
370
- if (proj_type == PJ_TYPE_GEOGRAPHIC_2D_CRS || proj_type == PJ_TYPE_GEOGRAPHIC_3D_CRS){
347
+ if (proj_type == PJ_TYPE_GEOGRAPHIC_2D_CRS ||
348
+ proj_type == PJ_TYPE_GEOGRAPHIC_3D_CRS) {
371
349
  result = Qtrue;
372
350
  } else {
373
351
  result = Qfalse;
@@ -376,9 +354,7 @@ static VALUE method_proj4_is_geographic(VALUE self)
376
354
  return result;
377
355
  }
378
356
 
379
-
380
- static VALUE method_proj4_is_geocentric(VALUE self)
381
- {
357
+ static VALUE method_proj4_is_geocentric(VALUE self) {
382
358
  VALUE result;
383
359
  PJ *pj;
384
360
  PJ_TYPE proj_type;
@@ -394,8 +370,7 @@ static VALUE method_proj4_is_geocentric(VALUE self)
394
370
  return result;
395
371
  }
396
372
 
397
- static VALUE method_proj4_is_projected(VALUE self)
398
- {
373
+ static VALUE method_proj4_is_projected(VALUE self) {
399
374
  VALUE result;
400
375
  PJ *pj;
401
376
  PJ_TYPE proj_type;
@@ -411,32 +386,27 @@ static VALUE method_proj4_is_projected(VALUE self)
411
386
  return result;
412
387
  }
413
388
 
414
-
415
- static VALUE method_proj4_is_valid(VALUE self)
416
- {
389
+ static VALUE method_proj4_is_valid(VALUE self) {
417
390
  RGeo_Proj4Data *data;
418
391
  TypedData_Get_Struct(self, RGeo_Proj4Data, &rgeo_proj4_data_type, data);
419
392
  return data->pj ? Qtrue : Qfalse;
420
393
  }
421
394
 
422
- static VALUE method_proj4_is_crs(VALUE self)
423
- {
395
+ static VALUE method_proj4_is_crs(VALUE self) {
424
396
  RGeo_Proj4Data *self_data;
425
397
 
426
398
  TypedData_Get_Struct(self, RGeo_Proj4Data, &rgeo_proj4_data_type, self_data);
427
399
  return proj_is_crs(self_data->pj) ? Qtrue : Qfalse;
428
400
  }
429
401
 
430
-
431
- static VALUE cmethod_proj4_version(VALUE module)
432
- {
433
- return rb_sprintf("%d.%d.%d", PROJ_VERSION_MAJOR, PROJ_VERSION_MINOR, PROJ_VERSION_PATCH);
402
+ static VALUE cmethod_proj4_version(VALUE module) {
403
+ return rb_sprintf("%d.%d.%d", PROJ_VERSION_MAJOR, PROJ_VERSION_MINOR,
404
+ PROJ_VERSION_PATCH);
434
405
  }
435
406
 
436
- static VALUE cmethod_proj4_create(VALUE klass, VALUE str, VALUE uses_radians)
437
- {
407
+ static VALUE cmethod_proj4_create(VALUE klass, VALUE str, VALUE uses_radians) {
438
408
  VALUE result;
439
- RGeo_Proj4Data* data;
409
+ RGeo_Proj4Data *data;
440
410
 
441
411
  result = Qnil;
442
412
  Check_Type(str, T_STRING);
@@ -450,8 +420,7 @@ static VALUE cmethod_proj4_create(VALUE klass, VALUE str, VALUE uses_radians)
450
420
  return result;
451
421
  }
452
422
 
453
- static VALUE cmethod_crs_to_crs_create(VALUE klass, VALUE from, VALUE to)
454
- {
423
+ static VALUE cmethod_crs_to_crs_create(VALUE klass, VALUE from, VALUE to) {
455
424
  VALUE result;
456
425
  RGeo_Proj4Data *from_data;
457
426
  RGeo_Proj4Data *to_data;
@@ -460,38 +429,39 @@ static VALUE cmethod_crs_to_crs_create(VALUE klass, VALUE from, VALUE to)
460
429
  PJ *to_pj;
461
430
  PJ *gis_pj;
462
431
  PJ *crs_to_crs;
463
- RGeo_CRSToCRSData* data;
432
+ RGeo_CRSToCRSData *data;
464
433
 
465
434
  TypedData_Get_Struct(from, RGeo_Proj4Data, &rgeo_proj4_data_type, from_data);
466
435
  TypedData_Get_Struct(to, RGeo_Proj4Data, &rgeo_proj4_data_type, to_data);
467
436
  from_pj = from_data->pj;
468
437
  to_pj = to_data->pj;
469
- crs_to_crs = proj_create_crs_to_crs_from_pj(PJ_DEFAULT_CTX, from_pj, to_pj, 0, NULL);
438
+ crs_to_crs =
439
+ proj_create_crs_to_crs_from_pj(PJ_DEFAULT_CTX, from_pj, to_pj, 0, NULL);
470
440
 
471
441
  // check for invalid transformation
472
442
  if (crs_to_crs == 0) {
473
- rb_raise(rb_eRGeoInvalidProjectionError, "CRSToCRS could not be created from input projections");
443
+ rb_raise(rb_eRGeoInvalidProjectionError,
444
+ "CRSToCRS could not be created from input projections");
474
445
  }
475
446
 
476
447
  // necessary to use proj_normalize_for_visualization so that we
477
448
  // do not have to worry about the order of coordinates in every
478
449
  // coord system
479
450
  gis_pj = proj_normalize_for_visualization(PJ_DEFAULT_CTX, crs_to_crs);
480
- if (gis_pj){
451
+ if (gis_pj) {
481
452
  proj_destroy(crs_to_crs);
482
453
  crs_to_crs = gis_pj;
483
454
  }
484
455
  data = ALLOC(RGeo_CRSToCRSData);
485
- if (data){
456
+ if (data) {
486
457
  data->crs_to_crs = crs_to_crs;
487
458
  result = TypedData_Wrap_Struct(klass, &rgeo_crs_to_crs_data_type, data);
488
459
  }
489
460
  return result;
490
461
  }
491
462
 
492
-
493
- static VALUE method_crs_to_crs_transform(VALUE self, VALUE x, VALUE y, VALUE z)
494
- {
463
+ static VALUE method_crs_to_crs_transform(VALUE self, VALUE x, VALUE y,
464
+ VALUE z) {
495
465
  VALUE result;
496
466
  RGeo_CRSToCRSData *crs_to_crs_data;
497
467
  PJ *crs_to_crs_pj;
@@ -500,9 +470,10 @@ static VALUE method_crs_to_crs_transform(VALUE self, VALUE x, VALUE y, VALUE z)
500
470
  PJ_COORD output;
501
471
 
502
472
  result = Qnil;
503
- TypedData_Get_Struct(self, RGeo_CRSToCRSData, &rgeo_crs_to_crs_data_type, crs_to_crs_data);
473
+ TypedData_Get_Struct(self, RGeo_CRSToCRSData, &rgeo_crs_to_crs_data_type,
474
+ crs_to_crs_data);
504
475
  crs_to_crs_pj = crs_to_crs_data->crs_to_crs;
505
- if (crs_to_crs_pj){
476
+ if (crs_to_crs_pj) {
506
477
  xval = rb_num2dbl(x);
507
478
  yval = rb_num2dbl(y);
508
479
  zval = NIL_P(z) ? 0.0 : rb_num2dbl(z);
@@ -513,60 +484,61 @@ static VALUE method_crs_to_crs_transform(VALUE self, VALUE x, VALUE y, VALUE z)
513
484
  result = rb_ary_new2(NIL_P(z) ? 2 : 3);
514
485
  rb_ary_push(result, DBL2NUM(output.xyz.x));
515
486
  rb_ary_push(result, DBL2NUM(output.xyz.y));
516
- if (!NIL_P(z)){
487
+ if (!NIL_P(z)) {
517
488
  rb_ary_push(result, DBL2NUM(output.xyz.z));
518
489
  }
519
490
  }
520
491
  return result;
521
492
  }
522
493
 
523
- static VALUE method_crs_to_crs_wkt_str(VALUE self)
524
- {
494
+ static VALUE method_crs_to_crs_wkt_str(VALUE self) {
525
495
  VALUE result;
526
496
  RGeo_CRSToCRSData *crs_to_crs_data;
527
497
  PJ *crs_to_crs_pj;
528
498
  const char *str;
529
499
 
530
500
  result = Qnil;
531
- TypedData_Get_Struct(self, RGeo_CRSToCRSData, &rgeo_crs_to_crs_data_type, crs_to_crs_data);
501
+ TypedData_Get_Struct(self, RGeo_CRSToCRSData, &rgeo_crs_to_crs_data_type,
502
+ crs_to_crs_data);
532
503
  crs_to_crs_pj = crs_to_crs_data->crs_to_crs;
533
504
  if (crs_to_crs_pj) {
534
505
  const char *const options[] = {"MULTILINE=NO", NULL};
535
506
  str = proj_as_wkt(PJ_DEFAULT_CTX, crs_to_crs_pj, WKT_TYPE, options);
536
- if (str){
507
+ if (str) {
537
508
  result = rb_str_new2(str);
538
509
  }
539
510
  }
540
511
  return result;
541
512
  }
542
513
 
543
- static VALUE method_crs_to_crs_area_of_use_str(VALUE self)
544
- {
514
+ static VALUE method_crs_to_crs_area_of_use_str(VALUE self) {
545
515
  VALUE result;
546
516
  RGeo_CRSToCRSData *crs_to_crs_data;
547
517
  PJ *crs_to_crs_pj;
548
518
  const char *str;
549
519
 
550
520
  result = Qnil;
551
- TypedData_Get_Struct(self, RGeo_CRSToCRSData, &rgeo_crs_to_crs_data_type, crs_to_crs_data);
521
+ TypedData_Get_Struct(self, RGeo_CRSToCRSData, &rgeo_crs_to_crs_data_type,
522
+ crs_to_crs_data);
552
523
  crs_to_crs_pj = crs_to_crs_data->crs_to_crs;
553
524
  if (crs_to_crs_pj) {
554
- if (proj_get_area_of_use(PJ_DEFAULT_CTX, crs_to_crs_pj, NULL, NULL, NULL, NULL, &str)){
525
+ if (proj_get_area_of_use(PJ_DEFAULT_CTX, crs_to_crs_pj, NULL, NULL, NULL,
526
+ NULL, &str)) {
555
527
  result = rb_str_new2(str);
556
528
  }
557
529
  }
558
530
  return result;
559
531
  }
560
532
 
561
- static VALUE method_crs_to_crs_proj_type(VALUE self)
562
- {
533
+ static VALUE method_crs_to_crs_proj_type(VALUE self) {
563
534
  VALUE result;
564
535
  RGeo_CRSToCRSData *crs_to_crs_data;
565
536
  PJ *crs_to_crs_pj;
566
537
  int proj_type;
567
538
 
568
539
  result = Qnil;
569
- TypedData_Get_Struct(self, RGeo_CRSToCRSData, &rgeo_crs_to_crs_data_type, crs_to_crs_data);
540
+ TypedData_Get_Struct(self, RGeo_CRSToCRSData, &rgeo_crs_to_crs_data_type,
541
+ crs_to_crs_data);
570
542
  crs_to_crs_pj = crs_to_crs_data->crs_to_crs;
571
543
  if (crs_to_crs_pj) {
572
544
  proj_type = proj_get_type(crs_to_crs_pj);
@@ -575,8 +547,7 @@ static VALUE method_crs_to_crs_proj_type(VALUE self)
575
547
  return result;
576
548
  }
577
549
 
578
- static VALUE method_crs_to_crs_identity(VALUE self, VALUE from, VALUE to)
579
- {
550
+ static VALUE method_crs_to_crs_identity(VALUE self, VALUE from, VALUE to) {
580
551
  VALUE result;
581
552
  RGeo_Proj4Data *from_data;
582
553
  RGeo_Proj4Data *to_data;
@@ -591,8 +562,8 @@ static VALUE method_crs_to_crs_identity(VALUE self, VALUE from, VALUE to)
591
562
  from_pj = from_data->pj;
592
563
  to_pj = to_data->pj;
593
564
 
594
- if (from_pj && to_pj){
595
- if (proj_is_equivalent_to(from_pj, to_pj, PJ_COMP_EQUIVALENT)){
565
+ if (from_pj && to_pj) {
566
+ if (proj_is_equivalent_to(from_pj, to_pj, PJ_COMP_EQUIVALENT)) {
596
567
  result = Qtrue;
597
568
  }
598
569
  }
@@ -600,8 +571,7 @@ static VALUE method_crs_to_crs_identity(VALUE self, VALUE from, VALUE to)
600
571
  return result;
601
572
  }
602
573
 
603
- static void rgeo_init_proj4()
604
- {
574
+ static void rgeo_init_proj4() {
605
575
  VALUE rgeo_module;
606
576
  VALUE coordsys_module;
607
577
  VALUE cs_module;
@@ -618,14 +588,18 @@ static void rgeo_init_proj4()
618
588
  cs_base_class = rb_define_class_under(cs_module, "Base", rb_cObject);
619
589
  cs_info_class = rb_define_class_under(cs_module, "Info", cs_base_class);
620
590
 
621
- coordinate_system_class = rb_define_class_under(cs_module, "CoordinateSystem", cs_info_class);
622
- proj4_class = rb_define_class_under(coordsys_module, "Proj4", coordinate_system_class);
591
+ coordinate_system_class =
592
+ rb_define_class_under(cs_module, "CoordinateSystem", cs_info_class);
593
+ proj4_class =
594
+ rb_define_class_under(coordsys_module, "Proj4", coordinate_system_class);
623
595
  rb_define_alloc_func(proj4_class, rgeo_proj4_data_alloc);
624
596
  rb_define_module_function(proj4_class, "_create", cmethod_proj4_create, 2);
625
- rb_define_method(proj4_class, "initialize_copy", method_proj4_initialize_copy, 1);
597
+ rb_define_method(proj4_class, "initialize_copy", method_proj4_initialize_copy,
598
+ 1);
626
599
  rb_define_method(proj4_class, "_set_value", method_proj4_set_value, 2);
627
600
  rb_define_method(proj4_class, "_original_str", method_proj4_original_str, 0);
628
- rb_define_method(proj4_class, "_canonical_str", method_proj4_canonical_str, 0);
601
+ rb_define_method(proj4_class, "_canonical_str", method_proj4_canonical_str,
602
+ 0);
629
603
  rb_define_method(proj4_class, "_as_text", method_proj4_wkt_str, 0);
630
604
  rb_define_method(proj4_class, "_auth_name", method_proj4_auth_name_str, 0);
631
605
  rb_define_method(proj4_class, "_valid?", method_proj4_is_valid, 0);
@@ -633,35 +607,41 @@ static void rgeo_init_proj4()
633
607
  rb_define_method(proj4_class, "_geocentric?", method_proj4_is_geocentric, 0);
634
608
  rb_define_method(proj4_class, "_projected?", method_proj4_is_projected, 0);
635
609
  rb_define_method(proj4_class, "_radians?", method_proj4_uses_radians, 0);
636
- rb_define_method(proj4_class, "_get_geographic", method_proj4_get_geographic, 0);
610
+ rb_define_method(proj4_class, "_get_geographic", method_proj4_get_geographic,
611
+ 0);
637
612
  rb_define_method(proj4_class, "_crs?", method_proj4_is_crs, 0);
638
- rb_define_method(proj4_class, "_axis_and_unit_info", method_proj4_axis_and_unit_info_str, 1);
613
+ rb_define_method(proj4_class, "_axis_and_unit_info",
614
+ method_proj4_axis_and_unit_info_str, 1);
639
615
  rb_define_method(proj4_class, "_axis_count", method_proj4_axis_count, 0);
640
- rb_define_module_function(proj4_class, "_proj_version", cmethod_proj4_version, 0);
616
+ rb_define_module_function(proj4_class, "_proj_version", cmethod_proj4_version,
617
+ 0);
641
618
 
642
- coordinate_transform_class = rb_define_class_under(cs_module, "CoordinateTransform", cs_info_class);
619
+ coordinate_transform_class =
620
+ rb_define_class_under(cs_module, "CoordinateTransform", cs_info_class);
643
621
 
644
- crs_to_crs_class = rb_define_class_under(coordsys_module, "CRSToCRS", coordinate_transform_class);
622
+ crs_to_crs_class = rb_define_class_under(coordsys_module, "CRSToCRS",
623
+ coordinate_transform_class);
645
624
  rb_define_alloc_func(crs_to_crs_class, rgeo_crs_to_crs_data_alloc);
646
- rb_define_module_function(crs_to_crs_class, "_create", cmethod_crs_to_crs_create, 2);
647
- rb_define_method(crs_to_crs_class, "_transform_coords", method_crs_to_crs_transform, 3);
625
+ rb_define_module_function(crs_to_crs_class, "_create",
626
+ cmethod_crs_to_crs_create, 2);
627
+ rb_define_method(crs_to_crs_class, "_transform_coords",
628
+ method_crs_to_crs_transform, 3);
648
629
  rb_define_method(crs_to_crs_class, "_as_text", method_crs_to_crs_wkt_str, 0);
649
- rb_define_method(crs_to_crs_class, "_proj_type", method_crs_to_crs_proj_type, 0);
650
- rb_define_method(crs_to_crs_class, "_area_of_use", method_crs_to_crs_area_of_use_str, 0);
651
- rb_define_method(crs_to_crs_class, "_identity?", method_crs_to_crs_identity, 2);
630
+ rb_define_method(crs_to_crs_class, "_proj_type", method_crs_to_crs_proj_type,
631
+ 0);
632
+ rb_define_method(crs_to_crs_class, "_area_of_use",
633
+ method_crs_to_crs_area_of_use_str, 0);
634
+ rb_define_method(crs_to_crs_class, "_identity?", method_crs_to_crs_identity,
635
+ 2);
652
636
  }
653
637
 
654
-
655
638
  #endif
656
639
 
657
-
658
- void Init_proj4_c_impl()
659
- {
640
+ void Init_proj4_c_impl() {
660
641
  #ifdef RGEO_PROJ4_SUPPORTED
661
642
  rgeo_init_proj4();
662
643
  rgeo_init_proj_errors();
663
644
  #endif
664
645
  }
665
646
 
666
-
667
647
  RGEO_END_C
@@ -14,6 +14,10 @@
14
14
  #define mark rb_gc_mark
15
15
  #endif
16
16
 
17
+ // When using ruby ALLOC* macros, we are using ruby_xmalloc, which counterpart
18
+ // is ruby_xfree. This macro helps enforcing that by showing us the way.
19
+ #define FREE ruby_xfree
20
+
17
21
  #ifdef __cplusplus
18
22
  #define RGEO_BEGIN_C extern "C" {
19
23
  #define RGEO_END_C }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RGeo
4
4
  module Proj4
5
- VERSION = "4.0.0-rc.1"
5
+ VERSION = "4.0.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgeo-proj4
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.pre.rc.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Tee Parham, Daniel Azuma
7
+ - Tee Parham, Daniel Azuma, Keith Doggett, Ulysse Buonomo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-12 00:00:00.000000000 Z
11
+ date: 2023-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rgeo
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0.pre.rc.3
19
+ version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.0.0.pre.rc.3
26
+ version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ffi-geos
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,9 +94,23 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.8.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: ruby_memcheck
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.0'
97
111
  description: Proj4 extension for rgeo.
98
112
  email:
99
- - parhameter@gmail.com, dazuma@gmail.com
113
+ - parhameter@gmail.com, dazuma@gmail.com, kfdoggett@gmail.com
100
114
  executables: []
101
115
  extensions:
102
116
  - ext/proj4_c_impl/extconf.rb
@@ -125,12 +139,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
139
  requirements:
126
140
  - - ">="
127
141
  - !ruby/object:Gem::Version
128
- version: 2.5.0
142
+ version: 2.6.0
129
143
  required_rubygems_version: !ruby/object:Gem::Requirement
130
144
  requirements:
131
- - - ">"
145
+ - - ">="
132
146
  - !ruby/object:Gem::Version
133
- version: 1.3.1
147
+ version: '0'
134
148
  requirements: []
135
149
  rubygems_version: 3.1.4
136
150
  signing_key: