swisseph-wasm 0.0.1 → 0.0.4
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.
- package/README.md +386 -7
- package/examples/api-explorer.html +829 -0
- package/examples/basic-usage.js +2 -1
- package/examples/birth-chart.js +2 -1
- package/examples/demo.html +943 -38
- package/examples/playground.html +434 -0
- package/examples/tests.html +363 -0
- package/package.json +3 -12
- package/src/swisseph.js +571 -137
- package/wsam/swisseph.js +2 -3412
- package/wsam/swisseph.wasm +0 -0
package/src/swisseph.js
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swiss Ephemeris WebAssembly Library
|
|
3
|
+
*
|
|
4
|
+
* A high-precision astronomical calculation library for JavaScript,
|
|
5
|
+
* compiled from the renowned Swiss Ephemeris C library to WebAssembly.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Planetary positions and velocities
|
|
9
|
+
* - House calculations
|
|
10
|
+
* - Time conversions (Julian Day, sidereal time)
|
|
11
|
+
* - Coordinate transformations
|
|
12
|
+
* - Eclipse and occultation calculations
|
|
13
|
+
* - Fixed star positions
|
|
14
|
+
* - And much more...
|
|
15
|
+
*
|
|
16
|
+
* @author prolaxu
|
|
17
|
+
* @version 0.0.2
|
|
18
|
+
* @license GPL-3.0-or-later
|
|
19
|
+
*
|
|
20
|
+
* IMPORTANT LICENSING INFORMATION:
|
|
21
|
+
*
|
|
22
|
+
* This library incorporates the Swiss Ephemeris, which is subject to dual licensing:
|
|
23
|
+
*
|
|
24
|
+
* 1. GNU General Public License (GPL) v2 or later
|
|
25
|
+
* - Free for open source projects
|
|
26
|
+
* - Requires derivative works to also be GPL licensed
|
|
27
|
+
*
|
|
28
|
+
* 2. Commercial License (from Astrodienst AG)
|
|
29
|
+
* - Required for proprietary/commercial applications
|
|
30
|
+
* - Contact: swisseph@astro.ch
|
|
31
|
+
* - Website: https://www.astro.com/swisseph/
|
|
32
|
+
*
|
|
33
|
+
* For commercial use, you may need to obtain a commercial license for Swiss Ephemeris
|
|
34
|
+
* from Astrodienst AG. This WebAssembly wrapper is provided under GPL v3.
|
|
35
|
+
*
|
|
36
|
+
* The author is not affiliated with Astrodienst AG and cannot provide commercial
|
|
37
|
+
* licenses for Swiss Ephemeris.
|
|
38
|
+
*/
|
|
39
|
+
|
|
1
40
|
import WasamSwissEph from '../wsam/swisseph.js';
|
|
2
41
|
|
|
3
42
|
class SwissEph {
|
|
@@ -280,7 +319,42 @@ class SwissEph {
|
|
|
280
319
|
|
|
281
320
|
// Initializes the Swiss Ephemeris WebAssembly module
|
|
282
321
|
async initSwissEph() {
|
|
283
|
-
|
|
322
|
+
let moduleConfig = {};
|
|
323
|
+
|
|
324
|
+
// In Node.js environment, we need to help locate the WASM and data files
|
|
325
|
+
if (typeof process !== 'undefined' && process.versions && process.versions.node) {
|
|
326
|
+
try {
|
|
327
|
+
const { fileURLToPath } = await import('url');
|
|
328
|
+
const { dirname, join } = await import('path');
|
|
329
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
330
|
+
const __dirname = dirname(__filename);
|
|
331
|
+
|
|
332
|
+
moduleConfig.locateFile = (path, prefix) => {
|
|
333
|
+
if (path.endsWith('.data') || path.endsWith('.wasm')) {
|
|
334
|
+
return join(__dirname, '../wsam', path);
|
|
335
|
+
}
|
|
336
|
+
return prefix + path;
|
|
337
|
+
};
|
|
338
|
+
} catch (e) {
|
|
339
|
+
console.warn('Failed to configure path resolution for SwissEph WASM:', e);
|
|
340
|
+
}
|
|
341
|
+
} else {
|
|
342
|
+
// Browser environment
|
|
343
|
+
moduleConfig.locateFile = (path, prefix) => {
|
|
344
|
+
if (path.endsWith('.data') || path.endsWith('.wasm')) {
|
|
345
|
+
return new URL('../wsam/' + path, import.meta.url).href;
|
|
346
|
+
}
|
|
347
|
+
return prefix + path;
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
this.SweModule = await WasamSwissEph(moduleConfig);
|
|
352
|
+
|
|
353
|
+
// Ensure HEAP32 is available
|
|
354
|
+
if (!this.SweModule.HEAP32) {
|
|
355
|
+
this.SweModule.HEAP32 = new Int32Array(this.SweModule.HEAPF64.buffer);
|
|
356
|
+
}
|
|
357
|
+
|
|
284
358
|
this.set_ephe_path('sweph');
|
|
285
359
|
}
|
|
286
360
|
|
|
@@ -289,18 +363,95 @@ class SwissEph {
|
|
|
289
363
|
}
|
|
290
364
|
|
|
291
365
|
house_pos(armc, geoLat, eps, hsys, lon, lat) {
|
|
292
|
-
|
|
366
|
+
const xpinPtr = this.SweModule._malloc(2 * 8);
|
|
367
|
+
const HEAPF64 = this.SweModule.HEAPF64;
|
|
368
|
+
HEAPF64[xpinPtr >> 3] = lon;
|
|
369
|
+
HEAPF64[(xpinPtr >> 3) + 1] = lat;
|
|
370
|
+
|
|
371
|
+
const serr = this.SweModule._malloc(256);
|
|
372
|
+
const result = this.SweModule.ccall(
|
|
373
|
+
'swe_house_pos',
|
|
374
|
+
'number',
|
|
375
|
+
['number', 'number', 'number', 'number', 'pointer', 'pointer'],
|
|
376
|
+
[armc, geoLat, eps, hsys.charCodeAt(0), xpinPtr, serr]
|
|
377
|
+
);
|
|
378
|
+
|
|
379
|
+
this.SweModule._free(xpinPtr);
|
|
380
|
+
this.SweModule._free(serr);
|
|
381
|
+
return result;
|
|
293
382
|
}
|
|
294
383
|
|
|
295
384
|
julday(year, month, day, hour) {
|
|
296
385
|
return this.SweModule.ccall('swe_julday', 'number', ['number', 'number', 'number', 'number', 'number'], [year, month, day, hour, 1]);
|
|
297
386
|
}
|
|
387
|
+
|
|
388
|
+
date_conversion(year, month, day, hour, calendar) {
|
|
389
|
+
const tjdPtr = this.SweModule._malloc(8);
|
|
390
|
+
// calendar is a char, pass char code
|
|
391
|
+
const result = this.SweModule.ccall(
|
|
392
|
+
'swe_date_conversion',
|
|
393
|
+
'number',
|
|
394
|
+
['number', 'number', 'number', 'number', 'number', 'pointer'],
|
|
395
|
+
[year, month, day, hour, calendar.charCodeAt(0), tjdPtr]
|
|
396
|
+
);
|
|
397
|
+
const tjd = this.SweModule.HEAPF64[tjdPtr >> 3];
|
|
398
|
+
this.SweModule._free(tjdPtr);
|
|
399
|
+
|
|
400
|
+
if (result === this.ERR) {
|
|
401
|
+
throw new Error("Invalid date");
|
|
402
|
+
}
|
|
403
|
+
return tjd;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
revjul(julianDay, gregflag) {
|
|
407
|
+
const yearPtr = this.SweModule._malloc(4);
|
|
408
|
+
const monthPtr = this.SweModule._malloc(4);
|
|
409
|
+
const dayPtr = this.SweModule._malloc(4);
|
|
410
|
+
const hourPtr = this.SweModule._malloc(8);
|
|
411
|
+
|
|
412
|
+
this.SweModule.ccall(
|
|
413
|
+
'swe_revjul',
|
|
414
|
+
'void',
|
|
415
|
+
['number', 'number', 'pointer', 'pointer', 'pointer', 'pointer'],
|
|
416
|
+
[julianDay, gregflag, yearPtr, monthPtr, dayPtr, hourPtr]
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
const year = this.SweModule.HEAP32[yearPtr >> 2];
|
|
420
|
+
const month = this.SweModule.HEAP32[monthPtr >> 2];
|
|
421
|
+
const day = this.SweModule.HEAP32[dayPtr >> 2];
|
|
422
|
+
const hour = this.SweModule.HEAPF64[hourPtr >> 3];
|
|
423
|
+
|
|
424
|
+
this.SweModule._free(yearPtr);
|
|
425
|
+
this.SweModule._free(monthPtr);
|
|
426
|
+
this.SweModule._free(dayPtr);
|
|
427
|
+
this.SweModule._free(hourPtr);
|
|
428
|
+
|
|
429
|
+
return { year, month, day, hour };
|
|
430
|
+
}
|
|
298
431
|
|
|
299
432
|
calc_ut(julianDay, body, flags) {
|
|
300
|
-
const
|
|
301
|
-
this.SweModule.
|
|
302
|
-
const
|
|
303
|
-
|
|
433
|
+
const resultPtr = this.SweModule._malloc(6 * Float64Array.BYTES_PER_ELEMENT);
|
|
434
|
+
const errorBuffer = this.SweModule._malloc(256);
|
|
435
|
+
const retFlag = this.SweModule.ccall(
|
|
436
|
+
'swe_calc_ut',
|
|
437
|
+
'number',
|
|
438
|
+
['number', 'number', 'number', 'pointer', 'pointer'],
|
|
439
|
+
[julianDay, body, flags, resultPtr, errorBuffer]
|
|
440
|
+
);
|
|
441
|
+
|
|
442
|
+
if (retFlag < 0) {
|
|
443
|
+
const error = this.SweModule.UTF8ToString(errorBuffer);
|
|
444
|
+
this.SweModule._free(resultPtr);
|
|
445
|
+
this.SweModule._free(errorBuffer);
|
|
446
|
+
throw new Error(`Error in swe_calc_ut: ${error}`);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// Copy data to a safe array before freeing memory
|
|
450
|
+
const start = resultPtr / 8;
|
|
451
|
+
const result = this.SweModule.HEAPF64.slice(start, start + 6);
|
|
452
|
+
|
|
453
|
+
this.SweModule._free(resultPtr);
|
|
454
|
+
this.SweModule._free(errorBuffer);
|
|
304
455
|
return result;
|
|
305
456
|
}
|
|
306
457
|
|
|
@@ -309,7 +460,13 @@ class SwissEph {
|
|
|
309
460
|
}
|
|
310
461
|
|
|
311
462
|
time_equ(julianDay) {
|
|
312
|
-
|
|
463
|
+
const tePtr = this.SweModule._malloc(8);
|
|
464
|
+
const serr = this.SweModule._malloc(256);
|
|
465
|
+
this.SweModule.ccall('swe_time_equ', 'number', ['number', 'pointer', 'pointer'], [julianDay, tePtr, serr]);
|
|
466
|
+
const result = this.SweModule.HEAPF64[tePtr >> 3];
|
|
467
|
+
this.SweModule._free(tePtr);
|
|
468
|
+
this.SweModule._free(serr);
|
|
469
|
+
return result;
|
|
313
470
|
}
|
|
314
471
|
|
|
315
472
|
sidtime0(julianDay, eps, nut) {
|
|
@@ -321,11 +478,35 @@ class SwissEph {
|
|
|
321
478
|
}
|
|
322
479
|
|
|
323
480
|
cotrans(xpo, eps) {
|
|
324
|
-
|
|
481
|
+
const xpoPtr = this.SweModule._malloc(3 * 8); // 3 doubles
|
|
482
|
+
const xpnPtr = this.SweModule._malloc(3 * 8); // 3 doubles
|
|
483
|
+
|
|
484
|
+
this.SweModule.HEAPF64.set(xpo, xpoPtr >> 3);
|
|
485
|
+
|
|
486
|
+
this.SweModule.ccall('swe_cotrans', 'void', ['number', 'number', 'number'], [xpoPtr, xpnPtr, eps]);
|
|
487
|
+
|
|
488
|
+
const result = new Float64Array(this.SweModule.HEAPF64.buffer, xpnPtr, 3).slice();
|
|
489
|
+
|
|
490
|
+
this.SweModule._free(xpoPtr);
|
|
491
|
+
this.SweModule._free(xpnPtr);
|
|
492
|
+
|
|
493
|
+
return Array.from(result);
|
|
325
494
|
}
|
|
326
495
|
|
|
327
496
|
cotrans_sp(xpo, eps) {
|
|
328
|
-
|
|
497
|
+
const xpoPtr = this.SweModule._malloc(6 * 8); // 6 doubles
|
|
498
|
+
const xpnPtr = this.SweModule._malloc(6 * 8); // 6 doubles
|
|
499
|
+
|
|
500
|
+
this.SweModule.HEAPF64.set(xpo, xpoPtr >> 3);
|
|
501
|
+
|
|
502
|
+
this.SweModule.ccall('swe_cotrans_sp', 'void', ['number', 'number', 'number'], [xpoPtr, xpnPtr, eps]);
|
|
503
|
+
|
|
504
|
+
const result = new Float64Array(this.SweModule.HEAPF64.buffer, xpnPtr, 6).slice();
|
|
505
|
+
|
|
506
|
+
this.SweModule._free(xpoPtr);
|
|
507
|
+
this.SweModule._free(xpnPtr);
|
|
508
|
+
|
|
509
|
+
return Array.from(result);
|
|
329
510
|
}
|
|
330
511
|
|
|
331
512
|
get_tid_acc() {
|
|
@@ -340,8 +521,8 @@ class SwissEph {
|
|
|
340
521
|
return this.SweModule.ccall('swe_degnorm', 'number', ['number'], [x]);
|
|
341
522
|
}
|
|
342
523
|
|
|
343
|
-
radnorm(
|
|
344
|
-
return this.SweModule.ccall('swe_radnorm', 'number', ['number'], [
|
|
524
|
+
radnorm(angle) {
|
|
525
|
+
return this.SweModule.ccall('swe_radnorm', 'number', ['number'], [angle]);
|
|
345
526
|
}
|
|
346
527
|
|
|
347
528
|
rad_midp(x1, x2) {
|
|
@@ -353,17 +534,37 @@ class SwissEph {
|
|
|
353
534
|
}
|
|
354
535
|
|
|
355
536
|
split_deg(ddeg, roundFlag) {
|
|
356
|
-
const
|
|
357
|
-
this.SweModule.
|
|
358
|
-
const
|
|
359
|
-
this.SweModule.
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
537
|
+
const degPtr = this.SweModule._malloc(4);
|
|
538
|
+
const minPtr = this.SweModule._malloc(4);
|
|
539
|
+
const secPtr = this.SweModule._malloc(4);
|
|
540
|
+
const dsecfrPtr = this.SweModule._malloc(8);
|
|
541
|
+
const isgnPtr = this.SweModule._malloc(4);
|
|
542
|
+
|
|
543
|
+
this.SweModule.ccall(
|
|
544
|
+
'swe_split_deg',
|
|
545
|
+
'void',
|
|
546
|
+
['number', 'number', 'pointer', 'pointer', 'pointer', 'pointer', 'pointer'],
|
|
547
|
+
[ddeg, roundFlag, degPtr, minPtr, secPtr, dsecfrPtr, isgnPtr]
|
|
548
|
+
);
|
|
549
|
+
|
|
550
|
+
const HEAP32 = new Int32Array(this.SweModule.HEAPF64.buffer);
|
|
551
|
+
const HEAPF64 = new Float64Array(this.SweModule.HEAPF64.buffer);
|
|
552
|
+
|
|
553
|
+
const result = {
|
|
554
|
+
degree: HEAP32[degPtr >> 2],
|
|
555
|
+
min: HEAP32[minPtr >> 2],
|
|
556
|
+
second: HEAP32[secPtr >> 2],
|
|
557
|
+
fraction: HEAPF64[dsecfrPtr >> 3],
|
|
558
|
+
sign: HEAP32[isgnPtr >> 2],
|
|
366
559
|
};
|
|
560
|
+
|
|
561
|
+
this.SweModule._free(degPtr);
|
|
562
|
+
this.SweModule._free(minPtr);
|
|
563
|
+
this.SweModule._free(secPtr);
|
|
564
|
+
this.SweModule._free(dsecfrPtr);
|
|
565
|
+
this.SweModule._free(isgnPtr);
|
|
566
|
+
|
|
567
|
+
return result;
|
|
367
568
|
}
|
|
368
569
|
|
|
369
570
|
csnorm(p) {
|
|
@@ -403,44 +604,30 @@ class SwissEph {
|
|
|
403
604
|
}
|
|
404
605
|
|
|
405
606
|
cs2timestr(t, sep, suppressZero) {
|
|
406
|
-
|
|
607
|
+
const bufPtr = this.SweModule._malloc(256);
|
|
608
|
+
this.SweModule.ccall('swe_cs2timestr', 'void', ['number', 'number', 'number', 'pointer'], [t, sep.charCodeAt(0), suppressZero ? 1 : 0, bufPtr]);
|
|
609
|
+
const result = this.SweModule.UTF8ToString(bufPtr);
|
|
610
|
+
this.SweModule._free(bufPtr);
|
|
611
|
+
return result;
|
|
407
612
|
}
|
|
408
613
|
|
|
409
614
|
cs2lonlatstr(t, pChar, mChar) {
|
|
410
|
-
|
|
615
|
+
const bufPtr = this.SweModule._malloc(256);
|
|
616
|
+
this.SweModule.ccall('swe_cs2lonlatstr', 'void', ['number', 'number', 'number', 'pointer'], [t, pChar.charCodeAt(0), mChar.charCodeAt(0), bufPtr]);
|
|
617
|
+
const result = this.SweModule.UTF8ToString(bufPtr);
|
|
618
|
+
this.SweModule._free(bufPtr);
|
|
619
|
+
return result;
|
|
411
620
|
}
|
|
412
621
|
|
|
413
622
|
cs2degstr(t) {
|
|
414
|
-
|
|
623
|
+
const bufPtr = this.SweModule._malloc(256);
|
|
624
|
+
this.SweModule.ccall('swe_cs2degstr', 'void', ['number', 'pointer'], [t, bufPtr]);
|
|
625
|
+
const result = this.SweModule.UTF8ToString(bufPtr);
|
|
626
|
+
this.SweModule._free(bufPtr);
|
|
627
|
+
return result;
|
|
415
628
|
}
|
|
416
629
|
|
|
417
|
-
date_conversion(year, month, day, hour, gregflag) {
|
|
418
|
-
const julianDay = this.SweModule.ccall(
|
|
419
|
-
'swe_date_conversion',
|
|
420
|
-
'number',
|
|
421
|
-
['number', 'number', 'number', 'number', 'number'],
|
|
422
|
-
[year, month, day, hour, gregflag]
|
|
423
|
-
);
|
|
424
|
-
return julianDay;
|
|
425
|
-
}
|
|
426
630
|
|
|
427
|
-
revjul(julianDay, gregflag) {
|
|
428
|
-
const buffer = this.SweModule._malloc(4 * Float64Array.BYTES_PER_ELEMENT);
|
|
429
|
-
this.SweModule.ccall(
|
|
430
|
-
'swe_revjul',
|
|
431
|
-
'void',
|
|
432
|
-
['number', 'number', 'pointer'],
|
|
433
|
-
[julianDay, gregflag, buffer]
|
|
434
|
-
);
|
|
435
|
-
const result = new Float64Array(this.SweModule.HEAPF64.buffer, buffer, 4);
|
|
436
|
-
this.SweModule._free(buffer);
|
|
437
|
-
return {
|
|
438
|
-
year: result[0],
|
|
439
|
-
month: result[1],
|
|
440
|
-
day: result[2],
|
|
441
|
-
hour: result[3],
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
631
|
|
|
445
632
|
utc_to_jd(year, month, day, hour, minute, second, gregflag) {
|
|
446
633
|
const resultPtr = this.SweModule._malloc(2 * Float64Array.BYTES_PER_ELEMENT);
|
|
@@ -459,67 +646,122 @@ class SwissEph {
|
|
|
459
646
|
}
|
|
460
647
|
|
|
461
648
|
jdet_to_utc(julianDay, gregflag) {
|
|
462
|
-
const
|
|
649
|
+
const yearPtr = this.SweModule._malloc(4);
|
|
650
|
+
const monthPtr = this.SweModule._malloc(4);
|
|
651
|
+
const dayPtr = this.SweModule._malloc(4);
|
|
652
|
+
const hourPtr = this.SweModule._malloc(4);
|
|
653
|
+
const minPtr = this.SweModule._malloc(4);
|
|
654
|
+
const secPtr = this.SweModule._malloc(8);
|
|
655
|
+
|
|
463
656
|
this.SweModule.ccall(
|
|
464
657
|
'swe_jdet_to_utc',
|
|
465
658
|
'void',
|
|
466
|
-
['number', 'number', 'pointer'],
|
|
467
|
-
[julianDay, gregflag,
|
|
659
|
+
['number', 'number', 'pointer', 'pointer', 'pointer', 'pointer', 'pointer', 'pointer'],
|
|
660
|
+
[julianDay, gregflag, yearPtr, monthPtr, dayPtr, hourPtr, minPtr, secPtr]
|
|
468
661
|
);
|
|
469
|
-
|
|
470
|
-
this.SweModule.
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
662
|
+
|
|
663
|
+
const HEAP32 = new Int32Array(this.SweModule.HEAPF64.buffer);
|
|
664
|
+
const HEAPF64 = new Float64Array(this.SweModule.HEAPF64.buffer);
|
|
665
|
+
|
|
666
|
+
const result = {
|
|
667
|
+
year: HEAP32[yearPtr >> 2],
|
|
668
|
+
month: HEAP32[monthPtr >> 2],
|
|
669
|
+
day: HEAP32[dayPtr >> 2],
|
|
670
|
+
hour: HEAP32[hourPtr >> 2],
|
|
671
|
+
minute: HEAP32[minPtr >> 2],
|
|
672
|
+
second: HEAPF64[secPtr >> 3],
|
|
478
673
|
};
|
|
674
|
+
|
|
675
|
+
this.SweModule._free(yearPtr);
|
|
676
|
+
this.SweModule._free(monthPtr);
|
|
677
|
+
this.SweModule._free(dayPtr);
|
|
678
|
+
this.SweModule._free(hourPtr);
|
|
679
|
+
this.SweModule._free(minPtr);
|
|
680
|
+
this.SweModule._free(secPtr);
|
|
681
|
+
|
|
682
|
+
return result;
|
|
479
683
|
}
|
|
480
684
|
|
|
481
685
|
jdut1_to_utc(julianDay, gregflag) {
|
|
482
|
-
const
|
|
686
|
+
const yearPtr = this.SweModule._malloc(4);
|
|
687
|
+
const monthPtr = this.SweModule._malloc(4);
|
|
688
|
+
const dayPtr = this.SweModule._malloc(4);
|
|
689
|
+
const hourPtr = this.SweModule._malloc(4);
|
|
690
|
+
const minPtr = this.SweModule._malloc(4);
|
|
691
|
+
const secPtr = this.SweModule._malloc(8);
|
|
692
|
+
|
|
483
693
|
this.SweModule.ccall(
|
|
484
694
|
'swe_jdut1_to_utc',
|
|
485
695
|
'void',
|
|
486
|
-
['number', 'number', 'pointer'],
|
|
487
|
-
[julianDay, gregflag,
|
|
696
|
+
['number', 'number', 'pointer', 'pointer', 'pointer', 'pointer', 'pointer', 'pointer'],
|
|
697
|
+
[julianDay, gregflag, yearPtr, monthPtr, dayPtr, hourPtr, minPtr, secPtr]
|
|
488
698
|
);
|
|
489
|
-
|
|
490
|
-
this.SweModule.
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
699
|
+
|
|
700
|
+
const HEAP32 = new Int32Array(this.SweModule.HEAPF64.buffer);
|
|
701
|
+
const HEAPF64 = new Float64Array(this.SweModule.HEAPF64.buffer);
|
|
702
|
+
|
|
703
|
+
const result = {
|
|
704
|
+
year: HEAP32[yearPtr >> 2],
|
|
705
|
+
month: HEAP32[monthPtr >> 2],
|
|
706
|
+
day: HEAP32[dayPtr >> 2],
|
|
707
|
+
hour: HEAP32[hourPtr >> 2],
|
|
708
|
+
minute: HEAP32[minPtr >> 2],
|
|
709
|
+
second: HEAPF64[secPtr >> 3],
|
|
498
710
|
};
|
|
711
|
+
|
|
712
|
+
this.SweModule._free(yearPtr);
|
|
713
|
+
this.SweModule._free(monthPtr);
|
|
714
|
+
this.SweModule._free(dayPtr);
|
|
715
|
+
this.SweModule._free(hourPtr);
|
|
716
|
+
this.SweModule._free(minPtr);
|
|
717
|
+
this.SweModule._free(secPtr);
|
|
718
|
+
|
|
719
|
+
return result;
|
|
499
720
|
}
|
|
500
721
|
|
|
501
722
|
utc_time_zone(year, month, day, hour, minute, second, timezone) {
|
|
502
|
-
const
|
|
723
|
+
const yearPtr = this.SweModule._malloc(4);
|
|
724
|
+
const monthPtr = this.SweModule._malloc(4);
|
|
725
|
+
const dayPtr = this.SweModule._malloc(4);
|
|
726
|
+
const hourPtr = this.SweModule._malloc(4);
|
|
727
|
+
const minPtr = this.SweModule._malloc(4);
|
|
728
|
+
const secPtr = this.SweModule._malloc(8);
|
|
729
|
+
|
|
503
730
|
this.SweModule.ccall(
|
|
504
731
|
'swe_utc_time_zone',
|
|
505
732
|
'void',
|
|
506
|
-
['number', 'number', 'number', 'number', 'number', 'number', 'number', 'pointer'],
|
|
507
|
-
[year, month, day, hour, minute, second, timezone,
|
|
733
|
+
['number', 'number', 'number', 'number', 'number', 'number', 'number', 'pointer', 'pointer', 'pointer', 'pointer', 'pointer', 'pointer'],
|
|
734
|
+
[year, month, day, hour, minute, second, timezone, yearPtr, monthPtr, dayPtr, hourPtr, minPtr, secPtr]
|
|
508
735
|
);
|
|
509
|
-
|
|
510
|
-
this.SweModule.
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
736
|
+
|
|
737
|
+
const HEAP32 = new Int32Array(this.SweModule.HEAPF64.buffer);
|
|
738
|
+
const HEAPF64 = new Float64Array(this.SweModule.HEAPF64.buffer);
|
|
739
|
+
|
|
740
|
+
const result = {
|
|
741
|
+
year: HEAP32[yearPtr >> 2],
|
|
742
|
+
month: HEAP32[monthPtr >> 2],
|
|
743
|
+
day: HEAP32[dayPtr >> 2],
|
|
744
|
+
hour: HEAP32[hourPtr >> 2],
|
|
745
|
+
minute: HEAP32[minPtr >> 2],
|
|
746
|
+
second: HEAPF64[secPtr >> 3],
|
|
518
747
|
};
|
|
748
|
+
|
|
749
|
+
this.SweModule._free(yearPtr);
|
|
750
|
+
this.SweModule._free(monthPtr);
|
|
751
|
+
this.SweModule._free(dayPtr);
|
|
752
|
+
this.SweModule._free(hourPtr);
|
|
753
|
+
this.SweModule._free(minPtr);
|
|
754
|
+
this.SweModule._free(secPtr);
|
|
755
|
+
|
|
756
|
+
return result;
|
|
519
757
|
}
|
|
520
758
|
|
|
521
759
|
version() {
|
|
522
|
-
|
|
760
|
+
const bufPtr = this.SweModule._malloc(256);
|
|
761
|
+
this.SweModule.ccall('swe_version', 'void', ['pointer'], [bufPtr]);
|
|
762
|
+
const version = this.SweModule.UTF8ToString(bufPtr);
|
|
763
|
+
this.SweModule._free(bufPtr);
|
|
764
|
+
return version;
|
|
523
765
|
}
|
|
524
766
|
|
|
525
767
|
calc(julianDay, body, flags) {
|
|
@@ -537,7 +779,7 @@ class SwissEph {
|
|
|
537
779
|
this.SweModule._free(errorBuffer);
|
|
538
780
|
throw new Error(`Error in swe_calc: ${error}`);
|
|
539
781
|
}
|
|
540
|
-
const results = new Float64Array(this.SweModule.HEAPF64.buffer, resultPtr, 6);
|
|
782
|
+
const results = new Float64Array(this.SweModule.HEAPF64.buffer, resultPtr, 6).slice();
|
|
541
783
|
this.SweModule._free(resultPtr);
|
|
542
784
|
this.SweModule._free(errorBuffer);
|
|
543
785
|
return {
|
|
@@ -566,6 +808,22 @@ class SwissEph {
|
|
|
566
808
|
return retFlag < 0 ? null : results;
|
|
567
809
|
}
|
|
568
810
|
|
|
811
|
+
fixstar_ut(star, julianDay, flags) {
|
|
812
|
+
const resultPtr = this.SweModule._malloc(6 * Float64Array.BYTES_PER_ELEMENT);
|
|
813
|
+
const starBuffer = this.SweModule._malloc(star.length + 1);
|
|
814
|
+
this.SweModule.stringToUTF8(star, starBuffer, star.length + 1);
|
|
815
|
+
const retFlag = this.SweModule.ccall(
|
|
816
|
+
'swe_fixstar_ut',
|
|
817
|
+
'number',
|
|
818
|
+
['pointer', 'number', 'number', 'pointer'],
|
|
819
|
+
[starBuffer, julianDay, flags, resultPtr]
|
|
820
|
+
);
|
|
821
|
+
const results = new Float64Array(this.SweModule.HEAPF64.buffer, resultPtr, 6);
|
|
822
|
+
this.SweModule._free(starBuffer);
|
|
823
|
+
this.SweModule._free(resultPtr);
|
|
824
|
+
return retFlag < 0 ? null : results;
|
|
825
|
+
}
|
|
826
|
+
|
|
569
827
|
fixstar_mag(star) {
|
|
570
828
|
const magBuffer = this.SweModule._malloc(8);
|
|
571
829
|
const starBuffer = this.SweModule._malloc(star.length + 1);
|
|
@@ -648,12 +906,11 @@ class SwissEph {
|
|
|
648
906
|
}
|
|
649
907
|
|
|
650
908
|
get_planet_name(planetId) {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
);
|
|
909
|
+
const bufPtr = this.SweModule._malloc(256);
|
|
910
|
+
this.SweModule.ccall('swe_get_planet_name', 'void', ['number', 'pointer'], [planetId, bufPtr]);
|
|
911
|
+
const name = this.SweModule.UTF8ToString(bufPtr);
|
|
912
|
+
this.SweModule._free(bufPtr);
|
|
913
|
+
return name;
|
|
657
914
|
}
|
|
658
915
|
|
|
659
916
|
set_topo(longitude, latitude, altitude) {
|
|
@@ -694,27 +951,31 @@ class SwissEph {
|
|
|
694
951
|
|
|
695
952
|
get_ayanamsa_ex(julianDay, ephemerisFlag) {
|
|
696
953
|
const resultPtr = this.SweModule._malloc(8);
|
|
954
|
+
const errorPtr = this.SweModule._malloc(256);
|
|
697
955
|
const retFlag = this.SweModule.ccall(
|
|
698
956
|
'swe_get_ayanamsa_ex',
|
|
699
957
|
'number',
|
|
700
|
-
['number', 'number', 'pointer'],
|
|
701
|
-
[julianDay, ephemerisFlag, resultPtr]
|
|
958
|
+
['number', 'number', 'pointer', 'pointer'],
|
|
959
|
+
[julianDay, ephemerisFlag, resultPtr, errorPtr]
|
|
702
960
|
);
|
|
703
961
|
const result = this.SweModule.HEAPF64[resultPtr / 8];
|
|
704
962
|
this.SweModule._free(resultPtr);
|
|
963
|
+
this.SweModule._free(errorPtr);
|
|
705
964
|
return retFlag < 0 ? null : result;
|
|
706
965
|
}
|
|
707
966
|
|
|
708
967
|
get_ayanamsa_ex_ut(julianDay, ephemerisFlag) {
|
|
709
968
|
const resultPtr = this.SweModule._malloc(8);
|
|
969
|
+
const errorPtr = this.SweModule._malloc(256);
|
|
710
970
|
const retFlag = this.SweModule.ccall(
|
|
711
971
|
'swe_get_ayanamsa_ex_ut',
|
|
712
972
|
'number',
|
|
713
|
-
['number', 'number', 'pointer'],
|
|
714
|
-
[julianDay, ephemerisFlag, resultPtr]
|
|
973
|
+
['number', 'number', 'pointer', 'pointer'],
|
|
974
|
+
[julianDay, ephemerisFlag, resultPtr, errorPtr]
|
|
715
975
|
);
|
|
716
976
|
const result = this.SweModule.HEAPF64[resultPtr / 8];
|
|
717
977
|
this.SweModule._free(resultPtr);
|
|
978
|
+
this.SweModule._free(errorPtr);
|
|
718
979
|
return retFlag < 0 ? null : result;
|
|
719
980
|
}
|
|
720
981
|
|
|
@@ -728,21 +989,75 @@ class SwissEph {
|
|
|
728
989
|
}
|
|
729
990
|
|
|
730
991
|
nod_aps(julianDay, planet, flags, method) {
|
|
731
|
-
|
|
992
|
+
const xnPtr = this.SweModule._malloc(4 * 8);
|
|
993
|
+
const xasPtr = this.SweModule._malloc(4 * 8);
|
|
994
|
+
const serrPtr = this.SweModule._malloc(256);
|
|
995
|
+
|
|
996
|
+
const retFlag = this.SweModule.ccall(
|
|
732
997
|
'swe_nod_aps',
|
|
733
998
|
'number',
|
|
734
|
-
['number', 'number', 'number', 'number'],
|
|
735
|
-
[julianDay, planet, flags, method]
|
|
999
|
+
['number', 'number', 'number', 'number', 'number', 'number', 'number'],
|
|
1000
|
+
[julianDay, planet, flags, method, xnPtr, xasPtr, serrPtr]
|
|
736
1001
|
);
|
|
1002
|
+
|
|
1003
|
+
if (retFlag < 0) {
|
|
1004
|
+
this.SweModule._free(xnPtr);
|
|
1005
|
+
this.SweModule._free(xasPtr);
|
|
1006
|
+
this.SweModule._free(serrPtr);
|
|
1007
|
+
return { error: retFlag };
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
const nodes = new Float64Array(this.SweModule.HEAPF64.buffer, xnPtr, 4).slice();
|
|
1011
|
+
const apsides = new Float64Array(this.SweModule.HEAPF64.buffer, xasPtr, 4).slice();
|
|
1012
|
+
|
|
1013
|
+
this.SweModule._free(xnPtr);
|
|
1014
|
+
this.SweModule._free(xasPtr);
|
|
1015
|
+
this.SweModule._free(serrPtr);
|
|
1016
|
+
|
|
1017
|
+
return {
|
|
1018
|
+
nodes: Array.from(nodes),
|
|
1019
|
+
apsides: Array.from(apsides),
|
|
1020
|
+
asc_node: nodes[0],
|
|
1021
|
+
desc_node: nodes[1],
|
|
1022
|
+
perihelion: apsides[0],
|
|
1023
|
+
aphelion: apsides[1]
|
|
1024
|
+
};
|
|
737
1025
|
}
|
|
738
1026
|
|
|
739
1027
|
nod_aps_ut(julianDay, planet, flags, method) {
|
|
740
|
-
|
|
1028
|
+
const xnPtr = this.SweModule._malloc(4 * 8);
|
|
1029
|
+
const xasPtr = this.SweModule._malloc(4 * 8);
|
|
1030
|
+
const serrPtr = this.SweModule._malloc(256);
|
|
1031
|
+
|
|
1032
|
+
const retFlag = this.SweModule.ccall(
|
|
741
1033
|
'swe_nod_aps_ut',
|
|
742
1034
|
'number',
|
|
743
|
-
['number', 'number', 'number', 'number'],
|
|
744
|
-
[julianDay, planet, flags, method]
|
|
1035
|
+
['number', 'number', 'number', 'number', 'number', 'number', 'number'],
|
|
1036
|
+
[julianDay, planet, flags, method, xnPtr, xasPtr, serrPtr]
|
|
745
1037
|
);
|
|
1038
|
+
|
|
1039
|
+
if (retFlag < 0) {
|
|
1040
|
+
this.SweModule._free(xnPtr);
|
|
1041
|
+
this.SweModule._free(xasPtr);
|
|
1042
|
+
this.SweModule._free(serrPtr);
|
|
1043
|
+
return { error: retFlag };
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
const nodes = new Float64Array(this.SweModule.HEAPF64.buffer, xnPtr, 4).slice();
|
|
1047
|
+
const apsides = new Float64Array(this.SweModule.HEAPF64.buffer, xasPtr, 4).slice();
|
|
1048
|
+
|
|
1049
|
+
this.SweModule._free(xnPtr);
|
|
1050
|
+
this.SweModule._free(xasPtr);
|
|
1051
|
+
this.SweModule._free(serrPtr);
|
|
1052
|
+
|
|
1053
|
+
return {
|
|
1054
|
+
nodes: Array.from(nodes),
|
|
1055
|
+
apsides: Array.from(apsides),
|
|
1056
|
+
asc_node: nodes[0],
|
|
1057
|
+
desc_node: nodes[1],
|
|
1058
|
+
perihelion: apsides[0],
|
|
1059
|
+
aphelion: apsides[1]
|
|
1060
|
+
};
|
|
746
1061
|
}
|
|
747
1062
|
|
|
748
1063
|
get_orbital_elements(julianDay, planet, flags) {
|
|
@@ -791,48 +1106,103 @@ class SwissEph {
|
|
|
791
1106
|
}
|
|
792
1107
|
|
|
793
1108
|
houses(julianDay, geoLat, geoLon, houseSystem) {
|
|
794
|
-
|
|
1109
|
+
const cuspsPtr = this.SweModule._malloc(13 * 8); // 13 doubles
|
|
1110
|
+
const ascmcPtr = this.SweModule._malloc(10 * 8); // 10 doubles
|
|
1111
|
+
|
|
1112
|
+
this.SweModule.ccall(
|
|
795
1113
|
'swe_houses',
|
|
796
1114
|
'number',
|
|
797
|
-
['number', 'number', 'number', '
|
|
798
|
-
[julianDay, geoLat, geoLon, houseSystem]
|
|
1115
|
+
['number', 'number', 'number', 'number', 'pointer', 'pointer'],
|
|
1116
|
+
[julianDay, geoLat, geoLon, houseSystem.charCodeAt(0), cuspsPtr, ascmcPtr]
|
|
799
1117
|
);
|
|
1118
|
+
|
|
1119
|
+
const cusps = new Float64Array(this.SweModule.HEAPF64.buffer, cuspsPtr, 13).slice();
|
|
1120
|
+
const ascmc = new Float64Array(this.SweModule.HEAPF64.buffer, ascmcPtr, 10).slice();
|
|
1121
|
+
|
|
1122
|
+
this.SweModule._free(cuspsPtr);
|
|
1123
|
+
this.SweModule._free(ascmcPtr);
|
|
1124
|
+
|
|
1125
|
+
return { cusps, ascmc };
|
|
800
1126
|
}
|
|
801
1127
|
|
|
802
1128
|
houses_ex(julianDay, iflag, geoLat, geoLon, houseSystem) {
|
|
803
|
-
|
|
1129
|
+
const cuspsPtr = this.SweModule._malloc(13 * 8);
|
|
1130
|
+
const ascmcPtr = this.SweModule._malloc(10 * 8);
|
|
1131
|
+
|
|
1132
|
+
this.SweModule.ccall(
|
|
804
1133
|
'swe_houses_ex',
|
|
805
1134
|
'number',
|
|
806
|
-
['number', 'number', 'number', 'number', '
|
|
807
|
-
[julianDay, iflag, geoLat, geoLon, houseSystem]
|
|
1135
|
+
['number', 'number', 'number', 'number', 'number', 'pointer', 'pointer'],
|
|
1136
|
+
[julianDay, iflag, geoLat, geoLon, houseSystem.charCodeAt(0), cuspsPtr, ascmcPtr]
|
|
808
1137
|
);
|
|
1138
|
+
|
|
1139
|
+
const cusps = new Float64Array(this.SweModule.HEAPF64.buffer, cuspsPtr, 13).slice();
|
|
1140
|
+
const ascmc = new Float64Array(this.SweModule.HEAPF64.buffer, ascmcPtr, 10).slice();
|
|
1141
|
+
|
|
1142
|
+
this.SweModule._free(cuspsPtr);
|
|
1143
|
+
this.SweModule._free(ascmcPtr);
|
|
1144
|
+
|
|
1145
|
+
return { cusps, ascmc };
|
|
809
1146
|
}
|
|
810
1147
|
|
|
811
1148
|
houses_ex2(julianDay, iflag, geoLat, geoLon, houseSystem) {
|
|
812
|
-
|
|
1149
|
+
const cuspsPtr = this.SweModule._malloc(13 * 8);
|
|
1150
|
+
const ascmcPtr = this.SweModule._malloc(10 * 8);
|
|
1151
|
+
|
|
1152
|
+
this.SweModule.ccall(
|
|
813
1153
|
'swe_houses_ex2',
|
|
814
1154
|
'number',
|
|
815
|
-
['number', 'number', 'number', 'number', '
|
|
816
|
-
[julianDay, iflag, geoLat, geoLon, houseSystem]
|
|
1155
|
+
['number', 'number', 'number', 'number', 'number', 'pointer', 'pointer'],
|
|
1156
|
+
[julianDay, iflag, geoLat, geoLon, houseSystem.charCodeAt(0), cuspsPtr, ascmcPtr]
|
|
817
1157
|
);
|
|
1158
|
+
|
|
1159
|
+
const cusps = new Float64Array(this.SweModule.HEAPF64.buffer, cuspsPtr, 13).slice();
|
|
1160
|
+
const ascmc = new Float64Array(this.SweModule.HEAPF64.buffer, ascmcPtr, 10).slice();
|
|
1161
|
+
|
|
1162
|
+
this.SweModule._free(cuspsPtr);
|
|
1163
|
+
this.SweModule._free(ascmcPtr);
|
|
1164
|
+
|
|
1165
|
+
return { cusps, ascmc };
|
|
818
1166
|
}
|
|
819
1167
|
|
|
820
1168
|
houses_armc(armc, geoLat, eps, houseSystem) {
|
|
821
|
-
|
|
1169
|
+
const cuspsPtr = this.SweModule._malloc(13 * 8);
|
|
1170
|
+
const ascmcPtr = this.SweModule._malloc(10 * 8);
|
|
1171
|
+
|
|
1172
|
+
this.SweModule.ccall(
|
|
822
1173
|
'swe_houses_armc',
|
|
823
1174
|
'number',
|
|
824
|
-
['number', 'number', 'number', '
|
|
825
|
-
[armc, geoLat, eps, houseSystem]
|
|
1175
|
+
['number', 'number', 'number', 'number', 'pointer', 'pointer'],
|
|
1176
|
+
[armc, geoLat, eps, houseSystem.charCodeAt(0), cuspsPtr, ascmcPtr]
|
|
826
1177
|
);
|
|
1178
|
+
|
|
1179
|
+
const cusps = new Float64Array(this.SweModule.HEAPF64.buffer, cuspsPtr, 13).slice();
|
|
1180
|
+
const ascmc = new Float64Array(this.SweModule.HEAPF64.buffer, ascmcPtr, 10).slice();
|
|
1181
|
+
|
|
1182
|
+
this.SweModule._free(cuspsPtr);
|
|
1183
|
+
this.SweModule._free(ascmcPtr);
|
|
1184
|
+
|
|
1185
|
+
return { cusps, ascmc };
|
|
827
1186
|
}
|
|
828
1187
|
|
|
829
1188
|
houses_armc_ex2(armc, geoLat, eps, houseSystem) {
|
|
830
|
-
|
|
1189
|
+
const cuspsPtr = this.SweModule._malloc(13 * 8);
|
|
1190
|
+
const ascmcPtr = this.SweModule._malloc(10 * 8);
|
|
1191
|
+
|
|
1192
|
+
this.SweModule.ccall(
|
|
831
1193
|
'swe_houses_armc_ex2',
|
|
832
1194
|
'number',
|
|
833
|
-
['number', 'number', 'number', '
|
|
834
|
-
[armc, geoLat, eps, houseSystem]
|
|
1195
|
+
['number', 'number', 'number', 'number', 'pointer', 'pointer'],
|
|
1196
|
+
[armc, geoLat, eps, houseSystem.charCodeAt(0), cuspsPtr, ascmcPtr]
|
|
835
1197
|
);
|
|
1198
|
+
|
|
1199
|
+
const cusps = new Float64Array(this.SweModule.HEAPF64.buffer, cuspsPtr, 13).slice();
|
|
1200
|
+
const ascmc = new Float64Array(this.SweModule.HEAPF64.buffer, ascmcPtr, 10).slice();
|
|
1201
|
+
|
|
1202
|
+
this.SweModule._free(cuspsPtr);
|
|
1203
|
+
this.SweModule._free(ascmcPtr);
|
|
1204
|
+
|
|
1205
|
+
return { cusps, ascmc };
|
|
836
1206
|
}
|
|
837
1207
|
|
|
838
1208
|
sol_eclipse_where(julianDay, flags) {
|
|
@@ -1035,30 +1405,94 @@ class SwissEph {
|
|
|
1035
1405
|
);
|
|
1036
1406
|
}
|
|
1037
1407
|
|
|
1038
|
-
|
|
1039
|
-
const
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1408
|
+
houses(julianDay, geoLat, geoLon, houseSystem) {
|
|
1409
|
+
const cuspsPtr = this.SweModule._malloc(13 * 8); // 13 doubles
|
|
1410
|
+
const ascmcPtr = this.SweModule._malloc(10 * 8); // 10 doubles
|
|
1411
|
+
|
|
1412
|
+
this.SweModule.ccall(
|
|
1413
|
+
'swe_houses',
|
|
1042
1414
|
'number',
|
|
1043
|
-
['number', 'number', 'number', '
|
|
1044
|
-
[julianDay, geoLat, geoLon,
|
|
1415
|
+
['number', 'number', 'number', 'string', 'pointer', 'pointer'],
|
|
1416
|
+
[julianDay, geoLat, geoLon, houseSystem, cuspsPtr, ascmcPtr]
|
|
1045
1417
|
);
|
|
1046
|
-
|
|
1047
|
-
this.SweModule.
|
|
1048
|
-
|
|
1418
|
+
|
|
1419
|
+
const cusps = new Float64Array(this.SweModule.HEAPF64.buffer, cuspsPtr, 13).slice();
|
|
1420
|
+
const ascmc = new Float64Array(this.SweModule.HEAPF64.buffer, ascmcPtr, 10).slice();
|
|
1421
|
+
|
|
1422
|
+
this.SweModule._free(cuspsPtr);
|
|
1423
|
+
this.SweModule._free(ascmcPtr);
|
|
1424
|
+
|
|
1425
|
+
return { cusps, ascmc };
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
azalt(tjd_ut, calc_flag, geopos, atpress, attemp, xin) {
|
|
1429
|
+
const xazPtr = this.SweModule._malloc(3 * 8);
|
|
1430
|
+
const xinPtr = this.SweModule._malloc(3 * 8);
|
|
1431
|
+
const geoposPtr = this.SweModule._malloc(3 * 8);
|
|
1432
|
+
|
|
1433
|
+
// Copy input coordinates
|
|
1434
|
+
const HEAPF64 = this.SweModule.HEAPF64;
|
|
1435
|
+
HEAPF64[xinPtr >> 3] = xin[0];
|
|
1436
|
+
HEAPF64[(xinPtr >> 3) + 1] = xin[1];
|
|
1437
|
+
HEAPF64[(xinPtr >> 3) + 2] = xin[2];
|
|
1438
|
+
|
|
1439
|
+
HEAPF64[geoposPtr >> 3] = geopos[0];
|
|
1440
|
+
HEAPF64[(geoposPtr >> 3) + 1] = geopos[1];
|
|
1441
|
+
HEAPF64[(geoposPtr >> 3) + 2] = geopos[2];
|
|
1442
|
+
|
|
1443
|
+
this.SweModule.ccall(
|
|
1444
|
+
'swe_azalt',
|
|
1445
|
+
'void',
|
|
1446
|
+
['number', 'number', 'pointer', 'number', 'number', 'pointer', 'pointer'],
|
|
1447
|
+
[tjd_ut, calc_flag, geoposPtr, atpress, attemp, xinPtr, xazPtr]
|
|
1448
|
+
);
|
|
1449
|
+
|
|
1450
|
+
const result = {
|
|
1451
|
+
azimuth: HEAPF64[xazPtr >> 3],
|
|
1452
|
+
trueAltitude: HEAPF64[(xazPtr >> 3) + 1],
|
|
1453
|
+
apparentAltitude: HEAPF64[(xazPtr >> 3) + 2],
|
|
1454
|
+
};
|
|
1455
|
+
|
|
1456
|
+
this.SweModule._free(xazPtr);
|
|
1457
|
+
this.SweModule._free(xinPtr);
|
|
1458
|
+
this.SweModule._free(geoposPtr);
|
|
1459
|
+
|
|
1460
|
+
return result;
|
|
1049
1461
|
}
|
|
1050
1462
|
|
|
1051
|
-
|
|
1052
|
-
const
|
|
1053
|
-
const
|
|
1463
|
+
azalt_rev(tjd_ut, calc_flag, geopos, xin) {
|
|
1464
|
+
const xoutPtr = this.SweModule._malloc(3 * 8);
|
|
1465
|
+
const xinPtr = this.SweModule._malloc(3 * 8);
|
|
1466
|
+
const geoposPtr = this.SweModule._malloc(3 * 8);
|
|
1467
|
+
|
|
1468
|
+
// Copy input coordinates
|
|
1469
|
+
const HEAPF64 = this.SweModule.HEAPF64;
|
|
1470
|
+
HEAPF64[xinPtr >> 3] = xin[0];
|
|
1471
|
+
HEAPF64[(xinPtr >> 3) + 1] = xin[1];
|
|
1472
|
+
HEAPF64[(xinPtr >> 3) + 2] = xin[2];
|
|
1473
|
+
|
|
1474
|
+
HEAPF64[geoposPtr >> 3] = geopos[0];
|
|
1475
|
+
HEAPF64[(geoposPtr >> 3) + 1] = geopos[1];
|
|
1476
|
+
HEAPF64[(geoposPtr >> 3) + 2] = geopos[2];
|
|
1477
|
+
|
|
1478
|
+
this.SweModule.ccall(
|
|
1054
1479
|
'swe_azalt_rev',
|
|
1055
|
-
'
|
|
1056
|
-
['number', 'number', '
|
|
1057
|
-
[
|
|
1480
|
+
'void',
|
|
1481
|
+
['number', 'number', 'pointer', 'pointer', 'pointer'],
|
|
1482
|
+
[tjd_ut, calc_flag, geoposPtr, xinPtr, xoutPtr]
|
|
1058
1483
|
);
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1484
|
+
|
|
1485
|
+
const result = {
|
|
1486
|
+
ra: HEAPF64[xoutPtr >> 3],
|
|
1487
|
+
dec: HEAPF64[(xoutPtr >> 3) + 1],
|
|
1488
|
+
distance: HEAPF64[(xoutPtr >> 3) + 2],
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
this.SweModule._free(xoutPtr);
|
|
1492
|
+
this.SweModule._free(xinPtr);
|
|
1493
|
+
this.SweModule._free(geoposPtr);
|
|
1494
|
+
|
|
1495
|
+
return result;
|
|
1062
1496
|
}
|
|
1063
1497
|
|
|
1064
1498
|
rise_trans(julianDay, planet, longitude, latitude, altitude, flags) {
|