simple-proj-carray 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9e86e595e2cb9e35de18e0c3ac4ad6a5a3125c672461cc7ba8c058825ede0000
4
+ data.tar.gz: 9b19b6cbb2ca770794a134593cc10b4a3afaa206a1d5e0f0c6f51ed7935913ad
5
+ SHA512:
6
+ metadata.gz: 147a7445f08a219ac6dbe5ae90c2890b922efad0852b19a06aba66bae78f13c17378c024f279e9570884b689c6c0a0399d257cb22b25ac33d9956421c62d0f7c
7
+ data.tar.gz: 2473c957e5d1c5727b2596257107e782dfeea4470e68bf224be34f53a1d75dad0a84d01041c33b5caf663eb1b57b3400c493f13b003a9de13e0dec8cb2b950bf
data/README.md ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ GEMSPEC = "simple-proj-carray.gemspec"
2
+
3
+ task :install do
4
+ spec = eval File.read(GEMSPEC)
5
+ system %{
6
+ gem build #{GEMSPEC}; gem install #{spec.full_name}.gem
7
+ }
8
+ end
data/ext/extconf.rb ADDED
@@ -0,0 +1,23 @@
1
+ require "mkmf"
2
+ require 'carray/mkmf'
3
+
4
+ if defined?(Gem)
5
+ if Gem::VERSION >= "1.7.0"
6
+ rb_proj_include = [$sitearchdir, *Gem::Specification.find_all_by_name("simple-proj").map { |s| File.join(s.gem_dir,"ext") }]
7
+ else
8
+ rb_proj_include = [$sitearchdir, *Gem.all_load_paths.reverse.grep(/simple-proj/)]
9
+ end
10
+ else
11
+ rb_proj_include = [$sitearchdir]
12
+ end
13
+
14
+ dir_config("proj", possible_includes, possible_libs)
15
+
16
+ $CFLAGS += rb_proj_include.map{|s| " -I #{s}"}.join(" ")
17
+
18
+ if have_header("rb_proj.h")
19
+ have_carray()
20
+ create_makefile("simple_proj_carray")
21
+ end
22
+
23
+
@@ -0,0 +1,517 @@
1
+ #include "ruby.h"
2
+ #include "rb_proj.h"
3
+ #include "carray.h"
4
+
5
+ static VALUE
6
+ rb_proj_forward_ca_2 (VALUE self, volatile VALUE vlon, volatile VALUE vlat,
7
+ volatile VALUE vx, volatile VALUE vy)
8
+ {
9
+ Proj *proj;
10
+ PJ_COORD data_in, data_out;
11
+
12
+ CArray *clon, *clat, *cx, *cy;
13
+ double *p1, *p2, *p3, *p4;
14
+ ca_size_t s1, s2, s3, s4;
15
+ int8_t *m, *mp;
16
+ ca_size_t count, err_count, i;
17
+
18
+ int angular_input;
19
+
20
+ Data_Get_Struct(self, Proj, proj);
21
+
22
+ if ( ! proj->is_src_latlong ) {
23
+ rb_raise(rb_eRuntimeError, "requires latlong src crs. use #transform_forward instead of #forward.");
24
+ }
25
+
26
+ angular_input = proj_angular_input(proj->ref, PJ_FWD);
27
+
28
+ clon = ca_wrap_readonly(vlon, CA_DOUBLE);
29
+ clat = ca_wrap_readonly(vlat, CA_DOUBLE);
30
+ cx = ca_wrap_writable(vx, CA_DOUBLE);
31
+ cy = ca_wrap_writable(vy, CA_DOUBLE);
32
+
33
+ ca_attach_n(4, clon, clat, cx, cy);
34
+
35
+ count = ca_set_iterator(4,
36
+ clon, &p1, &s1,
37
+ clat, &p2, &s2,
38
+ cx, &p3, &s3,
39
+ cy, &p4, &s4);
40
+
41
+ m = ca_allocate_mask_iterator(2, clon, clat);
42
+
43
+ mp = m;
44
+ err_count = 0;
45
+ for (i=0; i<count; i++) {
46
+ if ( *mp ) {
47
+ err_count += 1;
48
+ *p3 = 0.0/0.0;
49
+ *p4 = 0.0/0.0;
50
+ }
51
+ else {
52
+ if ( angular_input == 1 ) {
53
+ data_in.lp.lam = proj_torad(*p1);
54
+ data_in.lp.phi = proj_torad(*p2);
55
+ }
56
+ else {
57
+ data_in.xy.x = (*p1);
58
+ data_in.xy.y = (*p2);
59
+ }
60
+ data_out = proj_trans(proj->ref, PJ_FWD, data_in);
61
+ if ( data_out.xy.x == HUGE_VAL ) {
62
+ err_count += 1;
63
+ *p3 = 0.0/0.0;
64
+ *p4 = 0.0/0.0;
65
+ }
66
+ else {
67
+ *p3 = data_out.xy.x;
68
+ *p4 = data_out.xy.y;
69
+ }
70
+ }
71
+ p1+=s1; p2+=s2; p3+=s3; p4+=s4; mp++;
72
+ }
73
+
74
+ free(m);
75
+
76
+ ca_sync_n(2, cx, cy);
77
+ ca_detach_n(4, clon, clat, cx, cy);
78
+
79
+ return SIZE2NUM(err_count);
80
+ }
81
+
82
+ static VALUE
83
+ rb_proj_forward_ca_3 (VALUE self, volatile VALUE vlon, volatile VALUE vlat, volatile VALUE vzi,
84
+ volatile VALUE vx, volatile VALUE vy, volatile VALUE vzo)
85
+ {
86
+ Proj *proj;
87
+ PJ_COORD data_in, data_out;
88
+
89
+ CArray *clon, *clat, *czi, *cx, *cy, *czo;
90
+ double *p1, *p2, *p3, *p4, *p5, *p6;
91
+ ca_size_t s1, s2, s3, s4, s5, s6;
92
+ int8_t *m, *mp;
93
+ ca_size_t count, err_count, i;
94
+
95
+ int angular_input;
96
+
97
+ Data_Get_Struct(self, Proj, proj);
98
+
99
+ if ( ! proj->is_src_latlong ) {
100
+ rb_raise(rb_eRuntimeError, "requires latlong src crs. use #transform_forward instead of #forward.");
101
+ }
102
+
103
+ angular_input = proj_angular_input(proj->ref, PJ_FWD);
104
+
105
+ clon = ca_wrap_readonly(vlon, CA_DOUBLE);
106
+ clat = ca_wrap_readonly(vlat, CA_DOUBLE);
107
+ czi = ca_wrap_readonly(vzi, CA_DOUBLE);
108
+ cx = ca_wrap_writable(vx, CA_DOUBLE);
109
+ cy = ca_wrap_writable(vy, CA_DOUBLE);
110
+ czo = ca_wrap_writable(vzo, CA_DOUBLE);
111
+
112
+ ca_attach_n(6, clon, clat, czi, cx, cy, czo);
113
+
114
+ count = ca_set_iterator(6,
115
+ clon, &p1, &s1,
116
+ clat, &p2, &s2,
117
+ czi, &p3, &s3,
118
+ cx, &p4, &s4,
119
+ cy, &p5, &s5,
120
+ czo, &p6, &s6);
121
+
122
+ m = ca_allocate_mask_iterator(3, clon, clat, czi);
123
+
124
+ mp = m;
125
+ err_count = 0;
126
+ for (i=0; i<count; i++) {
127
+ if ( *mp ) {
128
+ err_count += 1;
129
+ *p4 = 0.0/0.0;
130
+ *p5 = 0.0/0.0;
131
+ *p6 = 0.0/0.0;
132
+ }
133
+ else {
134
+ if ( proj->is_src_latlong == 1 ) {
135
+ data_in.lpz.lam = proj_torad(*p1);
136
+ data_in.lpz.phi = proj_torad(*p2);
137
+ data_in.lpz.z = (*p3);
138
+ }
139
+ else {
140
+ data_in.xyz.x = (*p1);
141
+ data_in.xyz.y = (*p2);
142
+ data_in.xyz.z = (*p3);
143
+ }
144
+ data_out = proj_trans(proj->ref, PJ_FWD, data_in);
145
+ if ( data_out.xyz.x == HUGE_VAL ) {
146
+ err_count += 1;
147
+ *p4 = 0.0/0.0;
148
+ *p5 = 0.0/0.0;
149
+ *p6 = 0.0/0.0;
150
+ }
151
+ else {
152
+ *p4 = data_out.xyz.x;
153
+ *p5 = data_out.xyz.y;
154
+ *p6 = data_out.xyz.z;
155
+ }
156
+ }
157
+ p1+=s1; p2+=s2; p3+=s3; p4+=s4; p5+=s5; p5+=s5; mp++;
158
+ }
159
+
160
+ free(m);
161
+
162
+ ca_sync_n(3, cx, cy, czo);
163
+ ca_detach_n(6, clon, clat, czi, cx, cy, czo);
164
+
165
+ return SIZE2NUM(err_count);
166
+ }
167
+
168
+ static VALUE
169
+ rb_proj_inverse_ca_2 (VALUE self, volatile VALUE vx, volatile VALUE vy,
170
+ volatile VALUE vlon, volatile VALUE vlat)
171
+ {
172
+ Proj *proj;
173
+ PJ_COORD data_in, data_out;
174
+
175
+ CArray *cx, *cy, *clon, *clat;
176
+ double *p1, *p2, *p3, *p4;
177
+ ca_size_t s1, s2, s3, s4;
178
+ int8_t *m, *mp;
179
+ ca_size_t count, err_count, i;
180
+
181
+ int angular_output;
182
+
183
+
184
+ Data_Get_Struct(self, Proj, proj);
185
+
186
+ if ( ! proj->is_src_latlong ) {
187
+ rb_raise(rb_eRuntimeError, "requires latlong src crs. use #transform_inverse instead of #inverse.");
188
+ }
189
+
190
+ angular_output = proj_angular_output(proj->ref, PJ_INV);
191
+
192
+ cx = ca_wrap_readonly(vx, CA_DOUBLE);
193
+ cy = ca_wrap_readonly(vy, CA_DOUBLE);
194
+ clon = ca_wrap_writable(vlon, CA_DOUBLE);
195
+ clat = ca_wrap_writable(vlat, CA_DOUBLE);
196
+
197
+ ca_attach_n(4, cx, cy, clon, clat);
198
+
199
+ count = ca_set_iterator(4,
200
+ cx, &p1, &s1,
201
+ cy, &p2, &s2,
202
+ clon, &p3, &s3,
203
+ clat, &p4, &s4);
204
+
205
+ m = ca_allocate_mask_iterator(2, clon, clat);
206
+
207
+ mp = m;
208
+ err_count = 0;
209
+ for (i=0; i<count; i++) {
210
+ if ( *mp ) {
211
+ err_count += 1;
212
+ *p3 = 0.0/0.0;
213
+ *p4 = 0.0/0.0;
214
+ }
215
+ else {
216
+ data_in.xy.x = (*p1);
217
+ data_in.xy.y = (*p2);
218
+ data_out = proj_trans(proj->ref, PJ_INV, data_in);
219
+ if ( data_out.lp.lam == HUGE_VAL ) {
220
+ err_count += 1;
221
+ *p3 = 0.0/0.0;
222
+ *p4 = 0.0/0.0;
223
+ }
224
+ else {
225
+ if ( angular_output == 1 ) {
226
+ *p3 = proj_todeg(data_out.lp.lam);
227
+ *p4 = proj_todeg(data_out.lp.phi);
228
+ }
229
+ else {
230
+ *p3 = data_out.xy.x;
231
+ *p4 = data_out.xy.y;
232
+ }
233
+ }
234
+ }
235
+ p1+=s1; p2+=s2; p3+=s3; p4+=s4;
236
+ mp++;
237
+ }
238
+
239
+ free(m);
240
+
241
+ ca_sync_n(2, clon, clat);
242
+ ca_detach_n(4, cx, cy, clon, clat);
243
+
244
+ return SIZE2NUM(err_count);
245
+ }
246
+
247
+
248
+ static VALUE
249
+ rb_proj_inverse_ca_3 (VALUE self, volatile VALUE vx, volatile VALUE vy, volatile VALUE vzi,
250
+ volatile VALUE vlon, volatile VALUE vlat, volatile VALUE vzo)
251
+ {
252
+ Proj *proj;
253
+ PJ_COORD data_in, data_out;
254
+
255
+ CArray *cx, *cy, *czi, *clon, *clat, *czo;
256
+ double *p1, *p2, *p3, *p4, *p5, *p6;
257
+ ca_size_t s1, s2, s3, s4, s5, s6;
258
+ int8_t *m, *mp;
259
+ ca_size_t count, err_count, i;
260
+
261
+ int angular_output;
262
+
263
+ Data_Get_Struct(self, Proj, proj);
264
+
265
+ if ( ! proj->is_src_latlong ) {
266
+ rb_raise(rb_eRuntimeError, "requires latlong src crs. use #transform_inverse instead of #inverse.");
267
+ }
268
+
269
+ angular_output = proj_angular_output(proj->ref, PJ_INV);
270
+
271
+ cx = ca_wrap_readonly(vx, CA_DOUBLE);
272
+ cy = ca_wrap_readonly(vy, CA_DOUBLE);
273
+ czi = ca_wrap_readonly(vzi, CA_DOUBLE);
274
+ clon = ca_wrap_writable(vlon, CA_DOUBLE);
275
+ clat = ca_wrap_writable(vlat, CA_DOUBLE);
276
+ czo = ca_wrap_writable(vzo, CA_DOUBLE);
277
+
278
+ ca_attach_n(6, cx, cy, czi, clon, clat, czo);
279
+
280
+ count = ca_set_iterator(6,
281
+ cx, &p1, &s1,
282
+ cy, &p2, &s2,
283
+ czi, &p3, &s3,
284
+ clon, &p4, &s4,
285
+ clat, &p5, &s5,
286
+ czo, &p6, &s6);
287
+
288
+ m = ca_allocate_mask_iterator(3, clon, clat, czi);
289
+
290
+ mp = m;
291
+ err_count = 0;
292
+ for (i=0; i<count; i++) {
293
+ if ( *mp ) {
294
+ err_count += 1;
295
+ *p4 = 0.0/0.0;
296
+ *p5 = 0.0/0.0;
297
+ *p6 = 0.0/0.0;
298
+ }
299
+ else {
300
+ data_in.xyz.x = (*p1);
301
+ data_in.xyz.y = (*p2);
302
+ data_in.xyz.z = (*p3);
303
+ data_out = proj_trans(proj->ref, PJ_INV, data_in);
304
+ if ( data_out.lpz.lam == HUGE_VAL ) {
305
+ err_count += 1;
306
+ *p4 = 0.0/0.0;
307
+ *p5 = 0.0/0.0;
308
+ *p6 = 0.0/0.0;
309
+ }
310
+ else {
311
+ if ( angular_output == 1 ) {
312
+ *p4 = proj_todeg(data_out.lpz.lam);
313
+ *p5 = proj_todeg(data_out.lpz.phi);
314
+ *p6 = data_out.lpz.z;
315
+ }
316
+ else {
317
+ *p4 = data_out.xyz.x;
318
+ *p5 = data_out.xyz.y;
319
+ *p6 = data_out.xyz.z;
320
+ }
321
+ }
322
+ }
323
+ p1+=s1; p2+=s2; p3+=s3; p4+=s4;
324
+ mp++;
325
+ }
326
+
327
+ free(m);
328
+
329
+ ca_sync_n(3, clon, clat, czo);
330
+ ca_detach_n(6, cx, cy, czi, clon, clat, czo);
331
+
332
+ return SIZE2NUM(err_count);
333
+ }
334
+
335
+ static VALUE
336
+ rb_proj_transform_ca_2_i (VALUE self, VALUE vx, VALUE vy,
337
+ VALUE vxo, VALUE vyo, PJ_DIRECTION direction)
338
+ {
339
+ Proj *trans;
340
+ PJ_COORD c_in, c_out;
341
+ CArray *cx, *cy, *cxo, *cyo;
342
+ double *p1, *p2, *p4, *p5;
343
+ ca_size_t s1, s2, s4, s5;
344
+ int8_t *m, *mp;
345
+ ca_size_t count, err_count, i;
346
+
347
+ Data_Get_Struct(self, Proj, trans);
348
+
349
+ cx = ca_wrap_readonly(vx, CA_DOUBLE);
350
+ cy = ca_wrap_readonly(vy, CA_DOUBLE);
351
+ cxo = ca_wrap_writable(vxo, CA_DOUBLE);
352
+ cyo = ca_wrap_writable(vyo, CA_DOUBLE);
353
+
354
+ count = ca_get_loop_count(2, cx, cy);
355
+ if ( count == -1 ) {
356
+ rb_raise(rb_eRuntimeError, "invalid data_num");
357
+ }
358
+
359
+ ca_attach_n(4, cx, cy, cxo, cyo);
360
+
361
+ ca_set_iterator(4,
362
+ cx, &p1, &s1,
363
+ cy, &p2, &s2,
364
+ cxo, &p4, &s4,
365
+ cyo, &p5, &s5);
366
+
367
+ m = ca_allocate_mask_iterator(2, cx, cy);
368
+
369
+ mp = m;
370
+ err_count = 0;
371
+ for (i=0; i<count; i++) {
372
+ if ( *mp ) {
373
+ err_count += 1;
374
+ *p4 = 0.0/0.0;
375
+ *p5 = 0.0/0.0;
376
+ }
377
+ else {
378
+ c_in.xyz.x = (*p1);
379
+ c_in.xyz.y = (*p2);
380
+ c_out = proj_trans(trans->ref, PJ_FWD, c_in);
381
+ (*p4) = c_out.xyz.x;
382
+ (*p5) = c_out.xyz.y;
383
+ if ( c_out.xyz.x == HUGE_VAL ) {
384
+ err_count += 1;
385
+ }
386
+ }
387
+ p1+=s1; p2+=s2;
388
+ p4+=s4; p5+=s5;
389
+ mp++;
390
+ }
391
+
392
+ free(m);
393
+
394
+ ca_sync_n(2, cxo, cyo);
395
+ ca_detach_n(4, cx, cy, cxo, cyo);
396
+
397
+ return SIZE2NUM(err_count);
398
+ }
399
+
400
+ static VALUE
401
+ rb_proj_transform_forward_ca_2 (VALUE self, VALUE vx, VALUE vy,
402
+ VALUE vxo, VALUE vyo)
403
+ {
404
+ return rb_proj_transform_ca_2_i(self, vx, vy, vxo, vyo, PJ_FWD);
405
+ }
406
+
407
+ static VALUE
408
+ rb_proj_transform_inverse_ca_2 (VALUE self, VALUE vx, VALUE vy,
409
+ VALUE vxo, VALUE vyo)
410
+ {
411
+ return rb_proj_transform_ca_2_i(self, vx, vy, vxo, vyo, PJ_INV);
412
+ }
413
+
414
+ static VALUE
415
+ rb_proj_transform_ca_3_i (VALUE self, VALUE vx, VALUE vy, VALUE vz,
416
+ VALUE vxo, VALUE vyo, VALUE vzo, PJ_DIRECTION direction)
417
+ {
418
+ Proj *trans;
419
+ PJ_COORD c_in, c_out;
420
+ CArray *cx, *cy, *cz, *cxo, *cyo, *czo;
421
+ double *p1, *p2, *p3, *p4, *p5, *p6;
422
+ ca_size_t s1, s2, s3, s4, s5, s6;
423
+ int8_t *m, *mp;
424
+ ca_size_t count, err_count, i;
425
+
426
+ Data_Get_Struct(self, Proj, trans);
427
+
428
+ cx = ca_wrap_readonly(vx, CA_DOUBLE);
429
+ cy = ca_wrap_readonly(vy, CA_DOUBLE);
430
+ cz = ca_wrap_readonly(vz, CA_DOUBLE);
431
+ cxo = ca_wrap_writable(vxo, CA_DOUBLE);
432
+ cyo = ca_wrap_writable(vyo, CA_DOUBLE);
433
+ czo = ca_wrap_writable(vzo, CA_DOUBLE);
434
+
435
+ count = ca_get_loop_count(3, cx, cy, cz);
436
+ if ( count == -1 ) {
437
+ rb_raise(rb_eRuntimeError, "invalid data_num");
438
+ }
439
+
440
+ ca_attach_n(6, cx, cy, cz, cxo, cyo, czo);
441
+
442
+ ca_set_iterator(6,
443
+ cx, &p1, &s1,
444
+ cy, &p2, &s2,
445
+ cz, &p3, &s3,
446
+ cxo, &p4, &s4,
447
+ cyo, &p5, &s5,
448
+ czo, &p6, &s6);
449
+
450
+ m = ca_allocate_mask_iterator(3, cx, cy, cz);
451
+
452
+ mp = m;
453
+ err_count = 0;
454
+ for (i=0; i<count; i++) {
455
+ if ( *mp ) {
456
+ err_count += 1;
457
+ *p4 = 0.0/0.0;
458
+ *p5 = 0.0/0.0;
459
+ *p6 = 0.0/0.0;
460
+ }
461
+ else {
462
+ c_in.xyz.x = (*p1);
463
+ c_in.xyz.y = (*p2);
464
+ c_in.xyz.z = (*p3);
465
+ c_out = proj_trans(trans->ref, PJ_FWD, c_in);
466
+ (*p4) = c_out.xyz.x;
467
+ (*p5) = c_out.xyz.y;
468
+ (*p6) = c_out.xyz.z;
469
+ /* if ( status < 0 ) {
470
+ err_count += 1;
471
+ }
472
+ */
473
+ }
474
+ p1+=s1; p2+=s2; p3+=s3;
475
+ p4+=s4; p5+=s5; p6+=s6;
476
+ mp++;
477
+ }
478
+
479
+ free(m);
480
+
481
+ ca_sync_n(3, cxo, cyo, czo);
482
+ ca_detach_n(6, cx, cy, cz, cxo, cyo, czo);
483
+
484
+ return SIZE2NUM(err_count);
485
+ }
486
+
487
+ static VALUE
488
+ rb_proj_transform_forward_ca_3 (VALUE self, VALUE vx, VALUE vy, VALUE vz,
489
+ VALUE vxo, VALUE vyo, VALUE vzo)
490
+ {
491
+ return rb_proj_transform_ca_3_i(self, vx, vy, vz, vxo, vyo, vzo, PJ_FWD);
492
+ }
493
+
494
+ static VALUE
495
+ rb_proj_transform_inverse_ca_3 (VALUE self, VALUE vx, VALUE vy, VALUE vz,
496
+ VALUE vxo, VALUE vyo, VALUE vzo)
497
+ {
498
+ return rb_proj_transform_ca_3_i(self, vx, vy, vz, vxo, vyo, vzo, PJ_INV);
499
+ }
500
+
501
+ void
502
+ Init_simple_proj_carray ()
503
+ {
504
+ rb_cProj = rb_define_class("PROJ", rb_cObject);
505
+
506
+ rb_define_private_method(rb_cProj, "_forward_ca_2", rb_proj_forward_ca_2, 4);
507
+ rb_define_private_method(rb_cProj, "_forward_ca_3", rb_proj_forward_ca_3, 6);
508
+ rb_define_private_method(rb_cProj, "_inverse_ca_2", rb_proj_inverse_ca_2, 4);
509
+ rb_define_private_method(rb_cProj, "_inverse_ca_3", rb_proj_inverse_ca_3, 6);
510
+
511
+ rb_define_private_method(rb_cProj, "_transform_forward_ca_2", rb_proj_transform_forward_ca_2, 4);
512
+ rb_define_private_method(rb_cProj, "_transform_forward_ca_3", rb_proj_transform_forward_ca_3, 6);
513
+
514
+ rb_define_private_method(rb_cProj, "_transform_inverse_ca_2", rb_proj_transform_inverse_ca_2, 4);
515
+ rb_define_private_method(rb_cProj, "_transform_inverse_ca_3", rb_proj_transform_inverse_ca_3, 6);
516
+
517
+ }
@@ -0,0 +1,104 @@
1
+ require 'simple-proj'
2
+ require 'carray'
3
+ require 'simple_proj_carray.so'
4
+
5
+ class PROJ
6
+
7
+ def forward_carray (lon, lat, z = nil)
8
+ if z.nil?
9
+ argv = [lon, lat].map{|a| a.is_a?(CArray) ? a : CA_DOUBLE(a) }
10
+ lon, lat = *argv
11
+ ref = argv[argv.map(&:size).to_ca.max_addr]
12
+ x = ref.template
13
+ y = ref.template
14
+ _forward_ca_2(lon, lat, x, y)
15
+ return x, y
16
+ else
17
+ argv = [lon, lat, z].map{|a| a.is_a?(CArray) ? a : CA_DOUBLE(a) }
18
+ lat, lon, z = *argv
19
+ ref = argv[argv.map(&:size).to_ca.max_addr]
20
+ x = ref.template
21
+ y = ref.template
22
+ zo = ref.template
23
+ _forward_ca_3(lon, lat, z, x, y, zo)
24
+ return x, y, zo
25
+ end
26
+ end
27
+
28
+ alias forward_lonlat_carray forward_carray
29
+
30
+ def forward_latlon_carray (lat, lon, z = nil)
31
+ return forward_carray(lon, lat, z)
32
+ end
33
+
34
+ def inverse_carray (x, y, z = nil)
35
+ if z.nil?
36
+ argv = [x, y].map{|a| a.is_a?(CArray) ? a : CA_DOUBLE(a) }
37
+ x, y = *argv
38
+ ref = argv[argv.map(&:size).to_ca.max_addr]
39
+ lon = ref.template
40
+ lat = ref.template
41
+ _inverse_ca_2(x, y, lon, lat)
42
+ return lon, lat
43
+ else
44
+ argv = [x, y, z].map{|a| a.is_a?(CArray) ? a : CA_DOUBLE(a) }
45
+ x, y, z = *argv
46
+ ref = argv[argv.map(&:size).to_ca.max_addr]
47
+ lon = ref.template
48
+ lat = ref.template
49
+ zo = ref.template
50
+ _inverse_ca_3(x, y, z, lon, lat, zo)
51
+ return lon, lat, zo
52
+ end
53
+ end
54
+
55
+ alias inverse_lonlat_carray inverse_carray
56
+
57
+ def inverse_lonlat_carray (lat, lon, z = nil)
58
+ return inverse_carray(lon, lat, z)
59
+ end
60
+
61
+ def transform_forward_carray (x, y, z = nil)
62
+ if z.nil?
63
+ argv = [x, y].map{|a| a.is_a?(CArray) ? a : CA_DOUBLE(a) }
64
+ x, y = *argv
65
+ ref = argv[argv.map(&:size).to_ca.max_addr]
66
+ xo = ref.template
67
+ yo = ref.template
68
+ p x,y
69
+ _transform_forward_ca_2(x, y, xo, yo)
70
+ return xo, yo
71
+ else
72
+ argv = [x, y, z].map{|a| a.is_a?(CArray) ? a : CA_DOUBLE(a) }
73
+ x, y, z = *argv
74
+ ref = argv[argv.map(&:size).to_ca.max_addr]
75
+ xo = ref.template
76
+ yo = ref.template
77
+ zo = ref.template
78
+ _transform_forward_ca_3(x, y, z, xo, yo, zo)
79
+ return xo, yo, zo
80
+ end
81
+ end
82
+
83
+ def transform_inverse_carray (x, y, z = nil)
84
+ if z.nil?
85
+ argv = [x, y].map{|a| a.is_a?(CArray) ? a : CA_DOUBLE(a) }
86
+ x, y = *argv
87
+ ref = argv[argv.map(&:size).to_ca.max_addr]
88
+ xo = ref.template
89
+ yo = ref.template
90
+ _transform_inverse_ca_2(x, y, xo, yo)
91
+ return xo, yo
92
+ else
93
+ argv = [x, y, z].map{|a| a.is_a?(CArray) ? a : CA_DOUBLE(a) }
94
+ x, y, z = *argv
95
+ ref = argv[argv.map(&:size).to_ca.max_addr]
96
+ xo = ref.template
97
+ yo = ref.template
98
+ zo = ref.template
99
+ _transform_inverse_ca_3(x, y, z, xo, yo, zo)
100
+ return xo, yo, zo
101
+ end
102
+ end
103
+
104
+ end
@@ -0,0 +1,27 @@
1
+
2
+ Gem::Specification::new do |s|
3
+ version = "1.0.0"
4
+
5
+ files = Dir.glob("**/*") - [
6
+ Dir.glob("simple-proj-carray-*.gem"),
7
+ Dir.glob("doc/**/*"),
8
+ Dir.glob("test/**/*"),
9
+ ].flatten
10
+
11
+ s.platform = Gem::Platform::RUBY
12
+ s.name = "simple-proj-carray"
13
+ s.summary = "An extension library for PROJ for carray"
14
+ s.description = <<-HERE
15
+ An extension library for PROJ for carray
16
+ HERE
17
+ s.version = version
18
+ s.licenses = ['MIT']
19
+ s.author = "Hiroki Motoyoshi"
20
+ s.email = ""
21
+ s.homepage = 'https://github.com/himotoyoshi/simple-proj-carray'
22
+ s.files = files
23
+ s.extensions = [ "ext/extconf.rb" ]
24
+ s.required_ruby_version = ">= 1.8.1"
25
+ s.add_runtime_dependency 'simple-proj', '~> 1.0'
26
+ s.add_runtime_dependency 'carray', '~> 1.3'
27
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple-proj-carray
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Hiroki Motoyoshi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-09-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: simple-proj
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: carray
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ description: " An extension library for PROJ for carray\n"
42
+ email: ''
43
+ executables: []
44
+ extensions:
45
+ - ext/extconf.rb
46
+ extra_rdoc_files: []
47
+ files:
48
+ - README.md
49
+ - Rakefile
50
+ - ext/extconf.rb
51
+ - ext/rb_simple_proj_carray.c
52
+ - lib/simple-proj-carray.rb
53
+ - simple-proj-carray.gemspec
54
+ homepage: https://github.com/himotoyoshi/simple-proj-carray
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.8.1
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubygems_version: 3.1.2
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: An extension library for PROJ for carray
77
+ test_files: []