@math.gl/web-mercator 5.0.0-alpha.2 → 5.0.0-alpha.20
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 +3 -0
- package/dist/fly-to-viewport.js.map +1 -1
- package/dist/get-bounds.d.ts.map +1 -1
- package/dist/get-bounds.js +3 -0
- package/dist/get-bounds.js.map +1 -1
- package/dist/index.cjs +59 -427
- 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 +3 -0
- 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 +3 -0
- 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 +3 -5
- 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 +3 -0
- package/src/get-bounds.ts +3 -0
- package/src/index.ts +3 -0
- package/src/math-utils.ts +3 -0
- package/src/mercator-meters.ts +1 -1
- package/src/normalize-viewport-props.ts +3 -0
- package/src/web-mercator-utils.ts +3 -0
- package/src/web-mercator-viewport.ts +3 -7
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
|
|
25
|
+
mod2
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
|
|
18
28
|
|
|
19
29
|
// dist/index.js
|
|
@@ -53,37 +63,14 @@ __export(index_exports, {
|
|
|
53
63
|
});
|
|
54
64
|
module.exports = __toCommonJS(index_exports);
|
|
55
65
|
|
|
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
66
|
// dist/math-utils.js
|
|
67
|
+
var vec4 = __toESM(require("@math.gl/core/vec4"), 1);
|
|
81
68
|
function createMat4() {
|
|
82
69
|
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
83
70
|
}
|
|
84
71
|
function transformVector(matrix, vector) {
|
|
85
|
-
const result = transformMat4([], vector, matrix);
|
|
86
|
-
scale(result, result, 1 / result[3]);
|
|
72
|
+
const result = vec4.transformMat4([], vector, matrix);
|
|
73
|
+
vec4.scale(result, result, 1 / result[3]);
|
|
87
74
|
return result;
|
|
88
75
|
}
|
|
89
76
|
function mod(value, divisor) {
|
|
@@ -101,365 +88,10 @@ function ieLog2(x) {
|
|
|
101
88
|
}
|
|
102
89
|
var log2 = Math.log2 || ieLog2;
|
|
103
90
|
|
|
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;
|
|
91
|
+
// dist/web-mercator-utils.js
|
|
92
|
+
var mat4 = __toESM(require("@math.gl/core/mat4"), 1);
|
|
93
|
+
var vec2 = __toESM(require("@math.gl/core/vec2"), 1);
|
|
94
|
+
var vec3 = __toESM(require("@math.gl/core/vec3"), 1);
|
|
463
95
|
|
|
464
96
|
// dist/assert.js
|
|
465
97
|
function assert(condition, message) {
|
|
@@ -480,8 +112,8 @@ var DEFAULT_ALTITUDE = 1.5;
|
|
|
480
112
|
function zoomToScale(zoom) {
|
|
481
113
|
return Math.pow(2, zoom);
|
|
482
114
|
}
|
|
483
|
-
function scaleToZoom(
|
|
484
|
-
return log2(
|
|
115
|
+
function scaleToZoom(scale5) {
|
|
116
|
+
return log2(scale5);
|
|
485
117
|
}
|
|
486
118
|
function lngLatToWorld(lngLat) {
|
|
487
119
|
const [lng, lat] = lngLat;
|
|
@@ -556,22 +188,22 @@ function getViewMatrix(options) {
|
|
|
556
188
|
bearing,
|
|
557
189
|
altitude,
|
|
558
190
|
// Pre-calculated parameters
|
|
559
|
-
scale:
|
|
191
|
+
scale: scale5,
|
|
560
192
|
center
|
|
561
193
|
} = options;
|
|
562
194
|
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
|
-
|
|
195
|
+
mat4.translate(vm, vm, [0, 0, -altitude]);
|
|
196
|
+
mat4.rotateX(vm, vm, -pitch * DEGREES_TO_RADIANS);
|
|
197
|
+
mat4.rotateZ(vm, vm, bearing * DEGREES_TO_RADIANS);
|
|
198
|
+
const relativeScale = scale5 / height;
|
|
199
|
+
mat4.scale(vm, vm, [relativeScale, relativeScale, relativeScale]);
|
|
568
200
|
if (center) {
|
|
569
|
-
translate(vm, vm,
|
|
201
|
+
mat4.translate(vm, vm, vec3.negate([], center));
|
|
570
202
|
}
|
|
571
203
|
return vm;
|
|
572
204
|
}
|
|
573
205
|
function getProjectionParameters(options) {
|
|
574
|
-
const { width, height, altitude, pitch = 0, offset, center, scale:
|
|
206
|
+
const { width, height, altitude, pitch = 0, offset, center, scale: scale5, nearZMultiplier = 1, farZMultiplier = 1 } = options;
|
|
575
207
|
let { fovy = altitudeToFovy(DEFAULT_ALTITUDE) } = options;
|
|
576
208
|
if (altitude !== void 0) {
|
|
577
209
|
fovy = altitudeToFovy(altitude);
|
|
@@ -581,7 +213,7 @@ function getProjectionParameters(options) {
|
|
|
581
213
|
const focalDistance = fovyToAltitude(fovy);
|
|
582
214
|
let cameraToSeaLevelDistance = focalDistance;
|
|
583
215
|
if (center) {
|
|
584
|
-
cameraToSeaLevelDistance += center[2] *
|
|
216
|
+
cameraToSeaLevelDistance += center[2] * scale5 / Math.cos(pitchRadians) / height;
|
|
585
217
|
}
|
|
586
218
|
const fovAboveCenter = fovRadians * (0.5 + (offset ? offset[1] : 0) / height);
|
|
587
219
|
const topHalfSurfaceDistance = Math.sin(fovAboveCenter) * cameraToSeaLevelDistance / Math.sin(clamp(Math.PI / 2 - pitchRadians - fovAboveCenter, 0.01, Math.PI - 0.01));
|
|
@@ -598,7 +230,7 @@ function getProjectionParameters(options) {
|
|
|
598
230
|
}
|
|
599
231
|
function getProjectionMatrix(options) {
|
|
600
232
|
const { fov, aspect, near, far } = getProjectionParameters(options);
|
|
601
|
-
const projectionMatrix = perspective(
|
|
233
|
+
const projectionMatrix = mat4.perspective(
|
|
602
234
|
[],
|
|
603
235
|
fov,
|
|
604
236
|
// fov in radians
|
|
@@ -634,7 +266,7 @@ function pixelsToWorld(xyz, pixelUnprojectionMatrix, targetZ = 0) {
|
|
|
634
266
|
const z0 = coord0[2];
|
|
635
267
|
const z1 = coord1[2];
|
|
636
268
|
const t = z0 === z1 ? 0 : ((targetZ || 0) - z0) / (z1 - z0);
|
|
637
|
-
return
|
|
269
|
+
return vec2.lerp([], coord0, coord1, t);
|
|
638
270
|
}
|
|
639
271
|
|
|
640
272
|
// dist/fit-bounds.js
|
|
@@ -690,6 +322,7 @@ function getPaddingObject(padding = 0) {
|
|
|
690
322
|
}
|
|
691
323
|
|
|
692
324
|
// dist/get-bounds.js
|
|
325
|
+
var vec22 = __toESM(require("@math.gl/core/vec2"), 1);
|
|
693
326
|
var DEGREES_TO_RADIANS2 = Math.PI / 180;
|
|
694
327
|
function getBounds(viewport, z = 0) {
|
|
695
328
|
const { width, height, unproject } = viewport;
|
|
@@ -715,13 +348,16 @@ function unprojectOnFarPlane(viewport, x, targetZ) {
|
|
|
715
348
|
const coord1 = transformVector(pixelUnprojectionMatrix, [x, viewport.height, 1, 1]);
|
|
716
349
|
const z = targetZ * viewport.distanceScales.unitsPerMeter[2];
|
|
717
350
|
const t = (z - coord0[2]) / (coord1[2] - coord0[2]);
|
|
718
|
-
const coord =
|
|
351
|
+
const coord = vec22.lerp([], coord0, coord1, t);
|
|
719
352
|
const result = worldToLngLat(coord);
|
|
720
353
|
result.push(targetZ);
|
|
721
354
|
return result;
|
|
722
355
|
}
|
|
723
356
|
|
|
724
357
|
// dist/web-mercator-viewport.js
|
|
358
|
+
var mat42 = __toESM(require("@math.gl/core/mat4"), 1);
|
|
359
|
+
var vec23 = __toESM(require("@math.gl/core/vec2"), 1);
|
|
360
|
+
var vec32 = __toESM(require("@math.gl/core/vec3"), 1);
|
|
725
361
|
var WebMercatorViewport = class _WebMercatorViewport {
|
|
726
362
|
/**
|
|
727
363
|
* @classdesc
|
|
@@ -735,7 +371,7 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
735
371
|
if (!(viewport instanceof _WebMercatorViewport)) {
|
|
736
372
|
return false;
|
|
737
373
|
}
|
|
738
|
-
return viewport.width === this.width && viewport.height === this.height && equals(viewport.projectionMatrix, this.projectionMatrix) && equals(viewport.viewMatrix, this.viewMatrix);
|
|
374
|
+
return viewport.width === this.width && viewport.height === this.height && mat42.equals(viewport.projectionMatrix, this.projectionMatrix) && mat42.equals(viewport.viewMatrix, this.viewMatrix);
|
|
739
375
|
};
|
|
740
376
|
this.project = (lngLatZ, options = {}) => {
|
|
741
377
|
const { topLeft = true } = options;
|
|
@@ -785,18 +421,18 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
785
421
|
} else if (altitude === null) {
|
|
786
422
|
altitude = fovyToAltitude(fovy);
|
|
787
423
|
}
|
|
788
|
-
const
|
|
424
|
+
const scale5 = zoomToScale(zoom);
|
|
789
425
|
altitude = Math.max(0.75, altitude);
|
|
790
426
|
const distanceScales = getDistanceScales({ longitude, latitude });
|
|
791
427
|
const center = lngLatToWorld([longitude, latitude]);
|
|
792
428
|
center.push(0);
|
|
793
429
|
if (position) {
|
|
794
|
-
|
|
430
|
+
vec32.add(center, center, vec32.mul([], position, distanceScales.unitsPerMeter));
|
|
795
431
|
}
|
|
796
432
|
this.projectionMatrix = getProjectionMatrix({
|
|
797
433
|
width,
|
|
798
434
|
height,
|
|
799
|
-
scale:
|
|
435
|
+
scale: scale5,
|
|
800
436
|
center,
|
|
801
437
|
pitch,
|
|
802
438
|
fovy,
|
|
@@ -805,7 +441,7 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
805
441
|
});
|
|
806
442
|
this.viewMatrix = getViewMatrix({
|
|
807
443
|
height,
|
|
808
|
-
scale:
|
|
444
|
+
scale: scale5,
|
|
809
445
|
center,
|
|
810
446
|
pitch,
|
|
811
447
|
bearing,
|
|
@@ -813,7 +449,7 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
813
449
|
});
|
|
814
450
|
this.width = width;
|
|
815
451
|
this.height = height;
|
|
816
|
-
this.scale =
|
|
452
|
+
this.scale = scale5;
|
|
817
453
|
this.latitude = latitude;
|
|
818
454
|
this.longitude = longitude;
|
|
819
455
|
this.zoom = zoom;
|
|
@@ -830,14 +466,14 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
830
466
|
_initMatrices() {
|
|
831
467
|
const { width, height, projectionMatrix, viewMatrix } = this;
|
|
832
468
|
const vpm = createMat4();
|
|
833
|
-
multiply(vpm, vpm, projectionMatrix);
|
|
834
|
-
multiply(vpm, vpm, viewMatrix);
|
|
469
|
+
mat42.multiply(vpm, vpm, projectionMatrix);
|
|
470
|
+
mat42.multiply(vpm, vpm, viewMatrix);
|
|
835
471
|
this.viewProjectionMatrix = vpm;
|
|
836
472
|
const m = createMat4();
|
|
837
|
-
|
|
838
|
-
translate(m, m, [1, -1, 0]);
|
|
839
|
-
multiply(m, m, vpm);
|
|
840
|
-
const mInverse = invert(createMat4(), m);
|
|
473
|
+
mat42.scale(m, m, [width / 2, -height / 2, 1]);
|
|
474
|
+
mat42.translate(m, m, [1, -1, 0]);
|
|
475
|
+
mat42.multiply(m, m, vpm);
|
|
476
|
+
const mInverse = mat42.invert(createMat4(), m);
|
|
841
477
|
if (!mInverse) {
|
|
842
478
|
throw new Error("Pixel project matrix not invertible");
|
|
843
479
|
}
|
|
@@ -881,8 +517,8 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
881
517
|
getMapCenterByLngLatPosition({ lngLat, pos }) {
|
|
882
518
|
const fromLocation = pixelsToWorld(pos, this.pixelUnprojectionMatrix);
|
|
883
519
|
const toLocation = lngLatToWorld(lngLat);
|
|
884
|
-
const
|
|
885
|
-
const newCenter = add([], this.center,
|
|
520
|
+
const translate3 = vec23.add([], toLocation, vec23.negate([], fromLocation));
|
|
521
|
+
const newCenter = vec23.add([], this.center, translate3);
|
|
886
522
|
return worldToLngLat(newCenter);
|
|
887
523
|
}
|
|
888
524
|
/**
|
|
@@ -926,11 +562,6 @@ var WebMercatorViewport = class _WebMercatorViewport {
|
|
|
926
562
|
getBoundingRegion(options = {}) {
|
|
927
563
|
return getBounds(this, options.z || 0);
|
|
928
564
|
}
|
|
929
|
-
// DEPRECATED
|
|
930
|
-
/** @deprecated Legacy method name */
|
|
931
|
-
getLocationAtPoint({ lngLat, pos }) {
|
|
932
|
-
return this.getMapCenterByLngLatPosition({ lngLat, pos });
|
|
933
|
-
}
|
|
934
565
|
};
|
|
935
566
|
|
|
936
567
|
// dist/normalize-viewport-props.js
|
|
@@ -964,7 +595,8 @@ function normalizeViewportProps(props) {
|
|
|
964
595
|
}
|
|
965
596
|
|
|
966
597
|
// dist/fly-to-viewport.js
|
|
967
|
-
var
|
|
598
|
+
var vec24 = __toESM(require("@math.gl/core/vec2"), 1);
|
|
599
|
+
var EPSILON = 0.01;
|
|
968
600
|
var VIEWPORT_TRANSITION_PROPS = ["longitude", "latitude", "zoom"];
|
|
969
601
|
var DEFAULT_OPTS = {
|
|
970
602
|
curve: 1.414,
|
|
@@ -973,7 +605,7 @@ var DEFAULT_OPTS = {
|
|
|
973
605
|
};
|
|
974
606
|
function flyToViewport(startProps, endProps, t, options) {
|
|
975
607
|
const { startZoom, startCenterXY, uDelta, w0, u1, S, rho, rho2, r0 } = getFlyToTransitionParams(startProps, endProps, options);
|
|
976
|
-
if (u1 <
|
|
608
|
+
if (u1 < EPSILON) {
|
|
977
609
|
const viewport = {
|
|
978
610
|
longitude: 0,
|
|
979
611
|
latitude: 0,
|
|
@@ -991,8 +623,8 @@ function flyToViewport(startProps, endProps, t, options) {
|
|
|
991
623
|
const u = w0 * ((Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2) / u1;
|
|
992
624
|
const scaleIncrement = 1 / w;
|
|
993
625
|
const newZoom = startZoom + scaleToZoom(scaleIncrement);
|
|
994
|
-
const newCenterWorld =
|
|
995
|
-
add(newCenterWorld, newCenterWorld, startCenterXY);
|
|
626
|
+
const newCenterWorld = vec24.scale([], uDelta, u);
|
|
627
|
+
vec24.add(newCenterWorld, newCenterWorld, startCenterXY);
|
|
996
628
|
const newCenter = worldToLngLat(newCenterWorld);
|
|
997
629
|
return {
|
|
998
630
|
longitude: newCenter[0],
|
|
@@ -1021,14 +653,14 @@ function getFlyToTransitionParams(startProps, endProps, opts) {
|
|
|
1021
653
|
const startScale = zoomToScale(startZoom);
|
|
1022
654
|
const endZoom = endProps.zoom;
|
|
1023
655
|
const endCenter = [endProps.longitude, endProps.latitude];
|
|
1024
|
-
const
|
|
656
|
+
const scale5 = zoomToScale(endZoom - startZoom);
|
|
1025
657
|
const startCenterXY = lngLatToWorld(startCenter);
|
|
1026
658
|
const endCenterXY = lngLatToWorld(endCenter);
|
|
1027
|
-
const uDelta = sub([], endCenterXY, startCenterXY);
|
|
659
|
+
const uDelta = vec24.sub([], endCenterXY, startCenterXY);
|
|
1028
660
|
const w0 = Math.max(startProps.width, startProps.height);
|
|
1029
|
-
const w1 = w0 /
|
|
1030
|
-
const u1 = length(uDelta) * startScale;
|
|
1031
|
-
const _u1 = Math.max(u1,
|
|
661
|
+
const w1 = w0 / scale5;
|
|
662
|
+
const u1 = vec24.length(uDelta) * startScale;
|
|
663
|
+
const _u1 = Math.max(u1, EPSILON);
|
|
1032
664
|
const rho2 = rho * rho;
|
|
1033
665
|
const b0 = (w1 * w1 - w0 * w0 + rho2 * rho2 * _u1 * _u1) / (2 * w0 * rho2 * _u1);
|
|
1034
666
|
const b1 = (w1 * w1 - w0 * w0 - rho2 * rho2 * _u1 * _u1) / (2 * w1 * rho2 * _u1);
|