@antv/l7-map 2.5.34 → 2.5.37-mini10
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/lib/geo/lng_lat.js +1 -1
- package/lib/geo/mercator.js +11 -7
- package/lib/geo/mercator.js.map +1 -1
- package/lib/geo/simple.js +11 -7
- package/lib/geo/simple.js.map +1 -1
- package/lib/geo/transform.js +6 -2
- package/lib/geo/transform.js.map +1 -1
- package/lib/handler/mouse/index.js +4 -4
- package/lib/handler/mouse/util.js +1 -1
- package/lib/handler/scroll_zoom.js +1 -1
- package/lib/handler/scroll_zoom.js.map +1 -1
- package/lib/handler/tap/single_tap_recognizer.js +1 -1
- package/lib/handler/tap/tap_recognizer.js +6 -2
- package/lib/handler/tap/tap_recognizer.js.map +1 -1
- package/lib/util.js +7 -4
- package/lib/util.js.map +1 -1
- package/package.json +3 -3
- package/LICENSE.md +0 -21
- package/es/camera.d.ts +0 -82
- package/es/camera.js +0 -729
- package/es/camera.js.map +0 -1
- package/es/earthmap.d.ts +0 -67
- package/es/earthmap.js +0 -454
- package/es/earthmap.js.map +0 -1
- package/es/geo/edge_insets.d.ts +0 -54
- package/es/geo/edge_insets.js +0 -88
- package/es/geo/edge_insets.js.map +0 -1
- package/es/geo/lng_lat.d.ts +0 -18
- package/es/geo/lng_lat.js +0 -77
- package/es/geo/lng_lat.js.map +0 -1
- package/es/geo/lng_lat_bounds.d.ts +0 -24
- package/es/geo/lng_lat_bounds.js +0 -170
- package/es/geo/lng_lat_bounds.js.map +0 -1
- package/es/geo/mercator.d.ts +0 -28
- package/es/geo/mercator.js +0 -79
- package/es/geo/mercator.js.map +0 -1
- package/es/geo/point.d.ts +0 -40
- package/es/geo/point.js +0 -237
- package/es/geo/point.js.map +0 -1
- package/es/geo/simple.d.ts +0 -28
- package/es/geo/simple.js +0 -78
- package/es/geo/simple.js.map +0 -1
- package/es/geo/transform.d.ts +0 -198
- package/es/geo/transform.js +0 -663
- package/es/geo/transform.js.map +0 -1
- package/es/handler/IHandler.d.ts +0 -34
- package/es/handler/IHandler.js +0 -2
- package/es/handler/IHandler.js.map +0 -1
- package/es/handler/blockable_map_event.d.ts +0 -17
- package/es/handler/blockable_map_event.js +0 -84
- package/es/handler/blockable_map_event.js.map +0 -1
- package/es/handler/box_zoom.d.ts +0 -59
- package/es/handler/box_zoom.js +0 -184
- package/es/handler/box_zoom.js.map +0 -1
- package/es/handler/click_zoom.d.ts +0 -16
- package/es/handler/click_zoom.js +0 -64
- package/es/handler/click_zoom.js.map +0 -1
- package/es/handler/events/event.d.ts +0 -4
- package/es/handler/events/event.js +0 -14
- package/es/handler/events/event.js.map +0 -1
- package/es/handler/events/index.d.ts +0 -4
- package/es/handler/events/index.js +0 -5
- package/es/handler/events/index.js.map +0 -1
- package/es/handler/events/map_mouse_event.d.ts +0 -34
- package/es/handler/events/map_mouse_event.js +0 -65
- package/es/handler/events/map_mouse_event.js.map +0 -1
- package/es/handler/events/map_touch_event.d.ts +0 -57
- package/es/handler/events/map_touch_event.js +0 -75
- package/es/handler/events/map_touch_event.js.map +0 -1
- package/es/handler/events/map_wheel_event.d.ts +0 -33
- package/es/handler/events/map_wheel_event.js +0 -52
- package/es/handler/events/map_wheel_event.js.map +0 -1
- package/es/handler/events/render_event.d.ts +0 -5
- package/es/handler/events/render_event.js +0 -41
- package/es/handler/events/render_event.js.map +0 -1
- package/es/handler/handler_inertia.d.ts +0 -23
- package/es/handler/handler_inertia.js +0 -186
- package/es/handler/handler_inertia.js.map +0 -1
- package/es/handler/handler_manager.d.ts +0 -57
- package/es/handler/handler_manager.js +0 -655
- package/es/handler/handler_manager.js.map +0 -1
- package/es/handler/handler_util.d.ts +0 -4
- package/es/handler/handler_util.js +0 -10
- package/es/handler/handler_util.js.map +0 -1
- package/es/handler/keyboard.d.ts +0 -36
- package/es/handler/keyboard.js +0 -157
- package/es/handler/keyboard.js.map +0 -1
- package/es/handler/map_event.d.ts +0 -29
- package/es/handler/map_event.js +0 -120
- package/es/handler/map_event.js.map +0 -1
- package/es/handler/mouse/index.d.ts +0 -4
- package/es/handler/mouse/index.js +0 -5
- package/es/handler/mouse/index.js.map +0 -1
- package/es/handler/mouse/mouse_handler.d.ts +0 -22
- package/es/handler/mouse/mouse_handler.js +0 -131
- package/es/handler/mouse/mouse_handler.js.map +0 -1
- package/es/handler/mouse/mousepan_handler.d.ts +0 -10
- package/es/handler/mouse/mousepan_handler.js +0 -54
- package/es/handler/mouse/mousepan_handler.js.map +0 -1
- package/es/handler/mouse/mousepitch_hander.d.ts +0 -9
- package/es/handler/mouse/mousepitch_hander.js +0 -54
- package/es/handler/mouse/mousepitch_hander.js.map +0 -1
- package/es/handler/mouse/mouserotate_hander.d.ts +0 -9
- package/es/handler/mouse/mouserotate_hander.js +0 -54
- package/es/handler/mouse/mouserotate_hander.js.map +0 -1
- package/es/handler/mouse/util.d.ts +0 -6
- package/es/handler/mouse/util.js +0 -12
- package/es/handler/mouse/util.js.map +0 -1
- package/es/handler/scroll_zoom.d.ts +0 -93
- package/es/handler/scroll_zoom.js +0 -317
- package/es/handler/scroll_zoom.js.map +0 -1
- package/es/handler/shim/dblclick_zoom.d.ts +0 -40
- package/es/handler/shim/dblclick_zoom.js +0 -45
- package/es/handler/shim/dblclick_zoom.js.map +0 -1
- package/es/handler/shim/drag_pan.d.ts +0 -61
- package/es/handler/shim/drag_pan.js +0 -53
- package/es/handler/shim/drag_pan.js.map +0 -1
- package/es/handler/shim/drag_rotate.d.ts +0 -46
- package/es/handler/shim/drag_rotate.js +0 -51
- package/es/handler/shim/drag_rotate.js.map +0 -1
- package/es/handler/shim/touch_zoom_rotate.d.ts +0 -70
- package/es/handler/shim/touch_zoom_rotate.js +0 -80
- package/es/handler/shim/touch_zoom_rotate.js.map +0 -1
- package/es/handler/tap/single_tap_recognizer.d.ts +0 -20
- package/es/handler/tap/single_tap_recognizer.js +0 -127
- package/es/handler/tap/single_tap_recognizer.js.map +0 -1
- package/es/handler/tap/tap_drag_zoom.d.ts +0 -22
- package/es/handler/tap/tap_drag_zoom.js +0 -124
- package/es/handler/tap/tap_drag_zoom.js.map +0 -1
- package/es/handler/tap/tap_recognizer.d.ts +0 -17
- package/es/handler/tap/tap_recognizer.js +0 -72
- package/es/handler/tap/tap_recognizer.js.map +0 -1
- package/es/handler/tap/tap_zoom.d.ts +0 -22
- package/es/handler/tap/tap_zoom.js +0 -124
- package/es/handler/tap/tap_zoom.js.map +0 -1
- package/es/handler/touch/index.d.ts +0 -5
- package/es/handler/touch/index.js +0 -6
- package/es/handler/touch/index.js.map +0 -1
- package/es/handler/touch/touch_pan.d.ts +0 -30
- package/es/handler/touch/touch_pan.js +0 -139
- package/es/handler/touch/touch_pan.js.map +0 -1
- package/es/handler/touch/touch_pitch.d.ts +0 -13
- package/es/handler/touch/touch_pitch.js +0 -120
- package/es/handler/touch/touch_pitch.js.map +0 -1
- package/es/handler/touch/touch_rotate.d.ts +0 -12
- package/es/handler/touch/touch_rotate.js +0 -88
- package/es/handler/touch/touch_rotate.js.map +0 -1
- package/es/handler/touch/touch_zoom.d.ts +0 -12
- package/es/handler/touch/touch_zoom.js +0 -79
- package/es/handler/touch/touch_zoom.js.map +0 -1
- package/es/handler/touch/two_touch.d.ts +0 -23
- package/es/handler/touch/two_touch.js +0 -140
- package/es/handler/touch/two_touch.js.map +0 -1
- package/es/hash.d.ts +0 -15
- package/es/hash.js +0 -143
- package/es/hash.js.map +0 -1
- package/es/index.d.ts +0 -2
- package/es/index.js +0 -3
- package/es/index.js.map +0 -1
- package/es/interface.d.ts +0 -31
- package/es/interface.js +0 -2
- package/es/interface.js.map +0 -1
- package/es/map.d.ts +0 -67
- package/es/map.js +0 -454
- package/es/map.js.map +0 -1
- package/es/util.d.ts +0 -18
- package/es/util.js +0 -74
- package/es/util.js.map +0 -1
- package/es/utils/Aabb.d.ts +0 -12
- package/es/utils/Aabb.js +0 -134
- package/es/utils/Aabb.js.map +0 -1
- package/es/utils/dom.d.ts +0 -4
- package/es/utils/dom.js +0 -165
- package/es/utils/dom.js.map +0 -1
- package/es/utils/performance.d.ts +0 -17
- package/es/utils/performance.js +0 -57
- package/es/utils/performance.js.map +0 -1
- package/es/utils/primitives.d.ts +0 -6
- package/es/utils/primitives.js +0 -44
- package/es/utils/primitives.js.map +0 -1
- package/es/utils/task_queue.d.ts +0 -13
- package/es/utils/task_queue.js +0 -113
- package/es/utils/task_queue.js.map +0 -1
package/lib/geo/lng_lat.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.earthRadius = exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
11
|
|
package/lib/geo/mercator.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
+
exports.altitudeFromMercatorZ = altitudeFromMercatorZ;
|
|
11
|
+
exports.default = void 0;
|
|
12
|
+
exports.latFromMercatorY = latFromMercatorY;
|
|
13
|
+
exports.lngFromMercatorX = lngFromMercatorX;
|
|
14
|
+
exports.mercatorScale = mercatorScale;
|
|
10
15
|
exports.mercatorXfromLng = mercatorXfromLng;
|
|
11
16
|
exports.mercatorYfromLat = mercatorYfromLat;
|
|
12
17
|
exports.mercatorZfromAltitude = mercatorZfromAltitude;
|
|
13
|
-
exports.lngFromMercatorX = lngFromMercatorX;
|
|
14
|
-
exports.latFromMercatorY = latFromMercatorY;
|
|
15
|
-
exports.altitudeFromMercatorZ = altitudeFromMercatorZ;
|
|
16
|
-
exports.mercatorScale = mercatorScale;
|
|
17
|
-
exports.default = void 0;
|
|
18
18
|
|
|
19
19
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
20
20
|
|
|
@@ -24,6 +24,10 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
24
24
|
|
|
25
25
|
var _lng_lat = _interopRequireWildcard(require("../geo/lng_lat"));
|
|
26
26
|
|
|
27
|
+
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); }
|
|
28
|
+
|
|
29
|
+
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; }
|
|
30
|
+
|
|
27
31
|
var earthCircumfrence = 2 * Math.PI * _lng_lat.earthRadius;
|
|
28
32
|
|
|
29
33
|
function circumferenceAtLatitude(latitude) {
|
package/lib/geo/mercator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geo/mercator.ts"],"names":["earthCircumfrence","Math","PI","earthRadius","circumferenceAtLatitude","latitude","cos","mercatorXfromLng","lng","mercatorYfromLat","lat","log","tan","mercatorZfromAltitude","altitude","lngFromMercatorX","x","latFromMercatorY","y","y2","atan","exp","altitudeFromMercatorZ","z","mercatorScale","MercatorCoordinate","LngLat","lngLatLike","lngLat","convert"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"sources":["../../src/geo/mercator.ts"],"names":["earthCircumfrence","Math","PI","earthRadius","circumferenceAtLatitude","latitude","cos","mercatorXfromLng","lng","mercatorYfromLat","lat","log","tan","mercatorZfromAltitude","altitude","lngFromMercatorX","x","latFromMercatorY","y","y2","atan","exp","altitudeFromMercatorZ","z","mercatorScale","MercatorCoordinate","LngLat","lngLatLike","lngLat","convert"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAKA,IAAMA,iBAAiB,GAAG,IAAIC,IAAI,CAACC,EAAT,GAAcC,oBAAxC;;AAKA,SAASC,uBAAT,CAAiCC,QAAjC,EAAmD;AACjD,SAAOL,iBAAiB,GAAGC,IAAI,CAACK,GAAL,CAAUD,QAAQ,GAAGJ,IAAI,CAACC,EAAjB,GAAuB,GAAhC,CAA3B;AACD;;AAEM,SAASK,gBAAT,CAA0BC,GAA1B,EAAuC;AAC5C,SAAO,CAAC,MAAMA,GAAP,IAAc,GAArB;AACD;;AAEM,SAASC,gBAAT,CAA0BC,GAA1B,EAAuC;AAC5C,SACE,CAAC,MACE,MAAMT,IAAI,CAACC,EAAZ,GACED,IAAI,CAACU,GAAL,CAASV,IAAI,CAACW,GAAL,CAASX,IAAI,CAACC,EAAL,GAAU,CAAV,GAAeQ,GAAG,GAAGT,IAAI,CAACC,EAAZ,GAAkB,GAAzC,CAAT,CAFJ,IAGA,GAJF;AAMD;;AAEM,SAASW,qBAAT,CAA+BC,QAA/B,EAAiDJ,GAAjD,EAA8D;AACnE,SAAOI,QAAQ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B,CAAC,KAAKC,CAAN,CAAjB,CAA9C;AACD;;;WA9BD,oBAAyBS,UAAzB,EAAuE;AAAA,UAAtBb,QAAsB,uEAAH,CAAG;;AACrE,UAAMc,MAAM,GAAGF,iBAAOG,OAAP,CAAeF,UAAf,CAAf;;AAEA,aAAO,IAAIF,kBAAJ,CACLlB,gBAAgB,CAACqB,MAAM,CAACpB,GAAR,CADX,EAELC,gBAAgB,CAACmB,MAAM,CAAClB,GAAR,CAFX,EAGLG,qBAAqB,CAACC,QAAD,EAAWc,MAAM,CAAClB,GAAlB,CAHhB,CAAP;AAKD","sourcesContent":["import LngLat, { earthRadius, LngLatLike } from '../geo/lng_lat';\n\n/*\n * The average circumference of the world in meters.\n */\nconst earthCircumfrence = 2 * Math.PI * earthRadius; // meters\n\n/*\n * The circumference at a line of latitude in meters.\n */\nfunction circumferenceAtLatitude(latitude: number) {\n return earthCircumfrence * Math.cos((latitude * Math.PI) / 180);\n}\n\nexport function mercatorXfromLng(lng: number) {\n return (180 + lng) / 360;\n}\n\nexport function mercatorYfromLat(lat: number) {\n return (\n (180 -\n (180 / Math.PI) *\n Math.log(Math.tan(Math.PI / 4 + (lat * Math.PI) / 360))) /\n 360\n );\n}\n\nexport function mercatorZfromAltitude(altitude: number, lat: number) {\n return altitude / circumferenceAtLatitude(lat);\n}\n\nexport function lngFromMercatorX(x: number) {\n return x * 360 - 180;\n}\n\nexport function latFromMercatorY(y: number) {\n const y2 = 180 - y * 360;\n return (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;\n}\n\nexport function altitudeFromMercatorZ(z: number, y: number) {\n return z * circumferenceAtLatitude(latFromMercatorY(y));\n}\n\n/**\n * Determine the Mercator scale factor for a given latitude, see\n * https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor\n *\n * At the equator the scale factor will be 1, which increases at higher latitudes.\n *\n * @param {number} lat Latitude\n * @returns {number} scale factor\n * @private\n */\nexport function mercatorScale(lat: number) {\n return 1 / Math.cos((lat * Math.PI) / 180);\n}\n\nexport default class MercatorCoordinate {\n public static fromLngLat(lngLatLike: LngLatLike, altitude: number = 0) {\n const lngLat = LngLat.convert(lngLatLike);\n\n return new MercatorCoordinate(\n mercatorXfromLng(lngLat.lng),\n mercatorYfromLat(lngLat.lat),\n mercatorZfromAltitude(altitude, lngLat.lat),\n );\n }\n public x: number;\n public y: number;\n public z: number;\n\n constructor(x: number, y: number, z: number = 0) {\n this.x = +x;\n this.y = +y;\n this.z = +z;\n }\n\n public toLngLat() {\n return new LngLat(lngFromMercatorX(this.x), latFromMercatorY(this.y));\n }\n\n public toAltitude() {\n return altitudeFromMercatorZ(this.z, this.y);\n }\n\n public meterInMercatorCoordinateUnits() {\n // 1 meter / circumference at equator in meters * Mercator projection scale factor at this latitude\n return (1 / earthCircumfrence) * mercatorScale(latFromMercatorY(this.y));\n }\n}\n"],"file":"mercator.js"}
|
package/lib/geo/simple.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
+
exports.altitudeFromMercatorZ = altitudeFromMercatorZ;
|
|
11
|
+
exports.default = void 0;
|
|
12
|
+
exports.latFromMercatorY = latFromMercatorY;
|
|
13
|
+
exports.lngFromMercatorX = lngFromMercatorX;
|
|
14
|
+
exports.mercatorScale = mercatorScale;
|
|
10
15
|
exports.mercatorXfromLng = mercatorXfromLng;
|
|
11
16
|
exports.mercatorYfromLat = mercatorYfromLat;
|
|
12
17
|
exports.mercatorZfromAltitude = mercatorZfromAltitude;
|
|
13
|
-
exports.lngFromMercatorX = lngFromMercatorX;
|
|
14
|
-
exports.latFromMercatorY = latFromMercatorY;
|
|
15
|
-
exports.altitudeFromMercatorZ = altitudeFromMercatorZ;
|
|
16
|
-
exports.mercatorScale = mercatorScale;
|
|
17
|
-
exports.default = void 0;
|
|
18
18
|
|
|
19
19
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
20
20
|
|
|
@@ -24,6 +24,10 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
24
24
|
|
|
25
25
|
var _lng_lat = _interopRequireWildcard(require("../geo/lng_lat"));
|
|
26
26
|
|
|
27
|
+
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); }
|
|
28
|
+
|
|
29
|
+
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; }
|
|
30
|
+
|
|
27
31
|
var earthCircumfrence = 2 * Math.PI * _lng_lat.earthRadius;
|
|
28
32
|
|
|
29
33
|
function circumferenceAtLatitude(latitude) {
|
package/lib/geo/simple.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geo/simple.ts"],"names":["earthCircumfrence","Math","PI","earthRadius","circumferenceAtLatitude","latitude","cos","mercatorXfromLng","lng","mercatorYfromLat","lat","mercatorZfromAltitude","altitude","lngFromMercatorX","x","latFromMercatorY","y","altitudeFromMercatorZ","z","mercatorScale","SimpleCoordinate","LngLat","lngLatLike","lngLat","convert"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"sources":["../../src/geo/simple.ts"],"names":["earthCircumfrence","Math","PI","earthRadius","circumferenceAtLatitude","latitude","cos","mercatorXfromLng","lng","mercatorYfromLat","lat","mercatorZfromAltitude","altitude","lngFromMercatorX","x","latFromMercatorY","y","altitudeFromMercatorZ","z","mercatorScale","SimpleCoordinate","LngLat","lngLatLike","lngLat","convert"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;AAKA,IAAMA,iBAAiB,GAAG,IAAIC,IAAI,CAACC,EAAT,GAAcC,oBAAxC;;AAKA,SAASC,uBAAT,CAAiCC,QAAjC,EAAmD;AACjD,SAAOL,iBAAiB,GAAGC,IAAI,CAACK,GAAL,CAAUD,QAAQ,GAAGJ,IAAI,CAACC,EAAjB,GAAuB,GAAhC,CAA3B;AACD;;AAEM,SAASK,gBAAT,CAA0BC,GAA1B,EAAuC;AAC5C,SAAOA,GAAP;AACD;;AAEM,SAASC,gBAAT,CAA0BC,GAA1B,EAAuC;AAC5C,SAAOA,GAAP;AACD;;AAEM,SAASC,qBAAT,CAA+BC,QAA/B,EAAiDF,GAAjD,EAA8D;AACnE,SAAOE,QAAP;AACD;;AAEM,SAASC,gBAAT,CAA0BC,CAA1B,EAAqC;AAC1C,SAAOA,CAAP;AACD;;AAEM,SAASC,gBAAT,CAA0BC,CAA1B,EAAqC;AAC1C,SAAOA,CAAP;AACD;;AAEM,SAASC,qBAAT,CAA+BC,CAA/B,EAA0CF,CAA1C,EAAqD;AAC1D,SAAOE,CAAP;AACD;;AAYM,SAASC,aAAT,CAAuBT,GAAvB,EAAoC;AACzC,SAAO,CAAP;AACD;;IAEoBU,gB;AAcnB,4BAAYN,CAAZ,EAAuBE,CAAvB,EAAiD;AAAA,QAAfE,CAAe,uEAAH,CAAG;AAAA;AAAA;AAAA;AAAA;AAC/C,SAAKJ,CAAL,GAAS,CAACA,CAAV;AACA,SAAKE,CAAL,GAAS,CAACA,CAAV;AACA,SAAKE,CAAL,GAAS,CAACA,CAAV;AACD;;;;WACD,oBAAkB;AAChB,aAAO,IAAIG,gBAAJ,CAAW,KAAKP,CAAhB,EAAmB,KAAKE,CAAxB,CAAP;AACD;;;WAED,sBAAoB;AAClB,aAAO,KAAKE,CAAZ;AACD;;;WAED,0CAAwC;AAEtC,aAAO,CAAP;AACD;;;WA7BD,oBAAyBI,UAAzB,EAAuE;AAAA,UAAtBV,QAAsB,uEAAH,CAAG;;AACrE,UAAMW,MAAM,GAAGF,iBAAOG,OAAP,CAAeF,UAAf,CAAf;;AAEA,aAAO,IAAIF,gBAAJ,CACLb,gBAAgB,CAACgB,MAAM,CAACf,GAAR,CADX,EAELC,gBAAgB,CAACc,MAAM,CAACb,GAAR,CAFX,EAGLC,qBAAqB,CAACC,QAAD,EAAWW,MAAM,CAACb,GAAlB,CAHhB,CAAP;AAKD","sourcesContent":["import LngLat, { earthRadius, LngLatLike } from '../geo/lng_lat';\n\n/*\n * The average circumference of the world in meters.\n */\nconst earthCircumfrence = 2 * Math.PI * earthRadius; // meters\n\n/*\n * The circumference at a line of latitude in meters.\n */\nfunction circumferenceAtLatitude(latitude: number) {\n return earthCircumfrence * Math.cos((latitude * Math.PI) / 180);\n}\n\nexport function mercatorXfromLng(lng: number) {\n return lng;\n}\n\nexport function mercatorYfromLat(lat: number) {\n return lat;\n}\n\nexport function mercatorZfromAltitude(altitude: number, lat: number) {\n return altitude;\n}\n\nexport function lngFromMercatorX(x: number) {\n return x;\n}\n\nexport function latFromMercatorY(y: number) {\n return y;\n}\n\nexport function altitudeFromMercatorZ(z: number, y: number) {\n return z;\n}\n\n/**\n * Determine the Mercator scale factor for a given latitude, see\n * https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor\n *\n * At the equator the scale factor will be 1, which increases at higher latitudes.\n *\n * @param {number} lat Latitude\n * @returns {number} scale factor\n * @private\n */\nexport function mercatorScale(lat: number) {\n return 1;\n}\n\nexport default class SimpleCoordinate {\n public static fromLngLat(lngLatLike: LngLatLike, altitude: number = 0) {\n const lngLat = LngLat.convert(lngLatLike);\n\n return new SimpleCoordinate(\n mercatorXfromLng(lngLat.lng),\n mercatorYfromLat(lngLat.lat),\n mercatorZfromAltitude(altitude, lngLat.lat),\n );\n }\n public x: number;\n public y: number;\n public z: number;\n\n constructor(x: number, y: number, z: number = 0) {\n this.x = +x;\n this.y = +y;\n this.z = +z;\n }\n public toLngLat() {\n return new LngLat(this.x, this.y);\n }\n\n public toAltitude() {\n return this.z;\n }\n\n public meterInMercatorCoordinateUnits() {\n // 1 meter / circumference at equator in meters * Mercator projection scale factor at this latitude\n return 1;\n }\n}\n"],"file":"simple.js"}
|
package/lib/geo/transform.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
@@ -29,6 +29,10 @@ var _lng_lat_bounds = _interopRequireDefault(require("./lng_lat_bounds"));
|
|
|
29
29
|
|
|
30
30
|
var _mercator = _interopRequireWildcard(require("./mercator"));
|
|
31
31
|
|
|
32
|
+
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
|
+
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
|
+
|
|
32
36
|
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; } } }; }
|
|
33
37
|
|
|
34
38
|
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); }
|
package/lib/geo/transform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/geo/transform.ts"],"names":["EXTENT","Transform","minZoom","maxZoom","minPitch","maxPitch","renderWorldCopies","tileSize","maxValidLatitude","_renderWorldCopies","undefined","_minZoom","_maxZoom","_minPitch","_maxPitch","setMaxBounds","width","height","_center","LngLat","zoom","angle","_fov","_pitch","unmodified","edgeInsets","EdgeInsets","posMatrixCache","alignedPosMatrixCache","Math","max","min","pitch","scale","centerPoint","_sub","size","_div","Point","PI","bearing","b","calcMatrices","rotationMatrix","mat2","create","rotate","p","fov","_zoom","z","zoomScale","tileZoom","floor","zoomFraction","constrain","center","lat","lng","toJSON","padding","equals","interpolate","getCenter","project","clone","latRange","start","target","t","options","roundZoom","round","scaleZoom","pixelsToGLUnits","pow","log","LN2","lnglat","worldSize","point","MercatorCoordinate","x","y","toLngLat","a","pointCoordinate","loc","locationCoordinate","newCenter","coordinateLocation","wrap","targetZ","coord0","Float32Array","coord1","vec4","transformMat4","pixelMatrixInverse","w0","w1","x0","x1","y0","y1","z0","z1","LngLatBounds","extend","pointLocation","length","lngRange","bounds","getWest","getEast","getSouth","getNorth","mercatorMatrix","slice","coord","topPoint","pixelMatrix","cameraToCenterDistance","yOffset","tan","add","queryGeometry","c","getCameraPoint","minX","minY","maxX","maxY","fromValues","coordinatePoint","fromLngLat","projMatrix","constraining","sy","sx","x2","y2","s","unproject","h2","w2","halfFov","offset","centerOffset","groundAngle","fovAboveCenter","topHalfSurfaceDistance","sin","furthestDistance","cos","farZ","nearZ","m","mat4","perspective","translate","rotateX","rotateZ","vec3","invProjMatrix","invert","xShift","yShift","angleCos","angleSin","dx","dy","alignedM","alignedProjMatrix","labelPlaneMatrix","glCoordMatrix","multiply","Error"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AAC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AL,CAAW4H,CAAX,EAAcA,CAAd,EAAiB,CAAC,CAAD,EAAI,CAAC,CAAL,EAAQ,CAAR,CAAjB;;AACAC,qBAAKE,SAAL,CAAeH,CAAf,EAAkBA,CAAlB,EAAqB,CAAC,CAAC,CAAF,EAAK,CAAC,CAAN,EAAS,CAAT,CAArB;;AACAC,qBAAK7H,KAAL,CAAW4H,CAAX,EAAcA,CAAd,EAAiB,CAAC,IAAI,KAAK7I,KAAV,EAAiB,IAAI,KAAKC,MAA1B,EAAkC,CAAlC,CAAjB;;AACA,WAAK8J,aAAL,GAAqBlB,CAArB;AAGA,WAAKpC,WAAL,GAAmBqC,eAAKkB,QAAL,CACjBlB,eAAKjH,MAAL,EADiB,EAEjB,KAAKiI,gBAFY,EAGjB,KAAKtC,UAHY,CAAnB;AAOAqB,MAAAA,CAAC,GAAGC,eAAKO,MAAL,CAAYP,eAAKjH,MAAL,EAAZ,EAA2B,KAAK4E,WAAhC,CAAJ;;AACA,UAAI,CAACoC,CAAL,EAAQ;AACN,cAAM,IAAIoB,KAAJ,CAAU,yBAAV,CAAN;AACD;;AACD,WAAK/E,kBAAL,GAA0B2D,CAA1B;AAEA,WAAKlI,cAAL,GAAsB,EAAtB;AACA,WAAKC,qBAAL,GAA6B,EAA7B;AACD","sourcesContent":["// @ts-ignore\nimport { mat2, mat4, vec3, vec4 } from 'gl-matrix';\nimport Point, { PointLike } from '../geo/point';\nimport { clamp, interpolate, wrap } from '../util';\nimport Aabb from '../utils/Aabb';\nimport Frustum from '../utils/primitives';\nimport EdgeInsets, { IPaddingOptions } from './edge_insets';\nimport LngLat from './lng_lat';\nimport LngLatBounds from './lng_lat_bounds';\nimport MercatorCoordinate, {\n mercatorXfromLng,\n mercatorYfromLat,\n mercatorZfromAltitude,\n} from './mercator';\nexport const EXTENT = 8192;\nexport default class Transform {\n get minZoom(): number {\n return this._minZoom;\n }\n set minZoom(zoom: number) {\n if (this._minZoom === zoom) {\n return;\n }\n this._minZoom = zoom;\n this.zoom = Math.max(this.zoom, zoom);\n }\n\n get maxZoom(): number {\n return this._maxZoom;\n }\n set maxZoom(zoom: number) {\n if (this._maxZoom === zoom) {\n return;\n }\n this._maxZoom = zoom;\n this.zoom = Math.min(this.zoom, zoom);\n }\n\n get minPitch(): number {\n return this._minPitch;\n }\n set minPitch(pitch: number) {\n if (this._minPitch === pitch) {\n return;\n }\n this._minPitch = pitch;\n this._pitch = Math.max(this._pitch, pitch);\n }\n\n get maxPitch(): number {\n return this._maxPitch;\n }\n set maxPitch(pitch: number) {\n if (this._maxPitch === pitch) {\n return;\n }\n this._maxPitch = pitch;\n this._pitch = Math.min(this._pitch, pitch);\n }\n\n get renderWorldCopies(): boolean {\n return this._renderWorldCopies;\n }\n set renderWorldCopies(renderWorldCopies: boolean) {\n if (renderWorldCopies === undefined) {\n renderWorldCopies = true;\n } else if (renderWorldCopies === null) {\n renderWorldCopies = false;\n }\n\n this._renderWorldCopies = renderWorldCopies;\n }\n\n get worldSize(): number {\n return this.tileSize * this.scale;\n }\n\n get centerOffset(): Point {\n return this.centerPoint._sub(this.size._div(2));\n }\n\n get size(): Point {\n return new Point(this.width, this.height);\n }\n\n get bearing(): number {\n return (-this.angle / Math.PI) * 180;\n }\n set bearing(bearing: number) {\n const b = (-wrap(bearing, -180, 180) * Math.PI) / 180;\n if (this.angle === b) {\n return;\n }\n this.unmodified = false;\n this.angle = b;\n this.calcMatrices();\n\n // 2x2 matrix for rotating points\n this.rotationMatrix = mat2.create();\n mat2.rotate(this.rotationMatrix, this.rotationMatrix, this.angle);\n }\n\n get pitch(): number {\n return (this._pitch / Math.PI) * 180;\n }\n set pitch(pitch: number) {\n const p = (clamp(pitch, this._minPitch, this._maxPitch) / 180) * Math.PI;\n if (this._pitch === p) {\n return;\n }\n this.unmodified = false;\n this._pitch = p;\n this.calcMatrices();\n }\n\n get fov(): number {\n return (this._fov / Math.PI) * 180;\n }\n\n set fov(fov: number) {\n fov = Math.max(0.01, Math.min(60, fov));\n if (this._fov === fov) {\n return;\n }\n this.unmodified = false;\n this._fov = (fov / 180) * Math.PI;\n this.calcMatrices();\n }\n\n get zoom(): number {\n return this._zoom;\n }\n\n set zoom(zoom: number) {\n const z = Math.min(Math.max(zoom, this._minZoom), this._maxZoom);\n if (this._zoom === z) {\n return;\n }\n this.unmodified = false;\n this._zoom = z;\n this.scale = this.zoomScale(z);\n this.tileZoom = Math.floor(z);\n this.zoomFraction = z - this.tileZoom;\n this.constrain();\n this.calcMatrices();\n }\n\n get center(): LngLat {\n return this._center;\n }\n\n set center(center: LngLat) {\n if (center.lat === this._center.lat && center.lng === this._center.lng) {\n return;\n }\n this.unmodified = false;\n this._center = center;\n this.constrain();\n this.calcMatrices();\n }\n\n get padding(): IPaddingOptions {\n return this.edgeInsets.toJSON();\n }\n\n set padding(padding: IPaddingOptions) {\n if (this.edgeInsets.equals(padding)) {\n return;\n }\n this.unmodified = false;\n // Update edge-insets inplace\n this.edgeInsets.interpolate(this.edgeInsets, padding, 1);\n this.calcMatrices();\n }\n\n /**\n * The center of the screen in pixels with the top-left corner being (0,0)\n * and +y axis pointing downwards. This accounts for padding.\n *\n * @readonly\n * @type {Point}\n * @memberof Transform\n */\n get centerPoint(): Point {\n return this.edgeInsets.getCenter(this.width, this.height);\n }\n\n get point(): Point {\n return this.project(this.center);\n }\n public tileSize: number;\n public tileZoom: number;\n public lngRange?: [number, number];\n public latRange?: [number, number];\n public maxValidLatitude: number;\n public scale: number;\n public width: number;\n public height: number;\n public angle: number;\n public rotationMatrix: mat2;\n public pixelsToGLUnits: [number, number];\n public cameraToCenterDistance: number;\n public mercatorMatrix: mat4;\n public projMatrix: mat4;\n public invProjMatrix: mat4;\n public alignedProjMatrix: mat4;\n public pixelMatrix: mat4;\n public pixelMatrixInverse: mat4;\n public glCoordMatrix: mat4;\n public labelPlaneMatrix: mat4;\n // tslint:disable:variable-name\n private _fov: number;\n private _pitch: number;\n private _zoom: number;\n private _renderWorldCopies: boolean;\n private _minZoom: number;\n private _maxZoom: number;\n private _minPitch: number;\n private _maxPitch: number;\n private _center: LngLat;\n // tslint:enable\n private zoomFraction: number;\n private unmodified: boolean;\n private edgeInsets: EdgeInsets;\n private constraining: boolean;\n private posMatrixCache: { [_: string]: Float32Array };\n private alignedPosMatrixCache: { [_: string]: Float32Array };\n constructor(\n minZoom: number,\n maxZoom: number,\n minPitch: number,\n maxPitch: number,\n renderWorldCopies: boolean | void,\n ) {\n this.tileSize = 512; // constant\n this.maxValidLatitude = 85.051129; // constant\n\n this._renderWorldCopies = (renderWorldCopies === undefined\n ? true\n : renderWorldCopies) as boolean;\n this._minZoom = minZoom || 0;\n this._maxZoom = maxZoom || 22;\n\n this._minPitch = minPitch === undefined || minPitch === null ? 0 : minPitch;\n this._maxPitch =\n maxPitch === undefined || maxPitch === null ? 60 : maxPitch;\n\n this.setMaxBounds();\n\n this.width = 0;\n this.height = 0;\n this._center = new LngLat(0, 0);\n this.zoom = 0;\n this.angle = 0;\n this._fov = 0.6435011087932844;\n this._pitch = 0;\n this.unmodified = true;\n this.edgeInsets = new EdgeInsets();\n this.posMatrixCache = {};\n this.alignedPosMatrixCache = {};\n }\n\n public clone(): Transform {\n const clone = new Transform(\n this._minZoom,\n this._maxZoom,\n this._minPitch,\n this._maxPitch,\n this._renderWorldCopies,\n );\n clone.tileSize = this.tileSize;\n clone.latRange = this.latRange;\n clone.width = this.width;\n clone.height = this.height;\n clone.center = this._center;\n clone.zoom = this.zoom;\n clone.angle = this.angle;\n clone.fov = this._fov;\n clone.pitch = this._pitch;\n clone.unmodified = this.unmodified;\n clone.edgeInsets = this.edgeInsets.clone();\n clone.calcMatrices();\n return clone;\n }\n\n /**\n * Returns if the padding params match\n *\n * @param {IPaddingOptions} padding\n * @returns {boolean}\n * @memberof Transform\n */\n public isPaddingEqual(padding: IPaddingOptions): boolean {\n return this.edgeInsets.equals(padding);\n }\n\n /**\n * Helper method to upadte edge-insets inplace\n *\n * @param {IPaddingOptions} target\n * @param {number} t\n * @memberof Transform\n */\n public interpolatePadding(\n start: IPaddingOptions,\n target: IPaddingOptions,\n t: number,\n ) {\n this.unmodified = false;\n this.edgeInsets.interpolate(start, target, t);\n this.constrain();\n this.calcMatrices();\n }\n\n /**\n * Return a zoom level that will cover all tiles the transform\n * @param {Object} options options\n * @param {number} options.tileSize Tile size, expressed in screen pixels.\n * @param {boolean} options.roundZoom Target zoom level. If true, the value will be rounded to the closest integer. Otherwise the value will be floored.\n * @returns {number} zoom level An integer zoom level at which all tiles will be visible.\n */\n public coveringZoomLevel(options: { roundZoom?: boolean; tileSize: number }) {\n const z = (options.roundZoom ? Math.round : Math.floor)(\n this.zoom + this.scaleZoom(this.tileSize / options.tileSize),\n );\n // At negative zoom levels load tiles from z0 because negative tile zoom levels don't exist.\n return Math.max(0, z);\n }\n\n /**\n * Return any \"wrapped\" copies of a given tile coordinate that are visible\n * in the current view.\n *\n * @private\n */\n // public getVisibleUnwrappedCoordinates(tileID: CanonicalTileID) {\n // const result = [new UnwrappedTileID(0, tileID)];\n // if (this._renderWorldCopies) {\n // const utl = this.pointCoordinate(new Point(0, 0));\n // const utr = this.pointCoordinate(new Point(this.width, 0));\n // const ubl = this.pointCoordinate(new Point(this.width, this.height));\n // const ubr = this.pointCoordinate(new Point(0, this.height));\n // const w0 = Math.floor(Math.min(utl.x, utr.x, ubl.x, ubr.x));\n // const w1 = Math.floor(Math.max(utl.x, utr.x, ubl.x, ubr.x));\n\n // // Add an extra copy of the world on each side to properly render ImageSources and CanvasSources.\n // // Both sources draw outside the tile boundaries of the tile that \"contains them\" so we need\n // // to add extra copies on both sides in case offscreen tiles need to draw into on-screen ones.\n // const extraWorldCopy = 1;\n\n // for (let w = w0 - extraWorldCopy; w <= w1 + extraWorldCopy; w++) {\n // if (w === 0) {\n // continue;\n // }\n // result.push(new UnwrappedTileID(w, tileID));\n // }\n // }\n // return result;\n // }\n\n /**\n * Return all coordinates that could cover this transform for a covering\n * zoom level.\n * @param {Object} options\n * @param {number} options.tileSize\n * @param {number} options.minzoom\n * @param {number} options.maxzoom\n * @param {boolean} options.roundZoom\n * @param {boolean} options.reparseOverscaled\n * @param {boolean} options.renderWorldCopies\n * @returns {Array<OverscaledTileID>} OverscaledTileIDs\n * @private\n */\n // public coveringTiles(options: {\n // tileSize: number;\n // minzoom?: number;\n // maxzoom?: number;\n // roundZoom?: boolean;\n // reparseOverscaled?: boolean;\n // renderWorldCopies?: boolean;\n // }): OverscaledTileID[] {\n // let z = this.coveringZoomLevel(options);\n // const actualZ = z;\n\n // if (options.minzoom !== undefined && z < options.minzoom) {\n // return [];\n // }\n // if (options.maxzoom !== undefined && z > options.maxzoom) {\n // z = options.maxzoom;\n // }\n\n // const centerCoord = MercatorCoordinate.fromLngLat(this.center);\n // const numTiles = Math.pow(2, z);\n // const centerPoint = [numTiles * centerCoord.x, numTiles * centerCoord.y, 0];\n // const cameraFrustum = Frustum.fromInvProjectionMatrix(\n // this.invProjMatrix,\n // this.worldSize,\n // z,\n // );\n\n // // 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\n // let minZoom = options.minzoom || 0;\n // // Use 0.1 as an epsilon to avoid for explicit == 0.0 floating point checks\n // if (this._pitch <= 60.0 && this.edgeInsets.top < 0.1) {\n // minZoom = z;\n // }\n\n // // There should always be a certain number of maximum zoom level tiles surrounding the center location\n // const radiusOfMaxLvlLodInTiles = 3;\n\n // const newRootTile = (wrap: number): any => {\n // return {\n // // All tiles are on zero elevation plane => z difference is zero\n // aabb: new Aabb(\n // [wrap * numTiles, 0, 0],\n // [(wrap + 1) * numTiles, numTiles, 0],\n // ),\n // zoom: 0,\n // x: 0,\n // y: 0,\n // wrap,\n // fullyVisible: false,\n // };\n // };\n\n // // Do a depth-first traversal to find visible tiles and proper levels of detail\n // const stack = [];\n // const result = [];\n // const maxZoom = z;\n // const overscaledZ = options.reparseOverscaled ? actualZ : z;\n\n // if (this._renderWorldCopies) {\n // // Render copy of the globe thrice on both sides\n // for (let i = 1; i <= 3; i++) {\n // stack.push(newRootTile(-i));\n // stack.push(newRootTile(i));\n // }\n // }\n\n // stack.push(newRootTile(0));\n\n // while (stack.length > 0) {\n // const it = stack.pop();\n // const x = it.x;\n // const y = it.y;\n // let fullyVisible = it.fullyVisible;\n\n // // Visibility of a tile is not required if any of its ancestor if fully inside the frustum\n // if (!fullyVisible) {\n // const intersectResult = it.aabb.intersects(cameraFrustum);\n\n // if (intersectResult === 0) {\n // continue;\n // }\n\n // fullyVisible = intersectResult === 2;\n // }\n\n // const distanceX = it.aabb.distanceX(centerPoint);\n // const distanceY = it.aabb.distanceY(centerPoint);\n // const longestDim = Math.max(Math.abs(distanceX), Math.abs(distanceY));\n\n // // We're using distance based heuristics to determine if a tile should be split into quadrants or not.\n // // radiusOfMaxLvlLodInTiles defines that there's always a certain number of maxLevel tiles next to the map center.\n // // Using the fact that a parent node in quadtree is twice the size of its children (per dimension)\n // // we can define distance thresholds for each relative level:\n // // f(k) = offset + 2 + 4 + 8 + 16 + ... + 2^k. This is the same as \"offset+2^(k+1)-2\"\n // const distToSplit =\n // radiusOfMaxLvlLodInTiles + (1 << (maxZoom - it.zoom)) - 2;\n\n // // Have we reached the target depth or is the tile too far away to be any split further?\n // if (\n // it.zoom === maxZoom ||\n // (longestDim > distToSplit && it.zoom >= minZoom)\n // ) {\n // result.push({\n // tileID: new OverscaledTileID(\n // it.zoom === maxZoom ? overscaledZ : it.zoom,\n // it.wrap,\n // it.zoom,\n // x,\n // y,\n // ),\n // distanceSq: vec2.sqrLen([\n // centerPoint[0] - 0.5 - x,\n // centerPoint[1] - 0.5 - y,\n // ]),\n // });\n // continue;\n // }\n\n // for (let i = 0; i < 4; i++) {\n // const childX = (x << 1) + (i % 2);\n // const childY = (y << 1) + (i >> 1);\n\n // stack.push({\n // aabb: it.aabb.quadrant(i),\n // zoom: it.zoom + 1,\n // x: childX,\n // y: childY,\n // wrap: it.wrap,\n // fullyVisible,\n // });\n // }\n // }\n\n // return result\n // .sort((a, b) => a.distanceSq - b.distanceSq)\n // .map((a) => a.tileID);\n // }\n\n public resize(width: number, height: number) {\n this.width = width;\n this.height = height;\n\n this.pixelsToGLUnits = [2 / width, -2 / height];\n this.constrain();\n this.calcMatrices();\n }\n\n public zoomScale(zoom: number) {\n return Math.pow(2, zoom);\n }\n public scaleZoom(scale: number) {\n return Math.log(scale) / Math.LN2;\n }\n\n public project(lnglat: LngLat) {\n const lat = clamp(\n lnglat.lat,\n -this.maxValidLatitude,\n this.maxValidLatitude,\n );\n return new Point(\n mercatorXfromLng(lnglat.lng) * this.worldSize,\n mercatorYfromLat(lat) * this.worldSize,\n );\n }\n\n public unproject(point: Point): LngLat {\n return new MercatorCoordinate(\n point.x / this.worldSize,\n point.y / this.worldSize,\n ).toLngLat();\n }\n\n public setLocationAtPoint(lnglat: LngLat, point: Point) {\n const a = this.pointCoordinate(point);\n const b = this.pointCoordinate(this.centerPoint);\n const loc = this.locationCoordinate(lnglat);\n const newCenter = new MercatorCoordinate(\n loc.x - (a.x - b.x),\n loc.y - (a.y - b.y),\n );\n this.center = this.coordinateLocation(newCenter);\n if (this._renderWorldCopies) {\n this.center = this.center.wrap();\n }\n }\n\n public pointCoordinate(p: Point) {\n const targetZ = 0;\n // since we don't know the correct projected z value for the point,\n // unproject two points to get a line and then find the point on that\n // line with z=0\n\n const coord0 = new Float32Array([p.x, p.y, 0, 1]);\n const coord1 = new Float32Array([p.x, p.y, 1, 1]);\n\n vec4.transformMat4(coord0, coord0, this.pixelMatrixInverse);\n vec4.transformMat4(coord1, coord1, this.pixelMatrixInverse);\n\n const w0 = coord0[3];\n const w1 = coord1[3];\n const x0 = coord0[0] / w0;\n const x1 = coord1[0] / w1;\n const y0 = coord0[1] / w0;\n const y1 = coord1[1] / w1;\n const z0 = coord0[2] / w0;\n const z1 = coord1[2] / w1;\n\n const t = z0 === z1 ? 0 : (targetZ - z0) / (z1 - z0);\n\n return new MercatorCoordinate(\n interpolate(x0, x1, t) / this.worldSize,\n interpolate(y0, y1, t) / this.worldSize,\n );\n }\n\n /**\n * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not\n * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.\n * @returns {LngLatBounds} Returns a {@link LngLatBounds} object describing the map's geographical bounds.\n */\n public getBounds(): LngLatBounds {\n return new LngLatBounds()\n .extend(this.pointLocation(new Point(0, 0)))\n .extend(this.pointLocation(new Point(this.width, 0)))\n .extend(this.pointLocation(new Point(this.width, this.height)))\n .extend(this.pointLocation(new Point(0, this.height)));\n }\n\n /**\n * Returns the maximum geographical bounds the map is constrained to, or `null` if none set.\n * @returns {LngLatBounds} {@link LngLatBounds}\n */\n public getMaxBounds(): LngLatBounds | null {\n if (\n !this.latRange ||\n this.latRange.length !== 2 ||\n !this.lngRange ||\n this.lngRange.length !== 2\n ) {\n return null;\n }\n\n return new LngLatBounds(\n [this.lngRange[0], this.latRange[0]],\n [this.lngRange[1], this.latRange[1]],\n );\n }\n\n /**\n * Sets or clears the map's geographical constraints.\n * @param {LngLatBounds} bounds A {@link LngLatBounds} object describing the new geographic boundaries of the map.\n */\n public setMaxBounds(bounds?: LngLatBounds) {\n if (bounds) {\n this.lngRange = [bounds.getWest(), bounds.getEast()];\n this.latRange = [bounds.getSouth(), bounds.getNorth()];\n this.constrain();\n } else {\n this.lngRange = undefined;\n this.latRange = [-this.maxValidLatitude, this.maxValidLatitude];\n }\n }\n\n public customLayerMatrix(): number[] {\n return (this.mercatorMatrix as number[]).slice();\n }\n\n public maxPitchScaleFactor() {\n // calcMatrices hasn't run yet\n if (!this.pixelMatrixInverse) {\n return 1;\n }\n\n const coord = this.pointCoordinate(new Point(0, 0));\n const p = new Float32Array([\n coord.x * this.worldSize,\n coord.y * this.worldSize,\n 0,\n 1,\n ]);\n const topPoint = vec4.transformMat4(p, p, this.pixelMatrix);\n return topPoint[3] / this.cameraToCenterDistance;\n }\n\n /*\n * The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use `cameraLocation`\n * as the name for the location under the camera and on the surface of the earth (lng, lat, 0).\n * `cameraPoint` is the projected position of the `cameraLocation`.\n *\n * This point is useful to us because only fill-extrusions that are between `cameraPoint` and\n * the query point on the surface of the earth can extend and intersect the query.\n *\n * When the map is not pitched the `cameraPoint` is equivalent to the center of the map because\n * the camera is right above the center of the map.\n */\n public getCameraPoint() {\n const pitch = this._pitch;\n const yOffset = Math.tan(pitch) * (this.cameraToCenterDistance || 1);\n return this.centerPoint.add(new Point(0, yOffset));\n }\n\n /*\n * When the map is pitched, some of the 3D features that intersect a query will not intersect\n * the query at the surface of the earth. Instead the feature may be closer and only intersect\n * the query because it extrudes into the air.\n *\n * This returns a geometry that includes all of the original query as well as all possible ares of the\n * screen where the *base* of a visible extrusion could be.\n * - For point queries, the line from the query point to the \"camera point\"\n * - For other geometries, the envelope of the query geometry and the \"camera point\"\n */\n public getCameraQueryGeometry(queryGeometry: Point[]): Point[] {\n const c = this.getCameraPoint();\n\n if (queryGeometry.length === 1) {\n return [queryGeometry[0], c];\n } else {\n let minX = c.x;\n let minY = c.y;\n let maxX = c.x;\n let maxY = c.y;\n for (const p of queryGeometry) {\n minX = Math.min(minX, p.x);\n minY = Math.min(minY, p.y);\n maxX = Math.max(maxX, p.x);\n maxY = Math.max(maxY, p.y);\n }\n return [\n new Point(minX, minY),\n new Point(maxX, minY),\n new Point(maxX, maxY),\n new Point(minX, maxY),\n new Point(minX, minY),\n ];\n }\n }\n\n /**\n * Given a coordinate, return the screen point that corresponds to it\n * @param {Coordinate} coord\n * @returns {Point} screen point\n * @private\n */\n public coordinatePoint(coord: MercatorCoordinate) {\n const p = vec4.fromValues(\n coord.x * this.worldSize,\n coord.y * this.worldSize,\n 0,\n 1,\n );\n vec4.transformMat4(p, p, this.pixelMatrix);\n return new Point(p[0] / p[3], p[1] / p[3]);\n }\n /**\n * Given a location, return the screen point that corresponds to it\n * @param {LngLat} lnglat location\n * @returns {Point} screen point\n * @private\n */\n public locationPoint(lnglat: LngLat) {\n return this.coordinatePoint(this.locationCoordinate(lnglat));\n }\n\n /**\n * Given a point on screen, return its lnglat\n * @param {Point} p screen point\n * @returns {LngLat} lnglat location\n * @private\n */\n public pointLocation(p: Point) {\n return this.coordinateLocation(this.pointCoordinate(p));\n }\n\n /**\n * Given a geographical lnglat, return an unrounded\n * coordinate that represents it at this transform's zoom level.\n * @param {LngLat} lnglat\n * @returns {Coordinate}\n * @private\n */\n public locationCoordinate(lnglat: LngLat) {\n return MercatorCoordinate.fromLngLat(lnglat);\n }\n\n /**\n * Given a Coordinate, return its geographical position.\n * @param {Coordinate} coord\n * @returns {LngLat} lnglat\n * @private\n */\n public coordinateLocation(coord: MercatorCoordinate) {\n return coord.toLngLat();\n }\n\n public getProjectionMatrix(): mat4 {\n return this.projMatrix;\n }\n /**\n * Calculate the posMatrix that, given a tile coordinate, would be used to display the tile on a map.\n * @param {UnwrappedTileID} unwrappedTileID;\n * @private\n */\n // private calculatePosMatrix(\n // unwrappedTileID: UnwrappedTileID,\n // aligned: boolean = false,\n // ): Float32Array {\n // const posMatrixKey = unwrappedTileID.key;\n // const cache = aligned ? this.alignedPosMatrixCache : this.posMatrixCache;\n // if (cache[posMatrixKey]) {\n // return cache[posMatrixKey];\n // }\n\n // const canonical = unwrappedTileID.canonical;\n // const scale = this.worldSize / this.zoomScale(canonical.z);\n // const unwrappedX =\n // canonical.x + Math.pow(2, canonical.z) * unwrappedTileID.wrap;\n\n // const posMatrix = mat4.identity(new Float64Array(16));\n // mat4.translate(posMatrix, posMatrix, [\n // unwrappedX * scale,\n // canonical.y * scale,\n // 0,\n // ]);\n // mat4.scale(posMatrix, posMatrix, [scale / EXTENT, scale / EXTENT, 1]);\n // mat4.multiply(\n // posMatrix,\n // aligned ? this.alignedProjMatrix : this.projMatrix,\n // posMatrix,\n // );\n\n // cache[posMatrixKey] = new Float32Array(posMatrix);\n // return cache[posMatrixKey];\n // }\n\n private constrain() {\n if (!this.center || !this.width || !this.height || this.constraining) {\n return;\n }\n\n this.constraining = true;\n\n let minY = -90;\n let maxY = 90;\n let minX = -180;\n let maxX = 180;\n let sy;\n let sx;\n let x2;\n let y2;\n const size = this.size;\n const unmodified = this.unmodified;\n\n if (this.latRange) {\n const latRange = this.latRange;\n minY = mercatorYfromLat(latRange[1]) * this.worldSize;\n maxY = mercatorYfromLat(latRange[0]) * this.worldSize;\n sy = maxY - minY < size.y ? size.y / (maxY - minY) : 0;\n }\n\n if (this.lngRange) {\n const lngRange = this.lngRange;\n minX = mercatorXfromLng(lngRange[0]) * this.worldSize;\n maxX = mercatorXfromLng(lngRange[1]) * this.worldSize;\n sx = maxX - minX < size.x ? size.x / (maxX - minX) : 0;\n }\n\n const point = this.point;\n\n // how much the map should scale to fit the screen into given latitude/longitude ranges\n const s = Math.max(sx || 0, sy || 0);\n\n if (s) {\n this.center = this.unproject(\n new Point(\n sx ? (maxX + minX) / 2 : point.x,\n sy ? (maxY + minY) / 2 : point.y,\n ),\n );\n this.zoom += this.scaleZoom(s);\n this.unmodified = unmodified;\n this.constraining = false;\n return;\n }\n\n if (this.latRange) {\n const y = point.y;\n const h2 = size.y / 2;\n\n if (y - h2 < minY) {\n y2 = minY + h2;\n }\n if (y + h2 > maxY) {\n y2 = maxY - h2;\n }\n }\n\n if (this.lngRange) {\n const x = point.x;\n const w2 = size.x / 2;\n\n if (x - w2 < minX) {\n x2 = minX + w2;\n }\n if (x + w2 > maxX) {\n x2 = maxX - w2;\n }\n }\n\n // pan the map if the screen goes off the range\n if (x2 !== undefined || y2 !== undefined) {\n this.center = this.unproject(\n new Point(\n x2 !== undefined ? x2 : point.x,\n y2 !== undefined ? y2 : point.y,\n ),\n );\n }\n\n this.unmodified = unmodified;\n this.constraining = false;\n }\n\n private calcMatrices() {\n if (!this.height) {\n return;\n }\n\n const halfFov = this._fov / 2;\n const offset = this.centerOffset;\n this.cameraToCenterDistance = (0.5 / Math.tan(halfFov)) * this.height;\n\n // Find the distance from the center point [width/2 + offset.x, height/2 + offset.y] to the\n // center top point [width/2 + offset.x, 0] in Z units, using the law of sines.\n // 1 Z unit is equivalent to 1 horizontal px at the center of the map\n // (the distance between[width/2, height/2] and [width/2 + 1, height/2])\n const groundAngle = Math.PI / 2 + this._pitch;\n const fovAboveCenter = this._fov * (0.5 + offset.y / this.height);\n const topHalfSurfaceDistance =\n (Math.sin(fovAboveCenter) * this.cameraToCenterDistance) /\n Math.sin(\n clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01),\n );\n const point = this.point;\n const x = point.x;\n const y = point.y;\n\n // Calculate z distance of the farthest fragment that should be rendered.\n const furthestDistance =\n Math.cos(Math.PI / 2 - this._pitch) * topHalfSurfaceDistance +\n this.cameraToCenterDistance;\n // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`\n const farZ = furthestDistance * 1.01;\n\n // The larger the value of nearZ is\n // - the more depth precision is available for features (good)\n // - clipping starts appearing sooner when the camera is close to 3d features (bad)\n //\n // Smaller values worked well for mapbox-gl-js but deckgl was encountering precision issues\n // when rendering it's layers using custom layers. This value was experimentally chosen and\n // seems to solve z-fighting issues in deckgl while not clipping buildings too close to the camera.\n const nearZ = this.height / 50;\n\n // matrix for conversion from location to GL coordinates (-1 .. 1)\n let m = mat4.create();\n mat4.perspective(m, this._fov, this.width / this.height, nearZ, farZ);\n\n // Apply center of perspective offset\n m[8] = (-offset.x * 2) / this.width;\n m[9] = (offset.y * 2) / this.height;\n\n mat4.scale(m, m, [1, -1, 1]);\n mat4.translate(m, m, [0, 0, -this.cameraToCenterDistance]);\n mat4.rotateX(m, m, this._pitch);\n mat4.rotateZ(m, m, this.angle);\n mat4.translate(m, m, [-x, -y, 0]);\n\n // The mercatorMatrix can be used to transform points from mercator coordinates\n // ([0, 0] nw, [1, 1] se) to GL coordinates.\n this.mercatorMatrix = mat4.scale(mat4.create(), m, [\n this.worldSize,\n this.worldSize,\n this.worldSize,\n ]);\n // scale vertically to meters per pixel (inverse of ground resolution):\n\n mat4.scale(\n m,\n m,\n vec3.fromValues(\n 1,\n 1,\n mercatorZfromAltitude(1, this.center.lat) * this.worldSize,\n ),\n );\n\n this.projMatrix = m;\n this.invProjMatrix = mat4.invert(mat4.create(), this.projMatrix);\n\n // Make a second projection matrix that is aligned to a pixel grid for rendering raster tiles.\n // We're rounding the (floating point) x/y values to achieve to avoid rendering raster images to fractional\n // coordinates. Additionally, we adjust by half a pixel in either direction in case that viewport dimension\n // is an odd integer to preserve rendering to the pixel grid. We're rotating this shift based on the angle\n // of the transformation so that 0°, 90°, 180°, and 270° rasters are crisp, and adjust the shift so that\n // it is always <= 0.5 pixels.\n const xShift = (this.width % 2) / 2;\n const yShift = (this.height % 2) / 2;\n const angleCos = Math.cos(this.angle);\n const angleSin = Math.sin(this.angle);\n const dx = x - Math.round(x) + angleCos * xShift + angleSin * yShift;\n const dy = y - Math.round(y) + angleCos * yShift + angleSin * xShift;\n const alignedM = mat4.clone(m);\n mat4.translate(alignedM, alignedM, [\n dx > 0.5 ? dx - 1 : dx,\n dy > 0.5 ? dy - 1 : dy,\n 0,\n ]);\n this.alignedProjMatrix = alignedM;\n\n m = mat4.create();\n mat4.scale(m, m, [this.width / 2, -this.height / 2, 1]);\n mat4.translate(m, m, [1, -1, 0]);\n this.labelPlaneMatrix = m;\n\n m = mat4.create();\n mat4.scale(m, m, [1, -1, 1]);\n mat4.translate(m, m, [-1, -1, 0]);\n mat4.scale(m, m, [2 / this.width, 2 / this.height, 1]);\n this.glCoordMatrix = m;\n\n // matrix for conversion from location to screen coordinates\n this.pixelMatrix = mat4.multiply(\n mat4.create(),\n this.labelPlaneMatrix,\n this.projMatrix,\n );\n\n // inverse matrix for conversion from screen coordinaes to location\n m = mat4.invert(mat4.create(), this.pixelMatrix);\n if (!m) {\n throw new Error('failed to invert matrix');\n }\n this.pixelMatrixInverse = m;\n\n this.posMatrixCache = {};\n this.alignedPosMatrixCache = {};\n }\n}\n"],"file":"transform.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/geo/transform.ts"],"names":["EXTENT","Transform","minZoom","maxZoom","minPitch","maxPitch","renderWorldCopies","tileSize","maxValidLatitude","_renderWorldCopies","undefined","_minZoom","_maxZoom","_minPitch","_maxPitch","setMaxBounds","width","height","_center","LngLat","zoom","angle","_fov","_pitch","unmodified","edgeInsets","EdgeInsets","posMatrixCache","alignedPosMatrixCache","Math","max","min","pitch","scale","centerPoint","_sub","size","_div","Point","PI","bearing","b","calcMatrices","rotationMatrix","mat2","create","rotate","p","fov","_zoom","z","zoomScale","tileZoom","floor","zoomFraction","constrain","center","lat","lng","toJSON","padding","equals","interpolate","getCenter","project","clone","latRange","start","target","t","options","roundZoom","round","scaleZoom","pixelsToGLUnits","pow","log","LN2","lnglat","worldSize","point","MercatorCoordinate","x","y","toLngLat","a","pointCoordinate","loc","locationCoordinate","newCenter","coordinateLocation","wrap","targetZ","coord0","Float32Array","coord1","vec4","transformMat4","pixelMatrixInverse","w0","w1","x0","x1","y0","y1","z0","z1","LngLatBounds","extend","pointLocation","length","lngRange","bounds","getWest","getEast","getSouth","getNorth","mercatorMatrix","slice","coord","topPoint","pixelMatrix","cameraToCenterDistance","yOffset","tan","add","queryGeometry","c","getCameraPoint","minX","minY","maxX","maxY","fromValues","coordinatePoint","fromLngLat","projMatrix","constraining","sy","sx","x2","y2","s","unproject","h2","w2","halfFov","offset","centerOffset","groundAngle","fovAboveCenter","topHalfSurfaceDistance","sin","furthestDistance","cos","farZ","nearZ","m","mat4","perspective","translate","rotateX","rotateZ","vec3","invProjMatrix","invert","xShift","yShift","angleCos","angleSin","dx","dy","alignedM","alignedProjMatrix","labelPlaneMatrix","glCoordMatrix","multiply","Error"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAKO,IAAMA,MAAM,GAAG,IAAf;;;IACcC,S;AAoNnB,qBACEC,OADF,EAEEC,OAFF,EAGEC,QAHF,EAIEC,QAJF,EAKEC,iBALF,EAME;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AK7H,KAAL,CAAW4H,CAAX,EAAcA,CAAd,EAAiB,CAAC,IAAI,KAAK7I,KAAV,EAAiB,IAAI,KAAKC,MAA1B,EAAkC,CAAlC,CAAjB;;AACA,WAAK8J,aAAL,GAAqBlB,CAArB;AAGA,WAAKpC,WAAL,GAAmBqC,eAAKkB,QAAL,CACjBlB,eAAKjH,MAAL,EADiB,EAEjB,KAAKiI,gBAFY,EAGjB,KAAKtC,UAHY,CAAnB;AAOAqB,MAAAA,CAAC,GAAGC,eAAKO,MAAL,CAAYP,eAAKjH,MAAL,EAAZ,EAA2B,KAAK4E,WAAhC,CAAJ;;AACA,UAAI,CAACoC,CAAL,EAAQ;AACN,cAAM,IAAIoB,KAAJ,CAAU,yBAAV,CAAN;AACD;;AACD,WAAK/E,kBAAL,GAA0B2D,CAA1B;AAEA,WAAKlI,cAAL,GAAsB,EAAtB;AACA,WAAKC,qBAAL,GAA6B,EAA7B;AACD","sourcesContent":["// @ts-ignore\nimport { mat2, mat4, vec3, vec4 } from 'gl-matrix';\nimport Point, { PointLike } from '../geo/point';\nimport { clamp, interpolate, wrap } from '../util';\nimport Aabb from '../utils/Aabb';\nimport Frustum from '../utils/primitives';\nimport EdgeInsets, { IPaddingOptions } from './edge_insets';\nimport LngLat from './lng_lat';\nimport LngLatBounds from './lng_lat_bounds';\nimport MercatorCoordinate, {\n mercatorXfromLng,\n mercatorYfromLat,\n mercatorZfromAltitude,\n} from './mercator';\nexport const EXTENT = 8192;\nexport default class Transform {\n get minZoom(): number {\n return this._minZoom;\n }\n set minZoom(zoom: number) {\n if (this._minZoom === zoom) {\n return;\n }\n this._minZoom = zoom;\n this.zoom = Math.max(this.zoom, zoom);\n }\n\n get maxZoom(): number {\n return this._maxZoom;\n }\n set maxZoom(zoom: number) {\n if (this._maxZoom === zoom) {\n return;\n }\n this._maxZoom = zoom;\n this.zoom = Math.min(this.zoom, zoom);\n }\n\n get minPitch(): number {\n return this._minPitch;\n }\n set minPitch(pitch: number) {\n if (this._minPitch === pitch) {\n return;\n }\n this._minPitch = pitch;\n this._pitch = Math.max(this._pitch, pitch);\n }\n\n get maxPitch(): number {\n return this._maxPitch;\n }\n set maxPitch(pitch: number) {\n if (this._maxPitch === pitch) {\n return;\n }\n this._maxPitch = pitch;\n this._pitch = Math.min(this._pitch, pitch);\n }\n\n get renderWorldCopies(): boolean {\n return this._renderWorldCopies;\n }\n set renderWorldCopies(renderWorldCopies: boolean) {\n if (renderWorldCopies === undefined) {\n renderWorldCopies = true;\n } else if (renderWorldCopies === null) {\n renderWorldCopies = false;\n }\n\n this._renderWorldCopies = renderWorldCopies;\n }\n\n get worldSize(): number {\n return this.tileSize * this.scale;\n }\n\n get centerOffset(): Point {\n return this.centerPoint._sub(this.size._div(2));\n }\n\n get size(): Point {\n return new Point(this.width, this.height);\n }\n\n get bearing(): number {\n return (-this.angle / Math.PI) * 180;\n }\n set bearing(bearing: number) {\n const b = (-wrap(bearing, -180, 180) * Math.PI) / 180;\n if (this.angle === b) {\n return;\n }\n this.unmodified = false;\n this.angle = b;\n this.calcMatrices();\n\n // 2x2 matrix for rotating points\n this.rotationMatrix = mat2.create();\n mat2.rotate(this.rotationMatrix, this.rotationMatrix, this.angle);\n }\n\n get pitch(): number {\n return (this._pitch / Math.PI) * 180;\n }\n set pitch(pitch: number) {\n const p = (clamp(pitch, this._minPitch, this._maxPitch) / 180) * Math.PI;\n if (this._pitch === p) {\n return;\n }\n this.unmodified = false;\n this._pitch = p;\n this.calcMatrices();\n }\n\n get fov(): number {\n return (this._fov / Math.PI) * 180;\n }\n\n set fov(fov: number) {\n fov = Math.max(0.01, Math.min(60, fov));\n if (this._fov === fov) {\n return;\n }\n this.unmodified = false;\n this._fov = (fov / 180) * Math.PI;\n this.calcMatrices();\n }\n\n get zoom(): number {\n return this._zoom;\n }\n\n set zoom(zoom: number) {\n const z = Math.min(Math.max(zoom, this._minZoom), this._maxZoom);\n if (this._zoom === z) {\n return;\n }\n this.unmodified = false;\n this._zoom = z;\n this.scale = this.zoomScale(z);\n this.tileZoom = Math.floor(z);\n this.zoomFraction = z - this.tileZoom;\n this.constrain();\n this.calcMatrices();\n }\n\n get center(): LngLat {\n return this._center;\n }\n\n set center(center: LngLat) {\n if (center.lat === this._center.lat && center.lng === this._center.lng) {\n return;\n }\n this.unmodified = false;\n this._center = center;\n this.constrain();\n this.calcMatrices();\n }\n\n get padding(): IPaddingOptions {\n return this.edgeInsets.toJSON();\n }\n\n set padding(padding: IPaddingOptions) {\n if (this.edgeInsets.equals(padding)) {\n return;\n }\n this.unmodified = false;\n // Update edge-insets inplace\n this.edgeInsets.interpolate(this.edgeInsets, padding, 1);\n this.calcMatrices();\n }\n\n /**\n * The center of the screen in pixels with the top-left corner being (0,0)\n * and +y axis pointing downwards. This accounts for padding.\n *\n * @readonly\n * @type {Point}\n * @memberof Transform\n */\n get centerPoint(): Point {\n return this.edgeInsets.getCenter(this.width, this.height);\n }\n\n get point(): Point {\n return this.project(this.center);\n }\n public tileSize: number;\n public tileZoom: number;\n public lngRange?: [number, number];\n public latRange?: [number, number];\n public maxValidLatitude: number;\n public scale: number;\n public width: number;\n public height: number;\n public angle: number;\n public rotationMatrix: mat2;\n public pixelsToGLUnits: [number, number];\n public cameraToCenterDistance: number;\n public mercatorMatrix: mat4;\n public projMatrix: mat4;\n public invProjMatrix: mat4;\n public alignedProjMatrix: mat4;\n public pixelMatrix: mat4;\n public pixelMatrixInverse: mat4;\n public glCoordMatrix: mat4;\n public labelPlaneMatrix: mat4;\n // tslint:disable:variable-name\n private _fov: number;\n private _pitch: number;\n private _zoom: number;\n private _renderWorldCopies: boolean;\n private _minZoom: number;\n private _maxZoom: number;\n private _minPitch: number;\n private _maxPitch: number;\n private _center: LngLat;\n // tslint:enable\n private zoomFraction: number;\n private unmodified: boolean;\n private edgeInsets: EdgeInsets;\n private constraining: boolean;\n private posMatrixCache: { [_: string]: Float32Array };\n private alignedPosMatrixCache: { [_: string]: Float32Array };\n constructor(\n minZoom: number,\n maxZoom: number,\n minPitch: number,\n maxPitch: number,\n renderWorldCopies: boolean | void,\n ) {\n this.tileSize = 512; // constant\n this.maxValidLatitude = 85.051129; // constant\n\n this._renderWorldCopies = (renderWorldCopies === undefined\n ? true\n : renderWorldCopies) as boolean;\n this._minZoom = minZoom || 0;\n this._maxZoom = maxZoom || 22;\n\n this._minPitch = minPitch === undefined || minPitch === null ? 0 : minPitch;\n this._maxPitch =\n maxPitch === undefined || maxPitch === null ? 60 : maxPitch;\n\n this.setMaxBounds();\n\n this.width = 0;\n this.height = 0;\n this._center = new LngLat(0, 0);\n this.zoom = 0;\n this.angle = 0;\n this._fov = 0.6435011087932844;\n this._pitch = 0;\n this.unmodified = true;\n this.edgeInsets = new EdgeInsets();\n this.posMatrixCache = {};\n this.alignedPosMatrixCache = {};\n }\n\n public clone(): Transform {\n const clone = new Transform(\n this._minZoom,\n this._maxZoom,\n this._minPitch,\n this._maxPitch,\n this._renderWorldCopies,\n );\n clone.tileSize = this.tileSize;\n clone.latRange = this.latRange;\n clone.width = this.width;\n clone.height = this.height;\n clone.center = this._center;\n clone.zoom = this.zoom;\n clone.angle = this.angle;\n clone.fov = this._fov;\n clone.pitch = this._pitch;\n clone.unmodified = this.unmodified;\n clone.edgeInsets = this.edgeInsets.clone();\n clone.calcMatrices();\n return clone;\n }\n\n /**\n * Returns if the padding params match\n *\n * @param {IPaddingOptions} padding\n * @returns {boolean}\n * @memberof Transform\n */\n public isPaddingEqual(padding: IPaddingOptions): boolean {\n return this.edgeInsets.equals(padding);\n }\n\n /**\n * Helper method to upadte edge-insets inplace\n *\n * @param {IPaddingOptions} target\n * @param {number} t\n * @memberof Transform\n */\n public interpolatePadding(\n start: IPaddingOptions,\n target: IPaddingOptions,\n t: number,\n ) {\n this.unmodified = false;\n this.edgeInsets.interpolate(start, target, t);\n this.constrain();\n this.calcMatrices();\n }\n\n /**\n * Return a zoom level that will cover all tiles the transform\n * @param {Object} options options\n * @param {number} options.tileSize Tile size, expressed in screen pixels.\n * @param {boolean} options.roundZoom Target zoom level. If true, the value will be rounded to the closest integer. Otherwise the value will be floored.\n * @returns {number} zoom level An integer zoom level at which all tiles will be visible.\n */\n public coveringZoomLevel(options: { roundZoom?: boolean; tileSize: number }) {\n const z = (options.roundZoom ? Math.round : Math.floor)(\n this.zoom + this.scaleZoom(this.tileSize / options.tileSize),\n );\n // At negative zoom levels load tiles from z0 because negative tile zoom levels don't exist.\n return Math.max(0, z);\n }\n\n /**\n * Return any \"wrapped\" copies of a given tile coordinate that are visible\n * in the current view.\n *\n * @private\n */\n // public getVisibleUnwrappedCoordinates(tileID: CanonicalTileID) {\n // const result = [new UnwrappedTileID(0, tileID)];\n // if (this._renderWorldCopies) {\n // const utl = this.pointCoordinate(new Point(0, 0));\n // const utr = this.pointCoordinate(new Point(this.width, 0));\n // const ubl = this.pointCoordinate(new Point(this.width, this.height));\n // const ubr = this.pointCoordinate(new Point(0, this.height));\n // const w0 = Math.floor(Math.min(utl.x, utr.x, ubl.x, ubr.x));\n // const w1 = Math.floor(Math.max(utl.x, utr.x, ubl.x, ubr.x));\n\n // // Add an extra copy of the world on each side to properly render ImageSources and CanvasSources.\n // // Both sources draw outside the tile boundaries of the tile that \"contains them\" so we need\n // // to add extra copies on both sides in case offscreen tiles need to draw into on-screen ones.\n // const extraWorldCopy = 1;\n\n // for (let w = w0 - extraWorldCopy; w <= w1 + extraWorldCopy; w++) {\n // if (w === 0) {\n // continue;\n // }\n // result.push(new UnwrappedTileID(w, tileID));\n // }\n // }\n // return result;\n // }\n\n /**\n * Return all coordinates that could cover this transform for a covering\n * zoom level.\n * @param {Object} options\n * @param {number} options.tileSize\n * @param {number} options.minzoom\n * @param {number} options.maxzoom\n * @param {boolean} options.roundZoom\n * @param {boolean} options.reparseOverscaled\n * @param {boolean} options.renderWorldCopies\n * @returns {Array<OverscaledTileID>} OverscaledTileIDs\n * @private\n */\n // public coveringTiles(options: {\n // tileSize: number;\n // minzoom?: number;\n // maxzoom?: number;\n // roundZoom?: boolean;\n // reparseOverscaled?: boolean;\n // renderWorldCopies?: boolean;\n // }): OverscaledTileID[] {\n // let z = this.coveringZoomLevel(options);\n // const actualZ = z;\n\n // if (options.minzoom !== undefined && z < options.minzoom) {\n // return [];\n // }\n // if (options.maxzoom !== undefined && z > options.maxzoom) {\n // z = options.maxzoom;\n // }\n\n // const centerCoord = MercatorCoordinate.fromLngLat(this.center);\n // const numTiles = Math.pow(2, z);\n // const centerPoint = [numTiles * centerCoord.x, numTiles * centerCoord.y, 0];\n // const cameraFrustum = Frustum.fromInvProjectionMatrix(\n // this.invProjMatrix,\n // this.worldSize,\n // z,\n // );\n\n // // 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\n // let minZoom = options.minzoom || 0;\n // // Use 0.1 as an epsilon to avoid for explicit == 0.0 floating point checks\n // if (this._pitch <= 60.0 && this.edgeInsets.top < 0.1) {\n // minZoom = z;\n // }\n\n // // There should always be a certain number of maximum zoom level tiles surrounding the center location\n // const radiusOfMaxLvlLodInTiles = 3;\n\n // const newRootTile = (wrap: number): any => {\n // return {\n // // All tiles are on zero elevation plane => z difference is zero\n // aabb: new Aabb(\n // [wrap * numTiles, 0, 0],\n // [(wrap + 1) * numTiles, numTiles, 0],\n // ),\n // zoom: 0,\n // x: 0,\n // y: 0,\n // wrap,\n // fullyVisible: false,\n // };\n // };\n\n // // Do a depth-first traversal to find visible tiles and proper levels of detail\n // const stack = [];\n // const result = [];\n // const maxZoom = z;\n // const overscaledZ = options.reparseOverscaled ? actualZ : z;\n\n // if (this._renderWorldCopies) {\n // // Render copy of the globe thrice on both sides\n // for (let i = 1; i <= 3; i++) {\n // stack.push(newRootTile(-i));\n // stack.push(newRootTile(i));\n // }\n // }\n\n // stack.push(newRootTile(0));\n\n // while (stack.length > 0) {\n // const it = stack.pop();\n // const x = it.x;\n // const y = it.y;\n // let fullyVisible = it.fullyVisible;\n\n // // Visibility of a tile is not required if any of its ancestor if fully inside the frustum\n // if (!fullyVisible) {\n // const intersectResult = it.aabb.intersects(cameraFrustum);\n\n // if (intersectResult === 0) {\n // continue;\n // }\n\n // fullyVisible = intersectResult === 2;\n // }\n\n // const distanceX = it.aabb.distanceX(centerPoint);\n // const distanceY = it.aabb.distanceY(centerPoint);\n // const longestDim = Math.max(Math.abs(distanceX), Math.abs(distanceY));\n\n // // We're using distance based heuristics to determine if a tile should be split into quadrants or not.\n // // radiusOfMaxLvlLodInTiles defines that there's always a certain number of maxLevel tiles next to the map center.\n // // Using the fact that a parent node in quadtree is twice the size of its children (per dimension)\n // // we can define distance thresholds for each relative level:\n // // f(k) = offset + 2 + 4 + 8 + 16 + ... + 2^k. This is the same as \"offset+2^(k+1)-2\"\n // const distToSplit =\n // radiusOfMaxLvlLodInTiles + (1 << (maxZoom - it.zoom)) - 2;\n\n // // Have we reached the target depth or is the tile too far away to be any split further?\n // if (\n // it.zoom === maxZoom ||\n // (longestDim > distToSplit && it.zoom >= minZoom)\n // ) {\n // result.push({\n // tileID: new OverscaledTileID(\n // it.zoom === maxZoom ? overscaledZ : it.zoom,\n // it.wrap,\n // it.zoom,\n // x,\n // y,\n // ),\n // distanceSq: vec2.sqrLen([\n // centerPoint[0] - 0.5 - x,\n // centerPoint[1] - 0.5 - y,\n // ]),\n // });\n // continue;\n // }\n\n // for (let i = 0; i < 4; i++) {\n // const childX = (x << 1) + (i % 2);\n // const childY = (y << 1) + (i >> 1);\n\n // stack.push({\n // aabb: it.aabb.quadrant(i),\n // zoom: it.zoom + 1,\n // x: childX,\n // y: childY,\n // wrap: it.wrap,\n // fullyVisible,\n // });\n // }\n // }\n\n // return result\n // .sort((a, b) => a.distanceSq - b.distanceSq)\n // .map((a) => a.tileID);\n // }\n\n public resize(width: number, height: number) {\n this.width = width;\n this.height = height;\n\n this.pixelsToGLUnits = [2 / width, -2 / height];\n this.constrain();\n this.calcMatrices();\n }\n\n public zoomScale(zoom: number) {\n return Math.pow(2, zoom);\n }\n public scaleZoom(scale: number) {\n return Math.log(scale) / Math.LN2;\n }\n\n public project(lnglat: LngLat) {\n const lat = clamp(\n lnglat.lat,\n -this.maxValidLatitude,\n this.maxValidLatitude,\n );\n return new Point(\n mercatorXfromLng(lnglat.lng) * this.worldSize,\n mercatorYfromLat(lat) * this.worldSize,\n );\n }\n\n public unproject(point: Point): LngLat {\n return new MercatorCoordinate(\n point.x / this.worldSize,\n point.y / this.worldSize,\n ).toLngLat();\n }\n\n public setLocationAtPoint(lnglat: LngLat, point: Point) {\n const a = this.pointCoordinate(point);\n const b = this.pointCoordinate(this.centerPoint);\n const loc = this.locationCoordinate(lnglat);\n const newCenter = new MercatorCoordinate(\n loc.x - (a.x - b.x),\n loc.y - (a.y - b.y),\n );\n this.center = this.coordinateLocation(newCenter);\n if (this._renderWorldCopies) {\n this.center = this.center.wrap();\n }\n }\n\n public pointCoordinate(p: Point) {\n const targetZ = 0;\n // since we don't know the correct projected z value for the point,\n // unproject two points to get a line and then find the point on that\n // line with z=0\n\n const coord0 = new Float32Array([p.x, p.y, 0, 1]);\n const coord1 = new Float32Array([p.x, p.y, 1, 1]);\n\n vec4.transformMat4(coord0, coord0, this.pixelMatrixInverse);\n vec4.transformMat4(coord1, coord1, this.pixelMatrixInverse);\n\n const w0 = coord0[3];\n const w1 = coord1[3];\n const x0 = coord0[0] / w0;\n const x1 = coord1[0] / w1;\n const y0 = coord0[1] / w0;\n const y1 = coord1[1] / w1;\n const z0 = coord0[2] / w0;\n const z1 = coord1[2] / w1;\n\n const t = z0 === z1 ? 0 : (targetZ - z0) / (z1 - z0);\n\n return new MercatorCoordinate(\n interpolate(x0, x1, t) / this.worldSize,\n interpolate(y0, y1, t) / this.worldSize,\n );\n }\n\n /**\n * Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not\n * an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.\n * @returns {LngLatBounds} Returns a {@link LngLatBounds} object describing the map's geographical bounds.\n */\n public getBounds(): LngLatBounds {\n return new LngLatBounds()\n .extend(this.pointLocation(new Point(0, 0)))\n .extend(this.pointLocation(new Point(this.width, 0)))\n .extend(this.pointLocation(new Point(this.width, this.height)))\n .extend(this.pointLocation(new Point(0, this.height)));\n }\n\n /**\n * Returns the maximum geographical bounds the map is constrained to, or `null` if none set.\n * @returns {LngLatBounds} {@link LngLatBounds}\n */\n public getMaxBounds(): LngLatBounds | null {\n if (\n !this.latRange ||\n this.latRange.length !== 2 ||\n !this.lngRange ||\n this.lngRange.length !== 2\n ) {\n return null;\n }\n\n return new LngLatBounds(\n [this.lngRange[0], this.latRange[0]],\n [this.lngRange[1], this.latRange[1]],\n );\n }\n\n /**\n * Sets or clears the map's geographical constraints.\n * @param {LngLatBounds} bounds A {@link LngLatBounds} object describing the new geographic boundaries of the map.\n */\n public setMaxBounds(bounds?: LngLatBounds) {\n if (bounds) {\n this.lngRange = [bounds.getWest(), bounds.getEast()];\n this.latRange = [bounds.getSouth(), bounds.getNorth()];\n this.constrain();\n } else {\n this.lngRange = undefined;\n this.latRange = [-this.maxValidLatitude, this.maxValidLatitude];\n }\n }\n\n public customLayerMatrix(): number[] {\n return (this.mercatorMatrix as number[]).slice();\n }\n\n public maxPitchScaleFactor() {\n // calcMatrices hasn't run yet\n if (!this.pixelMatrixInverse) {\n return 1;\n }\n\n const coord = this.pointCoordinate(new Point(0, 0));\n const p = new Float32Array([\n coord.x * this.worldSize,\n coord.y * this.worldSize,\n 0,\n 1,\n ]);\n const topPoint = vec4.transformMat4(p, p, this.pixelMatrix);\n return topPoint[3] / this.cameraToCenterDistance;\n }\n\n /*\n * The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use `cameraLocation`\n * as the name for the location under the camera and on the surface of the earth (lng, lat, 0).\n * `cameraPoint` is the projected position of the `cameraLocation`.\n *\n * This point is useful to us because only fill-extrusions that are between `cameraPoint` and\n * the query point on the surface of the earth can extend and intersect the query.\n *\n * When the map is not pitched the `cameraPoint` is equivalent to the center of the map because\n * the camera is right above the center of the map.\n */\n public getCameraPoint() {\n const pitch = this._pitch;\n const yOffset = Math.tan(pitch) * (this.cameraToCenterDistance || 1);\n return this.centerPoint.add(new Point(0, yOffset));\n }\n\n /*\n * When the map is pitched, some of the 3D features that intersect a query will not intersect\n * the query at the surface of the earth. Instead the feature may be closer and only intersect\n * the query because it extrudes into the air.\n *\n * This returns a geometry that includes all of the original query as well as all possible ares of the\n * screen where the *base* of a visible extrusion could be.\n * - For point queries, the line from the query point to the \"camera point\"\n * - For other geometries, the envelope of the query geometry and the \"camera point\"\n */\n public getCameraQueryGeometry(queryGeometry: Point[]): Point[] {\n const c = this.getCameraPoint();\n\n if (queryGeometry.length === 1) {\n return [queryGeometry[0], c];\n } else {\n let minX = c.x;\n let minY = c.y;\n let maxX = c.x;\n let maxY = c.y;\n for (const p of queryGeometry) {\n minX = Math.min(minX, p.x);\n minY = Math.min(minY, p.y);\n maxX = Math.max(maxX, p.x);\n maxY = Math.max(maxY, p.y);\n }\n return [\n new Point(minX, minY),\n new Point(maxX, minY),\n new Point(maxX, maxY),\n new Point(minX, maxY),\n new Point(minX, minY),\n ];\n }\n }\n\n /**\n * Given a coordinate, return the screen point that corresponds to it\n * @param {Coordinate} coord\n * @returns {Point} screen point\n * @private\n */\n public coordinatePoint(coord: MercatorCoordinate) {\n const p = vec4.fromValues(\n coord.x * this.worldSize,\n coord.y * this.worldSize,\n 0,\n 1,\n );\n vec4.transformMat4(p, p, this.pixelMatrix);\n return new Point(p[0] / p[3], p[1] / p[3]);\n }\n /**\n * Given a location, return the screen point that corresponds to it\n * @param {LngLat} lnglat location\n * @returns {Point} screen point\n * @private\n */\n public locationPoint(lnglat: LngLat) {\n return this.coordinatePoint(this.locationCoordinate(lnglat));\n }\n\n /**\n * Given a point on screen, return its lnglat\n * @param {Point} p screen point\n * @returns {LngLat} lnglat location\n * @private\n */\n public pointLocation(p: Point) {\n return this.coordinateLocation(this.pointCoordinate(p));\n }\n\n /**\n * Given a geographical lnglat, return an unrounded\n * coordinate that represents it at this transform's zoom level.\n * @param {LngLat} lnglat\n * @returns {Coordinate}\n * @private\n */\n public locationCoordinate(lnglat: LngLat) {\n return MercatorCoordinate.fromLngLat(lnglat);\n }\n\n /**\n * Given a Coordinate, return its geographical position.\n * @param {Coordinate} coord\n * @returns {LngLat} lnglat\n * @private\n */\n public coordinateLocation(coord: MercatorCoordinate) {\n return coord.toLngLat();\n }\n\n public getProjectionMatrix(): mat4 {\n return this.projMatrix;\n }\n /**\n * Calculate the posMatrix that, given a tile coordinate, would be used to display the tile on a map.\n * @param {UnwrappedTileID} unwrappedTileID;\n * @private\n */\n // private calculatePosMatrix(\n // unwrappedTileID: UnwrappedTileID,\n // aligned: boolean = false,\n // ): Float32Array {\n // const posMatrixKey = unwrappedTileID.key;\n // const cache = aligned ? this.alignedPosMatrixCache : this.posMatrixCache;\n // if (cache[posMatrixKey]) {\n // return cache[posMatrixKey];\n // }\n\n // const canonical = unwrappedTileID.canonical;\n // const scale = this.worldSize / this.zoomScale(canonical.z);\n // const unwrappedX =\n // canonical.x + Math.pow(2, canonical.z) * unwrappedTileID.wrap;\n\n // const posMatrix = mat4.identity(new Float64Array(16));\n // mat4.translate(posMatrix, posMatrix, [\n // unwrappedX * scale,\n // canonical.y * scale,\n // 0,\n // ]);\n // mat4.scale(posMatrix, posMatrix, [scale / EXTENT, scale / EXTENT, 1]);\n // mat4.multiply(\n // posMatrix,\n // aligned ? this.alignedProjMatrix : this.projMatrix,\n // posMatrix,\n // );\n\n // cache[posMatrixKey] = new Float32Array(posMatrix);\n // return cache[posMatrixKey];\n // }\n\n private constrain() {\n if (!this.center || !this.width || !this.height || this.constraining) {\n return;\n }\n\n this.constraining = true;\n\n let minY = -90;\n let maxY = 90;\n let minX = -180;\n let maxX = 180;\n let sy;\n let sx;\n let x2;\n let y2;\n const size = this.size;\n const unmodified = this.unmodified;\n\n if (this.latRange) {\n const latRange = this.latRange;\n minY = mercatorYfromLat(latRange[1]) * this.worldSize;\n maxY = mercatorYfromLat(latRange[0]) * this.worldSize;\n sy = maxY - minY < size.y ? size.y / (maxY - minY) : 0;\n }\n\n if (this.lngRange) {\n const lngRange = this.lngRange;\n minX = mercatorXfromLng(lngRange[0]) * this.worldSize;\n maxX = mercatorXfromLng(lngRange[1]) * this.worldSize;\n sx = maxX - minX < size.x ? size.x / (maxX - minX) : 0;\n }\n\n const point = this.point;\n\n // how much the map should scale to fit the screen into given latitude/longitude ranges\n const s = Math.max(sx || 0, sy || 0);\n\n if (s) {\n this.center = this.unproject(\n new Point(\n sx ? (maxX + minX) / 2 : point.x,\n sy ? (maxY + minY) / 2 : point.y,\n ),\n );\n this.zoom += this.scaleZoom(s);\n this.unmodified = unmodified;\n this.constraining = false;\n return;\n }\n\n if (this.latRange) {\n const y = point.y;\n const h2 = size.y / 2;\n\n if (y - h2 < minY) {\n y2 = minY + h2;\n }\n if (y + h2 > maxY) {\n y2 = maxY - h2;\n }\n }\n\n if (this.lngRange) {\n const x = point.x;\n const w2 = size.x / 2;\n\n if (x - w2 < minX) {\n x2 = minX + w2;\n }\n if (x + w2 > maxX) {\n x2 = maxX - w2;\n }\n }\n\n // pan the map if the screen goes off the range\n if (x2 !== undefined || y2 !== undefined) {\n this.center = this.unproject(\n new Point(\n x2 !== undefined ? x2 : point.x,\n y2 !== undefined ? y2 : point.y,\n ),\n );\n }\n\n this.unmodified = unmodified;\n this.constraining = false;\n }\n\n private calcMatrices() {\n if (!this.height) {\n return;\n }\n\n const halfFov = this._fov / 2;\n const offset = this.centerOffset;\n this.cameraToCenterDistance = (0.5 / Math.tan(halfFov)) * this.height;\n\n // Find the distance from the center point [width/2 + offset.x, height/2 + offset.y] to the\n // center top point [width/2 + offset.x, 0] in Z units, using the law of sines.\n // 1 Z unit is equivalent to 1 horizontal px at the center of the map\n // (the distance between[width/2, height/2] and [width/2 + 1, height/2])\n const groundAngle = Math.PI / 2 + this._pitch;\n const fovAboveCenter = this._fov * (0.5 + offset.y / this.height);\n const topHalfSurfaceDistance =\n (Math.sin(fovAboveCenter) * this.cameraToCenterDistance) /\n Math.sin(\n clamp(Math.PI - groundAngle - fovAboveCenter, 0.01, Math.PI - 0.01),\n );\n const point = this.point;\n const x = point.x;\n const y = point.y;\n\n // Calculate z distance of the farthest fragment that should be rendered.\n const furthestDistance =\n Math.cos(Math.PI / 2 - this._pitch) * topHalfSurfaceDistance +\n this.cameraToCenterDistance;\n // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`\n const farZ = furthestDistance * 1.01;\n\n // The larger the value of nearZ is\n // - the more depth precision is available for features (good)\n // - clipping starts appearing sooner when the camera is close to 3d features (bad)\n //\n // Smaller values worked well for mapbox-gl-js but deckgl was encountering precision issues\n // when rendering it's layers using custom layers. This value was experimentally chosen and\n // seems to solve z-fighting issues in deckgl while not clipping buildings too close to the camera.\n const nearZ = this.height / 50;\n\n // matrix for conversion from location to GL coordinates (-1 .. 1)\n let m = mat4.create();\n mat4.perspective(m, this._fov, this.width / this.height, nearZ, farZ);\n\n // Apply center of perspective offset\n m[8] = (-offset.x * 2) / this.width;\n m[9] = (offset.y * 2) / this.height;\n\n mat4.scale(m, m, [1, -1, 1]);\n mat4.translate(m, m, [0, 0, -this.cameraToCenterDistance]);\n mat4.rotateX(m, m, this._pitch);\n mat4.rotateZ(m, m, this.angle);\n mat4.translate(m, m, [-x, -y, 0]);\n\n // The mercatorMatrix can be used to transform points from mercator coordinates\n // ([0, 0] nw, [1, 1] se) to GL coordinates.\n this.mercatorMatrix = mat4.scale(mat4.create(), m, [\n this.worldSize,\n this.worldSize,\n this.worldSize,\n ]);\n // scale vertically to meters per pixel (inverse of ground resolution):\n\n mat4.scale(\n m,\n m,\n vec3.fromValues(\n 1,\n 1,\n mercatorZfromAltitude(1, this.center.lat) * this.worldSize,\n ),\n );\n\n this.projMatrix = m;\n this.invProjMatrix = mat4.invert(mat4.create(), this.projMatrix);\n\n // Make a second projection matrix that is aligned to a pixel grid for rendering raster tiles.\n // We're rounding the (floating point) x/y values to achieve to avoid rendering raster images to fractional\n // coordinates. Additionally, we adjust by half a pixel in either direction in case that viewport dimension\n // is an odd integer to preserve rendering to the pixel grid. We're rotating this shift based on the angle\n // of the transformation so that 0°, 90°, 180°, and 270° rasters are crisp, and adjust the shift so that\n // it is always <= 0.5 pixels.\n const xShift = (this.width % 2) / 2;\n const yShift = (this.height % 2) / 2;\n const angleCos = Math.cos(this.angle);\n const angleSin = Math.sin(this.angle);\n const dx = x - Math.round(x) + angleCos * xShift + angleSin * yShift;\n const dy = y - Math.round(y) + angleCos * yShift + angleSin * xShift;\n const alignedM = mat4.clone(m);\n mat4.translate(alignedM, alignedM, [\n dx > 0.5 ? dx - 1 : dx,\n dy > 0.5 ? dy - 1 : dy,\n 0,\n ]);\n this.alignedProjMatrix = alignedM;\n\n m = mat4.create();\n mat4.scale(m, m, [this.width / 2, -this.height / 2, 1]);\n mat4.translate(m, m, [1, -1, 0]);\n this.labelPlaneMatrix = m;\n\n m = mat4.create();\n mat4.scale(m, m, [1, -1, 1]);\n mat4.translate(m, m, [-1, -1, 0]);\n mat4.scale(m, m, [2 / this.width, 2 / this.height, 1]);\n this.glCoordMatrix = m;\n\n // matrix for conversion from location to screen coordinates\n this.pixelMatrix = mat4.multiply(\n mat4.create(),\n this.labelPlaneMatrix,\n this.projMatrix,\n );\n\n // inverse matrix for conversion from screen coordinaes to location\n m = mat4.invert(mat4.create(), this.pixelMatrix);\n if (!m) {\n throw new Error('failed to invert matrix');\n }\n this.pixelMatrixInverse = m;\n\n this.posMatrixCache = {};\n this.alignedPosMatrixCache = {};\n }\n}\n"],"file":"transform.js"}
|
|
@@ -11,16 +11,16 @@ Object.defineProperty(exports, "MousePanHandler", {
|
|
|
11
11
|
return _mousepan_handler.default;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
Object.defineProperty(exports, "
|
|
14
|
+
Object.defineProperty(exports, "MousePitchHandler", {
|
|
15
15
|
enumerable: true,
|
|
16
16
|
get: function get() {
|
|
17
|
-
return
|
|
17
|
+
return _mouserotate_hander.default;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
Object.defineProperty(exports, "
|
|
20
|
+
Object.defineProperty(exports, "MouseRotateHandler", {
|
|
21
21
|
enumerable: true,
|
|
22
22
|
get: function get() {
|
|
23
|
-
return
|
|
23
|
+
return _mousepitch_hander.default;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
|
|
@@ -5,8 +5,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.RIGHT_BUTTON = exports.LEFT_BUTTON = exports.BUTTONS_FLAGS = void 0;
|
|
8
9
|
exports.buttonStillPressed = buttonStillPressed;
|
|
9
|
-
exports.BUTTONS_FLAGS = exports.RIGHT_BUTTON = exports.LEFT_BUTTON = void 0;
|
|
10
10
|
|
|
11
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
12
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/handler/scroll_zoom.ts"],"names":["wheelZoomDelta","defaultZoomRate","wheelZoomRate","maxScalePerFrame","ScrollZoomHandler","map","handler","frameId","isActive","tr","transform","delta","zoomRate","type","Math","abs","scale","exp","fromScale","targetZoom","zoomScale","min","maxZoom","max","minZoom","scaleZoom","startZoom","zoom","easing","smoothOutEasing","finished","t","lastWheelEventTime","k","active","finishTimeout","setTimeout","zooming","triggerRenderFrame","noInertia","needsRenderFrame","zoomDelta","around","aroundPoint","originalEvent","lastWheelEvent","el","getCanvasContainer","enabled","undefined","options","isEnabled","aroundCenter","e","value","deltaMode","window","WheelEvent","DOM_DELTA_LINE","deltaY","nowTime","timeDelta","lastValue","timeout","onTimeout","clearTimeout","shiftKey","start","preventDefault","onScrollFrame","initialEvent","isZooming","pos","DOM","mousePos","LngLat","convert","getCenter","unproject","locationPoint","duration","ease","prevEase","preEase","speed","x","sqrt","y"],"mappings":";;;;;;;;;;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,EAAE,gBADO;AAEda,QAAAA,QAAQ,EAARA,QAFc;AAGdpD,QAAAA,MAAM,EAANA;AAHc,OAAhB;AAMA,aAAOA,MAAP;AACD;;;;;eAGYxB,iB","sourcesContent":["// @ts-ignore\nimport { EarthMap } from '../earthmap';\nimport LngLat from '../geo/lng_lat';\nimport Point from '../geo/point';\nimport { Map } from '../map';\nimport { bezier, ease, interpolate, now } from '../util';\nimport DOM from '../utils/dom';\nimport HandlerManager from './handler_manager';\n\n// deltaY value for mouse scroll wheel identification\nconst wheelZoomDelta = 4.000244140625;\n\n// These magic numbers control the rate of zoom. Trackpad events fire at a greater\n// frequency than mouse scroll wheel, so reduce the zoom rate per wheel tick\nconst defaultZoomRate = 1 / 100;\nconst wheelZoomRate = 1 / 450;\n\n// upper bound on how much we scale the map in any single render frame; this\n// is used to limit zoom rate in the case of very fast scrolling\nconst maxScalePerFrame = 2;\n\n/**\n * The `ScrollZoomHandler` allows the user to zoom the map by scrolling.\n */\nclass ScrollZoomHandler {\n private map: Map | EarthMap;\n private el: HTMLElement;\n private enabled: boolean;\n private active: boolean;\n private zooming: boolean;\n private aroundCenter: boolean;\n private around: LngLat;\n private aroundPoint: Point;\n private type: 'wheel' | 'trackpad' | null;\n private lastValue: number;\n private timeout: number | null; // used for delayed-handling of a single wheel movement\n private finishTimeout: number; // used to delay final '{move,zoom}end' events\n\n private lastWheelEvent: any;\n private lastWheelEventTime: number;\n\n private startZoom: number;\n private targetZoom: number;\n private delta: number;\n private easing: (time: number) => number;\n private prevEase: {\n start: number;\n duration: number;\n easing: (_: number) => number;\n };\n\n private frameId: boolean | null;\n private handler: HandlerManager;\n\n private defaultZoomRate: number;\n private wheelZoomRate: number;\n\n /**\n * @private\n */\n constructor(map: Map | EarthMap, handler: HandlerManager) {\n this.map = map;\n this.el = map.getCanvasContainer();\n this.handler = handler;\n\n this.delta = 0;\n this.defaultZoomRate = defaultZoomRate;\n this.wheelZoomRate = wheelZoomRate;\n }\n\n /**\n * Set the zoom rate of a trackpad\n * @param {number} [zoomRate=1/100] The rate used to scale trackpad movement to a zoom value.\n * @example\n * // Speed up trackpad zoom\n * map.scrollZoom.setZoomRate(1/25);\n */\n public setZoomRate(zoomRate: number) {\n this.defaultZoomRate = zoomRate;\n }\n\n /**\n * Set the zoom rate of a mouse wheel\n * @param {number} [wheelZoomRate=1/450] The rate used to scale mouse wheel movement to a zoom value.\n * @example\n * // Slow down zoom of mouse wheel\n * map.scrollZoom.setWheelZoomRate(1/600);\n */\n public setWheelZoomRate(zoomRate: number) {\n this.wheelZoomRate = zoomRate;\n }\n\n /**\n * Returns a Boolean indicating whether the \"scroll to zoom\" interaction is enabled.\n *\n * @returns {boolean} `true` if the \"scroll to zoom\" interaction is enabled.\n */\n public isEnabled() {\n return !!this.enabled;\n }\n\n /*\n * Active state is turned on and off with every scroll wheel event and is set back to false before the map\n * render is called, so _active is not a good candidate for determining if a scroll zoom animation is in\n * progress.\n */\n public isActive() {\n return !!this.active || this.finishTimeout !== undefined;\n }\n\n public isZooming() {\n return !!this.zooming;\n }\n\n /**\n * Enables the \"scroll to zoom\" interaction.\n *\n * @param {Object} [options] Options object.\n * @param {string} [options.around] If \"center\" is passed, map will zoom around center of map\n *\n * @example\n * map.scrollZoom.enable();\n * @example\n * map.scrollZoom.enable({ around: 'center' })\n */\n public enable(options?: any) {\n if (this.isEnabled()) {\n return;\n }\n this.enabled = true;\n this.aroundCenter = options && options.around === 'center';\n }\n\n /**\n * Disables the \"scroll to zoom\" interaction.\n *\n * @example\n * map.scrollZoom.disable();\n */\n public disable() {\n if (!this.isEnabled()) {\n return;\n }\n this.enabled = false;\n }\n\n public wheel(e: WheelEvent) {\n if (!this.isEnabled()) {\n return;\n }\n // Remove `any` cast when https://github.com/facebook/flow/issues/4879 is fixed.\n let value =\n e.deltaMode === window.WheelEvent.DOM_DELTA_LINE\n ? e.deltaY * 40\n : e.deltaY;\n const nowTime = now();\n const timeDelta = nowTime - (this.lastWheelEventTime || 0);\n\n this.lastWheelEventTime = nowTime;\n\n if (value !== 0 && value % wheelZoomDelta === 0) {\n // This one is definitely a mouse wheel event.\n this.type = 'wheel';\n } else if (value !== 0 && Math.abs(value) < 4) {\n // This one is definitely a trackpad event because it is so small.\n this.type = 'trackpad';\n } else if (timeDelta > 400) {\n // This is likely a new scroll action.\n this.type = null;\n this.lastValue = value;\n\n // Start a timeout in case this was a singular event, and dely it by up to 40ms.\n // @ts-ignore\n this.timeout = setTimeout(this.onTimeout, 40, e);\n } else if (!this.type) {\n // This is a repeating event, but we don't know the type of event just yet.\n // If the delta per time is small, we assume it's a fast trackpad; otherwise we switch into wheel mode.\n this.type = Math.abs(timeDelta * value) < 200 ? 'trackpad' : 'wheel';\n\n // Make sure our delayed event isn't fired again, because we accumulate\n // the previous event (which was less than 40ms ago) into this event.\n if (this.timeout) {\n clearTimeout(this.timeout);\n this.timeout = null;\n value += this.lastValue;\n }\n }\n\n // Slow down zoom if shift key is held for more precise zooming\n if (e.shiftKey && value) {\n value = value / 4;\n }\n // Only fire the callback if we actually know what type of scrolling device the user uses.\n if (this.type) {\n this.lastWheelEvent = e;\n this.delta -= value;\n if (!this.active) {\n this.start(e);\n }\n }\n\n e.preventDefault();\n }\n\n public renderFrame() {\n return this.onScrollFrame();\n }\n\n public reset() {\n this.active = false;\n }\n\n private onScrollFrame = () => {\n if (!this.frameId) {\n return;\n }\n this.frameId = null;\n\n if (!this.isActive()) {\n return;\n }\n const tr = this.map.transform;\n\n // if we've had scroll events since the last render frame, consume the\n // accumulated delta, and update the target zoom level accordingly\n if (this.delta !== 0) {\n // For trackpad events and single mouse wheel ticks, use the default zoom rate\n const zoomRate =\n this.type === 'wheel' && Math.abs(this.delta) > wheelZoomDelta\n ? this.wheelZoomRate\n : this.defaultZoomRate;\n // Scale by sigmoid of scroll wheel delta.\n let scale =\n maxScalePerFrame / (1 + Math.exp(-Math.abs(this.delta * zoomRate)));\n\n if (this.delta < 0 && scale !== 0) {\n scale = 1 / scale;\n }\n\n const fromScale =\n typeof this.targetZoom === 'number'\n ? tr.zoomScale(this.targetZoom)\n : tr.scale;\n this.targetZoom = Math.min(\n tr.maxZoom,\n Math.max(tr.minZoom, tr.scaleZoom(fromScale * scale)),\n );\n\n // if this is a mouse wheel, refresh the starting zoom and easing\n // function we're using to smooth out the zooming between wheel\n // events\n if (this.type === 'wheel') {\n this.startZoom = tr.zoom;\n this.easing = this.smoothOutEasing(200);\n }\n\n this.delta = 0;\n }\n\n const targetZoom =\n typeof this.targetZoom === 'number' ? this.targetZoom : tr.zoom;\n const startZoom = this.startZoom;\n const easing = this.easing;\n\n let finished = false;\n let zoom;\n if (this.type === 'wheel' && startZoom && easing) {\n const t = Math.min((now() - this.lastWheelEventTime) / 200, 1);\n const k = easing(t);\n zoom = interpolate(startZoom, targetZoom, k);\n if (t < 1) {\n if (!this.frameId) {\n this.frameId = true;\n }\n } else {\n finished = true;\n }\n } else {\n zoom = targetZoom;\n finished = true;\n }\n\n this.active = true;\n\n if (finished) {\n this.active = false;\n // @ts-ignore\n this.finishTimeout = setTimeout(() => {\n this.zooming = false;\n this.handler.triggerRenderFrame();\n // @ts-ignore\n delete this.targetZoom;\n // @ts-ignore\n delete this.finishTimeout;\n }, 200);\n }\n\n return {\n noInertia: true,\n needsRenderFrame: !finished,\n zoomDelta: zoom - tr.zoom,\n around: this.aroundPoint,\n originalEvent: this.lastWheelEvent,\n };\n };\n\n private onTimeout(initialEvent: any) {\n this.type = 'wheel';\n this.delta -= this.lastValue;\n if (!this.active) {\n this.start(initialEvent);\n }\n }\n\n private start(e: any) {\n if (!this.delta) {\n return;\n }\n\n if (this.frameId) {\n this.frameId = null;\n }\n\n this.active = true;\n if (!this.isZooming()) {\n this.zooming = true;\n }\n\n if (this.finishTimeout) {\n clearTimeout(this.finishTimeout);\n // @ts-ignore\n delete this.finishTimeout;\n }\n\n const pos = DOM.mousePos(this.el, e);\n\n this.around = LngLat.convert(\n this.aroundCenter ? this.map.getCenter() : this.map.unproject(pos),\n );\n this.aroundPoint = this.map.transform.locationPoint(this.around);\n if (!this.frameId) {\n this.frameId = true;\n this.handler.triggerRenderFrame();\n }\n }\n\n private smoothOutEasing(duration: number) {\n let easing = ease;\n\n if (this.prevEase) {\n const preEase = this.prevEase;\n const t = (now() - preEase.start) / preEase.duration;\n const speed = preEase.easing(t + 0.01) - preEase.easing(t);\n\n // Quick hack to make new bezier that is continuous with last\n const x = (0.27 / Math.sqrt(speed * speed + 0.0001)) * 0.01;\n const y = Math.sqrt(0.27 * 0.27 - x * x);\n\n easing = bezier(x, y, 0.25, 1);\n }\n\n this.prevEase = {\n start: now(),\n duration,\n easing,\n };\n\n return easing;\n }\n}\n\nexport default ScrollZoomHandler;\n"],"file":"scroll_zoom.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/handler/scroll_zoom.ts"],"names":["wheelZoomDelta","defaultZoomRate","wheelZoomRate","maxScalePerFrame","ScrollZoomHandler","map","handler","frameId","isActive","tr","transform","delta","zoomRate","type","Math","abs","scale","exp","fromScale","targetZoom","zoomScale","min","maxZoom","max","minZoom","scaleZoom","startZoom","zoom","easing","smoothOutEasing","finished","t","lastWheelEventTime","k","active","finishTimeout","setTimeout","zooming","triggerRenderFrame","noInertia","needsRenderFrame","zoomDelta","around","aroundPoint","originalEvent","lastWheelEvent","el","getCanvasContainer","enabled","undefined","options","isEnabled","aroundCenter","e","value","deltaMode","window","WheelEvent","DOM_DELTA_LINE","deltaY","nowTime","timeDelta","lastValue","timeout","onTimeout","clearTimeout","shiftKey","start","preventDefault","onScrollFrame","initialEvent","isZooming","pos","DOM","mousePos","LngLat","convert","getCenter","unproject","locationPoint","duration","ease","prevEase","preEase","speed","x","sqrt","y"],"mappings":";;;;;;;;;;;;;;;AAEA;;AAGA;;AACA;;AAIA,IAAMA,cAAc,GAAG,cAAvB;AAIA,IAAMC,eAAe,GAAG,IAAI,GAA5B;AACA,IAAMC,aAAa,GAAG,IAAI,GAA1B;AAIA,IAAMC,gBAAgB,GAAG,CAAzB;;IAKMC,iB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ap } from '../earthmap';\nimport LngLat from '../geo/lng_lat';\nimport Point from '../geo/point';\nimport { Map } from '../map';\nimport { bezier, ease, interpolate, now } from '../util';\nimport DOM from '../utils/dom';\nimport HandlerManager from './handler_manager';\n\n// deltaY value for mouse scroll wheel identification\nconst wheelZoomDelta = 4.000244140625;\n\n// These magic numbers control the rate of zoom. Trackpad events fire at a greater\n// frequency than mouse scroll wheel, so reduce the zoom rate per wheel tick\nconst defaultZoomRate = 1 / 100;\nconst wheelZoomRate = 1 / 450;\n\n// upper bound on how much we scale the map in any single render frame; this\n// is used to limit zoom rate in the case of very fast scrolling\nconst maxScalePerFrame = 2;\n\n/**\n * The `ScrollZoomHandler` allows the user to zoom the map by scrolling.\n */\nclass ScrollZoomHandler {\n private map: Map | EarthMap;\n private el: HTMLElement;\n private enabled: boolean;\n private active: boolean;\n private zooming: boolean;\n private aroundCenter: boolean;\n private around: LngLat;\n private aroundPoint: Point;\n private type: 'wheel' | 'trackpad' | null;\n private lastValue: number;\n private timeout: number | null; // used for delayed-handling of a single wheel movement\n private finishTimeout: number; // used to delay final '{move,zoom}end' events\n\n private lastWheelEvent: any;\n private lastWheelEventTime: number;\n\n private startZoom: number;\n private targetZoom: number;\n private delta: number;\n private easing: (time: number) => number;\n private prevEase: {\n start: number;\n duration: number;\n easing: (_: number) => number;\n };\n\n private frameId: boolean | null;\n private handler: HandlerManager;\n\n private defaultZoomRate: number;\n private wheelZoomRate: number;\n\n /**\n * @private\n */\n constructor(map: Map | EarthMap, handler: HandlerManager) {\n this.map = map;\n this.el = map.getCanvasContainer();\n this.handler = handler;\n\n this.delta = 0;\n this.defaultZoomRate = defaultZoomRate;\n this.wheelZoomRate = wheelZoomRate;\n }\n\n /**\n * Set the zoom rate of a trackpad\n * @param {number} [zoomRate=1/100] The rate used to scale trackpad movement to a zoom value.\n * @example\n * // Speed up trackpad zoom\n * map.scrollZoom.setZoomRate(1/25);\n */\n public setZoomRate(zoomRate: number) {\n this.defaultZoomRate = zoomRate;\n }\n\n /**\n * Set the zoom rate of a mouse wheel\n * @param {number} [wheelZoomRate=1/450] The rate used to scale mouse wheel movement to a zoom value.\n * @example\n * // Slow down zoom of mouse wheel\n * map.scrollZoom.setWheelZoomRate(1/600);\n */\n public setWheelZoomRate(zoomRate: number) {\n this.wheelZoomRate = zoomRate;\n }\n\n /**\n * Returns a Boolean indicating whether the \"scroll to zoom\" interaction is enabled.\n *\n * @returns {boolean} `true` if the \"scroll to zoom\" interaction is enabled.\n */\n public isEnabled() {\n return !!this.enabled;\n }\n\n /*\n * Active state is turned on and off with every scroll wheel event and is set back to false before the map\n * render is called, so _active is not a good candidate for determining if a scroll zoom animation is in\n * progress.\n */\n public isActive() {\n return !!this.active || this.finishTimeout !== undefined;\n }\n\n public isZooming() {\n return !!this.zooming;\n }\n\n /**\n * Enables the \"scroll to zoom\" interaction.\n *\n * @param {Object} [options] Options object.\n * @param {string} [options.around] If \"center\" is passed, map will zoom around center of map\n *\n * @example\n * map.scrollZoom.enable();\n * @example\n * map.scrollZoom.enable({ around: 'center' })\n */\n public enable(options?: any) {\n if (this.isEnabled()) {\n return;\n }\n this.enabled = true;\n this.aroundCenter = options && options.around === 'center';\n }\n\n /**\n * Disables the \"scroll to zoom\" interaction.\n *\n * @example\n * map.scrollZoom.disable();\n */\n public disable() {\n if (!this.isEnabled()) {\n return;\n }\n this.enabled = false;\n }\n\n public wheel(e: WheelEvent) {\n if (!this.isEnabled()) {\n return;\n }\n // Remove `any` cast when https://github.com/facebook/flow/issues/4879 is fixed.\n let value =\n e.deltaMode === window.WheelEvent.DOM_DELTA_LINE\n ? e.deltaY * 40\n : e.deltaY;\n const nowTime = now();\n const timeDelta = nowTime - (this.lastWheelEventTime || 0);\n\n this.lastWheelEventTime = nowTime;\n\n if (value !== 0 && value % wheelZoomDelta === 0) {\n // This one is definitely a mouse wheel event.\n this.type = 'wheel';\n } else if (value !== 0 && Math.abs(value) < 4) {\n // This one is definitely a trackpad event because it is so small.\n this.type = 'trackpad';\n } else if (timeDelta > 400) {\n // This is likely a new scroll action.\n this.type = null;\n this.lastValue = value;\n\n // Start a timeout in case this was a singular event, and dely it by up to 40ms.\n // @ts-ignore\n this.timeout = setTimeout(this.onTimeout, 40, e);\n } else if (!this.type) {\n // This is a repeating event, but we don't know the type of event just yet.\n // If the delta per time is small, we assume it's a fast trackpad; otherwise we switch into wheel mode.\n this.type = Math.abs(timeDelta * value) < 200 ? 'trackpad' : 'wheel';\n\n // Make sure our delayed event isn't fired again, because we accumulate\n // the previous event (which was less than 40ms ago) into this event.\n if (this.timeout) {\n clearTimeout(this.timeout);\n this.timeout = null;\n value += this.lastValue;\n }\n }\n\n // Slow down zoom if shift key is held for more precise zooming\n if (e.shiftKey && value) {\n value = value / 4;\n }\n // Only fire the callback if we actually know what type of scrolling device the user uses.\n if (this.type) {\n this.lastWheelEvent = e;\n this.delta -= value;\n if (!this.active) {\n this.start(e);\n }\n }\n\n e.preventDefault();\n }\n\n public renderFrame() {\n return this.onScrollFrame();\n }\n\n public reset() {\n this.active = false;\n }\n\n private onScrollFrame = () => {\n if (!this.frameId) {\n return;\n }\n this.frameId = null;\n\n if (!this.isActive()) {\n return;\n }\n const tr = this.map.transform;\n\n // if we've had scroll events since the last render frame, consume the\n // accumulated delta, and update the target zoom level accordingly\n if (this.delta !== 0) {\n // For trackpad events and single mouse wheel ticks, use the default zoom rate\n const zoomRate =\n this.type === 'wheel' && Math.abs(this.delta) > wheelZoomDelta\n ? this.wheelZoomRate\n : this.defaultZoomRate;\n // Scale by sigmoid of scroll wheel delta.\n let scale =\n maxScalePerFrame / (1 + Math.exp(-Math.abs(this.delta * zoomRate)));\n\n if (this.delta < 0 && scale !== 0) {\n scale = 1 / scale;\n }\n\n const fromScale =\n typeof this.targetZoom === 'number'\n ? tr.zoomScale(this.targetZoom)\n : tr.scale;\n this.targetZoom = Math.min(\n tr.maxZoom,\n Math.max(tr.minZoom, tr.scaleZoom(fromScale * scale)),\n );\n\n // if this is a mouse wheel, refresh the starting zoom and easing\n // function we're using to smooth out the zooming between wheel\n // events\n if (this.type === 'wheel') {\n this.startZoom = tr.zoom;\n this.easing = this.smoothOutEasing(200);\n }\n\n this.delta = 0;\n }\n\n const targetZoom =\n typeof this.targetZoom === 'number' ? this.targetZoom : tr.zoom;\n const startZoom = this.startZoom;\n const easing = this.easing;\n\n let finished = false;\n let zoom;\n if (this.type === 'wheel' && startZoom && easing) {\n const t = Math.min((now() - this.lastWheelEventTime) / 200, 1);\n const k = easing(t);\n zoom = interpolate(startZoom, targetZoom, k);\n if (t < 1) {\n if (!this.frameId) {\n this.frameId = true;\n }\n } else {\n finished = true;\n }\n } else {\n zoom = targetZoom;\n finished = true;\n }\n\n this.active = true;\n\n if (finished) {\n this.active = false;\n // @ts-ignore\n this.finishTimeout = setTimeout(() => {\n this.zooming = false;\n this.handler.triggerRenderFrame();\n // @ts-ignore\n delete this.targetZoom;\n // @ts-ignore\n delete this.finishTimeout;\n }, 200);\n }\n\n return {\n noInertia: true,\n needsRenderFrame: !finished,\n zoomDelta: zoom - tr.zoom,\n around: this.aroundPoint,\n originalEvent: this.lastWheelEvent,\n };\n };\n\n private onTimeout(initialEvent: any) {\n this.type = 'wheel';\n this.delta -= this.lastValue;\n if (!this.active && this.start) {\n this.start(initialEvent);\n }\n }\n\n private start(e: any) {\n if (!this.delta) {\n return;\n }\n\n if (this.frameId) {\n this.frameId = null;\n }\n\n this.active = true;\n if (!this.isZooming()) {\n this.zooming = true;\n }\n\n if (this.finishTimeout) {\n clearTimeout(this.finishTimeout);\n // @ts-ignore\n delete this.finishTimeout;\n }\n\n const pos = DOM.mousePos(this.el, e);\n\n this.around = LngLat.convert(\n this.aroundCenter ? this.map.getCenter() : this.map.unproject(pos),\n );\n this.aroundPoint = this.map.transform.locationPoint(this.around);\n if (!this.frameId) {\n this.frameId = true;\n this.handler.triggerRenderFrame();\n }\n }\n\n private smoothOutEasing(duration: number) {\n let easing = ease;\n\n if (this.prevEase) {\n const preEase = this.prevEase;\n const t = (now() - preEase.start) / preEase.duration;\n const speed = preEase.easing(t + 0.01) - preEase.easing(t);\n\n // Quick hack to make new bezier that is continuous with last\n const x = (0.27 / Math.sqrt(speed * speed + 0.0001)) * 0.01;\n const y = Math.sqrt(0.27 * 0.27 - x * x);\n\n easing = bezier(x, y, 0.25, 1);\n }\n\n this.prevEase = {\n start: now(),\n duration,\n easing,\n };\n\n return easing;\n }\n}\n\nexport default ScrollZoomHandler;\n"],"file":"scroll_zoom.js"}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = exports.
|
|
8
|
+
exports.default = exports.MAX_TOUCH_TIME = exports.MAX_TAP_INTERVAL = exports.MAX_DIST = void 0;
|
|
9
9
|
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
|