@math.gl/earth 5.0.0-alpha.20 → 5.0.0-beta.2
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 +2 -2
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/geoid/create-geoid-from-grid.js +1 -1
- package/dist/geoid/create-geoid-from-grid.js.map +1 -1
- package/dist/geoid/geoid.js +1 -1
- package/dist/geoid/geoid.js.map +1 -1
- package/dist/index.cjs +13791 -171
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/sun/index.cjs +7905 -0
- package/dist/sun/index.cjs.map +3 -3
- package/dist/sun/index.d.ts +8 -0
- package/dist/sun/index.d.ts.map +1 -1
- package/dist/sun/index.js +5 -0
- package/dist/sun/index.js.map +1 -1
- package/dist/sun/planet-position.d.ts +1 -1
- package/dist/sun/planet-position.js +1 -1
- package/dist/sun/stars.cjs +18 -16
- package/dist/sun/stars.cjs.map +1 -1
- package/dist/sun/stars.js +3 -2
- package/dist/sun/stars.js.map +1 -1
- package/dist/sun/suncalc.d.ts +1 -0
- package/dist/sun/suncalc.d.ts.map +1 -1
- package/dist/sun/suncalc.js +1 -1
- package/dist/sun/suncalc.js.map +1 -1
- package/dist/sun/terminator.d.ts +20 -0
- package/dist/sun/terminator.d.ts.map +1 -0
- package/dist/sun/terminator.js +88 -0
- package/dist/sun/terminator.js.map +1 -0
- package/dist/timezone/index.cjs +5678 -19
- package/dist/timezone/index.cjs.map +3 -3
- package/dist/timezone/index.d.ts +3 -0
- package/dist/timezone/index.d.ts.map +1 -1
- package/dist/timezone/index.js +3 -0
- package/dist/timezone/index.js.map +1 -1
- package/geoid/data/README.md +1 -1
- package/package.json +9 -41
- package/src/geoid/create-geoid-from-grid.ts +1 -1
- package/src/geoid/geoid.ts +1 -1
- package/src/index.ts +100 -0
- package/src/sun/index.ts +38 -0
- package/src/sun/planet-position.ts +1 -1
- package/src/sun/stars.ts +3 -3
- package/src/sun/suncalc.ts +1 -1
- package/src/sun/terminator.ts +112 -0
- package/src/timezone/index.ts +5 -0
- package/dist/geoid/index.cjs +0 -727
- package/dist/geoid/index.cjs.map +0 -6
- package/dist/sun/astronomy.cjs +0 -1729
- package/dist/sun/astronomy.cjs.map +0 -6
- package/dist/sun/planets.cjs +0 -411
- package/dist/sun/planets.cjs.map +0 -6
- package/dist/timezone/lookup.cjs +0 -83
- package/dist/timezone/lookup.cjs.map +0 -6
- package/dist/timezone/temporal.cjs +0 -5696
- package/dist/timezone/temporal.cjs.map +0 -6
package/dist/geoid/index.cjs
DELETED
|
@@ -1,727 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// dist/geoid/index.js
|
|
20
|
-
var index_exports = {};
|
|
21
|
-
__export(index_exports, {
|
|
22
|
-
Geoid: () => Geoid,
|
|
23
|
-
createGeoidFromGrid: () => createGeoidFromGrid,
|
|
24
|
-
parsePGM: () => parsePGM
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
|
|
28
|
-
// dist/geoid/geoid.js
|
|
29
|
-
var import_types = require("@math.gl/core/types");
|
|
30
|
-
var c0_ = 240;
|
|
31
|
-
var c3_ = [
|
|
32
|
-
9,
|
|
33
|
-
-18,
|
|
34
|
-
-88,
|
|
35
|
-
0,
|
|
36
|
-
96,
|
|
37
|
-
90,
|
|
38
|
-
0,
|
|
39
|
-
0,
|
|
40
|
-
-60,
|
|
41
|
-
-20,
|
|
42
|
-
-9,
|
|
43
|
-
18,
|
|
44
|
-
8,
|
|
45
|
-
0,
|
|
46
|
-
-96,
|
|
47
|
-
30,
|
|
48
|
-
0,
|
|
49
|
-
0,
|
|
50
|
-
60,
|
|
51
|
-
-20,
|
|
52
|
-
9,
|
|
53
|
-
-88,
|
|
54
|
-
-18,
|
|
55
|
-
90,
|
|
56
|
-
96,
|
|
57
|
-
0,
|
|
58
|
-
-20,
|
|
59
|
-
-60,
|
|
60
|
-
0,
|
|
61
|
-
0,
|
|
62
|
-
186,
|
|
63
|
-
-42,
|
|
64
|
-
-42,
|
|
65
|
-
-150,
|
|
66
|
-
-96,
|
|
67
|
-
-150,
|
|
68
|
-
60,
|
|
69
|
-
60,
|
|
70
|
-
60,
|
|
71
|
-
60,
|
|
72
|
-
54,
|
|
73
|
-
162,
|
|
74
|
-
-78,
|
|
75
|
-
30,
|
|
76
|
-
-24,
|
|
77
|
-
-90,
|
|
78
|
-
-60,
|
|
79
|
-
60,
|
|
80
|
-
-60,
|
|
81
|
-
60,
|
|
82
|
-
-9,
|
|
83
|
-
-32,
|
|
84
|
-
18,
|
|
85
|
-
30,
|
|
86
|
-
24,
|
|
87
|
-
0,
|
|
88
|
-
20,
|
|
89
|
-
-60,
|
|
90
|
-
0,
|
|
91
|
-
0,
|
|
92
|
-
-9,
|
|
93
|
-
8,
|
|
94
|
-
18,
|
|
95
|
-
30,
|
|
96
|
-
-96,
|
|
97
|
-
0,
|
|
98
|
-
-20,
|
|
99
|
-
60,
|
|
100
|
-
0,
|
|
101
|
-
0,
|
|
102
|
-
54,
|
|
103
|
-
-78,
|
|
104
|
-
162,
|
|
105
|
-
-90,
|
|
106
|
-
-24,
|
|
107
|
-
30,
|
|
108
|
-
60,
|
|
109
|
-
-60,
|
|
110
|
-
60,
|
|
111
|
-
-60,
|
|
112
|
-
-54,
|
|
113
|
-
78,
|
|
114
|
-
78,
|
|
115
|
-
90,
|
|
116
|
-
144,
|
|
117
|
-
90,
|
|
118
|
-
-60,
|
|
119
|
-
-60,
|
|
120
|
-
-60,
|
|
121
|
-
-60,
|
|
122
|
-
9,
|
|
123
|
-
-8,
|
|
124
|
-
-18,
|
|
125
|
-
-30,
|
|
126
|
-
-24,
|
|
127
|
-
0,
|
|
128
|
-
20,
|
|
129
|
-
60,
|
|
130
|
-
0,
|
|
131
|
-
0,
|
|
132
|
-
-9,
|
|
133
|
-
18,
|
|
134
|
-
-32,
|
|
135
|
-
0,
|
|
136
|
-
24,
|
|
137
|
-
30,
|
|
138
|
-
0,
|
|
139
|
-
0,
|
|
140
|
-
-60,
|
|
141
|
-
20,
|
|
142
|
-
9,
|
|
143
|
-
-18,
|
|
144
|
-
-8,
|
|
145
|
-
0,
|
|
146
|
-
-24,
|
|
147
|
-
-30,
|
|
148
|
-
0,
|
|
149
|
-
0,
|
|
150
|
-
60,
|
|
151
|
-
20
|
|
152
|
-
];
|
|
153
|
-
var c0n_ = 372;
|
|
154
|
-
var c3n_ = [
|
|
155
|
-
0,
|
|
156
|
-
0,
|
|
157
|
-
-131,
|
|
158
|
-
0,
|
|
159
|
-
138,
|
|
160
|
-
144,
|
|
161
|
-
0,
|
|
162
|
-
0,
|
|
163
|
-
-102,
|
|
164
|
-
-31,
|
|
165
|
-
0,
|
|
166
|
-
0,
|
|
167
|
-
7,
|
|
168
|
-
0,
|
|
169
|
-
-138,
|
|
170
|
-
42,
|
|
171
|
-
0,
|
|
172
|
-
0,
|
|
173
|
-
102,
|
|
174
|
-
-31,
|
|
175
|
-
62,
|
|
176
|
-
0,
|
|
177
|
-
-31,
|
|
178
|
-
0,
|
|
179
|
-
0,
|
|
180
|
-
-62,
|
|
181
|
-
0,
|
|
182
|
-
0,
|
|
183
|
-
0,
|
|
184
|
-
31,
|
|
185
|
-
124,
|
|
186
|
-
0,
|
|
187
|
-
-62,
|
|
188
|
-
0,
|
|
189
|
-
0,
|
|
190
|
-
-124,
|
|
191
|
-
0,
|
|
192
|
-
0,
|
|
193
|
-
0,
|
|
194
|
-
62,
|
|
195
|
-
124,
|
|
196
|
-
0,
|
|
197
|
-
-62,
|
|
198
|
-
0,
|
|
199
|
-
0,
|
|
200
|
-
-124,
|
|
201
|
-
0,
|
|
202
|
-
0,
|
|
203
|
-
0,
|
|
204
|
-
62,
|
|
205
|
-
62,
|
|
206
|
-
0,
|
|
207
|
-
-31,
|
|
208
|
-
0,
|
|
209
|
-
0,
|
|
210
|
-
-62,
|
|
211
|
-
0,
|
|
212
|
-
0,
|
|
213
|
-
0,
|
|
214
|
-
31,
|
|
215
|
-
0,
|
|
216
|
-
0,
|
|
217
|
-
45,
|
|
218
|
-
0,
|
|
219
|
-
-183,
|
|
220
|
-
-9,
|
|
221
|
-
0,
|
|
222
|
-
93,
|
|
223
|
-
18,
|
|
224
|
-
0,
|
|
225
|
-
0,
|
|
226
|
-
0,
|
|
227
|
-
216,
|
|
228
|
-
0,
|
|
229
|
-
33,
|
|
230
|
-
87,
|
|
231
|
-
0,
|
|
232
|
-
-93,
|
|
233
|
-
12,
|
|
234
|
-
-93,
|
|
235
|
-
0,
|
|
236
|
-
0,
|
|
237
|
-
156,
|
|
238
|
-
0,
|
|
239
|
-
153,
|
|
240
|
-
99,
|
|
241
|
-
0,
|
|
242
|
-
-93,
|
|
243
|
-
-12,
|
|
244
|
-
-93,
|
|
245
|
-
0,
|
|
246
|
-
0,
|
|
247
|
-
-45,
|
|
248
|
-
0,
|
|
249
|
-
-3,
|
|
250
|
-
9,
|
|
251
|
-
0,
|
|
252
|
-
93,
|
|
253
|
-
-18,
|
|
254
|
-
0,
|
|
255
|
-
0,
|
|
256
|
-
0,
|
|
257
|
-
-55,
|
|
258
|
-
0,
|
|
259
|
-
48,
|
|
260
|
-
42,
|
|
261
|
-
0,
|
|
262
|
-
0,
|
|
263
|
-
-84,
|
|
264
|
-
31,
|
|
265
|
-
0,
|
|
266
|
-
0,
|
|
267
|
-
-7,
|
|
268
|
-
0,
|
|
269
|
-
-48,
|
|
270
|
-
-42,
|
|
271
|
-
0,
|
|
272
|
-
0,
|
|
273
|
-
84,
|
|
274
|
-
31
|
|
275
|
-
];
|
|
276
|
-
var c0s_ = 372;
|
|
277
|
-
var c3s_ = [
|
|
278
|
-
18,
|
|
279
|
-
-36,
|
|
280
|
-
-122,
|
|
281
|
-
0,
|
|
282
|
-
120,
|
|
283
|
-
135,
|
|
284
|
-
0,
|
|
285
|
-
0,
|
|
286
|
-
-84,
|
|
287
|
-
-31,
|
|
288
|
-
-18,
|
|
289
|
-
36,
|
|
290
|
-
-2,
|
|
291
|
-
0,
|
|
292
|
-
-120,
|
|
293
|
-
51,
|
|
294
|
-
0,
|
|
295
|
-
0,
|
|
296
|
-
84,
|
|
297
|
-
-31,
|
|
298
|
-
36,
|
|
299
|
-
-165,
|
|
300
|
-
-27,
|
|
301
|
-
93,
|
|
302
|
-
147,
|
|
303
|
-
-9,
|
|
304
|
-
0,
|
|
305
|
-
-93,
|
|
306
|
-
18,
|
|
307
|
-
0,
|
|
308
|
-
210,
|
|
309
|
-
45,
|
|
310
|
-
-111,
|
|
311
|
-
-93,
|
|
312
|
-
-57,
|
|
313
|
-
-192,
|
|
314
|
-
0,
|
|
315
|
-
93,
|
|
316
|
-
12,
|
|
317
|
-
93,
|
|
318
|
-
162,
|
|
319
|
-
141,
|
|
320
|
-
-75,
|
|
321
|
-
-93,
|
|
322
|
-
-129,
|
|
323
|
-
-180,
|
|
324
|
-
0,
|
|
325
|
-
93,
|
|
326
|
-
-12,
|
|
327
|
-
93,
|
|
328
|
-
-36,
|
|
329
|
-
-21,
|
|
330
|
-
27,
|
|
331
|
-
93,
|
|
332
|
-
39,
|
|
333
|
-
9,
|
|
334
|
-
0,
|
|
335
|
-
-93,
|
|
336
|
-
-18,
|
|
337
|
-
0,
|
|
338
|
-
0,
|
|
339
|
-
0,
|
|
340
|
-
62,
|
|
341
|
-
0,
|
|
342
|
-
0,
|
|
343
|
-
31,
|
|
344
|
-
0,
|
|
345
|
-
0,
|
|
346
|
-
0,
|
|
347
|
-
-31,
|
|
348
|
-
0,
|
|
349
|
-
0,
|
|
350
|
-
124,
|
|
351
|
-
0,
|
|
352
|
-
0,
|
|
353
|
-
62,
|
|
354
|
-
0,
|
|
355
|
-
0,
|
|
356
|
-
0,
|
|
357
|
-
-62,
|
|
358
|
-
0,
|
|
359
|
-
0,
|
|
360
|
-
124,
|
|
361
|
-
0,
|
|
362
|
-
0,
|
|
363
|
-
62,
|
|
364
|
-
0,
|
|
365
|
-
0,
|
|
366
|
-
0,
|
|
367
|
-
-62,
|
|
368
|
-
0,
|
|
369
|
-
0,
|
|
370
|
-
62,
|
|
371
|
-
0,
|
|
372
|
-
0,
|
|
373
|
-
31,
|
|
374
|
-
0,
|
|
375
|
-
0,
|
|
376
|
-
0,
|
|
377
|
-
-31,
|
|
378
|
-
-18,
|
|
379
|
-
36,
|
|
380
|
-
-64,
|
|
381
|
-
0,
|
|
382
|
-
66,
|
|
383
|
-
51,
|
|
384
|
-
0,
|
|
385
|
-
0,
|
|
386
|
-
-102,
|
|
387
|
-
31,
|
|
388
|
-
18,
|
|
389
|
-
-36,
|
|
390
|
-
2,
|
|
391
|
-
0,
|
|
392
|
-
-66,
|
|
393
|
-
-51,
|
|
394
|
-
0,
|
|
395
|
-
0,
|
|
396
|
-
102,
|
|
397
|
-
31
|
|
398
|
-
];
|
|
399
|
-
var stencilsize_ = 12;
|
|
400
|
-
var nterms_ = (3 + 1) * (3 + 2) / 2;
|
|
401
|
-
var PIXEL_SIZE = 2;
|
|
402
|
-
var Geoid = class {
|
|
403
|
-
/**
|
|
404
|
-
* @constructs
|
|
405
|
-
* Create a Geoid instance.
|
|
406
|
-
* @param options - grid parameters supplied by parsePGM or createGeoidFromGrid
|
|
407
|
-
* @param options.data - PGM bytes or decoded unsigned 16-bit samples
|
|
408
|
-
*/
|
|
409
|
-
constructor(options) {
|
|
410
|
-
this._v00 = 0;
|
|
411
|
-
this._v01 = 0;
|
|
412
|
-
this._v10 = 0;
|
|
413
|
-
this._v11 = 0;
|
|
414
|
-
this._t = [];
|
|
415
|
-
this.options = options;
|
|
416
|
-
this._ix = this.options._width;
|
|
417
|
-
this._iy = this.options._height;
|
|
418
|
-
this._hasUint16Data = (0, import_types.isUint16Array)(options.data);
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Calculates difference between mean see level height and WGS84 ellipsoid height
|
|
422
|
-
* Code is ported from /GeographicLib-1.50.1/src/Geoid.cpp
|
|
423
|
-
* @param lat - latitude
|
|
424
|
-
* @param lon - longitude
|
|
425
|
-
* @returns height in meters
|
|
426
|
-
*/
|
|
427
|
-
// eslint-disable-next-line max-statements, complexity
|
|
428
|
-
getHeight(lat, lon) {
|
|
429
|
-
lat = Math.abs(lat) > 90 ? NaN : lat;
|
|
430
|
-
if (Number.isNaN(lat) || Number.isNaN(lon)) {
|
|
431
|
-
return NaN;
|
|
432
|
-
}
|
|
433
|
-
const rem = remainder(lon, 360);
|
|
434
|
-
lon = rem !== -180 ? rem : 180;
|
|
435
|
-
let fx = lon * this.options._rlonres;
|
|
436
|
-
let fy = -lat * this.options._rlatres;
|
|
437
|
-
let ix = Math.floor(fx);
|
|
438
|
-
let iy = Math.min(Math.round((this.options._height - 1) / 2 - 1), Math.floor(fy));
|
|
439
|
-
fx -= ix;
|
|
440
|
-
fy -= iy;
|
|
441
|
-
iy += (this.options._height - 1) / 2;
|
|
442
|
-
ix += ix < 0 ? this.options._width : ix >= this.options._width ? -this.options._width : 0;
|
|
443
|
-
let v00 = 0;
|
|
444
|
-
let v01 = 0;
|
|
445
|
-
let v10 = 0;
|
|
446
|
-
let v11 = 0;
|
|
447
|
-
let t = new Array(nterms_);
|
|
448
|
-
if (!(ix === this._ix && iy === this._iy)) {
|
|
449
|
-
if (!this.options.cubic) {
|
|
450
|
-
v00 = this._rawval(ix, iy);
|
|
451
|
-
v01 = this._rawval(ix + 1, iy);
|
|
452
|
-
v10 = this._rawval(ix, iy + 1);
|
|
453
|
-
v11 = this._rawval(ix + 1, iy + 1);
|
|
454
|
-
} else {
|
|
455
|
-
const v = [
|
|
456
|
-
this._rawval(ix, iy - 1),
|
|
457
|
-
this._rawval(ix + 1, iy - 1),
|
|
458
|
-
this._rawval(ix - 1, iy),
|
|
459
|
-
this._rawval(ix, iy),
|
|
460
|
-
this._rawval(ix + 1, iy),
|
|
461
|
-
this._rawval(ix + 2, iy),
|
|
462
|
-
this._rawval(ix - 1, iy + 1),
|
|
463
|
-
this._rawval(ix, iy + 1),
|
|
464
|
-
this._rawval(ix + 1, iy + 1),
|
|
465
|
-
this._rawval(ix + 2, iy + 1),
|
|
466
|
-
this._rawval(ix, iy + 2),
|
|
467
|
-
this._rawval(ix + 1, iy + 2)
|
|
468
|
-
];
|
|
469
|
-
let c3x = c3n_;
|
|
470
|
-
if (iy !== 0) {
|
|
471
|
-
c3x = iy === this.options._height - 2 ? c3s_ : c3_;
|
|
472
|
-
}
|
|
473
|
-
let c0x = c0n_;
|
|
474
|
-
if (iy !== 0) {
|
|
475
|
-
c0x = iy === this.options._height - 2 ? c0s_ : c0_;
|
|
476
|
-
}
|
|
477
|
-
for (let i = 0; i < nterms_; ++i) {
|
|
478
|
-
t[i] = 0;
|
|
479
|
-
for (let j = 0; j < stencilsize_; ++j) {
|
|
480
|
-
t[i] += v[j] * c3x[nterms_ * j + i];
|
|
481
|
-
}
|
|
482
|
-
t[i] /= c0x;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
} else if (!this.options.cubic) {
|
|
486
|
-
v00 = this._v00;
|
|
487
|
-
v01 = this._v01;
|
|
488
|
-
v10 = this._v10;
|
|
489
|
-
v11 = this._v11;
|
|
490
|
-
} else {
|
|
491
|
-
t = this._t;
|
|
492
|
-
}
|
|
493
|
-
if (!this.options.cubic) {
|
|
494
|
-
const a = (1 - fx) * v00 + fx * v01;
|
|
495
|
-
const b = (1 - fx) * v10 + fx * v11;
|
|
496
|
-
const c = (1 - fy) * a + fy * b;
|
|
497
|
-
const h2 = this.options._offset + this.options._scale * c;
|
|
498
|
-
this._ix = ix;
|
|
499
|
-
this._iy = iy;
|
|
500
|
-
this._v00 = v00;
|
|
501
|
-
this._v01 = v01;
|
|
502
|
-
this._v10 = v10;
|
|
503
|
-
this._v11 = v11;
|
|
504
|
-
return h2;
|
|
505
|
-
}
|
|
506
|
-
let h = t[0] + fx * (t[1] + fx * (t[3] + fx * t[6])) + fy * (t[2] + fx * (t[4] + fx * t[7]) + fy * (t[5] + fx * t[8] + fy * t[9]));
|
|
507
|
-
h = this.options._offset + this.options._scale * h;
|
|
508
|
-
this._ix = ix;
|
|
509
|
-
this._iy = iy;
|
|
510
|
-
this._t = t;
|
|
511
|
-
return h;
|
|
512
|
-
}
|
|
513
|
-
// PRIVATE
|
|
514
|
-
/**
|
|
515
|
-
* Method seeks for particular data in th pgm buffer
|
|
516
|
-
* Code is ported from corresponding method
|
|
517
|
-
* in /GeographicLib-1.50.1/include/GeographicLib/Geoid.hpp
|
|
518
|
-
* @param {number} ix - longituge parameter
|
|
519
|
-
* @param {number} iy - latitude parameter
|
|
520
|
-
* @returns {number} data from pgm binary buffer
|
|
521
|
-
*/
|
|
522
|
-
_rawval(ix, iy) {
|
|
523
|
-
if (ix < 0) {
|
|
524
|
-
ix += this.options._width;
|
|
525
|
-
} else if (ix >= this.options._width) {
|
|
526
|
-
ix -= this.options._width;
|
|
527
|
-
}
|
|
528
|
-
if (iy < 0 || iy >= this.options._height) {
|
|
529
|
-
iy = iy < 0 ? -iy : 2 * (this.options._height - 1) - iy;
|
|
530
|
-
ix += (ix < this.options._width / 2 ? 1 : -1) * this.options._width / 2;
|
|
531
|
-
}
|
|
532
|
-
const sampleIndex = iy * this.options._swidth + ix;
|
|
533
|
-
if (this._hasUint16Data) {
|
|
534
|
-
return this.options.data[this.options._datastart + sampleIndex];
|
|
535
|
-
}
|
|
536
|
-
const bufferPosition = this.options._datastart + PIXEL_SIZE * sampleIndex;
|
|
537
|
-
const a = this.options.data[bufferPosition];
|
|
538
|
-
const b = this.options.data[bufferPosition + 1];
|
|
539
|
-
const r = a << 8 | b;
|
|
540
|
-
return r;
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
function remainder(x, y) {
|
|
544
|
-
y = Math.abs(y);
|
|
545
|
-
let z = fmod(x, y);
|
|
546
|
-
if (2 * Math.abs(z) === y)
|
|
547
|
-
z -= fmod(x, 2 * y) - z;
|
|
548
|
-
else if (2 * Math.abs(z) > y)
|
|
549
|
-
z += z < 0 ? y : -y;
|
|
550
|
-
return z;
|
|
551
|
-
}
|
|
552
|
-
function fmod(x, y) {
|
|
553
|
-
return x - Math.floor(x / y) * y;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
// dist/geoid/parse-pgm.js
|
|
557
|
-
var ENDL = 10;
|
|
558
|
-
var PIXEL_MAX = 65535;
|
|
559
|
-
function parsePGM(data, options) {
|
|
560
|
-
const getline = _getLineGenerator(data);
|
|
561
|
-
let currentLine = getline.next();
|
|
562
|
-
if (currentLine.done || currentLine.value.line !== "P5") {
|
|
563
|
-
throw new Error("Geoid model file: File not in PGM format");
|
|
564
|
-
}
|
|
565
|
-
let _offset = Number.MAX_VALUE;
|
|
566
|
-
let _scale = 0;
|
|
567
|
-
let _maxerror = -1;
|
|
568
|
-
let _rmserror = -1;
|
|
569
|
-
let _description = "NONE";
|
|
570
|
-
let _datetime = "UNKNOWN";
|
|
571
|
-
let _width = 0;
|
|
572
|
-
let _height = 0;
|
|
573
|
-
let _datastart = null;
|
|
574
|
-
let _swidth = null;
|
|
575
|
-
do {
|
|
576
|
-
currentLine = getline.next();
|
|
577
|
-
const s = currentLine.value.line;
|
|
578
|
-
if (!s.length) {
|
|
579
|
-
continue;
|
|
580
|
-
}
|
|
581
|
-
if (s[0] === "#") {
|
|
582
|
-
const sArr = s.split(" ");
|
|
583
|
-
const commentId = sArr[0];
|
|
584
|
-
const key = sArr[1];
|
|
585
|
-
if (commentId !== "#" || !key) {
|
|
586
|
-
continue;
|
|
587
|
-
}
|
|
588
|
-
const infoArr = sArr.length > 2 ? sArr.slice(2) : [];
|
|
589
|
-
if (key === "Description") {
|
|
590
|
-
_description = infoArr.join(" ");
|
|
591
|
-
} else if (key === "DateTime") {
|
|
592
|
-
_datetime = infoArr.join(" ");
|
|
593
|
-
} else if (key === "Offset") {
|
|
594
|
-
if (!sArr[2]) {
|
|
595
|
-
throw new Error("Geoid model file: Error reading offset");
|
|
596
|
-
}
|
|
597
|
-
_offset = parseInt(sArr[2], 10);
|
|
598
|
-
} else if (key === "Scale") {
|
|
599
|
-
if (!sArr[2]) {
|
|
600
|
-
throw new Error("Geoid model file: Error reading scale");
|
|
601
|
-
}
|
|
602
|
-
_scale = parseFloat(sArr[2]);
|
|
603
|
-
} else if (key === (options.cubic ? "MaxCubicError" : "MaxBilinearError")) {
|
|
604
|
-
if (isFinite(parseFloat(sArr[2]))) {
|
|
605
|
-
_maxerror = parseFloat(sArr[2]);
|
|
606
|
-
}
|
|
607
|
-
} else if (key === (options.cubic ? "RMSCubicError" : "RMSBilinearError")) {
|
|
608
|
-
if (isFinite(parseFloat(sArr[2]))) {
|
|
609
|
-
_rmserror = parseFloat(sArr[2]);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
} else {
|
|
613
|
-
let sArr = s.split(" ");
|
|
614
|
-
sArr = sArr.filter((testString) => testString !== "");
|
|
615
|
-
_width = parseInt(sArr[0], 10);
|
|
616
|
-
_height = parseInt(sArr[1], 10);
|
|
617
|
-
if (!(_width && _height)) {
|
|
618
|
-
throw new Error("Geoid model file: Error reading raster size");
|
|
619
|
-
}
|
|
620
|
-
break;
|
|
621
|
-
}
|
|
622
|
-
} while (!currentLine.done);
|
|
623
|
-
currentLine = getline.next();
|
|
624
|
-
const maxval = parseInt(currentLine.value.line, 10);
|
|
625
|
-
if (currentLine.done) {
|
|
626
|
-
throw new Error("Geoid model file: Error reading maxval");
|
|
627
|
-
}
|
|
628
|
-
if (maxval !== PIXEL_MAX) {
|
|
629
|
-
throw new Error("Geoid model file: Incorrect value of maxval");
|
|
630
|
-
}
|
|
631
|
-
_datastart = currentLine.value.offset;
|
|
632
|
-
_swidth = _width;
|
|
633
|
-
if (_offset === Number.MAX_VALUE) {
|
|
634
|
-
throw new Error("Geoid model file: Offset not set");
|
|
635
|
-
}
|
|
636
|
-
if (_scale === 0) {
|
|
637
|
-
throw new Error("Geoid model file: Scale not set");
|
|
638
|
-
}
|
|
639
|
-
if (_scale < 0) {
|
|
640
|
-
throw new Error("Geoid model file: Scale must be positive");
|
|
641
|
-
}
|
|
642
|
-
if (_height < 2 || _width < 2) {
|
|
643
|
-
throw new Error("Geoid model file: Raster size too small");
|
|
644
|
-
}
|
|
645
|
-
if (_width & 1) {
|
|
646
|
-
throw new Error("Geoid model file: Raster width is odd");
|
|
647
|
-
}
|
|
648
|
-
if (!(_height & 1)) {
|
|
649
|
-
throw new Error("Geoid model file: Raster height is even");
|
|
650
|
-
}
|
|
651
|
-
const _rlonres = _width / 360;
|
|
652
|
-
const _rlatres = (_height - 1) / 180;
|
|
653
|
-
return new Geoid({
|
|
654
|
-
cubic: options.cubic,
|
|
655
|
-
_width,
|
|
656
|
-
_height,
|
|
657
|
-
_rlonres,
|
|
658
|
-
_rlatres,
|
|
659
|
-
_offset,
|
|
660
|
-
_scale,
|
|
661
|
-
_swidth,
|
|
662
|
-
_datastart,
|
|
663
|
-
_maxerror,
|
|
664
|
-
_rmserror,
|
|
665
|
-
_description,
|
|
666
|
-
_datetime,
|
|
667
|
-
data
|
|
668
|
-
});
|
|
669
|
-
}
|
|
670
|
-
function* _getLineGenerator(data) {
|
|
671
|
-
let offset = 0;
|
|
672
|
-
do {
|
|
673
|
-
const endLineIndex = data.indexOf(ENDL, offset);
|
|
674
|
-
if (endLineIndex !== -1) {
|
|
675
|
-
const line = data.subarray(offset, endLineIndex);
|
|
676
|
-
offset = endLineIndex + 1;
|
|
677
|
-
yield { offset, line: _getStringFromCharArray(line) };
|
|
678
|
-
} else {
|
|
679
|
-
const line = data.subarray(offset, data.length);
|
|
680
|
-
offset = data.length;
|
|
681
|
-
yield { offset, line: _getStringFromCharArray(line) };
|
|
682
|
-
}
|
|
683
|
-
} while (offset < data.length);
|
|
684
|
-
return { offset, line: "" };
|
|
685
|
-
}
|
|
686
|
-
function _getStringFromCharArray(array) {
|
|
687
|
-
let s = "";
|
|
688
|
-
for (const char of array) {
|
|
689
|
-
s += String.fromCharCode(char);
|
|
690
|
-
}
|
|
691
|
-
return s;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
// dist/geoid/create-geoid-from-grid.js
|
|
695
|
-
var import_types2 = require("@math.gl/core/types");
|
|
696
|
-
function createGeoidFromGrid(props) {
|
|
697
|
-
const { width, height, values, offset, scale, cubic = false } = props;
|
|
698
|
-
if (!Number.isSafeInteger(width) || width < 2 || width % 2 !== 0) {
|
|
699
|
-
throw new Error("Geoid grid: width must be an even integer of at least 2");
|
|
700
|
-
}
|
|
701
|
-
if (!Number.isSafeInteger(height) || height < 3 || height % 2 !== 1) {
|
|
702
|
-
throw new Error("Geoid grid: height must be an odd integer of at least 3");
|
|
703
|
-
}
|
|
704
|
-
if (!(0, import_types2.isUint16Array)(values) || values.length !== width * height) {
|
|
705
|
-
throw new Error("Geoid grid: values must be a Uint16Array with width * height samples");
|
|
706
|
-
}
|
|
707
|
-
if (!Number.isFinite(offset) || !Number.isFinite(scale) || scale <= 0) {
|
|
708
|
-
throw new Error("Geoid grid: offset must be finite and scale must be finite and positive");
|
|
709
|
-
}
|
|
710
|
-
return new Geoid({
|
|
711
|
-
cubic,
|
|
712
|
-
_width: width,
|
|
713
|
-
_height: height,
|
|
714
|
-
_rlonres: width / 360,
|
|
715
|
-
_rlatres: (height - 1) / 180,
|
|
716
|
-
_offset: offset,
|
|
717
|
-
_scale: scale,
|
|
718
|
-
_swidth: width,
|
|
719
|
-
_datastart: 0,
|
|
720
|
-
_maxerror: -1,
|
|
721
|
-
_rmserror: -1,
|
|
722
|
-
_description: "Decoded geoid grid",
|
|
723
|
-
_datetime: "UNKNOWN",
|
|
724
|
-
data: values
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
//# sourceMappingURL=index.cjs.map
|