@eopf-dggs/healpix-geo 0.1.0

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.
@@ -0,0 +1,36 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Returns the depth (level) for a given nside value.
5
+ * nside must be a power of 2.
6
+ */
7
+ export function nside_to_depth(nside: number): number;
8
+ /**
9
+ * Returns the 4 corner vertices of a HEALPix cell as [lon0,lat0, lon1,lat1, ...].
10
+ *
11
+ * Corners are in order: S, E, N, W (south, east, north, west).
12
+ * Coordinates are in radians.
13
+ */
14
+ export function vertices_nest(depth: number, hash: bigint): Float64Array;
15
+ /**
16
+ * Morton/Z-order bit interleaving: combines i and j into a single index.
17
+ *
18
+ * Used for HEALPix nested-to-texture mapping (Morton order unshuffling).
19
+ */
20
+ export function bit_combine(x: number, y: number): bigint;
21
+ /**
22
+ * Returns [x, y, z] unit vector for a position within a HEALPix nested cell.
23
+ *
24
+ * `depth` is the HEALPix depth (level), where nside = 2^depth.
25
+ * `hash` is the cell index in nested ordering.
26
+ * `dx` and `dy` are fractional positions within the cell, both in [0, 1].
27
+ *
28
+ * This is the equivalent of `@hscmap/healpix`'s `pixcoord2vec_nest(nside, ipix, u, v)`
29
+ * but uses depth instead of nside, and supports 64-bit cell indices.
30
+ */
31
+ export function pixcoord2vec_nest(depth: number, hash: bigint, dx: number, dy: number): Float64Array;
32
+ /**
33
+ * Convenience wrapper that takes nside instead of depth.
34
+ * nside must be a power of 2 (nside = 2^depth).
35
+ */
36
+ export function pixcoord2vec_nest_nside(nside: number, hash: bigint, dx: number, dy: number): Float64Array;
@@ -0,0 +1,5 @@
1
+ import * as wasm from "./healpix_wasm_bg.wasm";
2
+ export * from "./healpix_wasm_bg.js";
3
+ import { __wbg_set_wasm } from "./healpix_wasm_bg.js";
4
+ __wbg_set_wasm(wasm);
5
+ wasm.__wbindgen_start();
@@ -0,0 +1,141 @@
1
+ let wasm;
2
+ export function __wbg_set_wasm(val) {
3
+ wasm = val;
4
+ }
5
+
6
+
7
+ let cachedUint8ArrayMemory0 = null;
8
+
9
+ function getUint8ArrayMemory0() {
10
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
+ }
13
+ return cachedUint8ArrayMemory0;
14
+ }
15
+
16
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
17
+
18
+ cachedTextDecoder.decode();
19
+
20
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
21
+ let numBytesDecoded = 0;
22
+ function decodeText(ptr, len) {
23
+ numBytesDecoded += len;
24
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
25
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
26
+ cachedTextDecoder.decode();
27
+ numBytesDecoded = len;
28
+ }
29
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
30
+ }
31
+
32
+ function getStringFromWasm0(ptr, len) {
33
+ ptr = ptr >>> 0;
34
+ return decodeText(ptr, len);
35
+ }
36
+ /**
37
+ * Returns the depth (level) for a given nside value.
38
+ * nside must be a power of 2.
39
+ * @param {number} nside
40
+ * @returns {number}
41
+ */
42
+ export function nside_to_depth(nside) {
43
+ const ret = wasm.nside_to_depth(nside);
44
+ return ret;
45
+ }
46
+
47
+ let cachedFloat64ArrayMemory0 = null;
48
+
49
+ function getFloat64ArrayMemory0() {
50
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
51
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
52
+ }
53
+ return cachedFloat64ArrayMemory0;
54
+ }
55
+
56
+ function getArrayF64FromWasm0(ptr, len) {
57
+ ptr = ptr >>> 0;
58
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
59
+ }
60
+ /**
61
+ * Returns the 4 corner vertices of a HEALPix cell as [lon0,lat0, lon1,lat1, ...].
62
+ *
63
+ * Corners are in order: S, E, N, W (south, east, north, west).
64
+ * Coordinates are in radians.
65
+ * @param {number} depth
66
+ * @param {bigint} hash
67
+ * @returns {Float64Array}
68
+ */
69
+ export function vertices_nest(depth, hash) {
70
+ const ret = wasm.vertices_nest(depth, hash);
71
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
72
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
73
+ return v1;
74
+ }
75
+
76
+ /**
77
+ * Morton/Z-order bit interleaving: combines i and j into a single index.
78
+ *
79
+ * Used for HEALPix nested-to-texture mapping (Morton order unshuffling).
80
+ * @param {number} x
81
+ * @param {number} y
82
+ * @returns {bigint}
83
+ */
84
+ export function bit_combine(x, y) {
85
+ const ret = wasm.bit_combine(x, y);
86
+ return BigInt.asUintN(64, ret);
87
+ }
88
+
89
+ /**
90
+ * Returns [x, y, z] unit vector for a position within a HEALPix nested cell.
91
+ *
92
+ * `depth` is the HEALPix depth (level), where nside = 2^depth.
93
+ * `hash` is the cell index in nested ordering.
94
+ * `dx` and `dy` are fractional positions within the cell, both in [0, 1].
95
+ *
96
+ * This is the equivalent of `@hscmap/healpix`'s `pixcoord2vec_nest(nside, ipix, u, v)`
97
+ * but uses depth instead of nside, and supports 64-bit cell indices.
98
+ * @param {number} depth
99
+ * @param {bigint} hash
100
+ * @param {number} dx
101
+ * @param {number} dy
102
+ * @returns {Float64Array}
103
+ */
104
+ export function pixcoord2vec_nest(depth, hash, dx, dy) {
105
+ const ret = wasm.pixcoord2vec_nest(depth, hash, dx, dy);
106
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
107
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
108
+ return v1;
109
+ }
110
+
111
+ /**
112
+ * Convenience wrapper that takes nside instead of depth.
113
+ * nside must be a power of 2 (nside = 2^depth).
114
+ * @param {number} nside
115
+ * @param {bigint} hash
116
+ * @param {number} dx
117
+ * @param {number} dy
118
+ * @returns {Float64Array}
119
+ */
120
+ export function pixcoord2vec_nest_nside(nside, hash, dx, dy) {
121
+ const ret = wasm.pixcoord2vec_nest_nside(nside, hash, dx, dy);
122
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
123
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
124
+ return v1;
125
+ }
126
+
127
+ export function __wbg___wbindgen_throw_b855445ff6a94295(arg0, arg1) {
128
+ throw new Error(getStringFromWasm0(arg0, arg1));
129
+ };
130
+
131
+ export function __wbindgen_init_externref_table() {
132
+ const table = wasm.__wbindgen_externrefs;
133
+ const offset = table.grow(4);
134
+ table.set(0, undefined);
135
+ table.set(offset + 0, undefined);
136
+ table.set(offset + 1, null);
137
+ table.set(offset + 2, true);
138
+ table.set(offset + 3, false);
139
+ ;
140
+ };
141
+
Binary file
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@eopf-dggs/healpix-geo",
3
+ "type": "module",
4
+ "description": "HEALPix geometry for JavaScript/WASM \u2014 cell vertex positions and Z-order curve",
5
+ "version": "0.1.0",
6
+ "license": "Apache-2.0",
7
+ "files": [
8
+ "healpix_wasm_bg.wasm",
9
+ "healpix_wasm.js",
10
+ "healpix_wasm_bg.js",
11
+ "healpix_wasm.d.ts"
12
+ ],
13
+ "main": "healpix_wasm.js",
14
+ "types": "healpix_wasm.d.ts",
15
+ "sideEffects": [
16
+ "./healpix_wasm.js",
17
+ "./snippets/*"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/EOPF-DGGS/healpix-geo"
22
+ }
23
+ }