@totorototo/navigo 0.3.0 → 0.3.1
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/bundler/navigo.d.ts +96 -0
- package/bundler/navigo.js +9 -0
- package/bundler/navigo_bg.js +366 -0
- package/bundler/navigo_bg.wasm +0 -0
- package/bundler/navigo_bg.wasm.d.ts +30 -0
- package/package.json +13 -3
- package/web/navigo.d.ts +151 -0
- package/web/navigo.js +467 -0
- package/web/navigo_bg.wasm +0 -0
- package/web/navigo_bg.wasm.d.ts +30 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Opaque handle to a computed `Trace` that lives entirely in WASM memory.
|
|
6
|
+
*
|
|
7
|
+
* **Memory note**: call `.free()` when done (or register a `FinalizationRegistry`)
|
|
8
|
+
* because Rust's allocator cannot reclaim this memory from JS GC alone.
|
|
9
|
+
*
|
|
10
|
+
* ```js
|
|
11
|
+
* const registry = new FinalizationRegistry(t => t.free());
|
|
12
|
+
* const trace = buildTrace(pts);
|
|
13
|
+
* registry.register(trace, trace);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export class WasmTrace {
|
|
17
|
+
private constructor();
|
|
18
|
+
free(): void;
|
|
19
|
+
[Symbol.dispose](): void;
|
|
20
|
+
/**
|
|
21
|
+
* Returns `{ min_longitude, max_longitude, min_latitude, max_latitude }`.
|
|
22
|
+
*/
|
|
23
|
+
area(): any;
|
|
24
|
+
/**
|
|
25
|
+
* Returns an array of climb objects:
|
|
26
|
+
* `[{ start_index, end_index, start_dist_km, climb_dist_km, elevation_gain, summit_elev, avg_gradient }, …]`
|
|
27
|
+
*/
|
|
28
|
+
climbs(): any;
|
|
29
|
+
/**
|
|
30
|
+
* Returns `{ positive, negative }` (raw, non-denoised elevation totals).
|
|
31
|
+
*/
|
|
32
|
+
elevation(): any;
|
|
33
|
+
/**
|
|
34
|
+
* Returns `{ location: { longitude, latitude, altitude }, index, distance }`,
|
|
35
|
+
* or `undefined` when no closest point is found.
|
|
36
|
+
*/
|
|
37
|
+
find_closest_point(longitude: number, latitude: number, altitude: number): any | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Like `find_closest_point` but only searches from `start_from` onwards —
|
|
40
|
+
* use this on live-tracking loops to avoid snapping to an earlier position.
|
|
41
|
+
*/
|
|
42
|
+
find_closest_point_from(longitude: number, latitude: number, altitude: number, start_from: number): any | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Flat `Float64Array` `[lon, lat, alt, …]` for the index range (inclusive).
|
|
45
|
+
* Throws on out-of-bounds or invalid input.
|
|
46
|
+
*/
|
|
47
|
+
get_section(start_index: number, end_index: number): Float64Array;
|
|
48
|
+
/**
|
|
49
|
+
* Index of the first location at or beyond `dist_km`.
|
|
50
|
+
*/
|
|
51
|
+
index_at_distance(dist_km: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* Returns `{ longitude, latitude, altitude }`, or `undefined` when the
|
|
54
|
+
* distance is negative / the trace has no matching point.
|
|
55
|
+
*/
|
|
56
|
+
point_at_distance(dist_km: number): any | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Flat `Float64Array` `[lon, lat, alt, …]` for all points between the two
|
|
59
|
+
* cumulative distances, or `undefined` on invalid input.
|
|
60
|
+
*/
|
|
61
|
+
slice_between_distances(start_km: number, end_km: number): Float64Array | undefined;
|
|
62
|
+
readonly cumulative_distances: Float64Array;
|
|
63
|
+
readonly cumulative_elevation_gains: Float64Array;
|
|
64
|
+
readonly cumulative_elevation_losses: Float64Array;
|
|
65
|
+
/**
|
|
66
|
+
* Number of (possibly D-P simplified) locations.
|
|
67
|
+
*/
|
|
68
|
+
readonly location_count: number;
|
|
69
|
+
/**
|
|
70
|
+
* Flat `Float64Array` `[lon₀, lat₀, alt₀, lon₁, lat₁, alt₁, …]`.
|
|
71
|
+
*/
|
|
72
|
+
readonly locations_flat: Float64Array;
|
|
73
|
+
/**
|
|
74
|
+
* Peak indices as `Uint32Array`.
|
|
75
|
+
*/
|
|
76
|
+
readonly peaks: Uint32Array;
|
|
77
|
+
readonly slopes: Float64Array;
|
|
78
|
+
readonly total_distance: number;
|
|
79
|
+
readonly total_elevation_gain: number;
|
|
80
|
+
readonly total_elevation_loss: number;
|
|
81
|
+
/**
|
|
82
|
+
* Valley indices as `Uint32Array`.
|
|
83
|
+
*/
|
|
84
|
+
readonly valleys: Uint32Array;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Build a trace from a flat `Float64Array` of interleaved coordinates:
|
|
89
|
+
* `[lon₀, lat₀, alt₀, lon₁, lat₁, alt₁, …]`.
|
|
90
|
+
*
|
|
91
|
+
* Data is copied from JS memory into WASM once here; all subsequent work
|
|
92
|
+
* stays inside WASM. Returns a `WasmTrace` class instance whose methods can
|
|
93
|
+
* be called with near-zero boundary overhead, or `null` if `flat` carries no
|
|
94
|
+
* points.
|
|
95
|
+
*/
|
|
96
|
+
export function buildTrace(flat: Float64Array): WasmTrace | undefined;
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opaque handle to a computed `Trace` that lives entirely in WASM memory.
|
|
3
|
+
*
|
|
4
|
+
* **Memory note**: call `.free()` when done (or register a `FinalizationRegistry`)
|
|
5
|
+
* because Rust's allocator cannot reclaim this memory from JS GC alone.
|
|
6
|
+
*
|
|
7
|
+
* ```js
|
|
8
|
+
* const registry = new FinalizationRegistry(t => t.free());
|
|
9
|
+
* const trace = buildTrace(pts);
|
|
10
|
+
* registry.register(trace, trace);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export class WasmTrace {
|
|
14
|
+
static __wrap(ptr) {
|
|
15
|
+
const obj = Object.create(WasmTrace.prototype);
|
|
16
|
+
obj.__wbg_ptr = ptr;
|
|
17
|
+
WasmTraceFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
20
|
+
__destroy_into_raw() {
|
|
21
|
+
const ptr = this.__wbg_ptr;
|
|
22
|
+
this.__wbg_ptr = 0;
|
|
23
|
+
WasmTraceFinalization.unregister(this);
|
|
24
|
+
return ptr;
|
|
25
|
+
}
|
|
26
|
+
free() {
|
|
27
|
+
const ptr = this.__destroy_into_raw();
|
|
28
|
+
wasm.__wbg_wasmtrace_free(ptr, 0);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns `{ min_longitude, max_longitude, min_latitude, max_latitude }`.
|
|
32
|
+
* @returns {any}
|
|
33
|
+
*/
|
|
34
|
+
area() {
|
|
35
|
+
const ret = wasm.wasmtrace_area(this.__wbg_ptr);
|
|
36
|
+
return ret;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Returns an array of climb objects:
|
|
40
|
+
* `[{ start_index, end_index, start_dist_km, climb_dist_km, elevation_gain, summit_elev, avg_gradient }, …]`
|
|
41
|
+
* @returns {any}
|
|
42
|
+
*/
|
|
43
|
+
climbs() {
|
|
44
|
+
const ret = wasm.wasmtrace_climbs(this.__wbg_ptr);
|
|
45
|
+
return ret;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @returns {Float64Array}
|
|
49
|
+
*/
|
|
50
|
+
get cumulative_distances() {
|
|
51
|
+
const ret = wasm.wasmtrace_cumulative_distances(this.__wbg_ptr);
|
|
52
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
53
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
54
|
+
return v1;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @returns {Float64Array}
|
|
58
|
+
*/
|
|
59
|
+
get cumulative_elevation_gains() {
|
|
60
|
+
const ret = wasm.wasmtrace_cumulative_elevation_gains(this.__wbg_ptr);
|
|
61
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
62
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
63
|
+
return v1;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @returns {Float64Array}
|
|
67
|
+
*/
|
|
68
|
+
get cumulative_elevation_losses() {
|
|
69
|
+
const ret = wasm.wasmtrace_cumulative_elevation_losses(this.__wbg_ptr);
|
|
70
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
71
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
72
|
+
return v1;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Returns `{ positive, negative }` (raw, non-denoised elevation totals).
|
|
76
|
+
* @returns {any}
|
|
77
|
+
*/
|
|
78
|
+
elevation() {
|
|
79
|
+
const ret = wasm.wasmtrace_elevation(this.__wbg_ptr);
|
|
80
|
+
return ret;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns `{ location: { longitude, latitude, altitude }, index, distance }`,
|
|
84
|
+
* or `undefined` when no closest point is found.
|
|
85
|
+
* @param {number} longitude
|
|
86
|
+
* @param {number} latitude
|
|
87
|
+
* @param {number} altitude
|
|
88
|
+
* @returns {any | undefined}
|
|
89
|
+
*/
|
|
90
|
+
find_closest_point(longitude, latitude, altitude) {
|
|
91
|
+
const ret = wasm.wasmtrace_find_closest_point(this.__wbg_ptr, longitude, latitude, altitude);
|
|
92
|
+
return ret;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Like `find_closest_point` but only searches from `start_from` onwards —
|
|
96
|
+
* use this on live-tracking loops to avoid snapping to an earlier position.
|
|
97
|
+
* @param {number} longitude
|
|
98
|
+
* @param {number} latitude
|
|
99
|
+
* @param {number} altitude
|
|
100
|
+
* @param {number} start_from
|
|
101
|
+
* @returns {any | undefined}
|
|
102
|
+
*/
|
|
103
|
+
find_closest_point_from(longitude, latitude, altitude, start_from) {
|
|
104
|
+
const ret = wasm.wasmtrace_find_closest_point_from(this.__wbg_ptr, longitude, latitude, altitude, start_from);
|
|
105
|
+
return ret;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Flat `Float64Array` `[lon, lat, alt, …]` for the index range (inclusive).
|
|
109
|
+
* Throws on out-of-bounds or invalid input.
|
|
110
|
+
* @param {number} start_index
|
|
111
|
+
* @param {number} end_index
|
|
112
|
+
* @returns {Float64Array}
|
|
113
|
+
*/
|
|
114
|
+
get_section(start_index, end_index) {
|
|
115
|
+
const ret = wasm.wasmtrace_get_section(this.__wbg_ptr, start_index, end_index);
|
|
116
|
+
if (ret[3]) {
|
|
117
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
118
|
+
}
|
|
119
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
120
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
121
|
+
return v1;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Index of the first location at or beyond `dist_km`.
|
|
125
|
+
* @param {number} dist_km
|
|
126
|
+
* @returns {number}
|
|
127
|
+
*/
|
|
128
|
+
index_at_distance(dist_km) {
|
|
129
|
+
const ret = wasm.wasmtrace_index_at_distance(this.__wbg_ptr, dist_km);
|
|
130
|
+
return ret >>> 0;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Number of (possibly D-P simplified) locations.
|
|
134
|
+
* @returns {number}
|
|
135
|
+
*/
|
|
136
|
+
get location_count() {
|
|
137
|
+
const ret = wasm.wasmtrace_location_count(this.__wbg_ptr);
|
|
138
|
+
return ret >>> 0;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Flat `Float64Array` `[lon₀, lat₀, alt₀, lon₁, lat₁, alt₁, …]`.
|
|
142
|
+
* @returns {Float64Array}
|
|
143
|
+
*/
|
|
144
|
+
get locations_flat() {
|
|
145
|
+
const ret = wasm.wasmtrace_locations_flat(this.__wbg_ptr);
|
|
146
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
147
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
148
|
+
return v1;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Peak indices as `Uint32Array`.
|
|
152
|
+
* @returns {Uint32Array}
|
|
153
|
+
*/
|
|
154
|
+
get peaks() {
|
|
155
|
+
const ret = wasm.wasmtrace_peaks(this.__wbg_ptr);
|
|
156
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
157
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
158
|
+
return v1;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Returns `{ longitude, latitude, altitude }`, or `undefined` when the
|
|
162
|
+
* distance is negative / the trace has no matching point.
|
|
163
|
+
* @param {number} dist_km
|
|
164
|
+
* @returns {any | undefined}
|
|
165
|
+
*/
|
|
166
|
+
point_at_distance(dist_km) {
|
|
167
|
+
const ret = wasm.wasmtrace_point_at_distance(this.__wbg_ptr, dist_km);
|
|
168
|
+
return ret;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Flat `Float64Array` `[lon, lat, alt, …]` for all points between the two
|
|
172
|
+
* cumulative distances, or `undefined` on invalid input.
|
|
173
|
+
* @param {number} start_km
|
|
174
|
+
* @param {number} end_km
|
|
175
|
+
* @returns {Float64Array | undefined}
|
|
176
|
+
*/
|
|
177
|
+
slice_between_distances(start_km, end_km) {
|
|
178
|
+
const ret = wasm.wasmtrace_slice_between_distances(this.__wbg_ptr, start_km, end_km);
|
|
179
|
+
let v1;
|
|
180
|
+
if (ret[0] !== 0) {
|
|
181
|
+
v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
182
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
183
|
+
}
|
|
184
|
+
return v1;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* @returns {Float64Array}
|
|
188
|
+
*/
|
|
189
|
+
get slopes() {
|
|
190
|
+
const ret = wasm.wasmtrace_slopes(this.__wbg_ptr);
|
|
191
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
192
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
193
|
+
return v1;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* @returns {number}
|
|
197
|
+
*/
|
|
198
|
+
get total_distance() {
|
|
199
|
+
const ret = wasm.wasmtrace_total_distance(this.__wbg_ptr);
|
|
200
|
+
return ret;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* @returns {number}
|
|
204
|
+
*/
|
|
205
|
+
get total_elevation_gain() {
|
|
206
|
+
const ret = wasm.wasmtrace_total_elevation_gain(this.__wbg_ptr);
|
|
207
|
+
return ret;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* @returns {number}
|
|
211
|
+
*/
|
|
212
|
+
get total_elevation_loss() {
|
|
213
|
+
const ret = wasm.wasmtrace_total_elevation_loss(this.__wbg_ptr);
|
|
214
|
+
return ret;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Valley indices as `Uint32Array`.
|
|
218
|
+
* @returns {Uint32Array}
|
|
219
|
+
*/
|
|
220
|
+
get valleys() {
|
|
221
|
+
const ret = wasm.wasmtrace_valleys(this.__wbg_ptr);
|
|
222
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
223
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
224
|
+
return v1;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (Symbol.dispose) WasmTrace.prototype[Symbol.dispose] = WasmTrace.prototype.free;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Build a trace from a flat `Float64Array` of interleaved coordinates:
|
|
231
|
+
* `[lon₀, lat₀, alt₀, lon₁, lat₁, alt₁, …]`.
|
|
232
|
+
*
|
|
233
|
+
* Data is copied from JS memory into WASM once here; all subsequent work
|
|
234
|
+
* stays inside WASM. Returns a `WasmTrace` class instance whose methods can
|
|
235
|
+
* be called with near-zero boundary overhead, or `null` if `flat` carries no
|
|
236
|
+
* points.
|
|
237
|
+
* @param {Float64Array} flat
|
|
238
|
+
* @returns {WasmTrace | undefined}
|
|
239
|
+
*/
|
|
240
|
+
export function buildTrace(flat) {
|
|
241
|
+
const ptr0 = passArrayF64ToWasm0(flat, wasm.__wbindgen_malloc);
|
|
242
|
+
const len0 = WASM_VECTOR_LEN;
|
|
243
|
+
const ret = wasm.buildTrace(ptr0, len0);
|
|
244
|
+
return ret === 0 ? undefined : WasmTrace.__wrap(ret);
|
|
245
|
+
}
|
|
246
|
+
export function __wbg_Error_fdd633d4bb5dd76a(arg0, arg1) {
|
|
247
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
248
|
+
return ret;
|
|
249
|
+
}
|
|
250
|
+
export function __wbg___wbindgen_throw_ea4887a5f8f9a9db(arg0, arg1) {
|
|
251
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
252
|
+
}
|
|
253
|
+
export function __wbg_new_2e117a478906f062() {
|
|
254
|
+
const ret = new Object();
|
|
255
|
+
return ret;
|
|
256
|
+
}
|
|
257
|
+
export function __wbg_new_36e147a8ced3c6e0() {
|
|
258
|
+
const ret = new Array();
|
|
259
|
+
return ret;
|
|
260
|
+
}
|
|
261
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
262
|
+
arg0[arg1] = arg2;
|
|
263
|
+
}
|
|
264
|
+
export function __wbg_set_dc601f4a69da0bc2(arg0, arg1, arg2) {
|
|
265
|
+
arg0[arg1 >>> 0] = arg2;
|
|
266
|
+
}
|
|
267
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
268
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
269
|
+
const ret = arg0;
|
|
270
|
+
return ret;
|
|
271
|
+
}
|
|
272
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
273
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
274
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
275
|
+
return ret;
|
|
276
|
+
}
|
|
277
|
+
export function __wbindgen_cast_0000000000000003(arg0) {
|
|
278
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
279
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
280
|
+
return ret;
|
|
281
|
+
}
|
|
282
|
+
export function __wbindgen_init_externref_table() {
|
|
283
|
+
const table = wasm.__wbindgen_externrefs;
|
|
284
|
+
const offset = table.grow(4);
|
|
285
|
+
table.set(0, undefined);
|
|
286
|
+
table.set(offset + 0, undefined);
|
|
287
|
+
table.set(offset + 1, null);
|
|
288
|
+
table.set(offset + 2, true);
|
|
289
|
+
table.set(offset + 3, false);
|
|
290
|
+
}
|
|
291
|
+
const WasmTraceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
292
|
+
? { register: () => {}, unregister: () => {} }
|
|
293
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmtrace_free(ptr, 1));
|
|
294
|
+
|
|
295
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
296
|
+
ptr = ptr >>> 0;
|
|
297
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
301
|
+
ptr = ptr >>> 0;
|
|
302
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
306
|
+
function getFloat64ArrayMemory0() {
|
|
307
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
308
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
309
|
+
}
|
|
310
|
+
return cachedFloat64ArrayMemory0;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function getStringFromWasm0(ptr, len) {
|
|
314
|
+
return decodeText(ptr >>> 0, len);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
let cachedUint32ArrayMemory0 = null;
|
|
318
|
+
function getUint32ArrayMemory0() {
|
|
319
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
320
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
321
|
+
}
|
|
322
|
+
return cachedUint32ArrayMemory0;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
let cachedUint8ArrayMemory0 = null;
|
|
326
|
+
function getUint8ArrayMemory0() {
|
|
327
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
328
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
329
|
+
}
|
|
330
|
+
return cachedUint8ArrayMemory0;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
334
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
335
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
336
|
+
WASM_VECTOR_LEN = arg.length;
|
|
337
|
+
return ptr;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function takeFromExternrefTable0(idx) {
|
|
341
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
342
|
+
wasm.__externref_table_dealloc(idx);
|
|
343
|
+
return value;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
347
|
+
cachedTextDecoder.decode();
|
|
348
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
349
|
+
let numBytesDecoded = 0;
|
|
350
|
+
function decodeText(ptr, len) {
|
|
351
|
+
numBytesDecoded += len;
|
|
352
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
353
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
354
|
+
cachedTextDecoder.decode();
|
|
355
|
+
numBytesDecoded = len;
|
|
356
|
+
}
|
|
357
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
let WASM_VECTOR_LEN = 0;
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
let wasm;
|
|
364
|
+
export function __wbg_set_wasm(val) {
|
|
365
|
+
wasm = val;
|
|
366
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_wasmtrace_free: (a: number, b: number) => void;
|
|
5
|
+
export const buildTrace: (a: number, b: number) => number;
|
|
6
|
+
export const wasmtrace_area: (a: number) => any;
|
|
7
|
+
export const wasmtrace_climbs: (a: number) => any;
|
|
8
|
+
export const wasmtrace_cumulative_distances: (a: number) => [number, number];
|
|
9
|
+
export const wasmtrace_cumulative_elevation_gains: (a: number) => [number, number];
|
|
10
|
+
export const wasmtrace_cumulative_elevation_losses: (a: number) => [number, number];
|
|
11
|
+
export const wasmtrace_elevation: (a: number) => any;
|
|
12
|
+
export const wasmtrace_find_closest_point: (a: number, b: number, c: number, d: number) => any;
|
|
13
|
+
export const wasmtrace_find_closest_point_from: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
14
|
+
export const wasmtrace_get_section: (a: number, b: number, c: number) => [number, number, number, number];
|
|
15
|
+
export const wasmtrace_index_at_distance: (a: number, b: number) => number;
|
|
16
|
+
export const wasmtrace_location_count: (a: number) => number;
|
|
17
|
+
export const wasmtrace_locations_flat: (a: number) => [number, number];
|
|
18
|
+
export const wasmtrace_peaks: (a: number) => [number, number];
|
|
19
|
+
export const wasmtrace_point_at_distance: (a: number, b: number) => any;
|
|
20
|
+
export const wasmtrace_slice_between_distances: (a: number, b: number, c: number) => [number, number];
|
|
21
|
+
export const wasmtrace_slopes: (a: number) => [number, number];
|
|
22
|
+
export const wasmtrace_total_distance: (a: number) => number;
|
|
23
|
+
export const wasmtrace_total_elevation_gain: (a: number) => number;
|
|
24
|
+
export const wasmtrace_total_elevation_loss: (a: number) => number;
|
|
25
|
+
export const wasmtrace_valleys: (a: number) => [number, number];
|
|
26
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
27
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
28
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
29
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
30
|
+
export const __wbindgen_start: () => void;
|
package/package.json
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totorototo/navigo",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Simply manipulate GPS/geospatial data — distances, elevation, simplification, climb detection. Compiled from Rust to WebAssembly.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/totorototo/navigo"
|
|
9
9
|
},
|
|
10
|
-
"keywords": [
|
|
10
|
+
"keywords": [
|
|
11
|
+
"gps",
|
|
12
|
+
"geospatial",
|
|
13
|
+
"navigation",
|
|
14
|
+
"elevation",
|
|
15
|
+
"trace",
|
|
16
|
+
"wasm"
|
|
17
|
+
],
|
|
11
18
|
"type": "module",
|
|
12
19
|
"main": "./bundler/navigo.js",
|
|
13
20
|
"types": "./bundler/navigo.d.ts",
|
|
14
|
-
"files": [
|
|
21
|
+
"files": [
|
|
22
|
+
"bundler",
|
|
23
|
+
"web"
|
|
24
|
+
],
|
|
15
25
|
"exports": {
|
|
16
26
|
".": {
|
|
17
27
|
"types": "./bundler/navigo.d.ts",
|
package/web/navigo.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Opaque handle to a computed `Trace` that lives entirely in WASM memory.
|
|
6
|
+
*
|
|
7
|
+
* **Memory note**: call `.free()` when done (or register a `FinalizationRegistry`)
|
|
8
|
+
* because Rust's allocator cannot reclaim this memory from JS GC alone.
|
|
9
|
+
*
|
|
10
|
+
* ```js
|
|
11
|
+
* const registry = new FinalizationRegistry(t => t.free());
|
|
12
|
+
* const trace = buildTrace(pts);
|
|
13
|
+
* registry.register(trace, trace);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export class WasmTrace {
|
|
17
|
+
private constructor();
|
|
18
|
+
free(): void;
|
|
19
|
+
[Symbol.dispose](): void;
|
|
20
|
+
/**
|
|
21
|
+
* Returns `{ min_longitude, max_longitude, min_latitude, max_latitude }`.
|
|
22
|
+
*/
|
|
23
|
+
area(): any;
|
|
24
|
+
/**
|
|
25
|
+
* Returns an array of climb objects:
|
|
26
|
+
* `[{ start_index, end_index, start_dist_km, climb_dist_km, elevation_gain, summit_elev, avg_gradient }, …]`
|
|
27
|
+
*/
|
|
28
|
+
climbs(): any;
|
|
29
|
+
/**
|
|
30
|
+
* Returns `{ positive, negative }` (raw, non-denoised elevation totals).
|
|
31
|
+
*/
|
|
32
|
+
elevation(): any;
|
|
33
|
+
/**
|
|
34
|
+
* Returns `{ location: { longitude, latitude, altitude }, index, distance }`,
|
|
35
|
+
* or `undefined` when no closest point is found.
|
|
36
|
+
*/
|
|
37
|
+
find_closest_point(longitude: number, latitude: number, altitude: number): any | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Like `find_closest_point` but only searches from `start_from` onwards —
|
|
40
|
+
* use this on live-tracking loops to avoid snapping to an earlier position.
|
|
41
|
+
*/
|
|
42
|
+
find_closest_point_from(longitude: number, latitude: number, altitude: number, start_from: number): any | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Flat `Float64Array` `[lon, lat, alt, …]` for the index range (inclusive).
|
|
45
|
+
* Throws on out-of-bounds or invalid input.
|
|
46
|
+
*/
|
|
47
|
+
get_section(start_index: number, end_index: number): Float64Array;
|
|
48
|
+
/**
|
|
49
|
+
* Index of the first location at or beyond `dist_km`.
|
|
50
|
+
*/
|
|
51
|
+
index_at_distance(dist_km: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* Returns `{ longitude, latitude, altitude }`, or `undefined` when the
|
|
54
|
+
* distance is negative / the trace has no matching point.
|
|
55
|
+
*/
|
|
56
|
+
point_at_distance(dist_km: number): any | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Flat `Float64Array` `[lon, lat, alt, …]` for all points between the two
|
|
59
|
+
* cumulative distances, or `undefined` on invalid input.
|
|
60
|
+
*/
|
|
61
|
+
slice_between_distances(start_km: number, end_km: number): Float64Array | undefined;
|
|
62
|
+
readonly cumulative_distances: Float64Array;
|
|
63
|
+
readonly cumulative_elevation_gains: Float64Array;
|
|
64
|
+
readonly cumulative_elevation_losses: Float64Array;
|
|
65
|
+
/**
|
|
66
|
+
* Number of (possibly D-P simplified) locations.
|
|
67
|
+
*/
|
|
68
|
+
readonly location_count: number;
|
|
69
|
+
/**
|
|
70
|
+
* Flat `Float64Array` `[lon₀, lat₀, alt₀, lon₁, lat₁, alt₁, …]`.
|
|
71
|
+
*/
|
|
72
|
+
readonly locations_flat: Float64Array;
|
|
73
|
+
/**
|
|
74
|
+
* Peak indices as `Uint32Array`.
|
|
75
|
+
*/
|
|
76
|
+
readonly peaks: Uint32Array;
|
|
77
|
+
readonly slopes: Float64Array;
|
|
78
|
+
readonly total_distance: number;
|
|
79
|
+
readonly total_elevation_gain: number;
|
|
80
|
+
readonly total_elevation_loss: number;
|
|
81
|
+
/**
|
|
82
|
+
* Valley indices as `Uint32Array`.
|
|
83
|
+
*/
|
|
84
|
+
readonly valleys: Uint32Array;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Build a trace from a flat `Float64Array` of interleaved coordinates:
|
|
89
|
+
* `[lon₀, lat₀, alt₀, lon₁, lat₁, alt₁, …]`.
|
|
90
|
+
*
|
|
91
|
+
* Data is copied from JS memory into WASM once here; all subsequent work
|
|
92
|
+
* stays inside WASM. Returns a `WasmTrace` class instance whose methods can
|
|
93
|
+
* be called with near-zero boundary overhead, or `null` if `flat` carries no
|
|
94
|
+
* points.
|
|
95
|
+
*/
|
|
96
|
+
export function buildTrace(flat: Float64Array): WasmTrace | undefined;
|
|
97
|
+
|
|
98
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
99
|
+
|
|
100
|
+
export interface InitOutput {
|
|
101
|
+
readonly memory: WebAssembly.Memory;
|
|
102
|
+
readonly __wbg_wasmtrace_free: (a: number, b: number) => void;
|
|
103
|
+
readonly buildTrace: (a: number, b: number) => number;
|
|
104
|
+
readonly wasmtrace_area: (a: number) => any;
|
|
105
|
+
readonly wasmtrace_climbs: (a: number) => any;
|
|
106
|
+
readonly wasmtrace_cumulative_distances: (a: number) => [number, number];
|
|
107
|
+
readonly wasmtrace_cumulative_elevation_gains: (a: number) => [number, number];
|
|
108
|
+
readonly wasmtrace_cumulative_elevation_losses: (a: number) => [number, number];
|
|
109
|
+
readonly wasmtrace_elevation: (a: number) => any;
|
|
110
|
+
readonly wasmtrace_find_closest_point: (a: number, b: number, c: number, d: number) => any;
|
|
111
|
+
readonly wasmtrace_find_closest_point_from: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
112
|
+
readonly wasmtrace_get_section: (a: number, b: number, c: number) => [number, number, number, number];
|
|
113
|
+
readonly wasmtrace_index_at_distance: (a: number, b: number) => number;
|
|
114
|
+
readonly wasmtrace_location_count: (a: number) => number;
|
|
115
|
+
readonly wasmtrace_locations_flat: (a: number) => [number, number];
|
|
116
|
+
readonly wasmtrace_peaks: (a: number) => [number, number];
|
|
117
|
+
readonly wasmtrace_point_at_distance: (a: number, b: number) => any;
|
|
118
|
+
readonly wasmtrace_slice_between_distances: (a: number, b: number, c: number) => [number, number];
|
|
119
|
+
readonly wasmtrace_slopes: (a: number) => [number, number];
|
|
120
|
+
readonly wasmtrace_total_distance: (a: number) => number;
|
|
121
|
+
readonly wasmtrace_total_elevation_gain: (a: number) => number;
|
|
122
|
+
readonly wasmtrace_total_elevation_loss: (a: number) => number;
|
|
123
|
+
readonly wasmtrace_valleys: (a: number) => [number, number];
|
|
124
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
125
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
126
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
127
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
128
|
+
readonly __wbindgen_start: () => void;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
135
|
+
* a precompiled `WebAssembly.Module`.
|
|
136
|
+
*
|
|
137
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
138
|
+
*
|
|
139
|
+
* @returns {InitOutput}
|
|
140
|
+
*/
|
|
141
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
145
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
146
|
+
*
|
|
147
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
148
|
+
*
|
|
149
|
+
* @returns {Promise<InitOutput>}
|
|
150
|
+
*/
|
|
151
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/web/navigo.js
ADDED
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
/* @ts-self-types="./navigo.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Opaque handle to a computed `Trace` that lives entirely in WASM memory.
|
|
5
|
+
*
|
|
6
|
+
* **Memory note**: call `.free()` when done (or register a `FinalizationRegistry`)
|
|
7
|
+
* because Rust's allocator cannot reclaim this memory from JS GC alone.
|
|
8
|
+
*
|
|
9
|
+
* ```js
|
|
10
|
+
* const registry = new FinalizationRegistry(t => t.free());
|
|
11
|
+
* const trace = buildTrace(pts);
|
|
12
|
+
* registry.register(trace, trace);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export class WasmTrace {
|
|
16
|
+
static __wrap(ptr) {
|
|
17
|
+
const obj = Object.create(WasmTrace.prototype);
|
|
18
|
+
obj.__wbg_ptr = ptr;
|
|
19
|
+
WasmTraceFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
__destroy_into_raw() {
|
|
23
|
+
const ptr = this.__wbg_ptr;
|
|
24
|
+
this.__wbg_ptr = 0;
|
|
25
|
+
WasmTraceFinalization.unregister(this);
|
|
26
|
+
return ptr;
|
|
27
|
+
}
|
|
28
|
+
free() {
|
|
29
|
+
const ptr = this.__destroy_into_raw();
|
|
30
|
+
wasm.__wbg_wasmtrace_free(ptr, 0);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns `{ min_longitude, max_longitude, min_latitude, max_latitude }`.
|
|
34
|
+
* @returns {any}
|
|
35
|
+
*/
|
|
36
|
+
area() {
|
|
37
|
+
const ret = wasm.wasmtrace_area(this.__wbg_ptr);
|
|
38
|
+
return ret;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns an array of climb objects:
|
|
42
|
+
* `[{ start_index, end_index, start_dist_km, climb_dist_km, elevation_gain, summit_elev, avg_gradient }, …]`
|
|
43
|
+
* @returns {any}
|
|
44
|
+
*/
|
|
45
|
+
climbs() {
|
|
46
|
+
const ret = wasm.wasmtrace_climbs(this.__wbg_ptr);
|
|
47
|
+
return ret;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @returns {Float64Array}
|
|
51
|
+
*/
|
|
52
|
+
get cumulative_distances() {
|
|
53
|
+
const ret = wasm.wasmtrace_cumulative_distances(this.__wbg_ptr);
|
|
54
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
55
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
56
|
+
return v1;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @returns {Float64Array}
|
|
60
|
+
*/
|
|
61
|
+
get cumulative_elevation_gains() {
|
|
62
|
+
const ret = wasm.wasmtrace_cumulative_elevation_gains(this.__wbg_ptr);
|
|
63
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
64
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
65
|
+
return v1;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @returns {Float64Array}
|
|
69
|
+
*/
|
|
70
|
+
get cumulative_elevation_losses() {
|
|
71
|
+
const ret = wasm.wasmtrace_cumulative_elevation_losses(this.__wbg_ptr);
|
|
72
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
73
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
74
|
+
return v1;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns `{ positive, negative }` (raw, non-denoised elevation totals).
|
|
78
|
+
* @returns {any}
|
|
79
|
+
*/
|
|
80
|
+
elevation() {
|
|
81
|
+
const ret = wasm.wasmtrace_elevation(this.__wbg_ptr);
|
|
82
|
+
return ret;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns `{ location: { longitude, latitude, altitude }, index, distance }`,
|
|
86
|
+
* or `undefined` when no closest point is found.
|
|
87
|
+
* @param {number} longitude
|
|
88
|
+
* @param {number} latitude
|
|
89
|
+
* @param {number} altitude
|
|
90
|
+
* @returns {any | undefined}
|
|
91
|
+
*/
|
|
92
|
+
find_closest_point(longitude, latitude, altitude) {
|
|
93
|
+
const ret = wasm.wasmtrace_find_closest_point(this.__wbg_ptr, longitude, latitude, altitude);
|
|
94
|
+
return ret;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Like `find_closest_point` but only searches from `start_from` onwards —
|
|
98
|
+
* use this on live-tracking loops to avoid snapping to an earlier position.
|
|
99
|
+
* @param {number} longitude
|
|
100
|
+
* @param {number} latitude
|
|
101
|
+
* @param {number} altitude
|
|
102
|
+
* @param {number} start_from
|
|
103
|
+
* @returns {any | undefined}
|
|
104
|
+
*/
|
|
105
|
+
find_closest_point_from(longitude, latitude, altitude, start_from) {
|
|
106
|
+
const ret = wasm.wasmtrace_find_closest_point_from(this.__wbg_ptr, longitude, latitude, altitude, start_from);
|
|
107
|
+
return ret;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Flat `Float64Array` `[lon, lat, alt, …]` for the index range (inclusive).
|
|
111
|
+
* Throws on out-of-bounds or invalid input.
|
|
112
|
+
* @param {number} start_index
|
|
113
|
+
* @param {number} end_index
|
|
114
|
+
* @returns {Float64Array}
|
|
115
|
+
*/
|
|
116
|
+
get_section(start_index, end_index) {
|
|
117
|
+
const ret = wasm.wasmtrace_get_section(this.__wbg_ptr, start_index, end_index);
|
|
118
|
+
if (ret[3]) {
|
|
119
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
120
|
+
}
|
|
121
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
122
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
123
|
+
return v1;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Index of the first location at or beyond `dist_km`.
|
|
127
|
+
* @param {number} dist_km
|
|
128
|
+
* @returns {number}
|
|
129
|
+
*/
|
|
130
|
+
index_at_distance(dist_km) {
|
|
131
|
+
const ret = wasm.wasmtrace_index_at_distance(this.__wbg_ptr, dist_km);
|
|
132
|
+
return ret >>> 0;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Number of (possibly D-P simplified) locations.
|
|
136
|
+
* @returns {number}
|
|
137
|
+
*/
|
|
138
|
+
get location_count() {
|
|
139
|
+
const ret = wasm.wasmtrace_location_count(this.__wbg_ptr);
|
|
140
|
+
return ret >>> 0;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Flat `Float64Array` `[lon₀, lat₀, alt₀, lon₁, lat₁, alt₁, …]`.
|
|
144
|
+
* @returns {Float64Array}
|
|
145
|
+
*/
|
|
146
|
+
get locations_flat() {
|
|
147
|
+
const ret = wasm.wasmtrace_locations_flat(this.__wbg_ptr);
|
|
148
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
149
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
150
|
+
return v1;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Peak indices as `Uint32Array`.
|
|
154
|
+
* @returns {Uint32Array}
|
|
155
|
+
*/
|
|
156
|
+
get peaks() {
|
|
157
|
+
const ret = wasm.wasmtrace_peaks(this.__wbg_ptr);
|
|
158
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
159
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
160
|
+
return v1;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Returns `{ longitude, latitude, altitude }`, or `undefined` when the
|
|
164
|
+
* distance is negative / the trace has no matching point.
|
|
165
|
+
* @param {number} dist_km
|
|
166
|
+
* @returns {any | undefined}
|
|
167
|
+
*/
|
|
168
|
+
point_at_distance(dist_km) {
|
|
169
|
+
const ret = wasm.wasmtrace_point_at_distance(this.__wbg_ptr, dist_km);
|
|
170
|
+
return ret;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Flat `Float64Array` `[lon, lat, alt, …]` for all points between the two
|
|
174
|
+
* cumulative distances, or `undefined` on invalid input.
|
|
175
|
+
* @param {number} start_km
|
|
176
|
+
* @param {number} end_km
|
|
177
|
+
* @returns {Float64Array | undefined}
|
|
178
|
+
*/
|
|
179
|
+
slice_between_distances(start_km, end_km) {
|
|
180
|
+
const ret = wasm.wasmtrace_slice_between_distances(this.__wbg_ptr, start_km, end_km);
|
|
181
|
+
let v1;
|
|
182
|
+
if (ret[0] !== 0) {
|
|
183
|
+
v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
184
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
185
|
+
}
|
|
186
|
+
return v1;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @returns {Float64Array}
|
|
190
|
+
*/
|
|
191
|
+
get slopes() {
|
|
192
|
+
const ret = wasm.wasmtrace_slopes(this.__wbg_ptr);
|
|
193
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
194
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
195
|
+
return v1;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* @returns {number}
|
|
199
|
+
*/
|
|
200
|
+
get total_distance() {
|
|
201
|
+
const ret = wasm.wasmtrace_total_distance(this.__wbg_ptr);
|
|
202
|
+
return ret;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* @returns {number}
|
|
206
|
+
*/
|
|
207
|
+
get total_elevation_gain() {
|
|
208
|
+
const ret = wasm.wasmtrace_total_elevation_gain(this.__wbg_ptr);
|
|
209
|
+
return ret;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* @returns {number}
|
|
213
|
+
*/
|
|
214
|
+
get total_elevation_loss() {
|
|
215
|
+
const ret = wasm.wasmtrace_total_elevation_loss(this.__wbg_ptr);
|
|
216
|
+
return ret;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Valley indices as `Uint32Array`.
|
|
220
|
+
* @returns {Uint32Array}
|
|
221
|
+
*/
|
|
222
|
+
get valleys() {
|
|
223
|
+
const ret = wasm.wasmtrace_valleys(this.__wbg_ptr);
|
|
224
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
225
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
226
|
+
return v1;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (Symbol.dispose) WasmTrace.prototype[Symbol.dispose] = WasmTrace.prototype.free;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Build a trace from a flat `Float64Array` of interleaved coordinates:
|
|
233
|
+
* `[lon₀, lat₀, alt₀, lon₁, lat₁, alt₁, …]`.
|
|
234
|
+
*
|
|
235
|
+
* Data is copied from JS memory into WASM once here; all subsequent work
|
|
236
|
+
* stays inside WASM. Returns a `WasmTrace` class instance whose methods can
|
|
237
|
+
* be called with near-zero boundary overhead, or `null` if `flat` carries no
|
|
238
|
+
* points.
|
|
239
|
+
* @param {Float64Array} flat
|
|
240
|
+
* @returns {WasmTrace | undefined}
|
|
241
|
+
*/
|
|
242
|
+
export function buildTrace(flat) {
|
|
243
|
+
const ptr0 = passArrayF64ToWasm0(flat, wasm.__wbindgen_malloc);
|
|
244
|
+
const len0 = WASM_VECTOR_LEN;
|
|
245
|
+
const ret = wasm.buildTrace(ptr0, len0);
|
|
246
|
+
return ret === 0 ? undefined : WasmTrace.__wrap(ret);
|
|
247
|
+
}
|
|
248
|
+
function __wbg_get_imports() {
|
|
249
|
+
const import0 = {
|
|
250
|
+
__proto__: null,
|
|
251
|
+
__wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
|
|
252
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
253
|
+
return ret;
|
|
254
|
+
},
|
|
255
|
+
__wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
|
|
256
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
257
|
+
},
|
|
258
|
+
__wbg_new_2e117a478906f062: function() {
|
|
259
|
+
const ret = new Object();
|
|
260
|
+
return ret;
|
|
261
|
+
},
|
|
262
|
+
__wbg_new_36e147a8ced3c6e0: function() {
|
|
263
|
+
const ret = new Array();
|
|
264
|
+
return ret;
|
|
265
|
+
},
|
|
266
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
267
|
+
arg0[arg1] = arg2;
|
|
268
|
+
},
|
|
269
|
+
__wbg_set_dc601f4a69da0bc2: function(arg0, arg1, arg2) {
|
|
270
|
+
arg0[arg1 >>> 0] = arg2;
|
|
271
|
+
},
|
|
272
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
273
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
274
|
+
const ret = arg0;
|
|
275
|
+
return ret;
|
|
276
|
+
},
|
|
277
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
278
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
279
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
280
|
+
return ret;
|
|
281
|
+
},
|
|
282
|
+
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
283
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
284
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
285
|
+
return ret;
|
|
286
|
+
},
|
|
287
|
+
__wbindgen_init_externref_table: function() {
|
|
288
|
+
const table = wasm.__wbindgen_externrefs;
|
|
289
|
+
const offset = table.grow(4);
|
|
290
|
+
table.set(0, undefined);
|
|
291
|
+
table.set(offset + 0, undefined);
|
|
292
|
+
table.set(offset + 1, null);
|
|
293
|
+
table.set(offset + 2, true);
|
|
294
|
+
table.set(offset + 3, false);
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
return {
|
|
298
|
+
__proto__: null,
|
|
299
|
+
"./navigo_bg.js": import0,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const WasmTraceFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
304
|
+
? { register: () => {}, unregister: () => {} }
|
|
305
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmtrace_free(ptr, 1));
|
|
306
|
+
|
|
307
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
308
|
+
ptr = ptr >>> 0;
|
|
309
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
313
|
+
ptr = ptr >>> 0;
|
|
314
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
318
|
+
function getFloat64ArrayMemory0() {
|
|
319
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
320
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
321
|
+
}
|
|
322
|
+
return cachedFloat64ArrayMemory0;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function getStringFromWasm0(ptr, len) {
|
|
326
|
+
return decodeText(ptr >>> 0, len);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
let cachedUint32ArrayMemory0 = null;
|
|
330
|
+
function getUint32ArrayMemory0() {
|
|
331
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
332
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
333
|
+
}
|
|
334
|
+
return cachedUint32ArrayMemory0;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
let cachedUint8ArrayMemory0 = null;
|
|
338
|
+
function getUint8ArrayMemory0() {
|
|
339
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
340
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
341
|
+
}
|
|
342
|
+
return cachedUint8ArrayMemory0;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
346
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
347
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
348
|
+
WASM_VECTOR_LEN = arg.length;
|
|
349
|
+
return ptr;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function takeFromExternrefTable0(idx) {
|
|
353
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
354
|
+
wasm.__externref_table_dealloc(idx);
|
|
355
|
+
return value;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
359
|
+
cachedTextDecoder.decode();
|
|
360
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
361
|
+
let numBytesDecoded = 0;
|
|
362
|
+
function decodeText(ptr, len) {
|
|
363
|
+
numBytesDecoded += len;
|
|
364
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
365
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
366
|
+
cachedTextDecoder.decode();
|
|
367
|
+
numBytesDecoded = len;
|
|
368
|
+
}
|
|
369
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
let WASM_VECTOR_LEN = 0;
|
|
373
|
+
|
|
374
|
+
let wasmModule, wasmInstance, wasm;
|
|
375
|
+
function __wbg_finalize_init(instance, module) {
|
|
376
|
+
wasmInstance = instance;
|
|
377
|
+
wasm = instance.exports;
|
|
378
|
+
wasmModule = module;
|
|
379
|
+
cachedFloat64ArrayMemory0 = null;
|
|
380
|
+
cachedUint32ArrayMemory0 = null;
|
|
381
|
+
cachedUint8ArrayMemory0 = null;
|
|
382
|
+
wasm.__wbindgen_start();
|
|
383
|
+
return wasm;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
async function __wbg_load(module, imports) {
|
|
387
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
388
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
389
|
+
try {
|
|
390
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
391
|
+
} catch (e) {
|
|
392
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
393
|
+
|
|
394
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
395
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
396
|
+
|
|
397
|
+
} else { throw e; }
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const bytes = await module.arrayBuffer();
|
|
402
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
403
|
+
} else {
|
|
404
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
405
|
+
|
|
406
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
407
|
+
return { instance, module };
|
|
408
|
+
} else {
|
|
409
|
+
return instance;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function expectedResponseType(type) {
|
|
414
|
+
switch (type) {
|
|
415
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
416
|
+
}
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function initSync(module) {
|
|
422
|
+
if (wasm !== undefined) return wasm;
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
if (module !== undefined) {
|
|
426
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
427
|
+
({module} = module)
|
|
428
|
+
} else {
|
|
429
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const imports = __wbg_get_imports();
|
|
434
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
435
|
+
module = new WebAssembly.Module(module);
|
|
436
|
+
}
|
|
437
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
438
|
+
return __wbg_finalize_init(instance, module);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
async function __wbg_init(module_or_path) {
|
|
442
|
+
if (wasm !== undefined) return wasm;
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
if (module_or_path !== undefined) {
|
|
446
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
447
|
+
({module_or_path} = module_or_path)
|
|
448
|
+
} else {
|
|
449
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (module_or_path === undefined) {
|
|
454
|
+
module_or_path = new URL('navigo_bg.wasm', import.meta.url);
|
|
455
|
+
}
|
|
456
|
+
const imports = __wbg_get_imports();
|
|
457
|
+
|
|
458
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
459
|
+
module_or_path = fetch(module_or_path);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
463
|
+
|
|
464
|
+
return __wbg_finalize_init(instance, module);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_wasmtrace_free: (a: number, b: number) => void;
|
|
5
|
+
export const buildTrace: (a: number, b: number) => number;
|
|
6
|
+
export const wasmtrace_area: (a: number) => any;
|
|
7
|
+
export const wasmtrace_climbs: (a: number) => any;
|
|
8
|
+
export const wasmtrace_cumulative_distances: (a: number) => [number, number];
|
|
9
|
+
export const wasmtrace_cumulative_elevation_gains: (a: number) => [number, number];
|
|
10
|
+
export const wasmtrace_cumulative_elevation_losses: (a: number) => [number, number];
|
|
11
|
+
export const wasmtrace_elevation: (a: number) => any;
|
|
12
|
+
export const wasmtrace_find_closest_point: (a: number, b: number, c: number, d: number) => any;
|
|
13
|
+
export const wasmtrace_find_closest_point_from: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
14
|
+
export const wasmtrace_get_section: (a: number, b: number, c: number) => [number, number, number, number];
|
|
15
|
+
export const wasmtrace_index_at_distance: (a: number, b: number) => number;
|
|
16
|
+
export const wasmtrace_location_count: (a: number) => number;
|
|
17
|
+
export const wasmtrace_locations_flat: (a: number) => [number, number];
|
|
18
|
+
export const wasmtrace_peaks: (a: number) => [number, number];
|
|
19
|
+
export const wasmtrace_point_at_distance: (a: number, b: number) => any;
|
|
20
|
+
export const wasmtrace_slice_between_distances: (a: number, b: number, c: number) => [number, number];
|
|
21
|
+
export const wasmtrace_slopes: (a: number) => [number, number];
|
|
22
|
+
export const wasmtrace_total_distance: (a: number) => number;
|
|
23
|
+
export const wasmtrace_total_elevation_gain: (a: number) => number;
|
|
24
|
+
export const wasmtrace_total_elevation_loss: (a: number) => number;
|
|
25
|
+
export const wasmtrace_valleys: (a: number) => [number, number];
|
|
26
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
27
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
28
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
29
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
30
|
+
export const __wbindgen_start: () => void;
|