@math.gl/web-mercator 5.0.0-alpha.9 → 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/LICENSE +7 -119
- package/README.md +5 -0
- package/THIRD-PARTY-NOTICES.md +16 -0
- package/dist/assert.d.ts.map +1 -1
- package/dist/assert.js +3 -0
- package/dist/assert.js.map +1 -1
- package/dist/fit-bounds.d.ts.map +1 -1
- package/dist/fit-bounds.js +3 -0
- package/dist/fit-bounds.js.map +1 -1
- package/dist/fly-to-viewport.d.ts.map +1 -1
- package/dist/fly-to-viewport.js +4 -1
- package/dist/fly-to-viewport.js.map +1 -1
- package/dist/get-bounds.d.ts.map +1 -1
- package/dist/get-bounds.js +4 -1
- package/dist/get-bounds.js.map +1 -1
- package/dist/globe-mercator-projection.d.ts +19 -0
- package/dist/globe-mercator-projection.d.ts.map +1 -0
- package/dist/globe-mercator-projection.js +67 -0
- package/dist/globe-mercator-projection.js.map +1 -0
- package/dist/index.cjs +52 -430
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/math-utils.d.ts.map +1 -1
- package/dist/math-utils.js +4 -1
- package/dist/math-utils.js.map +1 -1
- package/dist/mercator-meters.js +1 -1
- package/dist/mercator-meters.js.map +1 -1
- package/dist/normalize-viewport-props.d.ts.map +1 -1
- package/dist/normalize-viewport-props.js +3 -0
- package/dist/normalize-viewport-props.js.map +1 -1
- package/dist/web-mercator-utils.d.ts.map +1 -1
- package/dist/web-mercator-utils.js +6 -3
- package/dist/web-mercator-utils.js.map +1 -1
- package/dist/web-mercator-viewport.d.ts +0 -5
- package/dist/web-mercator-viewport.d.ts.map +1 -1
- package/dist/web-mercator-viewport.js +6 -8
- package/dist/web-mercator-viewport.js.map +1 -1
- package/package.json +6 -4
- package/src/assert.ts +3 -0
- package/src/fit-bounds.ts +3 -0
- package/src/fly-to-viewport.ts +4 -1
- package/src/get-bounds.ts +4 -1
- package/src/globe-mercator-projection.ts +90 -0
- package/src/index.ts +3 -0
- package/src/math-utils.ts +4 -1
- package/src/mercator-meters.ts +1 -1
- package/src/normalize-viewport-props.ts +3 -0
- package/src/web-mercator-utils.ts +6 -3
- package/src/web-mercator-viewport.ts +6 -10
package/dist/index.cjs
CHANGED
|
@@ -53,37 +53,14 @@ __export(index_exports, {
|
|
|
53
53
|
});
|
|
54
54
|
module.exports = __toCommonJS(index_exports);
|
|
55
55
|
|
|
56
|
-
// ../core/src/gl-matrix/common.js
|
|
57
|
-
var EPSILON = 1e-6;
|
|
58
|
-
var degree = Math.PI / 180;
|
|
59
|
-
|
|
60
|
-
// ../core/src/gl-matrix/vec4.ts
|
|
61
|
-
function scale(out, a, b) {
|
|
62
|
-
out[0] = a[0] * b;
|
|
63
|
-
out[1] = a[1] * b;
|
|
64
|
-
out[2] = a[2] * b;
|
|
65
|
-
out[3] = a[3] * b;
|
|
66
|
-
return out;
|
|
67
|
-
}
|
|
68
|
-
function transformMat4(out, a, m) {
|
|
69
|
-
const x = a[0];
|
|
70
|
-
const y = a[1];
|
|
71
|
-
const z = a[2];
|
|
72
|
-
const w = a[3];
|
|
73
|
-
out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
|
|
74
|
-
out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
|
|
75
|
-
out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
|
|
76
|
-
out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
|
|
77
|
-
return out;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
56
|
// dist/math-utils.js
|
|
57
|
+
var import_core = require("@math.gl/core");
|
|
81
58
|
function createMat4() {
|
|
82
59
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
83
60
|
}
|
|
84
61
|
function transformVector(matrix, vector) {
|
|
85
|
-
const result = transformMat4([], vector, matrix);
|
|
86
|
-
scale(result, result, 1 / result[3]);
|
|
62
|
+
const result = import_core.vec4.transformMat4([], vector, matrix);
|
|
63
|
+
import_core.vec4.scale(result, result, 1 / result[3]);
|
|
87
64
|
return result;
|
|
88
65
|
}
|
|
89
66
|
function mod(value, divisor) {
|
|
@@ -101,365 +78,10 @@ function ieLog2(x) {
|
|
|
101
78
|
}
|
|
102
79
|
var log2 = Math.log2 || ieLog2;
|
|
103
80
|
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const a02 = a[2];
|
|
109
|
-
const a03 = a[3];
|
|
110
|
-
const a10 = a[4];
|
|
111
|
-
const a11 = a[5];
|
|
112
|
-
const a12 = a[6];
|
|
113
|
-
const a13 = a[7];
|
|
114
|
-
const a20 = a[8];
|
|
115
|
-
const a21 = a[9];
|
|
116
|
-
const a22 = a[10];
|
|
117
|
-
const a23 = a[11];
|
|
118
|
-
const a30 = a[12];
|
|
119
|
-
const a31 = a[13];
|
|
120
|
-
const a32 = a[14];
|
|
121
|
-
const a33 = a[15];
|
|
122
|
-
const b00 = a00 * a11 - a01 * a10;
|
|
123
|
-
const b01 = a00 * a12 - a02 * a10;
|
|
124
|
-
const b02 = a00 * a13 - a03 * a10;
|
|
125
|
-
const b03 = a01 * a12 - a02 * a11;
|
|
126
|
-
const b04 = a01 * a13 - a03 * a11;
|
|
127
|
-
const b05 = a02 * a13 - a03 * a12;
|
|
128
|
-
const b06 = a20 * a31 - a21 * a30;
|
|
129
|
-
const b07 = a20 * a32 - a22 * a30;
|
|
130
|
-
const b08 = a20 * a33 - a23 * a30;
|
|
131
|
-
const b09 = a21 * a32 - a22 * a31;
|
|
132
|
-
const b10 = a21 * a33 - a23 * a31;
|
|
133
|
-
const b11 = a22 * a33 - a23 * a32;
|
|
134
|
-
let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
135
|
-
if (!det) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
det = 1 / det;
|
|
139
|
-
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
|
|
140
|
-
out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
|
|
141
|
-
out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
|
|
142
|
-
out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
|
|
143
|
-
out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
|
|
144
|
-
out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
|
|
145
|
-
out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
|
|
146
|
-
out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
|
|
147
|
-
out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
|
|
148
|
-
out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
|
|
149
|
-
out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
|
|
150
|
-
out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
|
|
151
|
-
out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
|
|
152
|
-
out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
|
|
153
|
-
out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
|
|
154
|
-
out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
|
|
155
|
-
return out;
|
|
156
|
-
}
|
|
157
|
-
function multiply(out, a, b) {
|
|
158
|
-
const a00 = a[0];
|
|
159
|
-
const a01 = a[1];
|
|
160
|
-
const a02 = a[2];
|
|
161
|
-
const a03 = a[3];
|
|
162
|
-
const a10 = a[4];
|
|
163
|
-
const a11 = a[5];
|
|
164
|
-
const a12 = a[6];
|
|
165
|
-
const a13 = a[7];
|
|
166
|
-
const a20 = a[8];
|
|
167
|
-
const a21 = a[9];
|
|
168
|
-
const a22 = a[10];
|
|
169
|
-
const a23 = a[11];
|
|
170
|
-
const a30 = a[12];
|
|
171
|
-
const a31 = a[13];
|
|
172
|
-
const a32 = a[14];
|
|
173
|
-
const a33 = a[15];
|
|
174
|
-
let b0 = b[0];
|
|
175
|
-
let b1 = b[1];
|
|
176
|
-
let b2 = b[2];
|
|
177
|
-
let b3 = b[3];
|
|
178
|
-
out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
179
|
-
out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
180
|
-
out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
181
|
-
out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
182
|
-
b0 = b[4];
|
|
183
|
-
b1 = b[5];
|
|
184
|
-
b2 = b[6];
|
|
185
|
-
b3 = b[7];
|
|
186
|
-
out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
187
|
-
out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
188
|
-
out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
189
|
-
out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
190
|
-
b0 = b[8];
|
|
191
|
-
b1 = b[9];
|
|
192
|
-
b2 = b[10];
|
|
193
|
-
b3 = b[11];
|
|
194
|
-
out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
195
|
-
out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
196
|
-
out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
197
|
-
out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
198
|
-
b0 = b[12];
|
|
199
|
-
b1 = b[13];
|
|
200
|
-
b2 = b[14];
|
|
201
|
-
b3 = b[15];
|
|
202
|
-
out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
203
|
-
out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
204
|
-
out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
205
|
-
out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
206
|
-
return out;
|
|
207
|
-
}
|
|
208
|
-
function translate(out, a, v) {
|
|
209
|
-
const x = v[0];
|
|
210
|
-
const y = v[1];
|
|
211
|
-
const z = v[2];
|
|
212
|
-
let a00;
|
|
213
|
-
let a01;
|
|
214
|
-
let a02;
|
|
215
|
-
let a03;
|
|
216
|
-
let a10;
|
|
217
|
-
let a11;
|
|
218
|
-
let a12;
|
|
219
|
-
let a13;
|
|
220
|
-
let a20;
|
|
221
|
-
let a21;
|
|
222
|
-
let a22;
|
|
223
|
-
let a23;
|
|
224
|
-
if (a === out) {
|
|
225
|
-
out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
|
|
226
|
-
out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
|
|
227
|
-
out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
|
|
228
|
-
out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
|
|
229
|
-
} else {
|
|
230
|
-
a00 = a[0];
|
|
231
|
-
a01 = a[1];
|
|
232
|
-
a02 = a[2];
|
|
233
|
-
a03 = a[3];
|
|
234
|
-
a10 = a[4];
|
|
235
|
-
a11 = a[5];
|
|
236
|
-
a12 = a[6];
|
|
237
|
-
a13 = a[7];
|
|
238
|
-
a20 = a[8];
|
|
239
|
-
a21 = a[9];
|
|
240
|
-
a22 = a[10];
|
|
241
|
-
a23 = a[11];
|
|
242
|
-
out[0] = a00;
|
|
243
|
-
out[1] = a01;
|
|
244
|
-
out[2] = a02;
|
|
245
|
-
out[3] = a03;
|
|
246
|
-
out[4] = a10;
|
|
247
|
-
out[5] = a11;
|
|
248
|
-
out[6] = a12;
|
|
249
|
-
out[7] = a13;
|
|
250
|
-
out[8] = a20;
|
|
251
|
-
out[9] = a21;
|
|
252
|
-
out[10] = a22;
|
|
253
|
-
out[11] = a23;
|
|
254
|
-
out[12] = a00 * x + a10 * y + a20 * z + a[12];
|
|
255
|
-
out[13] = a01 * x + a11 * y + a21 * z + a[13];
|
|
256
|
-
out[14] = a02 * x + a12 * y + a22 * z + a[14];
|
|
257
|
-
out[15] = a03 * x + a13 * y + a23 * z + a[15];
|
|
258
|
-
}
|
|
259
|
-
return out;
|
|
260
|
-
}
|
|
261
|
-
function scale2(out, a, v) {
|
|
262
|
-
const x = v[0];
|
|
263
|
-
const y = v[1];
|
|
264
|
-
const z = v[2];
|
|
265
|
-
out[0] = a[0] * x;
|
|
266
|
-
out[1] = a[1] * x;
|
|
267
|
-
out[2] = a[2] * x;
|
|
268
|
-
out[3] = a[3] * x;
|
|
269
|
-
out[4] = a[4] * y;
|
|
270
|
-
out[5] = a[5] * y;
|
|
271
|
-
out[6] = a[6] * y;
|
|
272
|
-
out[7] = a[7] * y;
|
|
273
|
-
out[8] = a[8] * z;
|
|
274
|
-
out[9] = a[9] * z;
|
|
275
|
-
out[10] = a[10] * z;
|
|
276
|
-
out[11] = a[11] * z;
|
|
277
|
-
out[12] = a[12];
|
|
278
|
-
out[13] = a[13];
|
|
279
|
-
out[14] = a[14];
|
|
280
|
-
out[15] = a[15];
|
|
281
|
-
return out;
|
|
282
|
-
}
|
|
283
|
-
function rotateX(out, a, rad) {
|
|
284
|
-
const s = Math.sin(rad);
|
|
285
|
-
const c = Math.cos(rad);
|
|
286
|
-
const a10 = a[4];
|
|
287
|
-
const a11 = a[5];
|
|
288
|
-
const a12 = a[6];
|
|
289
|
-
const a13 = a[7];
|
|
290
|
-
const a20 = a[8];
|
|
291
|
-
const a21 = a[9];
|
|
292
|
-
const a22 = a[10];
|
|
293
|
-
const a23 = a[11];
|
|
294
|
-
if (a !== out) {
|
|
295
|
-
out[0] = a[0];
|
|
296
|
-
out[1] = a[1];
|
|
297
|
-
out[2] = a[2];
|
|
298
|
-
out[3] = a[3];
|
|
299
|
-
out[12] = a[12];
|
|
300
|
-
out[13] = a[13];
|
|
301
|
-
out[14] = a[14];
|
|
302
|
-
out[15] = a[15];
|
|
303
|
-
}
|
|
304
|
-
out[4] = a10 * c + a20 * s;
|
|
305
|
-
out[5] = a11 * c + a21 * s;
|
|
306
|
-
out[6] = a12 * c + a22 * s;
|
|
307
|
-
out[7] = a13 * c + a23 * s;
|
|
308
|
-
out[8] = a20 * c - a10 * s;
|
|
309
|
-
out[9] = a21 * c - a11 * s;
|
|
310
|
-
out[10] = a22 * c - a12 * s;
|
|
311
|
-
out[11] = a23 * c - a13 * s;
|
|
312
|
-
return out;
|
|
313
|
-
}
|
|
314
|
-
function rotateZ(out, a, rad) {
|
|
315
|
-
const s = Math.sin(rad);
|
|
316
|
-
const c = Math.cos(rad);
|
|
317
|
-
const a00 = a[0];
|
|
318
|
-
const a01 = a[1];
|
|
319
|
-
const a02 = a[2];
|
|
320
|
-
const a03 = a[3];
|
|
321
|
-
const a10 = a[4];
|
|
322
|
-
const a11 = a[5];
|
|
323
|
-
const a12 = a[6];
|
|
324
|
-
const a13 = a[7];
|
|
325
|
-
if (a !== out) {
|
|
326
|
-
out[8] = a[8];
|
|
327
|
-
out[9] = a[9];
|
|
328
|
-
out[10] = a[10];
|
|
329
|
-
out[11] = a[11];
|
|
330
|
-
out[12] = a[12];
|
|
331
|
-
out[13] = a[13];
|
|
332
|
-
out[14] = a[14];
|
|
333
|
-
out[15] = a[15];
|
|
334
|
-
}
|
|
335
|
-
out[0] = a00 * c + a10 * s;
|
|
336
|
-
out[1] = a01 * c + a11 * s;
|
|
337
|
-
out[2] = a02 * c + a12 * s;
|
|
338
|
-
out[3] = a03 * c + a13 * s;
|
|
339
|
-
out[4] = a10 * c - a00 * s;
|
|
340
|
-
out[5] = a11 * c - a01 * s;
|
|
341
|
-
out[6] = a12 * c - a02 * s;
|
|
342
|
-
out[7] = a13 * c - a03 * s;
|
|
343
|
-
return out;
|
|
344
|
-
}
|
|
345
|
-
function perspectiveNO(out, fovy, aspect, near, far) {
|
|
346
|
-
const f = 1 / Math.tan(fovy / 2);
|
|
347
|
-
out[0] = f / aspect;
|
|
348
|
-
out[1] = 0;
|
|
349
|
-
out[2] = 0;
|
|
350
|
-
out[3] = 0;
|
|
351
|
-
out[4] = 0;
|
|
352
|
-
out[5] = f;
|
|
353
|
-
out[6] = 0;
|
|
354
|
-
out[7] = 0;
|
|
355
|
-
out[8] = 0;
|
|
356
|
-
out[9] = 0;
|
|
357
|
-
out[11] = -1;
|
|
358
|
-
out[12] = 0;
|
|
359
|
-
out[13] = 0;
|
|
360
|
-
out[15] = 0;
|
|
361
|
-
if (far != null && far !== Infinity) {
|
|
362
|
-
const nf = 1 / (near - far);
|
|
363
|
-
out[10] = (far + near) * nf;
|
|
364
|
-
out[14] = 2 * far * near * nf;
|
|
365
|
-
} else {
|
|
366
|
-
out[10] = -1;
|
|
367
|
-
out[14] = -2 * near;
|
|
368
|
-
}
|
|
369
|
-
return out;
|
|
370
|
-
}
|
|
371
|
-
var perspective = perspectiveNO;
|
|
372
|
-
function equals(a, b) {
|
|
373
|
-
const a0 = a[0];
|
|
374
|
-
const a1 = a[1];
|
|
375
|
-
const a2 = a[2];
|
|
376
|
-
const a3 = a[3];
|
|
377
|
-
const a4 = a[4];
|
|
378
|
-
const a5 = a[5];
|
|
379
|
-
const a6 = a[6];
|
|
380
|
-
const a7 = a[7];
|
|
381
|
-
const a8 = a[8];
|
|
382
|
-
const a9 = a[9];
|
|
383
|
-
const a10 = a[10];
|
|
384
|
-
const a11 = a[11];
|
|
385
|
-
const a12 = a[12];
|
|
386
|
-
const a13 = a[13];
|
|
387
|
-
const a14 = a[14];
|
|
388
|
-
const a15 = a[15];
|
|
389
|
-
const b0 = b[0];
|
|
390
|
-
const b1 = b[1];
|
|
391
|
-
const b2 = b[2];
|
|
392
|
-
const b3 = b[3];
|
|
393
|
-
const b4 = b[4];
|
|
394
|
-
const b5 = b[5];
|
|
395
|
-
const b6 = b[6];
|
|
396
|
-
const b7 = b[7];
|
|
397
|
-
const b8 = b[8];
|
|
398
|
-
const b9 = b[9];
|
|
399
|
-
const b10 = b[10];
|
|
400
|
-
const b11 = b[11];
|
|
401
|
-
const b12 = b[12];
|
|
402
|
-
const b13 = b[13];
|
|
403
|
-
const b14 = b[14];
|
|
404
|
-
const b15 = b[15];
|
|
405
|
-
return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= EPSILON * Math.max(1, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= EPSILON * Math.max(1, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= EPSILON * Math.max(1, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= EPSILON * Math.max(1, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= EPSILON * Math.max(1, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= EPSILON * Math.max(1, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= EPSILON * Math.max(1, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= EPSILON * Math.max(1, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= EPSILON * Math.max(1, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= EPSILON * Math.max(1, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= EPSILON * Math.max(1, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= EPSILON * Math.max(1, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= EPSILON * Math.max(1, Math.abs(a15), Math.abs(b15));
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// ../core/src/gl-matrix/vec2.ts
|
|
409
|
-
function add(out, a, b) {
|
|
410
|
-
out[0] = a[0] + b[0];
|
|
411
|
-
out[1] = a[1] + b[1];
|
|
412
|
-
return out;
|
|
413
|
-
}
|
|
414
|
-
function subtract(out, a, b) {
|
|
415
|
-
out[0] = a[0] - b[0];
|
|
416
|
-
out[1] = a[1] - b[1];
|
|
417
|
-
return out;
|
|
418
|
-
}
|
|
419
|
-
function scale3(out, a, b) {
|
|
420
|
-
out[0] = a[0] * b;
|
|
421
|
-
out[1] = a[1] * b;
|
|
422
|
-
return out;
|
|
423
|
-
}
|
|
424
|
-
function length(a) {
|
|
425
|
-
const x = a[0];
|
|
426
|
-
const y = a[1];
|
|
427
|
-
return Math.sqrt(x * x + y * y);
|
|
428
|
-
}
|
|
429
|
-
function negate(out, a) {
|
|
430
|
-
out[0] = -a[0];
|
|
431
|
-
out[1] = -a[1];
|
|
432
|
-
return out;
|
|
433
|
-
}
|
|
434
|
-
function lerp2(out, a, b, t) {
|
|
435
|
-
const ax = a[0];
|
|
436
|
-
const ay = a[1];
|
|
437
|
-
out[0] = ax + t * (b[0] - ax);
|
|
438
|
-
out[1] = ay + t * (b[1] - ay);
|
|
439
|
-
return out;
|
|
440
|
-
}
|
|
441
|
-
var sub = subtract;
|
|
442
|
-
|
|
443
|
-
// ../core/src/gl-matrix/vec3.ts
|
|
444
|
-
function add2(out, a, b) {
|
|
445
|
-
out[0] = a[0] + b[0];
|
|
446
|
-
out[1] = a[1] + b[1];
|
|
447
|
-
out[2] = a[2] + b[2];
|
|
448
|
-
return out;
|
|
449
|
-
}
|
|
450
|
-
function multiply2(out, a, b) {
|
|
451
|
-
out[0] = a[0] * b[0];
|
|
452
|
-
out[1] = a[1] * b[1];
|
|
453
|
-
out[2] = a[2] * b[2];
|
|
454
|
-
return out;
|
|
455
|
-
}
|
|
456
|
-
function negate2(out, a) {
|
|
457
|
-
out[0] = -a[0];
|
|
458
|
-
out[1] = -a[1];
|
|
459
|
-
out[2] = -a[2];
|
|
460
|
-
return out;
|
|
461
|
-
}
|
|
462
|
-
var mul = multiply2;
|
|
81
|
+
// dist/web-mercator-utils.js
|
|
82
|
+
var import_core2 = require("@math.gl/core");
|
|
83
|
+
var import_core3 = require("@math.gl/core");
|
|
84
|
+
var import_core4 = require("@math.gl/core");
|
|
463
85
|
|
|
464
86
|
// dist/assert.js
|
|
465
87
|
function assert(condition, message) {
|
|
@@ -480,8 +102,8 @@ var DEFAULT_ALTITUDE = 1.5;
|
|
|
480
102
|
function zoomToScale(zoom) {
|
|
481
103
|
return Math.pow(2, zoom);
|
|
482
104
|
}
|
|
483
|
-
function scaleToZoom(
|
|
484
|
-
return log2(
|
|
105
|
+
function scaleToZoom(scale) {
|
|
106
|
+
return log2(scale);
|
|
485
107
|
}
|
|
486
108
|
function lngLatToWorld(lngLat) {
|
|
487
109
|
const [lng, lat] = lngLat;
|
|
@@ -556,22 +178,22 @@ function getViewMatrix(options) {
|
|
|
556
178
|
bearing,
|
|
557
179
|
altitude,
|
|
558
180
|
// Pre-calculated parameters
|
|
559
|
-
scale
|
|
181
|
+
scale,
|
|
560
182
|
center
|
|
561
183
|
} = options;
|
|
562
184
|
const vm = createMat4();
|
|
563
|
-
translate(vm, vm, [0, 0, -altitude]);
|
|
564
|
-
rotateX(vm, vm, -pitch * DEGREES_TO_RADIANS);
|
|
565
|
-
rotateZ(vm, vm, bearing * DEGREES_TO_RADIANS);
|
|
566
|
-
const relativeScale =
|
|
567
|
-
|
|
185
|
+
import_core2.mat4.translate(vm, vm, [0, 0, -altitude]);
|
|
186
|
+
import_core2.mat4.rotateX(vm, vm, -pitch * DEGREES_TO_RADIANS);
|
|
187
|
+
import_core2.mat4.rotateZ(vm, vm, bearing * DEGREES_TO_RADIANS);
|
|
188
|
+
const relativeScale = scale / height;
|
|
189
|
+
import_core2.mat4.scale(vm, vm, [relativeScale, relativeScale, relativeScale]);
|
|
568
190
|
if (center) {
|
|
569
|
-
translate(vm, vm,
|
|
191
|
+
import_core2.mat4.translate(vm, vm, import_core4.vec3.negate([], center));
|
|
570
192
|
}
|
|
571
193
|
return vm;
|
|
572
194
|
}
|
|
573
195
|
function getProjectionParameters(options) {
|
|
574
|
-
const { width, height, altitude, pitch = 0, offset, center, scale
|
|
196
|
+
const { width, height, altitude, pitch = 0, offset, center, scale, nearZMultiplier = 1, farZMultiplier = 1 } = options;
|
|
575
197
|
let { fovy = altitudeToFovy(DEFAULT_ALTITUDE) } = options;
|
|
576
198
|
if (altitude !== void 0) {
|
|
577
199
|
fovy = altitudeToFovy(altitude);
|
|
@@ -581,7 +203,7 @@ function getProjectionParameters(options) {
|
|
|
581
203
|
const focalDistance = fovyToAltitude(fovy);
|
|
582
204
|
let cameraToSeaLevelDistance = focalDistance;
|
|
583
205
|
if (center) {
|
|
584
|
-
cameraToSeaLevelDistance += center[2] *
|
|
206
|
+
cameraToSeaLevelDistance += center[2] * scale / Math.cos(pitchRadians) / height;
|
|
585
207
|
}
|
|
586
208
|
const fovAboveCenter = fovRadians * (0.5 + (offset ? offset[1] : 0) / height);
|
|
587
209
|
const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * cameraToSeaLevelDistance / Math.sin(clamp(Math.PI / 2 - pitchRadians - fovAboveCenter, 0.01, Math.PI - 0.01));
|
|
@@ -598,7 +220,7 @@ function getProjectionParameters(options) {
|
|
|
598
220
|
}
|
|
599
221
|
function getProjectionMatrix(options) {
|
|
600
222
|
const { fov, aspect, near, far } = getProjectionParameters(options);
|
|
601
|
-
const projectionMatrix = perspective(
|
|
223
|
+
const projectionMatrix = import_core2.mat4.perspective(
|
|
602
224
|
[],
|
|
603
225
|
fov,
|
|
604
226
|
// fov in radians
|
|
@@ -634,7 +256,7 @@ function pixelsToWorld(xyz, pixelUnprojectionMatrix, targetZ = 0) {
|
|
|
634
256
|
const z0 = coord0[2];
|
|
635
257
|
const z1 = coord1[2];
|
|
636
258
|
const t = z0 === z1 ? 0 : ((targetZ || 0) - z0) / (z1 - z0);
|
|
637
|
-
return
|
|
259
|
+
return import_core3.vec2.lerp([], coord0, coord1, t);
|
|
638
260
|
}
|
|
639
261
|
|
|
640
262
|
// dist/fit-bounds.js
|
|
@@ -690,6 +312,7 @@ function getPaddingObject(padding = 0) {
|
|
|
690
312
|
}
|
|
691
313
|
|
|
692
314
|
// dist/get-bounds.js
|
|
315
|
+
var import_core5 = require("@math.gl/core");
|
|
693
316
|
var DEGREES_TO_RADIANS2 = Math.PI / 180;
|
|
694
317
|
function getBounds(viewport, z = 0) {
|
|
695
318
|
const { width, height, unproject } = viewport;
|
|
@@ -715,13 +338,16 @@ function unprojectOnFarPlane(viewport, x, targetZ) {
|
|
|
715
338
|
const coord1 = transformVector(pixelUnprojectionMatrix, [x, viewport.height, 1, 1]);
|
|
716
339
|
const z = targetZ * viewport.distanceScales.unitsPerMeter[2];
|
|
717
340
|
const t = (z - coord0[2]) / (coord1[2] - coord0[2]);
|
|
718
|
-
const coord =
|
|
341
|
+
const coord = import_core5.vec2.lerp([], coord0, coord1, t);
|
|
719
342
|
const result = worldToLngLat(coord);
|
|
720
343
|
result.push(targetZ);
|
|
721
344
|
return result;
|
|
722
345
|
}
|
|
723
346
|
|
|
724
347
|
// dist/web-mercator-viewport.js
|
|
348
|
+
var import_core6 = require("@math.gl/core");
|
|
349
|
+
var import_core7 = require("@math.gl/core");
|
|
350
|
+
var import_core8 = require("@math.gl/core");
|
|
725
351
|
var WebMercatorViewport = class _WebMercatorViewport {
|
|
726
352
|
/**
|
|
727
353
|
* @classdesc
|
|
@@ -735,7 +361,7 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
735
361
|
if (!(viewport instanceof _WebMercatorViewport)) {
|
|
736
362
|
return false;
|
|
737
363
|
}
|
|
738
|
-
return viewport.width === this.width && viewport.height === this.height && equals(viewport.projectionMatrix, this.projectionMatrix) && equals(viewport.viewMatrix, this.viewMatrix);
|
|
364
|
+
return viewport.width === this.width && viewport.height === this.height && import_core6.mat4.equals(viewport.projectionMatrix, this.projectionMatrix) && import_core6.mat4.equals(viewport.viewMatrix, this.viewMatrix);
|
|
739
365
|
};
|
|
740
366
|
this.project = (lngLatZ, options = {}) => {
|
|
741
367
|
const { topLeft = true } = options;
|
|
@@ -785,18 +411,18 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
785
411
|
} else if (altitude === null) {
|
|
786
412
|
altitude = fovyToAltitude(fovy);
|
|
787
413
|
}
|
|
788
|
-
const
|
|
414
|
+
const scale = zoomToScale(zoom);
|
|
789
415
|
altitude = Math.max(0.75, altitude);
|
|
790
416
|
const distanceScales = getDistanceScales({ longitude, latitude });
|
|
791
417
|
const center = lngLatToWorld([longitude, latitude]);
|
|
792
418
|
center.push(0);
|
|
793
419
|
if (position) {
|
|
794
|
-
|
|
420
|
+
import_core8.vec3.add(center, center, import_core8.vec3.mul([], position, distanceScales.unitsPerMeter));
|
|
795
421
|
}
|
|
796
422
|
this.projectionMatrix = getProjectionMatrix({
|
|
797
423
|
width,
|
|
798
424
|
height,
|
|
799
|
-
scale
|
|
425
|
+
scale,
|
|
800
426
|
center,
|
|
801
427
|
pitch,
|
|
802
428
|
fovy,
|
|
@@ -805,7 +431,7 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
805
431
|
});
|
|
806
432
|
this.viewMatrix = getViewMatrix({
|
|
807
433
|
height,
|
|
808
|
-
scale
|
|
434
|
+
scale,
|
|
809
435
|
center,
|
|
810
436
|
pitch,
|
|
811
437
|
bearing,
|
|
@@ -813,7 +439,7 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
813
439
|
});
|
|
814
440
|
this.width = width;
|
|
815
441
|
this.height = height;
|
|
816
|
-
this.scale =
|
|
442
|
+
this.scale = scale;
|
|
817
443
|
this.latitude = latitude;
|
|
818
444
|
this.longitude = longitude;
|
|
819
445
|
this.zoom = zoom;
|
|
@@ -830,14 +456,14 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
830
456
|
_initMatrices() {
|
|
831
457
|
const { width, height, projectionMatrix, viewMatrix } = this;
|
|
832
458
|
const vpm = createMat4();
|
|
833
|
-
multiply(vpm, vpm, projectionMatrix);
|
|
834
|
-
multiply(vpm, vpm, viewMatrix);
|
|
459
|
+
import_core6.mat4.multiply(vpm, vpm, projectionMatrix);
|
|
460
|
+
import_core6.mat4.multiply(vpm, vpm, viewMatrix);
|
|
835
461
|
this.viewProjectionMatrix = vpm;
|
|
836
462
|
const m = createMat4();
|
|
837
|
-
|
|
838
|
-
translate(m, m, [1, -1, 0]);
|
|
839
|
-
multiply(m, m, vpm);
|
|
840
|
-
const mInverse = invert(createMat4(), m);
|
|
463
|
+
import_core6.mat4.scale(m, m, [width / 2, -height / 2, 1]);
|
|
464
|
+
import_core6.mat4.translate(m, m, [1, -1, 0]);
|
|
465
|
+
import_core6.mat4.multiply(m, m, vpm);
|
|
466
|
+
const mInverse = import_core6.mat4.invert(createMat4(), m);
|
|
841
467
|
if (!mInverse) {
|
|
842
468
|
throw new Error("Pixel project matrix not invertible");
|
|
843
469
|
}
|
|
@@ -881,8 +507,8 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
881
507
|
getMapCenterByLngLatPosition({ lngLat, pos }) {
|
|
882
508
|
const fromLocation = pixelsToWorld(pos, this.pixelUnprojectionMatrix);
|
|
883
509
|
const toLocation = lngLatToWorld(lngLat);
|
|
884
|
-
const
|
|
885
|
-
const newCenter = add([], this.center,
|
|
510
|
+
const translate = import_core7.vec2.add([], toLocation, import_core7.vec2.negate([], fromLocation));
|
|
511
|
+
const newCenter = import_core7.vec2.add([], this.center, translate);
|
|
886
512
|
return worldToLngLat(newCenter);
|
|
887
513
|
}
|
|
888
514
|
/**
|
|
@@ -926,11 +552,6 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
926
552
|
getBoundingRegion(options = {}) {
|
|
927
553
|
return getBounds(this, options.z || 0);
|
|
928
554
|
}
|
|
929
|
-
// DEPRECATED
|
|
930
|
-
/** @deprecated Legacy method name */
|
|
931
|
-
getLocationAtPoint({ lngLat, pos }) {
|
|
932
|
-
return this.getMapCenterByLngLatPosition({ lngLat, pos });
|
|
933
|
-
}
|
|
934
555
|
};
|
|
935
556
|
|
|
936
557
|
// dist/normalize-viewport-props.js
|
|
@@ -964,7 +585,8 @@ function normalizeViewportProps(props) {
|
|
|
964
585
|
}
|
|
965
586
|
|
|
966
587
|
// dist/fly-to-viewport.js
|
|
967
|
-
var
|
|
588
|
+
var import_core9 = require("@math.gl/core");
|
|
589
|
+
var EPSILON = 0.01;
|
|
968
590
|
var VIEWPORT_TRANSITION_PROPS = ["longitude", "latitude", "zoom"];
|
|
969
591
|
var DEFAULT_OPTS = {
|
|
970
592
|
curve: 1.414,
|
|
@@ -973,7 +595,7 @@ var DEFAULT_OPTS = {
|
|
|
973
595
|
};
|
|
974
596
|
function flyToViewport(startProps, endProps, t, options) {
|
|
975
597
|
const { startZoom, startCenterXY, uDelta, w0, u1, S, rho, rho2, r0 } = getFlyToTransitionParams(startProps, endProps, options);
|
|
976
|
-
if (u1 <
|
|
598
|
+
if (u1 < EPSILON) {
|
|
977
599
|
const viewport = {
|
|
978
600
|
longitude: 0,
|
|
979
601
|
latitude: 0,
|
|
@@ -991,8 +613,8 @@ function flyToViewport(startProps, endProps, t, options) {
|
|
|
991
613
|
const u = w0 * ((Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2) / u1;
|
|
992
614
|
const scaleIncrement = 1 / w;
|
|
993
615
|
const newZoom = startZoom + scaleToZoom(scaleIncrement);
|
|
994
|
-
const newCenterWorld =
|
|
995
|
-
add(newCenterWorld, newCenterWorld, startCenterXY);
|
|
616
|
+
const newCenterWorld = import_core9.vec2.scale([], uDelta, u);
|
|
617
|
+
import_core9.vec2.add(newCenterWorld, newCenterWorld, startCenterXY);
|
|
996
618
|
const newCenter = worldToLngLat(newCenterWorld);
|
|
997
619
|
return {
|
|
998
620
|
longitude: newCenter[0],
|
|
@@ -1004,12 +626,12 @@ function getFlyToDuration(startProps, endProps, options) {
|
|
|
1004
626
|
const opts = { ...DEFAULT_OPTS, ...options };
|
|
1005
627
|
const { screenSpeed, speed, maxDuration } = opts;
|
|
1006
628
|
const { S, rho } = getFlyToTransitionParams(startProps, endProps, opts);
|
|
1007
|
-
const
|
|
629
|
+
const length = 1e3 * S;
|
|
1008
630
|
let duration;
|
|
1009
631
|
if (Number.isFinite(screenSpeed)) {
|
|
1010
|
-
duration =
|
|
632
|
+
duration = length / (screenSpeed / rho);
|
|
1011
633
|
} else {
|
|
1012
|
-
duration =
|
|
634
|
+
duration = length / speed;
|
|
1013
635
|
}
|
|
1014
636
|
return Number.isFinite(maxDuration) && duration > maxDuration ? 0 : duration;
|
|
1015
637
|
}
|
|
@@ -1021,14 +643,14 @@ function getFlyToTransitionParams(startProps, endProps, opts) {
|
|
|
1021
643
|
const startScale = zoomToScale(startZoom);
|
|
1022
644
|
const endZoom = endProps.zoom;
|
|
1023
645
|
const endCenter = [endProps.longitude, endProps.latitude];
|
|
1024
|
-
const
|
|
646
|
+
const scale = zoomToScale(endZoom - startZoom);
|
|
1025
647
|
const startCenterXY = lngLatToWorld(startCenter);
|
|
1026
648
|
const endCenterXY = lngLatToWorld(endCenter);
|
|
1027
|
-
const uDelta = sub([], endCenterXY, startCenterXY);
|
|
649
|
+
const uDelta = import_core9.vec2.sub([], endCenterXY, startCenterXY);
|
|
1028
650
|
const w0 = Math.max(startProps.width, startProps.height);
|
|
1029
|
-
const w1 = w0 /
|
|
1030
|
-
const u1 = length(uDelta) * startScale;
|
|
1031
|
-
const _u1 = Math.max(u1,
|
|
651
|
+
const w1 = w0 / scale;
|
|
652
|
+
const u1 = import_core9.vec2.length(uDelta) * startScale;
|
|
653
|
+
const _u1 = Math.max(u1, EPSILON);
|
|
1032
654
|
const rho2 = rho * rho;
|
|
1033
655
|
const b0 = (w1 * w1 - w0 * w0 + rho2 * rho2 * _u1 * _u1) / (2 * w0 * rho2 * _u1);
|
|
1034
656
|
const b1 = (w1 * w1 - w0 * w0 - rho2 * rho2 * _u1 * _u1) / (2 * w1 * rho2 * _u1);
|