@antv/l7-map 2.17.4 → 2.17.5
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/es/camera.js +90 -148
- package/es/earthmap.js +13 -65
- package/es/geo/edge_insets.js +4 -14
- package/es/geo/lng_lat.js +5 -13
- package/es/geo/lng_lat_bounds.js +4 -17
- package/es/geo/mercator.js +2 -10
- package/es/geo/point.js +0 -7
- package/es/geo/simple.js +6 -11
- package/es/geo/transform.js +123 -132
- package/es/handler/blockable_map_event.js +7 -12
- package/es/handler/box_zoom.js +10 -30
- package/es/handler/click_zoom.js +0 -5
- package/es/handler/events/event.js +0 -2
- package/es/handler/events/map_mouse_event.js +0 -12
- package/es/handler/events/map_touch_event.js +2 -12
- package/es/handler/events/map_wheel_event.js +1 -12
- package/es/handler/events/render_event.js +0 -13
- package/es/handler/handler_inertia.js +6 -34
- package/es/handler/handler_manager.js +55 -147
- package/es/handler/handler_util.js +1 -2
- package/es/handler/keyboard.js +1 -20
- package/es/handler/map_event.js +3 -9
- package/es/handler/mouse/mouse_handler.js +11 -24
- package/es/handler/mouse/mousepan_handler.js +1 -11
- package/es/handler/mouse/mousepitch_hander.js +1 -11
- package/es/handler/mouse/mouserotate_hander.js +1 -11
- package/es/handler/mouse/util.js +2 -3
- package/es/handler/scroll_zoom.js +43 -71
- package/es/handler/shim/dblclick_zoom.js +4 -9
- package/es/handler/shim/drag_pan.js +4 -11
- package/es/handler/shim/drag_rotate.js +4 -10
- package/es/handler/shim/touch_zoom_rotate.js +6 -16
- package/es/handler/tap/single_tap_recognizer.js +8 -31
- package/es/handler/tap/tap_drag_zoom.js +7 -15
- package/es/handler/tap/tap_recognizer.js +3 -11
- package/es/handler/tap/tap_zoom.js +1 -7
- package/es/handler/touch/touch_pan.js +4 -22
- package/es/handler/touch/touch_pitch.js +10 -27
- package/es/handler/touch/touch_rotate.js +8 -19
- package/es/handler/touch/touch_zoom.js +5 -18
- package/es/handler/touch/two_touch.js +19 -32
- package/es/hash.js +9 -31
- package/es/map.js +16 -78
- package/es/util.js +18 -26
- package/es/utils/Aabb.js +10 -31
- package/es/utils/dom.js +24 -58
- package/es/utils/performance.js +8 -7
- package/es/utils/primitives.js +13 -11
- package/es/utils/task_queue.js +6 -23
- package/lib/camera.js +90 -168
- package/lib/earthmap.js +11 -79
- package/lib/geo/edge_insets.js +3 -18
- package/lib/geo/lng_lat.js +5 -18
- package/lib/geo/lng_lat_bounds.js +4 -20
- package/lib/geo/mercator.js +1 -22
- package/lib/geo/point.js +0 -8
- package/lib/geo/simple.js +5 -24
- package/lib/geo/transform.js +123 -164
- package/lib/handler/blockable_map_event.js +6 -14
- package/lib/handler/box_zoom.js +8 -39
- package/lib/handler/click_zoom.js +0 -6
- package/lib/handler/events/event.js +0 -5
- package/lib/handler/events/index.js +0 -4
- package/lib/handler/events/map_mouse_event.js +0 -19
- package/lib/handler/events/map_touch_event.js +1 -20
- package/lib/handler/events/map_wheel_event.js +1 -16
- package/lib/handler/events/render_event.js +0 -19
- package/lib/handler/handler_inertia.js +4 -37
- package/lib/handler/handler_manager.js +55 -171
- package/lib/handler/handler_util.js +1 -3
- package/lib/handler/keyboard.js +1 -22
- package/lib/handler/map_event.js +2 -11
- package/lib/handler/mouse/index.js +0 -4
- package/lib/handler/mouse/mouse_handler.js +10 -27
- package/lib/handler/mouse/mousepan_handler.js +0 -17
- package/lib/handler/mouse/mousepitch_hander.js +0 -16
- package/lib/handler/mouse/mouserotate_hander.js +0 -16
- package/lib/handler/mouse/util.js +2 -6
- package/lib/handler/scroll_zoom.js +43 -77
- package/lib/handler/shim/dblclick_zoom.js +4 -10
- package/lib/handler/shim/drag_pan.js +4 -13
- package/lib/handler/shim/drag_rotate.js +4 -11
- package/lib/handler/shim/touch_zoom_rotate.js +6 -18
- package/lib/handler/tap/single_tap_recognizer.js +8 -33
- package/lib/handler/tap/tap_drag_zoom.js +6 -18
- package/lib/handler/tap/tap_recognizer.js +2 -17
- package/lib/handler/tap/tap_zoom.js +0 -9
- package/lib/handler/touch/index.js +0 -5
- package/lib/handler/touch/touch_pan.js +4 -25
- package/lib/handler/touch/touch_pitch.js +9 -31
- package/lib/handler/touch/touch_rotate.js +7 -24
- package/lib/handler/touch/touch_zoom.js +4 -23
- package/lib/handler/touch/two_touch.js +18 -35
- package/lib/hash.js +8 -35
- package/lib/index.js +0 -8
- package/lib/map.js +14 -94
- package/lib/util.js +16 -38
- package/lib/utils/Aabb.js +10 -34
- package/lib/utils/dom.js +22 -64
- package/lib/utils/performance.js +8 -9
- package/lib/utils/primitives.js +13 -16
- package/lib/utils/task_queue.js +6 -24
- package/package.json +3 -3
package/lib/geo/transform.js
CHANGED
|
@@ -1,52 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.EXTENT = void 0;
|
|
11
|
-
|
|
12
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
11
|
var _l7Utils = require("@antv/l7-utils");
|
|
17
|
-
|
|
18
12
|
var _glMatrix = require("gl-matrix");
|
|
19
|
-
|
|
20
13
|
var _point = _interopRequireDefault(require("../geo/point"));
|
|
21
|
-
|
|
22
14
|
var _util = require("../util");
|
|
23
|
-
|
|
24
15
|
var _edge_insets = _interopRequireDefault(require("./edge_insets"));
|
|
25
|
-
|
|
26
16
|
var _lng_lat = _interopRequireDefault(require("./lng_lat"));
|
|
27
|
-
|
|
28
17
|
var _lng_lat_bounds = _interopRequireDefault(require("./lng_lat_bounds"));
|
|
29
|
-
|
|
30
18
|
var _mercator = _interopRequireWildcard(require("./mercator"));
|
|
31
|
-
|
|
32
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
-
|
|
34
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
|
-
|
|
36
21
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
37
|
-
|
|
38
22
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
39
|
-
|
|
40
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
41
|
-
|
|
23
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
42
24
|
var EXTENT = 8192;
|
|
43
25
|
exports.EXTENT = EXTENT;
|
|
44
|
-
|
|
45
26
|
var Transform = /*#__PURE__*/function () {
|
|
46
27
|
function Transform(minZoom, maxZoom, minPitch, maxPitch, renderWorldCopies) {
|
|
47
28
|
(0, _classCallCheck2.default)(this, Transform);
|
|
48
29
|
this.tileSize = 512; // constant
|
|
49
|
-
|
|
50
30
|
this.maxValidLatitude = 85.051129; // constant
|
|
51
31
|
|
|
52
32
|
this._renderWorldCopies = renderWorldCopies === undefined ? true : renderWorldCopies;
|
|
@@ -67,7 +47,6 @@ var Transform = /*#__PURE__*/function () {
|
|
|
67
47
|
this.posMatrixCache = {};
|
|
68
48
|
this.alignedPosMatrixCache = {};
|
|
69
49
|
}
|
|
70
|
-
|
|
71
50
|
(0, _createClass2.default)(Transform, [{
|
|
72
51
|
key: "minZoom",
|
|
73
52
|
get: function get() {
|
|
@@ -77,7 +56,6 @@ var Transform = /*#__PURE__*/function () {
|
|
|
77
56
|
if (this._minZoom === zoom) {
|
|
78
57
|
return;
|
|
79
58
|
}
|
|
80
|
-
|
|
81
59
|
this._minZoom = zoom;
|
|
82
60
|
this.zoom = Math.max(this.zoom, zoom);
|
|
83
61
|
}
|
|
@@ -90,7 +68,6 @@ var Transform = /*#__PURE__*/function () {
|
|
|
90
68
|
if (this._maxZoom === zoom) {
|
|
91
69
|
return;
|
|
92
70
|
}
|
|
93
|
-
|
|
94
71
|
this._maxZoom = zoom;
|
|
95
72
|
this.zoom = Math.min(this.zoom, zoom);
|
|
96
73
|
}
|
|
@@ -103,7 +80,6 @@ var Transform = /*#__PURE__*/function () {
|
|
|
103
80
|
if (this._minPitch === pitch) {
|
|
104
81
|
return;
|
|
105
82
|
}
|
|
106
|
-
|
|
107
83
|
this._minPitch = pitch;
|
|
108
84
|
this._pitch = Math.max(this._pitch, pitch);
|
|
109
85
|
}
|
|
@@ -116,7 +92,6 @@ var Transform = /*#__PURE__*/function () {
|
|
|
116
92
|
if (this._maxPitch === pitch) {
|
|
117
93
|
return;
|
|
118
94
|
}
|
|
119
|
-
|
|
120
95
|
this._maxPitch = pitch;
|
|
121
96
|
this._pitch = Math.min(this._pitch, pitch);
|
|
122
97
|
}
|
|
@@ -131,7 +106,6 @@ var Transform = /*#__PURE__*/function () {
|
|
|
131
106
|
} else if (renderWorldCopies === null) {
|
|
132
107
|
renderWorldCopies = false;
|
|
133
108
|
}
|
|
134
|
-
|
|
135
109
|
this._renderWorldCopies = renderWorldCopies;
|
|
136
110
|
}
|
|
137
111
|
}, {
|
|
@@ -156,17 +130,15 @@ var Transform = /*#__PURE__*/function () {
|
|
|
156
130
|
},
|
|
157
131
|
set: function set(bearing) {
|
|
158
132
|
var b = -(0, _util.wrap)(bearing, -180, 180) * Math.PI / 180;
|
|
159
|
-
|
|
160
133
|
if (this.angle === b) {
|
|
161
134
|
return;
|
|
162
135
|
}
|
|
163
|
-
|
|
164
136
|
this.unmodified = false;
|
|
165
137
|
this.angle = b;
|
|
166
|
-
this.calcMatrices();
|
|
138
|
+
this.calcMatrices();
|
|
167
139
|
|
|
140
|
+
// 2x2 matrix for rotating points
|
|
168
141
|
this.rotationMatrix = _glMatrix.mat2.create();
|
|
169
|
-
|
|
170
142
|
_glMatrix.mat2.rotate(this.rotationMatrix, this.rotationMatrix, this.angle);
|
|
171
143
|
}
|
|
172
144
|
}, {
|
|
@@ -176,11 +148,9 @@ var Transform = /*#__PURE__*/function () {
|
|
|
176
148
|
},
|
|
177
149
|
set: function set(pitch) {
|
|
178
150
|
var p = (0, _util.clamp)(pitch, this._minPitch, this._maxPitch) / 180 * Math.PI;
|
|
179
|
-
|
|
180
151
|
if (this._pitch === p) {
|
|
181
152
|
return;
|
|
182
153
|
}
|
|
183
|
-
|
|
184
154
|
this.unmodified = false;
|
|
185
155
|
this._pitch = p;
|
|
186
156
|
this.calcMatrices();
|
|
@@ -192,11 +162,9 @@ var Transform = /*#__PURE__*/function () {
|
|
|
192
162
|
},
|
|
193
163
|
set: function set(fov) {
|
|
194
164
|
fov = Math.max(0.01, Math.min(60, fov));
|
|
195
|
-
|
|
196
165
|
if (this._fov === fov) {
|
|
197
166
|
return;
|
|
198
167
|
}
|
|
199
|
-
|
|
200
168
|
this.unmodified = false;
|
|
201
169
|
this._fov = fov / 180 * Math.PI;
|
|
202
170
|
this.calcMatrices();
|
|
@@ -208,11 +176,9 @@ var Transform = /*#__PURE__*/function () {
|
|
|
208
176
|
},
|
|
209
177
|
set: function set(zoom) {
|
|
210
178
|
var z = Math.min(Math.max(zoom, this._minZoom), this._maxZoom);
|
|
211
|
-
|
|
212
179
|
if (this._zoom === z) {
|
|
213
180
|
return;
|
|
214
181
|
}
|
|
215
|
-
|
|
216
182
|
this.unmodified = false;
|
|
217
183
|
this._zoom = z;
|
|
218
184
|
this.scale = this.zoomScale(z);
|
|
@@ -230,7 +196,6 @@ var Transform = /*#__PURE__*/function () {
|
|
|
230
196
|
if (center.lat === this._center.lat && center.lng === this._center.lng) {
|
|
231
197
|
return;
|
|
232
198
|
}
|
|
233
|
-
|
|
234
199
|
this.unmodified = false;
|
|
235
200
|
this._center = center;
|
|
236
201
|
this.constrain();
|
|
@@ -245,12 +210,12 @@ var Transform = /*#__PURE__*/function () {
|
|
|
245
210
|
if (this.edgeInsets.equals(padding)) {
|
|
246
211
|
return;
|
|
247
212
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
213
|
+
this.unmodified = false;
|
|
214
|
+
// Update edge-insets inplace
|
|
251
215
|
this.edgeInsets.interpolate(this.edgeInsets, padding, 1);
|
|
252
216
|
this.calcMatrices();
|
|
253
217
|
}
|
|
218
|
+
|
|
254
219
|
/**
|
|
255
220
|
* The center of the screen in pixels with the top-left corner being (0,0)
|
|
256
221
|
* and +y axis pointing downwards. This accounts for padding.
|
|
@@ -259,7 +224,6 @@ var Transform = /*#__PURE__*/function () {
|
|
|
259
224
|
* @type {Point}
|
|
260
225
|
* @memberof Transform
|
|
261
226
|
*/
|
|
262
|
-
|
|
263
227
|
}, {
|
|
264
228
|
key: "centerPoint",
|
|
265
229
|
get: function get() {
|
|
@@ -288,6 +252,7 @@ var Transform = /*#__PURE__*/function () {
|
|
|
288
252
|
clone.calcMatrices();
|
|
289
253
|
return clone;
|
|
290
254
|
}
|
|
255
|
+
|
|
291
256
|
/**
|
|
292
257
|
* Returns if the padding params match
|
|
293
258
|
*
|
|
@@ -295,12 +260,12 @@ var Transform = /*#__PURE__*/function () {
|
|
|
295
260
|
* @returns {boolean}
|
|
296
261
|
* @memberof Transform
|
|
297
262
|
*/
|
|
298
|
-
|
|
299
263
|
}, {
|
|
300
264
|
key: "isPaddingEqual",
|
|
301
265
|
value: function isPaddingEqual(padding) {
|
|
302
266
|
return this.edgeInsets.equals(padding);
|
|
303
267
|
}
|
|
268
|
+
|
|
304
269
|
/**
|
|
305
270
|
* Helper method to upadte edge-insets inplace
|
|
306
271
|
*
|
|
@@ -308,7 +273,6 @@ var Transform = /*#__PURE__*/function () {
|
|
|
308
273
|
* @param {number} t
|
|
309
274
|
* @memberof Transform
|
|
310
275
|
*/
|
|
311
|
-
|
|
312
276
|
}, {
|
|
313
277
|
key: "interpolatePadding",
|
|
314
278
|
value: function interpolatePadding(start, target, t) {
|
|
@@ -317,6 +281,7 @@ var Transform = /*#__PURE__*/function () {
|
|
|
317
281
|
this.constrain();
|
|
318
282
|
this.calcMatrices();
|
|
319
283
|
}
|
|
284
|
+
|
|
320
285
|
/**
|
|
321
286
|
* Return a zoom level that will cover all tiles the transform
|
|
322
287
|
* @param {Object} options options
|
|
@@ -324,14 +289,14 @@ var Transform = /*#__PURE__*/function () {
|
|
|
324
289
|
* @param {boolean} options.roundZoom Target zoom level. If true, the value will be rounded to the closest integer. Otherwise the value will be floored.
|
|
325
290
|
* @returns {number} zoom level An integer zoom level at which all tiles will be visible.
|
|
326
291
|
*/
|
|
327
|
-
|
|
328
292
|
}, {
|
|
329
293
|
key: "coveringZoomLevel",
|
|
330
294
|
value: function coveringZoomLevel(options) {
|
|
331
|
-
var z = (options.roundZoom ? Math.round : Math.floor)(this.zoom + this.scaleZoom(this.tileSize / options.tileSize));
|
|
332
|
-
|
|
295
|
+
var z = (options.roundZoom ? Math.round : Math.floor)(this.zoom + this.scaleZoom(this.tileSize / options.tileSize));
|
|
296
|
+
// At negative zoom levels load tiles from z0 because negative tile zoom levels don't exist.
|
|
333
297
|
return Math.max(0, z);
|
|
334
298
|
}
|
|
299
|
+
|
|
335
300
|
/**
|
|
336
301
|
* Return any "wrapped" copies of a given tile coordinate that are visible
|
|
337
302
|
* in the current view.
|
|
@@ -347,10 +312,12 @@ var Transform = /*#__PURE__*/function () {
|
|
|
347
312
|
// const ubr = this.pointCoordinate(new Point(0, this.height));
|
|
348
313
|
// const w0 = Math.floor(Math.min(utl.x, utr.x, ubl.x, ubr.x));
|
|
349
314
|
// const w1 = Math.floor(Math.max(utl.x, utr.x, ubl.x, ubr.x));
|
|
315
|
+
|
|
350
316
|
// // Add an extra copy of the world on each side to properly render ImageSources and CanvasSources.
|
|
351
317
|
// // Both sources draw outside the tile boundaries of the tile that "contains them" so we need
|
|
352
318
|
// // to add extra copies on both sides in case offscreen tiles need to draw into on-screen ones.
|
|
353
319
|
// const extraWorldCopy = 1;
|
|
320
|
+
|
|
354
321
|
// for (let w = w0 - extraWorldCopy; w <= w1 + extraWorldCopy; w++) {
|
|
355
322
|
// if (w === 0) {
|
|
356
323
|
// continue;
|
|
@@ -384,12 +351,14 @@ var Transform = /*#__PURE__*/function () {
|
|
|
384
351
|
// }): OverscaledTileID[] {
|
|
385
352
|
// let z = this.coveringZoomLevel(options);
|
|
386
353
|
// const actualZ = z;
|
|
354
|
+
|
|
387
355
|
// if (options.minzoom !== undefined && z < options.minzoom) {
|
|
388
356
|
// return [];
|
|
389
357
|
// }
|
|
390
358
|
// if (options.maxzoom !== undefined && z > options.maxzoom) {
|
|
391
359
|
// z = options.maxzoom;
|
|
392
360
|
// }
|
|
361
|
+
|
|
393
362
|
// const centerCoord = MercatorCoordinate.fromLngLat(this.center);
|
|
394
363
|
// const numTiles = Math.pow(2, z);
|
|
395
364
|
// const centerPoint = [numTiles * centerCoord.x, numTiles * centerCoord.y, 0];
|
|
@@ -398,14 +367,17 @@ var Transform = /*#__PURE__*/function () {
|
|
|
398
367
|
// this.worldSize,
|
|
399
368
|
// z,
|
|
400
369
|
// );
|
|
370
|
+
|
|
401
371
|
// // No change of LOD behavior for pitch lower than 60 and when there is no top padding: return only tile ids from the requested zoom level
|
|
402
372
|
// let minZoom = options.minzoom || 0;
|
|
403
373
|
// // Use 0.1 as an epsilon to avoid for explicit == 0.0 floating point checks
|
|
404
374
|
// if (this._pitch <= 60.0 && this.edgeInsets.top < 0.1) {
|
|
405
375
|
// minZoom = z;
|
|
406
376
|
// }
|
|
377
|
+
|
|
407
378
|
// // There should always be a certain number of maximum zoom level tiles surrounding the center location
|
|
408
379
|
// const radiusOfMaxLvlLodInTiles = 3;
|
|
380
|
+
|
|
409
381
|
// const newRootTile = (wrap: number): any => {
|
|
410
382
|
// return {
|
|
411
383
|
// // All tiles are on zero elevation plane => z difference is zero
|
|
@@ -420,11 +392,13 @@ var Transform = /*#__PURE__*/function () {
|
|
|
420
392
|
// fullyVisible: false,
|
|
421
393
|
// };
|
|
422
394
|
// };
|
|
395
|
+
|
|
423
396
|
// // Do a depth-first traversal to find visible tiles and proper levels of detail
|
|
424
397
|
// const stack = [];
|
|
425
398
|
// const result = [];
|
|
426
399
|
// const maxZoom = z;
|
|
427
400
|
// const overscaledZ = options.reparseOverscaled ? actualZ : z;
|
|
401
|
+
|
|
428
402
|
// if (this._renderWorldCopies) {
|
|
429
403
|
// // Render copy of the globe thrice on both sides
|
|
430
404
|
// for (let i = 1; i <= 3; i++) {
|
|
@@ -432,23 +406,30 @@ var Transform = /*#__PURE__*/function () {
|
|
|
432
406
|
// stack.push(newRootTile(i));
|
|
433
407
|
// }
|
|
434
408
|
// }
|
|
409
|
+
|
|
435
410
|
// stack.push(newRootTile(0));
|
|
411
|
+
|
|
436
412
|
// while (stack.length > 0) {
|
|
437
413
|
// const it = stack.pop();
|
|
438
414
|
// const x = it.x;
|
|
439
415
|
// const y = it.y;
|
|
440
416
|
// let fullyVisible = it.fullyVisible;
|
|
417
|
+
|
|
441
418
|
// // Visibility of a tile is not required if any of its ancestor if fully inside the frustum
|
|
442
419
|
// if (!fullyVisible) {
|
|
443
420
|
// const intersectResult = it.aabb.intersects(cameraFrustum);
|
|
421
|
+
|
|
444
422
|
// if (intersectResult === 0) {
|
|
445
423
|
// continue;
|
|
446
424
|
// }
|
|
425
|
+
|
|
447
426
|
// fullyVisible = intersectResult === 2;
|
|
448
427
|
// }
|
|
428
|
+
|
|
449
429
|
// const distanceX = it.aabb.distanceX(centerPoint);
|
|
450
430
|
// const distanceY = it.aabb.distanceY(centerPoint);
|
|
451
431
|
// const longestDim = Math.max(Math.abs(distanceX), Math.abs(distanceY));
|
|
432
|
+
|
|
452
433
|
// // We're using distance based heuristics to determine if a tile should be split into quadrants or not.
|
|
453
434
|
// // radiusOfMaxLvlLodInTiles defines that there's always a certain number of maxLevel tiles next to the map center.
|
|
454
435
|
// // Using the fact that a parent node in quadtree is twice the size of its children (per dimension)
|
|
@@ -456,6 +437,7 @@ var Transform = /*#__PURE__*/function () {
|
|
|
456
437
|
// // f(k) = offset + 2 + 4 + 8 + 16 + ... + 2^k. This is the same as "offset+2^(k+1)-2"
|
|
457
438
|
// const distToSplit =
|
|
458
439
|
// radiusOfMaxLvlLodInTiles + (1 << (maxZoom - it.zoom)) - 2;
|
|
440
|
+
|
|
459
441
|
// // Have we reached the target depth or is the tile too far away to be any split further?
|
|
460
442
|
// if (
|
|
461
443
|
// it.zoom === maxZoom ||
|
|
@@ -476,9 +458,11 @@ var Transform = /*#__PURE__*/function () {
|
|
|
476
458
|
// });
|
|
477
459
|
// continue;
|
|
478
460
|
// }
|
|
461
|
+
|
|
479
462
|
// for (let i = 0; i < 4; i++) {
|
|
480
463
|
// const childX = (x << 1) + (i % 2);
|
|
481
464
|
// const childY = (y << 1) + (i >> 1);
|
|
465
|
+
|
|
482
466
|
// stack.push({
|
|
483
467
|
// aabb: it.aabb.quadrant(i),
|
|
484
468
|
// zoom: it.zoom + 1,
|
|
@@ -489,11 +473,11 @@ var Transform = /*#__PURE__*/function () {
|
|
|
489
473
|
// });
|
|
490
474
|
// }
|
|
491
475
|
// }
|
|
476
|
+
|
|
492
477
|
// return result
|
|
493
478
|
// .sort((a, b) => a.distanceSq - b.distanceSq)
|
|
494
479
|
// .map((a) => a.tileID);
|
|
495
480
|
// }
|
|
496
|
-
|
|
497
481
|
}, {
|
|
498
482
|
key: "resize",
|
|
499
483
|
value: function resize(width, height) {
|
|
@@ -532,7 +516,6 @@ var Transform = /*#__PURE__*/function () {
|
|
|
532
516
|
var loc = this.locationCoordinate(lnglat);
|
|
533
517
|
var newCenter = new _mercator.default(loc.x - (a.x - b.x), loc.y - (a.y - b.y));
|
|
534
518
|
this.center = this.coordinateLocation(newCenter);
|
|
535
|
-
|
|
536
519
|
if (this._renderWorldCopies) {
|
|
537
520
|
this.center = this.center.wrap();
|
|
538
521
|
}
|
|
@@ -540,18 +523,18 @@ var Transform = /*#__PURE__*/function () {
|
|
|
540
523
|
}, {
|
|
541
524
|
key: "pointCoordinate",
|
|
542
525
|
value: function pointCoordinate(p) {
|
|
543
|
-
var targetZ = 0;
|
|
526
|
+
var targetZ = 0;
|
|
527
|
+
// since we don't know the correct projected z value for the point,
|
|
544
528
|
// unproject two points to get a line and then find the point on that
|
|
545
529
|
// line with z=0
|
|
546
530
|
|
|
547
531
|
var coord0 = new Float64Array([p.x, p.y, 0, 1]);
|
|
548
|
-
var coord1 = new Float64Array([p.x, p.y, 1, 1]);
|
|
549
|
-
|
|
550
|
-
_glMatrix.vec4.transformMat4(coord0, coord0, this.pixelMatrixInverse); // @ts-ignore
|
|
551
|
-
|
|
532
|
+
var coord1 = new Float64Array([p.x, p.y, 1, 1]);
|
|
552
533
|
|
|
534
|
+
// @ts-ignore
|
|
535
|
+
_glMatrix.vec4.transformMat4(coord0, coord0, this.pixelMatrixInverse);
|
|
536
|
+
// @ts-ignore
|
|
553
537
|
_glMatrix.vec4.transformMat4(coord1, coord1, this.pixelMatrixInverse);
|
|
554
|
-
|
|
555
538
|
var w0 = coord0[3];
|
|
556
539
|
var w1 = coord1[3];
|
|
557
540
|
var x0 = coord0[0] / w0;
|
|
@@ -563,36 +546,35 @@ var Transform = /*#__PURE__*/function () {
|
|
|
563
546
|
var t = z0 === z1 ? 0 : (targetZ - z0) / (z1 - z0);
|
|
564
547
|
return new _mercator.default((0, _util.interpolate)(x0, x1, t) / this.worldSize, (0, _util.interpolate)(y0, y1, t) / this.worldSize);
|
|
565
548
|
}
|
|
549
|
+
|
|
566
550
|
/**
|
|
567
551
|
* Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not
|
|
568
552
|
* an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.
|
|
569
553
|
* @returns {LngLatBounds} Returns a {@link LngLatBounds} object describing the map's geographical bounds.
|
|
570
554
|
*/
|
|
571
|
-
|
|
572
555
|
}, {
|
|
573
556
|
key: "getBounds",
|
|
574
557
|
value: function getBounds() {
|
|
575
558
|
return new _lng_lat_bounds.default().extend(this.pointLocation(new _point.default(0, 0))).extend(this.pointLocation(new _point.default(this.width, 0))).extend(this.pointLocation(new _point.default(this.width, this.height))).extend(this.pointLocation(new _point.default(0, this.height)));
|
|
576
559
|
}
|
|
560
|
+
|
|
577
561
|
/**
|
|
578
562
|
* Returns the maximum geographical bounds the map is constrained to, or `null` if none set.
|
|
579
563
|
* @returns {LngLatBounds} {@link LngLatBounds}
|
|
580
564
|
*/
|
|
581
|
-
|
|
582
565
|
}, {
|
|
583
566
|
key: "getMaxBounds",
|
|
584
567
|
value: function getMaxBounds() {
|
|
585
568
|
if (!this.latRange || this.latRange.length !== 2 || !this.lngRange || this.lngRange.length !== 2) {
|
|
586
569
|
return null;
|
|
587
570
|
}
|
|
588
|
-
|
|
589
571
|
return new _lng_lat_bounds.default([this.lngRange[0], this.latRange[0]], [this.lngRange[1], this.latRange[1]]);
|
|
590
572
|
}
|
|
573
|
+
|
|
591
574
|
/**
|
|
592
575
|
* Sets or clears the map's geographical constraints.
|
|
593
576
|
* @param {LngLatBounds} bounds A {@link LngLatBounds} object describing the new geographic boundaries of the map.
|
|
594
577
|
*/
|
|
595
|
-
|
|
596
578
|
}, {
|
|
597
579
|
key: "setMaxBounds",
|
|
598
580
|
value: function setMaxBounds(bounds) {
|
|
@@ -617,14 +599,12 @@ var Transform = /*#__PURE__*/function () {
|
|
|
617
599
|
if (!this.pixelMatrixInverse) {
|
|
618
600
|
return 1;
|
|
619
601
|
}
|
|
620
|
-
|
|
621
602
|
var coord = this.pointCoordinate(new _point.default(0, 0));
|
|
622
603
|
var p = new Float32Array([coord.x * this.worldSize, coord.y * this.worldSize, 0, 1]);
|
|
623
|
-
|
|
624
604
|
var topPoint = _glMatrix.vec4.transformMat4(p, p, this.pixelMatrix);
|
|
625
|
-
|
|
626
605
|
return topPoint[3] / this.cameraToCenterDistance;
|
|
627
606
|
}
|
|
607
|
+
|
|
628
608
|
/*
|
|
629
609
|
* The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use `cameraLocation`
|
|
630
610
|
* as the name for the location under the camera and on the surface of the earth (lng, lat, 0).
|
|
@@ -636,7 +616,6 @@ var Transform = /*#__PURE__*/function () {
|
|
|
636
616
|
* When the map is not pitched the `cameraPoint` is equivalent to the center of the map because
|
|
637
617
|
* the camera is right above the center of the map.
|
|
638
618
|
*/
|
|
639
|
-
|
|
640
619
|
}, {
|
|
641
620
|
key: "getCameraPoint",
|
|
642
621
|
value: function getCameraPoint() {
|
|
@@ -644,6 +623,7 @@ var Transform = /*#__PURE__*/function () {
|
|
|
644
623
|
var yOffset = Math.tan(pitch) * (this.cameraToCenterDistance || 1);
|
|
645
624
|
return this.centerPoint.add(new _point.default(0, yOffset));
|
|
646
625
|
}
|
|
626
|
+
|
|
647
627
|
/*
|
|
648
628
|
* When the map is pitched, some of the 3D features that intersect a query will not intersect
|
|
649
629
|
* the query at the surface of the earth. Instead the feature may be closer and only intersect
|
|
@@ -654,12 +634,10 @@ var Transform = /*#__PURE__*/function () {
|
|
|
654
634
|
* - For point queries, the line from the query point to the "camera point"
|
|
655
635
|
* - For other geometries, the envelope of the query geometry and the "camera point"
|
|
656
636
|
*/
|
|
657
|
-
|
|
658
637
|
}, {
|
|
659
638
|
key: "getCameraQueryGeometry",
|
|
660
639
|
value: function getCameraQueryGeometry(queryGeometry) {
|
|
661
640
|
var c = this.getCameraPoint();
|
|
662
|
-
|
|
663
641
|
if (queryGeometry.length === 1) {
|
|
664
642
|
return [queryGeometry[0], c];
|
|
665
643
|
} else {
|
|
@@ -667,10 +645,8 @@ var Transform = /*#__PURE__*/function () {
|
|
|
667
645
|
var minY = c.y;
|
|
668
646
|
var maxX = c.x;
|
|
669
647
|
var maxY = c.y;
|
|
670
|
-
|
|
671
648
|
var _iterator = _createForOfIteratorHelper(queryGeometry),
|
|
672
|
-
|
|
673
|
-
|
|
649
|
+
_step;
|
|
674
650
|
try {
|
|
675
651
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
676
652
|
var p = _step.value;
|
|
@@ -684,24 +660,21 @@ var Transform = /*#__PURE__*/function () {
|
|
|
684
660
|
} finally {
|
|
685
661
|
_iterator.f();
|
|
686
662
|
}
|
|
687
|
-
|
|
688
663
|
return [new _point.default(minX, minY), new _point.default(maxX, minY), new _point.default(maxX, maxY), new _point.default(minX, maxY), new _point.default(minX, minY)];
|
|
689
664
|
}
|
|
690
665
|
}
|
|
666
|
+
|
|
691
667
|
/**
|
|
692
668
|
* Given a coordinate, return the screen point that corresponds to it
|
|
693
669
|
* @param {Coordinate} coord
|
|
694
670
|
* @returns {Point} screen point
|
|
695
671
|
* @private
|
|
696
672
|
*/
|
|
697
|
-
|
|
698
673
|
}, {
|
|
699
674
|
key: "coordinatePoint",
|
|
700
675
|
value: function coordinatePoint(coord) {
|
|
701
676
|
var p = _glMatrix.vec4.fromValues(coord.x * this.worldSize, coord.y * this.worldSize, 0, 1);
|
|
702
|
-
|
|
703
677
|
_glMatrix.vec4.transformMat4(p, p, this.pixelMatrix);
|
|
704
|
-
|
|
705
678
|
return new _point.default(p[0] / p[3], p[1] / p[3]);
|
|
706
679
|
}
|
|
707
680
|
/**
|
|
@@ -710,27 +683,28 @@ var Transform = /*#__PURE__*/function () {
|
|
|
710
683
|
* @returns {Point} screen point
|
|
711
684
|
* @private
|
|
712
685
|
*/
|
|
713
|
-
|
|
714
686
|
}, {
|
|
715
687
|
key: "locationPoint",
|
|
716
688
|
value: function locationPoint(lnglat) {
|
|
717
689
|
return this.coordinatePoint(this.locationCoordinate(lnglat));
|
|
718
690
|
}
|
|
691
|
+
|
|
719
692
|
/**
|
|
720
693
|
* Given a point on screen, return its lnglat
|
|
721
694
|
* @param {Point} p screen point
|
|
722
695
|
* @returns {LngLat} lnglat location
|
|
723
696
|
* @private
|
|
724
697
|
*/
|
|
725
|
-
|
|
726
698
|
}, {
|
|
727
699
|
key: "pointLocation",
|
|
728
700
|
value: function pointLocation(p) {
|
|
729
701
|
// if(p.x !== 0 && p.x !== 1001) {
|
|
730
702
|
// console.log(p.x)
|
|
731
703
|
// }
|
|
704
|
+
|
|
732
705
|
return this.coordinateLocation(this.pointCoordinate(p));
|
|
733
706
|
}
|
|
707
|
+
|
|
734
708
|
/**
|
|
735
709
|
* Given a geographical lnglat, return an unrounded
|
|
736
710
|
* coordinate that represents it at this transform's zoom level.
|
|
@@ -738,19 +712,18 @@ var Transform = /*#__PURE__*/function () {
|
|
|
738
712
|
* @returns {Coordinate}
|
|
739
713
|
* @private
|
|
740
714
|
*/
|
|
741
|
-
|
|
742
715
|
}, {
|
|
743
716
|
key: "locationCoordinate",
|
|
744
717
|
value: function locationCoordinate(lnglat) {
|
|
745
718
|
return _mercator.default.fromLngLat(lnglat);
|
|
746
719
|
}
|
|
720
|
+
|
|
747
721
|
/**
|
|
748
722
|
* Given a Coordinate, return its geographical position.
|
|
749
723
|
* @param {Coordinate} coord
|
|
750
724
|
* @returns {LngLat} lnglat
|
|
751
725
|
* @private
|
|
752
726
|
*/
|
|
753
|
-
|
|
754
727
|
}, {
|
|
755
728
|
key: "coordinateLocation",
|
|
756
729
|
value: function coordinateLocation(coord) {
|
|
@@ -775,10 +748,12 @@ var Transform = /*#__PURE__*/function () {
|
|
|
775
748
|
// if (cache[posMatrixKey]) {
|
|
776
749
|
// return cache[posMatrixKey];
|
|
777
750
|
// }
|
|
751
|
+
|
|
778
752
|
// const canonical = unwrappedTileID.canonical;
|
|
779
753
|
// const scale = this.worldSize / this.zoomScale(canonical.z);
|
|
780
754
|
// const unwrappedX =
|
|
781
755
|
// canonical.x + Math.pow(2, canonical.z) * unwrappedTileID.wrap;
|
|
756
|
+
|
|
782
757
|
// const posMatrix = mat4.identity(new Float64Array(16));
|
|
783
758
|
// mat4.translate(posMatrix, posMatrix, [
|
|
784
759
|
// unwrappedX * scale,
|
|
@@ -791,17 +766,16 @@ var Transform = /*#__PURE__*/function () {
|
|
|
791
766
|
// aligned ? this.alignedProjMatrix : this.projMatrix,
|
|
792
767
|
// posMatrix,
|
|
793
768
|
// );
|
|
769
|
+
|
|
794
770
|
// cache[posMatrixKey] = new Float32Array(posMatrix);
|
|
795
771
|
// return cache[posMatrixKey];
|
|
796
772
|
// }
|
|
797
|
-
|
|
798
773
|
}, {
|
|
799
774
|
key: "constrain",
|
|
800
775
|
value: function constrain() {
|
|
801
776
|
if (!this.center || !this.width || !this.height || this.constraining) {
|
|
802
777
|
return;
|
|
803
778
|
}
|
|
804
|
-
|
|
805
779
|
this.constraining = true;
|
|
806
780
|
var minY = -90;
|
|
807
781
|
var maxY = 90;
|
|
@@ -813,70 +787,58 @@ var Transform = /*#__PURE__*/function () {
|
|
|
813
787
|
var y2;
|
|
814
788
|
var size = this.size;
|
|
815
789
|
var unmodified = this.unmodified;
|
|
816
|
-
|
|
817
790
|
if (this.latRange) {
|
|
818
791
|
var latRange = this.latRange;
|
|
819
792
|
minY = (0, _mercator.mercatorYfromLat)(latRange[1]) * this.worldSize;
|
|
820
793
|
maxY = (0, _mercator.mercatorYfromLat)(latRange[0]) * this.worldSize;
|
|
821
794
|
sy = maxY - minY < size.y ? size.y / (maxY - minY) : 0;
|
|
822
795
|
}
|
|
823
|
-
|
|
824
796
|
if (this.lngRange) {
|
|
825
797
|
var lngRange = this.lngRange;
|
|
826
798
|
minX = (0, _mercator.mercatorXfromLng)(lngRange[0]) * this.worldSize;
|
|
827
799
|
maxX = (0, _mercator.mercatorXfromLng)(lngRange[1]) * this.worldSize;
|
|
828
800
|
sx = maxX - minX < size.x ? size.x / (maxX - minX) : 0;
|
|
829
801
|
}
|
|
802
|
+
var point = this.point;
|
|
830
803
|
|
|
831
|
-
|
|
832
|
-
|
|
804
|
+
// how much the map should scale to fit the screen into given latitude/longitude ranges
|
|
833
805
|
var s = Math.max(sx || 0, sy || 0);
|
|
834
|
-
|
|
835
806
|
if (s) {
|
|
836
807
|
this.center = this.unproject(new _point.default(sx ? (maxX + minX) / 2 : point.x, sy ? (maxY + minY) / 2 : point.y));
|
|
837
|
-
|
|
838
808
|
if (_l7Utils.isMini) {
|
|
839
809
|
this.zoom = Math.max(this.zoom, Math.max(-1, this.minZoom));
|
|
840
810
|
} else {
|
|
841
811
|
this.zoom += this.scaleZoom(s);
|
|
842
812
|
}
|
|
843
|
-
|
|
844
813
|
this.unmodified = unmodified;
|
|
845
814
|
this.constraining = false;
|
|
846
815
|
return;
|
|
847
816
|
}
|
|
848
|
-
|
|
849
817
|
if (this.latRange) {
|
|
850
818
|
var y = point.y;
|
|
851
819
|
var h2 = size.y / 2;
|
|
852
|
-
|
|
853
820
|
if (y - h2 < minY) {
|
|
854
821
|
y2 = minY + h2;
|
|
855
822
|
}
|
|
856
|
-
|
|
857
823
|
if (y + h2 > maxY) {
|
|
858
824
|
y2 = maxY - h2;
|
|
859
825
|
}
|
|
860
826
|
}
|
|
861
|
-
|
|
862
827
|
if (this.lngRange) {
|
|
863
828
|
var x = point.x;
|
|
864
829
|
var w2 = size.x / 2;
|
|
865
|
-
|
|
866
830
|
if (x - w2 < minX) {
|
|
867
831
|
x2 = minX + w2;
|
|
868
832
|
}
|
|
869
|
-
|
|
870
833
|
if (x + w2 > maxX) {
|
|
871
834
|
x2 = maxX - w2;
|
|
872
835
|
}
|
|
873
|
-
}
|
|
874
|
-
|
|
836
|
+
}
|
|
875
837
|
|
|
838
|
+
// pan the map if the screen goes off the range
|
|
876
839
|
if (x2 !== undefined || y2 !== undefined) {
|
|
877
840
|
this.center = this.unproject(new _point.default(x2 !== undefined ? x2 : point.x, y2 !== undefined ? y2 : point.y));
|
|
878
841
|
}
|
|
879
|
-
|
|
880
842
|
this.unmodified = unmodified;
|
|
881
843
|
this.constraining = false;
|
|
882
844
|
}
|
|
@@ -886,122 +848,120 @@ var Transform = /*#__PURE__*/function () {
|
|
|
886
848
|
if (!this.height) {
|
|
887
849
|
return;
|
|
888
850
|
}
|
|
889
|
-
|
|
890
851
|
var halfFov = this._fov / 2;
|
|
891
852
|
var offset = this.centerOffset;
|
|
892
|
-
this.cameraToCenterDistance = 0.5 / Math.tan(halfFov) * this.height;
|
|
853
|
+
this.cameraToCenterDistance = 0.5 / Math.tan(halfFov) * this.height;
|
|
854
|
+
|
|
855
|
+
// Find the distance from the center point [width/2 + offset.x, height/2 + offset.y] to the
|
|
893
856
|
// center top point [width/2 + offset.x, 0] in Z units, using the law of sines.
|
|
894
857
|
// 1 Z unit is equivalent to 1 horizontal px at the center of the map
|
|
895
858
|
// (the distance between[width/2, height/2] and [width/2 + 1, height/2])
|
|
896
|
-
|
|
897
859
|
var groundAngle = Math.PI / 2 + this._pitch;
|
|
898
860
|
var fovAboveCenter = this._fov * (0.5 + offset.y / this.height);
|
|
899
861
|
var topHalfSurfaceDistance = Math.sin(fovAboveCenter) * this.cameraToCenterDistance / Math.sin((0, _util.clamp)(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01));
|
|
900
862
|
var point = this.point;
|
|
901
863
|
var x = point.x;
|
|
902
|
-
var y = point.y;
|
|
864
|
+
var y = point.y;
|
|
903
865
|
|
|
904
|
-
|
|
866
|
+
// Calculate z distance of the farthest fragment that should be rendered.
|
|
867
|
+
var furthestDistance = Math.cos(Math.PI / 2 - this._pitch) * topHalfSurfaceDistance + this.cameraToCenterDistance;
|
|
868
|
+
// Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`
|
|
869
|
+
var farZ = furthestDistance * 1.01;
|
|
905
870
|
|
|
906
|
-
|
|
871
|
+
// The larger the value of nearZ is
|
|
907
872
|
// - the more depth precision is available for features (good)
|
|
908
873
|
// - clipping starts appearing sooner when the camera is close to 3d features (bad)
|
|
909
874
|
//
|
|
910
875
|
// Smaller values worked well for mapbox-gl-js but deckgl was encountering precision issues
|
|
911
876
|
// when rendering it's layers using custom layers. This value was experimentally chosen and
|
|
912
877
|
// seems to solve z-fighting issues in deckgl while not clipping buildings too close to the camera.
|
|
878
|
+
var nearZ = this.height / 50;
|
|
913
879
|
|
|
914
|
-
|
|
880
|
+
// matrix for conversion from location to GL coordinates (-1 .. 1)
|
|
915
881
|
// 使用 Float64Array 的原因是为了避免计算精度问题、 mat4.create() 默认使用 Float32Array
|
|
882
|
+
var m = new Float64Array(16);
|
|
883
|
+
// @ts-ignore
|
|
884
|
+
_glMatrix.mat4.perspective(m, this._fov, this.width / this.height, nearZ, farZ);
|
|
916
885
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
_glMatrix.mat4.perspective(m, this._fov, this.width / this.height, nearZ, farZ); // Apply center of perspective offset
|
|
920
|
-
|
|
921
|
-
|
|
886
|
+
// Apply center of perspective offset
|
|
922
887
|
m[8] = -offset.x * 2 / this.width;
|
|
923
|
-
m[9] = offset.y * 2 / this.height;
|
|
924
|
-
|
|
925
|
-
_glMatrix.mat4.scale(m, m, [1, -1, 1]); // @ts-ignore
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
_glMatrix.mat4.translate(m, m, [0, 0, -this.cameraToCenterDistance]); // @ts-ignore
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
_glMatrix.mat4.rotateX(m, m, this._pitch); // @ts-ignore
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
_glMatrix.mat4.rotateZ(m, m, this.angle); // @ts-ignore
|
|
888
|
+
m[9] = offset.y * 2 / this.height;
|
|
935
889
|
|
|
890
|
+
// @ts-ignore
|
|
891
|
+
_glMatrix.mat4.scale(m, m, [1, -1, 1]);
|
|
892
|
+
// @ts-ignore
|
|
893
|
+
_glMatrix.mat4.translate(m, m, [0, 0, -this.cameraToCenterDistance]);
|
|
894
|
+
// @ts-ignore
|
|
895
|
+
_glMatrix.mat4.rotateX(m, m, this._pitch);
|
|
896
|
+
// @ts-ignore
|
|
897
|
+
_glMatrix.mat4.rotateZ(m, m, this.angle);
|
|
898
|
+
// @ts-ignore
|
|
899
|
+
_glMatrix.mat4.translate(m, m, [-x, -y, 0]);
|
|
936
900
|
|
|
937
|
-
|
|
901
|
+
// The mercatorMatrix can be used to transform points from mercator coordinates
|
|
938
902
|
// ([0, 0] nw, [1, 1] se) to GL coordinates.
|
|
939
903
|
// @ts-ignore
|
|
904
|
+
this.mercatorMatrix = _glMatrix.mat4.scale([], m, [this.worldSize, this.worldSize, this.worldSize]);
|
|
905
|
+
// scale vertically to meters per pixel (inverse of ground resolution):
|
|
940
906
|
|
|
941
|
-
|
|
942
|
-
this.mercatorMatrix = _glMatrix.mat4.scale([], m, [this.worldSize, this.worldSize, this.worldSize]); // scale vertically to meters per pixel (inverse of ground resolution):
|
|
943
907
|
// @ts-ignore
|
|
908
|
+
_glMatrix.mat4.scale(m, m, [1, 1, (0, _mercator.mercatorZfromAltitude)(1, this.center.lat) * this.worldSize, 1]);
|
|
909
|
+
// @ts-ignore
|
|
910
|
+
this.projMatrix = m;
|
|
911
|
+
// @ts-ignore
|
|
912
|
+
this.invProjMatrix = _glMatrix.mat4.invert([], this.projMatrix);
|
|
944
913
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
this.projMatrix = m; // @ts-ignore
|
|
949
|
-
|
|
950
|
-
this.invProjMatrix = _glMatrix.mat4.invert([], this.projMatrix); // Make a second projection matrix that is aligned to a pixel grid for rendering raster tiles.
|
|
914
|
+
// Make a second projection matrix that is aligned to a pixel grid for rendering raster tiles.
|
|
951
915
|
// We're rounding the (floating point) x/y values to achieve to avoid rendering raster images to fractional
|
|
952
916
|
// coordinates. Additionally, we adjust by half a pixel in either direction in case that viewport dimension
|
|
953
917
|
// is an odd integer to preserve rendering to the pixel grid. We're rotating this shift based on the angle
|
|
954
918
|
// of the transformation so that 0°, 90°, 180°, and 270° rasters are crisp, and adjust the shift so that
|
|
955
919
|
// it is always <= 0.5 pixels.
|
|
956
|
-
|
|
957
920
|
var xShift = this.width % 2 / 2;
|
|
958
921
|
var yShift = this.height % 2 / 2;
|
|
959
922
|
var angleCos = Math.cos(this.angle);
|
|
960
923
|
var angleSin = Math.sin(this.angle);
|
|
961
924
|
var dx = x - Math.round(x) + angleCos * xShift + angleSin * yShift;
|
|
962
|
-
var dy = y - Math.round(y) + angleCos * yShift + angleSin * xShift;
|
|
963
|
-
|
|
964
|
-
var alignedM = new Float64Array(m);
|
|
965
|
-
|
|
966
|
-
_glMatrix.mat4.translate(alignedM, alignedM, [dx > 0.5 ? dx - 1 : dx, dy > 0.5 ? dy - 1 : dy, 0]);
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
this.alignedProjMatrix = alignedM; // @ts-ignore
|
|
970
|
-
|
|
971
|
-
m = _glMatrix.mat4.create(); // @ts-ignore
|
|
972
|
-
|
|
973
|
-
_glMatrix.mat4.scale(m, m, [this.width / 2, -this.height / 2, 1]); // @ts-ignore
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
_glMatrix.mat4.translate(m, m, [1, -1, 0]); // @ts-ignore
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
this.labelPlaneMatrix = m; // @ts-ignore
|
|
980
|
-
|
|
981
|
-
m = _glMatrix.mat4.create(); // @ts-ignore
|
|
982
|
-
|
|
983
|
-
_glMatrix.mat4.scale(m, m, [1, -1, 1]); // @ts-ignore
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
_glMatrix.mat4.translate(m, m, [-1, -1, 0]); // @ts-ignore
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
_glMatrix.mat4.scale(m, m, [2 / this.width, 2 / this.height, 1]); // @ts-ignore
|
|
925
|
+
var dy = y - Math.round(y) + angleCos * yShift + angleSin * xShift;
|
|
926
|
+
// const alignedM = mat4.clone(m);
|
|
927
|
+
var alignedM = new Float64Array(m);
|
|
928
|
+
// @ts-ignore
|
|
929
|
+
_glMatrix.mat4.translate(alignedM, alignedM, [dx > 0.5 ? dx - 1 : dx, dy > 0.5 ? dy - 1 : dy, 0]);
|
|
930
|
+
// @ts-ignore
|
|
931
|
+
this.alignedProjMatrix = alignedM;
|
|
990
932
|
|
|
933
|
+
// @ts-ignore
|
|
934
|
+
m = _glMatrix.mat4.create();
|
|
935
|
+
// @ts-ignore
|
|
936
|
+
_glMatrix.mat4.scale(m, m, [this.width / 2, -this.height / 2, 1]);
|
|
937
|
+
// @ts-ignore
|
|
938
|
+
_glMatrix.mat4.translate(m, m, [1, -1, 0]);
|
|
939
|
+
// @ts-ignore
|
|
940
|
+
this.labelPlaneMatrix = m;
|
|
991
941
|
|
|
992
|
-
|
|
942
|
+
// @ts-ignore
|
|
943
|
+
m = _glMatrix.mat4.create();
|
|
944
|
+
// @ts-ignore
|
|
945
|
+
_glMatrix.mat4.scale(m, m, [1, -1, 1]);
|
|
946
|
+
// @ts-ignore
|
|
947
|
+
_glMatrix.mat4.translate(m, m, [-1, -1, 0]);
|
|
948
|
+
// @ts-ignore
|
|
949
|
+
_glMatrix.mat4.scale(m, m, [2 / this.width, 2 / this.height, 1]);
|
|
950
|
+
// @ts-ignore
|
|
951
|
+
this.glCoordMatrix = m;
|
|
993
952
|
|
|
994
|
-
|
|
995
|
-
|
|
953
|
+
// matrix for conversion from location to screen coordinates
|
|
954
|
+
this.pixelMatrix = _glMatrix.mat4.multiply(
|
|
996
955
|
// @ts-ignore
|
|
956
|
+
new Float64Array(16), this.labelPlaneMatrix, this.projMatrix);
|
|
997
957
|
|
|
958
|
+
// inverse matrix for conversion from screen coordinaes to location
|
|
959
|
+
// @ts-ignore
|
|
998
960
|
m = _glMatrix.mat4.invert(new Float64Array(16), this.pixelMatrix);
|
|
999
|
-
|
|
1000
961
|
if (!m) {
|
|
1001
962
|
throw new Error('failed to invert matrix');
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
|
|
963
|
+
}
|
|
964
|
+
// @ts-ignore
|
|
1005
965
|
this.pixelMatrixInverse = m;
|
|
1006
966
|
this.posMatrixCache = {};
|
|
1007
967
|
this.alignedPosMatrixCache = {};
|
|
@@ -1009,5 +969,4 @@ var Transform = /*#__PURE__*/function () {
|
|
|
1009
969
|
}]);
|
|
1010
970
|
return Transform;
|
|
1011
971
|
}();
|
|
1012
|
-
|
|
1013
972
|
exports.default = Transform;
|