@math.gl/web-mercator 3.6.3 → 4.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assert.d.ts +1 -1
- package/dist/assert.d.ts.map +1 -1
- package/dist/{esm/assert.js → assert.js} +1 -1
- package/dist/assert.js.map +1 -0
- package/dist/fit-bounds.d.ts +1 -1
- package/dist/fit-bounds.d.ts.map +1 -1
- package/dist/{esm/fit-bounds.js → fit-bounds.js} +4 -4
- package/dist/fit-bounds.js.map +1 -0
- package/dist/fly-to-viewport.d.ts +1 -1
- package/dist/fly-to-viewport.d.ts.map +1 -1
- package/dist/{esm/fly-to-viewport.js → fly-to-viewport.js} +3 -3
- package/dist/fly-to-viewport.js.map +1 -0
- package/dist/get-bounds.d.ts +2 -2
- package/dist/get-bounds.d.ts.map +1 -1
- package/dist/{esm/get-bounds.js → get-bounds.js} +5 -5
- package/dist/get-bounds.js.map +1 -0
- package/dist/index.cjs +630 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/math-utils.js.map +1 -0
- package/dist/normalize-viewport-props.d.ts +1 -1
- package/dist/normalize-viewport-props.d.ts.map +1 -1
- package/dist/{esm/normalize-viewport-props.js → normalize-viewport-props.js} +3 -3
- package/dist/normalize-viewport-props.js.map +1 -0
- package/dist/{esm/web-mercator-utils.js → web-mercator-utils.js} +2 -2
- package/dist/web-mercator-utils.js.map +1 -0
- package/dist/web-mercator-viewport.d.ts +1 -1
- package/dist/web-mercator-viewport.d.ts.map +1 -1
- package/dist/{esm/web-mercator-viewport.js → web-mercator-viewport.js} +5 -5
- package/dist/web-mercator-viewport.js.map +1 -0
- package/package.json +6 -5
- package/src/assert.ts +1 -1
- package/src/fit-bounds.ts +2 -2
- package/src/fly-to-viewport.ts +2 -1
- package/src/get-bounds.ts +5 -4
- package/src/index.ts +8 -6
- package/src/normalize-viewport-props.ts +1 -1
- package/src/web-mercator-utils.ts +1 -1
- package/src/web-mercator-viewport.ts +3 -3
- package/dist/es5/assert.js +0 -13
- package/dist/es5/assert.js.map +0 -1
- package/dist/es5/fit-bounds.js +0 -73
- package/dist/es5/fit-bounds.js.map +0 -1
- package/dist/es5/fly-to-viewport.js +0 -151
- package/dist/es5/fly-to-viewport.js.map +0 -1
- package/dist/es5/get-bounds.js +0 -59
- package/dist/es5/get-bounds.js.map +0 -1
- package/dist/es5/index.js +0 -164
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/math-utils.js +0 -44
- package/dist/es5/math-utils.js.map +0 -1
- package/dist/es5/normalize-viewport-props.js +0 -63
- package/dist/es5/normalize-viewport-props.js.map +0 -1
- package/dist/es5/web-mercator-utils.js +0 -271
- package/dist/es5/web-mercator-utils.js.map +0 -1
- package/dist/es5/web-mercator-viewport.js +0 -328
- package/dist/es5/web-mercator-viewport.js.map +0 -1
- package/dist/esm/assert.js.map +0 -1
- package/dist/esm/fit-bounds.js.map +0 -1
- package/dist/esm/fly-to-viewport.js.map +0 -1
- package/dist/esm/get-bounds.js.map +0 -1
- package/dist/esm/index.js +0 -8
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/math-utils.js.map +0 -1
- package/dist/esm/normalize-viewport-props.js.map +0 -1
- package/dist/esm/web-mercator-utils.js.map +0 -1
- package/dist/esm/web-mercator-viewport.js.map +0 -1
- /package/dist/{esm/math-utils.js → math-utils.js} +0 -0
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.default = flyToViewport;
|
|
11
|
-
exports.getFlyToDuration = getFlyToDuration;
|
|
12
|
-
|
|
13
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
|
|
15
|
-
var _mathUtils = require("./math-utils");
|
|
16
|
-
|
|
17
|
-
var _webMercatorUtils = require("./web-mercator-utils");
|
|
18
|
-
|
|
19
|
-
var vec2 = _interopRequireWildcard(require("gl-matrix/vec2"));
|
|
20
|
-
|
|
21
|
-
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); }
|
|
22
|
-
|
|
23
|
-
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; }
|
|
24
|
-
|
|
25
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
26
|
-
|
|
27
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
28
|
-
|
|
29
|
-
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; } } }; }
|
|
30
|
-
|
|
31
|
-
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); }
|
|
32
|
-
|
|
33
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
34
|
-
|
|
35
|
-
var EPSILON = 0.01;
|
|
36
|
-
var VIEWPORT_TRANSITION_PROPS = ['longitude', 'latitude', 'zoom'];
|
|
37
|
-
var DEFAULT_OPTS = {
|
|
38
|
-
curve: 1.414,
|
|
39
|
-
speed: 1.2
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function flyToViewport(startProps, endProps, t, options) {
|
|
43
|
-
var _getFlyToTransitionPa = getFlyToTransitionParams(startProps, endProps, options),
|
|
44
|
-
startZoom = _getFlyToTransitionPa.startZoom,
|
|
45
|
-
startCenterXY = _getFlyToTransitionPa.startCenterXY,
|
|
46
|
-
uDelta = _getFlyToTransitionPa.uDelta,
|
|
47
|
-
w0 = _getFlyToTransitionPa.w0,
|
|
48
|
-
u1 = _getFlyToTransitionPa.u1,
|
|
49
|
-
S = _getFlyToTransitionPa.S,
|
|
50
|
-
rho = _getFlyToTransitionPa.rho,
|
|
51
|
-
rho2 = _getFlyToTransitionPa.rho2,
|
|
52
|
-
r0 = _getFlyToTransitionPa.r0;
|
|
53
|
-
|
|
54
|
-
if (u1 < EPSILON) {
|
|
55
|
-
var viewport = {};
|
|
56
|
-
|
|
57
|
-
var _iterator = _createForOfIteratorHelper(VIEWPORT_TRANSITION_PROPS),
|
|
58
|
-
_step;
|
|
59
|
-
|
|
60
|
-
try {
|
|
61
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
62
|
-
var key = _step.value;
|
|
63
|
-
var startValue = startProps[key];
|
|
64
|
-
var endValue = endProps[key];
|
|
65
|
-
viewport[key] = (0, _mathUtils.lerp)(startValue, endValue, t);
|
|
66
|
-
}
|
|
67
|
-
} catch (err) {
|
|
68
|
-
_iterator.e(err);
|
|
69
|
-
} finally {
|
|
70
|
-
_iterator.f();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return viewport;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
var s = t * S;
|
|
77
|
-
var w = Math.cosh(r0) / Math.cosh(r0 + rho * s);
|
|
78
|
-
var u = w0 * ((Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2) / u1;
|
|
79
|
-
var scaleIncrement = 1 / w;
|
|
80
|
-
var newZoom = startZoom + (0, _webMercatorUtils.scaleToZoom)(scaleIncrement);
|
|
81
|
-
var newCenterWorld = vec2.scale([], uDelta, u);
|
|
82
|
-
vec2.add(newCenterWorld, newCenterWorld, startCenterXY);
|
|
83
|
-
var newCenter = (0, _webMercatorUtils.worldToLngLat)(newCenterWorld);
|
|
84
|
-
return {
|
|
85
|
-
longitude: newCenter[0],
|
|
86
|
-
latitude: newCenter[1],
|
|
87
|
-
zoom: newZoom
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function getFlyToDuration(startProps, endProps, options) {
|
|
92
|
-
var opts = _objectSpread(_objectSpread({}, DEFAULT_OPTS), options);
|
|
93
|
-
|
|
94
|
-
var screenSpeed = opts.screenSpeed,
|
|
95
|
-
speed = opts.speed,
|
|
96
|
-
maxDuration = opts.maxDuration;
|
|
97
|
-
|
|
98
|
-
var _getFlyToTransitionPa2 = getFlyToTransitionParams(startProps, endProps, opts),
|
|
99
|
-
S = _getFlyToTransitionPa2.S,
|
|
100
|
-
rho = _getFlyToTransitionPa2.rho;
|
|
101
|
-
|
|
102
|
-
var length = 1000 * S;
|
|
103
|
-
var duration;
|
|
104
|
-
|
|
105
|
-
if (Number.isFinite(screenSpeed)) {
|
|
106
|
-
duration = length / (screenSpeed / rho);
|
|
107
|
-
} else {
|
|
108
|
-
duration = length / speed;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return Number.isFinite(maxDuration) && duration > maxDuration ? 0 : duration;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function getFlyToTransitionParams(startProps, endProps, opts) {
|
|
115
|
-
opts = Object.assign({}, DEFAULT_OPTS, opts);
|
|
116
|
-
var rho = opts.curve;
|
|
117
|
-
var startZoom = startProps.zoom;
|
|
118
|
-
var startCenter = [startProps.longitude, startProps.latitude];
|
|
119
|
-
var startScale = (0, _webMercatorUtils.zoomToScale)(startZoom);
|
|
120
|
-
var endZoom = endProps.zoom;
|
|
121
|
-
var endCenter = [endProps.longitude, endProps.latitude];
|
|
122
|
-
var scale = (0, _webMercatorUtils.zoomToScale)(endZoom - startZoom);
|
|
123
|
-
var startCenterXY = (0, _webMercatorUtils.lngLatToWorld)(startCenter);
|
|
124
|
-
var endCenterXY = (0, _webMercatorUtils.lngLatToWorld)(endCenter);
|
|
125
|
-
var uDelta = vec2.sub([], endCenterXY, startCenterXY);
|
|
126
|
-
var w0 = Math.max(startProps.width, startProps.height);
|
|
127
|
-
var w1 = w0 / scale;
|
|
128
|
-
var u1 = vec2.length(uDelta) * startScale;
|
|
129
|
-
|
|
130
|
-
var _u1 = Math.max(u1, EPSILON);
|
|
131
|
-
|
|
132
|
-
var rho2 = rho * rho;
|
|
133
|
-
var b0 = (w1 * w1 - w0 * w0 + rho2 * rho2 * _u1 * _u1) / (2 * w0 * rho2 * _u1);
|
|
134
|
-
var b1 = (w1 * w1 - w0 * w0 - rho2 * rho2 * _u1 * _u1) / (2 * w1 * rho2 * _u1);
|
|
135
|
-
var r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0);
|
|
136
|
-
var r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
|
|
137
|
-
var S = (r1 - r0) / rho;
|
|
138
|
-
return {
|
|
139
|
-
startZoom: startZoom,
|
|
140
|
-
startCenterXY: startCenterXY,
|
|
141
|
-
uDelta: uDelta,
|
|
142
|
-
w0: w0,
|
|
143
|
-
u1: u1,
|
|
144
|
-
S: S,
|
|
145
|
-
rho: rho,
|
|
146
|
-
rho2: rho2,
|
|
147
|
-
r0: r0,
|
|
148
|
-
r1: r1
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
//# sourceMappingURL=fly-to-viewport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fly-to-viewport.ts"],"names":["EPSILON","VIEWPORT_TRANSITION_PROPS","DEFAULT_OPTS","curve","speed","flyToViewport","startProps","endProps","t","options","getFlyToTransitionParams","startZoom","startCenterXY","uDelta","w0","u1","S","rho","rho2","r0","viewport","key","startValue","endValue","s","w","Math","cosh","u","tanh","sinh","scaleIncrement","newZoom","newCenterWorld","vec2","scale","add","newCenter","longitude","latitude","zoom","getFlyToDuration","opts","screenSpeed","maxDuration","length","duration","Number","isFinite","Object","assign","startCenter","startScale","endZoom","endCenter","endCenterXY","sub","max","width","height","w1","_u1","b0","b1","log","sqrt","r1"],"mappings":";;;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;;;;;;;AAIA,IAAMA,OAAO,GAAG,IAAhB;AACA,IAAMC,yBAAyB,GAAG,CAAC,WAAD,EAAc,UAAd,EAA0B,MAA1B,CAAlC;AACA,IAAMC,YAAY,GAAG;AACnBC,EAAAA,KAAK,EAAE,KADY;AAEnBC,EAAAA,KAAK,EAAE;AAFY,CAArB;;AAkBe,SAASC,aAAT,CACbC,UADa,EAEbC,QAFa,EAGbC,CAHa,EAIbC,OAJa,EASb;AAGA,8BAAqEC,wBAAwB,CAC3FJ,UAD2F,EAE3FC,QAF2F,EAG3FE,OAH2F,CAA7F;AAAA,MAAOE,SAAP,yBAAOA,SAAP;AAAA,MAAkBC,aAAlB,yBAAkBA,aAAlB;AAAA,MAAiCC,MAAjC,yBAAiCA,MAAjC;AAAA,MAAyCC,EAAzC,yBAAyCA,EAAzC;AAAA,MAA6CC,EAA7C,yBAA6CA,EAA7C;AAAA,MAAiDC,CAAjD,yBAAiDA,CAAjD;AAAA,MAAoDC,GAApD,yBAAoDA,GAApD;AAAA,MAAyDC,IAAzD,yBAAyDA,IAAzD;AAAA,MAA+DC,EAA/D,yBAA+DA,EAA/D;;AAOA,MAAIJ,EAAE,GAAGf,OAAT,EAAkB;AAChB,QAAMoB,QAAQ,GAAG,EAAjB;;AADgB,+CAEEnB,yBAFF;AAAA;;AAAA;AAEhB,0DAA6C;AAAA,YAAlCoB,GAAkC;AAC3C,YAAMC,UAAU,GAAGhB,UAAU,CAACe,GAAD,CAA7B;AACA,YAAME,QAAQ,GAAGhB,QAAQ,CAACc,GAAD,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AAE,GAAG/C,EAAN,IAAYF,GAAtB;AAEA,SAAO;AAACN,IAAAA,SAAS,EAATA,SAAD;AAAYC,IAAAA,aAAa,EAAbA,aAAZ;AAA2BC,IAAAA,MAAM,EAANA,MAA3B;AAAmCC,IAAAA,EAAE,EAAFA,EAAnC;AAAuCC,IAAAA,EAAE,EAAFA,EAAvC;AAA2CC,IAAAA,CAAC,EAADA,CAA3C;AAA8CC,IAAAA,GAAG,EAAHA,GAA9C;AAAmDC,IAAAA,IAAI,EAAJA,IAAnD;AAAyDC,IAAAA,EAAE,EAAFA,EAAzD;AAA6D+C,IAAAA,EAAE,EAAFA;AAA7D,GAAP;AACD","sourcesContent":["import {lerp} from './math-utils';\nimport {scaleToZoom, zoomToScale, lngLatToWorld, worldToLngLat} from './web-mercator-utils';\nimport * as vec2 from 'gl-matrix/vec2';\n\nimport type {ViewportProps} from './normalize-viewport-props';\n\nconst EPSILON = 0.01;\nconst VIEWPORT_TRANSITION_PROPS = ['longitude', 'latitude', 'zoom'] as const;\nconst DEFAULT_OPTS = {\n curve: 1.414,\n speed: 1.2\n // screenSpeed and maxDuration are used only if specified\n};\n\nexport type FlytoTransitionOptions = {\n curve?: number;\n speed?: number;\n screenSpeed?: number;\n maxDuration?: number;\n};\n\n/**\n * mapbox-gl-js flyTo : https://www.mapbox.com/mapbox-gl-js/api/#map#flyto.\n * It implements “Smooth and efficient zooming and panning.” algorithm by\n * \"Jarke J. van Wijk and Wim A.A. Nuij\"\n */\nexport default function flyToViewport(\n startProps: ViewportProps,\n endProps: ViewportProps,\n t: number,\n options?: FlytoTransitionOptions\n): {\n longitude: number;\n latitude: number;\n zoom: number;\n} {\n // Equations from above paper are referred where needed.\n\n const {startZoom, startCenterXY, uDelta, w0, u1, S, rho, rho2, r0} = getFlyToTransitionParams(\n startProps,\n endProps,\n options\n );\n\n // If change in center is too small, do linear interpolaiton.\n if (u1 < EPSILON) {\n const viewport = {};\n for (const key of VIEWPORT_TRANSITION_PROPS) {\n const startValue = startProps[key];\n const endValue = endProps[key];\n viewport[key] = lerp(startValue, endValue, t);\n }\n // @ts-expect-error properties are populated dynamically\n return viewport;\n }\n\n const s = t * S;\n\n const w = Math.cosh(r0) / Math.cosh(r0 + rho * s);\n const u = (w0 * ((Math.cosh(r0) * Math.tanh(r0 + rho * s) - Math.sinh(r0)) / rho2)) / u1;\n\n const scaleIncrement = 1 / w; // Using w method for scaling.\n const newZoom = startZoom + scaleToZoom(scaleIncrement);\n\n const newCenterWorld = vec2.scale([], uDelta, u);\n vec2.add(newCenterWorld, newCenterWorld, startCenterXY);\n\n const newCenter = worldToLngLat(newCenterWorld);\n return {\n longitude: newCenter[0],\n latitude: newCenter[1],\n zoom: newZoom\n };\n}\n\n// returns transition duration in milliseconds\nexport function getFlyToDuration(\n startProps: ViewportProps,\n endProps: ViewportProps,\n options?: FlytoTransitionOptions\n): number {\n const opts = {...DEFAULT_OPTS, ...options};\n const {screenSpeed, speed, maxDuration} = opts;\n const {S, rho} = getFlyToTransitionParams(startProps, endProps, opts);\n const length = 1000 * S;\n let duration: number;\n if (Number.isFinite(screenSpeed)) {\n duration = length / (screenSpeed / rho);\n } else {\n duration = length / speed;\n }\n\n return Number.isFinite(maxDuration) && duration > maxDuration ? 0 : duration;\n}\n\n// Private Methods\n\n// Calculate all parameters that are static for given startProps and endProps\nfunction getFlyToTransitionParams(\n startProps: ViewportProps,\n endProps: ViewportProps,\n opts: FlytoTransitionOptions\n): {\n startZoom: number;\n startCenterXY: number[];\n uDelta: number[];\n w0: number;\n u1: number;\n S: number;\n rho: number;\n rho2: number;\n r0: number;\n r1: number;\n} {\n opts = Object.assign({}, DEFAULT_OPTS, opts);\n const rho = opts.curve;\n const startZoom = startProps.zoom;\n const startCenter = [startProps.longitude, startProps.latitude];\n const startScale = zoomToScale(startZoom);\n const endZoom = endProps.zoom;\n const endCenter = [endProps.longitude, endProps.latitude];\n const scale = zoomToScale(endZoom - startZoom);\n\n const startCenterXY = lngLatToWorld(startCenter);\n const endCenterXY = lngLatToWorld(endCenter);\n const uDelta = vec2.sub([] as number[], endCenterXY, startCenterXY);\n\n const w0 = Math.max(startProps.width, startProps.height);\n const w1 = w0 / scale;\n const u1 = vec2.length(uDelta) * startScale;\n // u0 is treated as '0' in Eq (9).\n\n // If u1 is too small, will generate invalid number\n const _u1 = Math.max(u1, EPSILON);\n\n // Implement Equation (9) from above algorithm.\n const rho2 = rho * rho;\n const b0 = (w1 * w1 - w0 * w0 + rho2 * rho2 * _u1 * _u1) / (2 * w0 * rho2 * _u1);\n const b1 = (w1 * w1 - w0 * w0 - rho2 * rho2 * _u1 * _u1) / (2 * w1 * rho2 * _u1);\n const r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0);\n const r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);\n const S = (r1 - r0) / rho;\n\n return {startZoom, startCenterXY, uDelta, w0, u1, S, rho, rho2, r0, r1};\n}\n"],"file":"fly-to-viewport.js"}
|
package/dist/es5/get-bounds.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = getBounds;
|
|
9
|
-
|
|
10
|
-
var _webMercatorUtils = require("./web-mercator-utils");
|
|
11
|
-
|
|
12
|
-
var vec2 = _interopRequireWildcard(require("gl-matrix/vec2"));
|
|
13
|
-
|
|
14
|
-
var _mathUtils = require("./math-utils");
|
|
15
|
-
|
|
16
|
-
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); }
|
|
17
|
-
|
|
18
|
-
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; }
|
|
19
|
-
|
|
20
|
-
var DEGREES_TO_RADIANS = Math.PI / 180;
|
|
21
|
-
|
|
22
|
-
function getBounds(viewport) {
|
|
23
|
-
var z = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
24
|
-
var width = viewport.width,
|
|
25
|
-
height = viewport.height,
|
|
26
|
-
unproject = viewport.unproject;
|
|
27
|
-
var unprojectOps = {
|
|
28
|
-
targetZ: z
|
|
29
|
-
};
|
|
30
|
-
var bottomLeft = unproject([0, height], unprojectOps);
|
|
31
|
-
var bottomRight = unproject([width, height], unprojectOps);
|
|
32
|
-
var topLeft;
|
|
33
|
-
var topRight;
|
|
34
|
-
var halfFov = viewport.fovy ? 0.5 * viewport.fovy * DEGREES_TO_RADIANS : Math.atan(0.5 / viewport.altitude);
|
|
35
|
-
var angleToGround = (90 - viewport.pitch) * DEGREES_TO_RADIANS;
|
|
36
|
-
|
|
37
|
-
if (halfFov > angleToGround - 0.01) {
|
|
38
|
-
topLeft = unprojectOnFarPlane(viewport, 0, z);
|
|
39
|
-
topRight = unprojectOnFarPlane(viewport, width, z);
|
|
40
|
-
} else {
|
|
41
|
-
topLeft = unproject([0, 0], unprojectOps);
|
|
42
|
-
topRight = unproject([width, 0], unprojectOps);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return [bottomLeft, bottomRight, topRight, topLeft];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function unprojectOnFarPlane(viewport, x, targetZ) {
|
|
49
|
-
var pixelUnprojectionMatrix = viewport.pixelUnprojectionMatrix;
|
|
50
|
-
var coord0 = (0, _mathUtils.transformVector)(pixelUnprojectionMatrix, [x, 0, 1, 1]);
|
|
51
|
-
var coord1 = (0, _mathUtils.transformVector)(pixelUnprojectionMatrix, [x, viewport.height, 1, 1]);
|
|
52
|
-
var z = targetZ * viewport.distanceScales.unitsPerMeter[2];
|
|
53
|
-
var t = (z - coord0[2]) / (coord1[2] - coord0[2]);
|
|
54
|
-
var coord = vec2.lerp([], coord0, coord1, t);
|
|
55
|
-
var result = (0, _webMercatorUtils.worldToLngLat)(coord);
|
|
56
|
-
result.push(targetZ);
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=get-bounds.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/get-bounds.ts"],"names":["DEGREES_TO_RADIANS","Math","PI","getBounds","viewport","z","width","height","unproject","unprojectOps","targetZ","bottomLeft","bottomRight","topLeft","topRight","halfFov","fovy","atan","altitude","angleToGround","pitch","unprojectOnFarPlane","x","pixelUnprojectionMatrix","coord0","coord1","distanceScales","unitsPerMeter","t","coord","vec2","lerp","result","push"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;;;;;AAGA,IAAMA,kBAAkB,GAAGC,IAAI,CAACC,EAAL,GAAU,GAArC;;AAOe,SAASC,SAAT,CAAmBC,QAAnB,EAA6E;AAAA,MAA3BC,CAA2B,uEAAf,CAAe;AAE1F,MAAOC,KAAP,GAAmCF,QAAnC,CAAOE,KAAP;AAAA,MAAcC,MAAd,GAAmCH,QAAnC,CAAcG,MAAd;AAAA,MAAsBC,SAAtB,GAAmCJ,QAAnC,CAAsBI,SAAtB;AACA,MAAMC,YAAY,GAAG;AAACC,IAAAA,OAAO,EAAEL;AAAV,G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G,gCAAgBF,uBAAhB,EAAyC,CAACD,CAAD,EAAIlB,QAAQ,CAACG,MAAb,EAAqB,CAArB,EAAwB,CAAxB,CAAzC,CAAf;AAEA,MAAMF,CAAC,GAAGK,OAAO,GAAGN,QAAQ,CAACsB,cAAT,CAAwBC,aAAxB,CAAsC,CAAtC,CAApB;AACA,MAAMC,CAAC,GAAG,CAACvB,CAAC,GAAGmB,MAAM,CAAC,CAAD,CAAX,KAAmBC,MAAM,CAAC,CAAD,CAAN,GAAYD,MAAM,CAAC,CAAD,CAArC,CAAV;AACA,MAAMK,KAAK,GAAGC,IAAI,CAACC,IAAL,CAAU,EAAV,EAAcP,MAAd,EAAsBC,MAAtB,EAA8BG,CAA9B,CAAd;AAEA,MAAMI,MAAM,GAAG,qCAAcH,KAAd,CAAf;AACAG,EAAAA,MAAM,CAACC,IAAP,CAAYvB,OAAZ;AACA,SAAOsB,MAAP;AACD","sourcesContent":["import {worldToLngLat} from './web-mercator-utils';\nimport * as vec2 from 'gl-matrix/vec2';\nimport {transformVector} from './math-utils';\nimport type WebMercatorViewport from './web-mercator-viewport';\n\nconst DEGREES_TO_RADIANS = Math.PI / 180;\n\n/*\n * Returns the quad at the intersection of the frustum and the given z plane\n * @param {WebMercatorViewport} viewport\n * @param {Number} z - elevation in meters\n */\nexport default function getBounds(viewport: WebMercatorViewport, z: number = 0): number[][] {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const {width, height, unproject} = viewport;\n const unprojectOps = {targetZ: z};\n const bottomLeft = unproject([0, height], unprojectOps);\n const bottomRight = unproject([width, height], unprojectOps);\n let topLeft: number[];\n let topRight: number[];\n\n const halfFov = viewport.fovy\n ? 0.5 * viewport.fovy * DEGREES_TO_RADIANS\n : Math.atan(0.5 / viewport.altitude);\n const angleToGround = (90 - viewport.pitch) * DEGREES_TO_RADIANS;\n // The top plane is parallel to the ground if halfFov == angleToGround\n if (halfFov > angleToGround - 0.01) {\n // intersect with the far plane\n topLeft = unprojectOnFarPlane(viewport, 0, z);\n topRight = unprojectOnFarPlane(viewport, width, z);\n } else {\n // intersect with the top plane\n topLeft = unproject([0, 0], unprojectOps);\n topRight = unproject([width, 0], unprojectOps);\n }\n\n return [bottomLeft, bottomRight, topRight, topLeft];\n}\n\n/*\n * Find a point on the far clipping plane of the viewport\n * @param {WebMercatorViewport} viewport\n * @param {Number} x - projected x in screen space\n * @param {Number} targetZ - the elevation of the point in meters\n */\nfunction unprojectOnFarPlane(viewport: WebMercatorViewport, x: number, targetZ: number): number[] {\n const {pixelUnprojectionMatrix} = viewport;\n const coord0 = transformVector(pixelUnprojectionMatrix, [x, 0, 1, 1]);\n const coord1 = transformVector(pixelUnprojectionMatrix, [x, viewport.height, 1, 1]);\n\n const z = targetZ * viewport.distanceScales.unitsPerMeter[2];\n const t = (z - coord0[2]) / (coord1[2] - coord0[2]);\n const coord = vec2.lerp([], coord0, coord1, t);\n\n const result = worldToLngLat(coord);\n result.push(targetZ);\n return result;\n}\n"],"file":"get-bounds.js"}
|
package/dist/es5/index.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
Object.defineProperty(exports, "default", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _webMercatorViewport.default;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(exports, "WebMercatorViewport", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function get() {
|
|
19
|
-
return _webMercatorViewport.default;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
Object.defineProperty(exports, "getBounds", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function get() {
|
|
25
|
-
return _getBounds.default;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports, "fitBounds", {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function get() {
|
|
31
|
-
return _fitBounds.default;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(exports, "normalizeViewportProps", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function get() {
|
|
37
|
-
return _normalizeViewportProps.default;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
Object.defineProperty(exports, "flyToViewport", {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
get: function get() {
|
|
43
|
-
return _flyToViewport.default;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
Object.defineProperty(exports, "getFlyToDuration", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
get: function get() {
|
|
49
|
-
return _flyToViewport.getFlyToDuration;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
Object.defineProperty(exports, "MAX_LATITUDE", {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
get: function get() {
|
|
55
|
-
return _webMercatorUtils.MAX_LATITUDE;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperty(exports, "lngLatToWorld", {
|
|
59
|
-
enumerable: true,
|
|
60
|
-
get: function get() {
|
|
61
|
-
return _webMercatorUtils.lngLatToWorld;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
Object.defineProperty(exports, "worldToLngLat", {
|
|
65
|
-
enumerable: true,
|
|
66
|
-
get: function get() {
|
|
67
|
-
return _webMercatorUtils.worldToLngLat;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
Object.defineProperty(exports, "worldToPixels", {
|
|
71
|
-
enumerable: true,
|
|
72
|
-
get: function get() {
|
|
73
|
-
return _webMercatorUtils.worldToPixels;
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
Object.defineProperty(exports, "pixelsToWorld", {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function get() {
|
|
79
|
-
return _webMercatorUtils.pixelsToWorld;
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
Object.defineProperty(exports, "zoomToScale", {
|
|
83
|
-
enumerable: true,
|
|
84
|
-
get: function get() {
|
|
85
|
-
return _webMercatorUtils.zoomToScale;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
Object.defineProperty(exports, "scaleToZoom", {
|
|
89
|
-
enumerable: true,
|
|
90
|
-
get: function get() {
|
|
91
|
-
return _webMercatorUtils.scaleToZoom;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
Object.defineProperty(exports, "altitudeToFovy", {
|
|
95
|
-
enumerable: true,
|
|
96
|
-
get: function get() {
|
|
97
|
-
return _webMercatorUtils.altitudeToFovy;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
Object.defineProperty(exports, "fovyToAltitude", {
|
|
101
|
-
enumerable: true,
|
|
102
|
-
get: function get() {
|
|
103
|
-
return _webMercatorUtils.fovyToAltitude;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
Object.defineProperty(exports, "getMeterZoom", {
|
|
107
|
-
enumerable: true,
|
|
108
|
-
get: function get() {
|
|
109
|
-
return _webMercatorUtils.getMeterZoom;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
Object.defineProperty(exports, "unitsPerMeter", {
|
|
113
|
-
enumerable: true,
|
|
114
|
-
get: function get() {
|
|
115
|
-
return _webMercatorUtils.unitsPerMeter;
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
Object.defineProperty(exports, "getDistanceScales", {
|
|
119
|
-
enumerable: true,
|
|
120
|
-
get: function get() {
|
|
121
|
-
return _webMercatorUtils.getDistanceScales;
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
Object.defineProperty(exports, "addMetersToLngLat", {
|
|
125
|
-
enumerable: true,
|
|
126
|
-
get: function get() {
|
|
127
|
-
return _webMercatorUtils.addMetersToLngLat;
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
Object.defineProperty(exports, "getViewMatrix", {
|
|
131
|
-
enumerable: true,
|
|
132
|
-
get: function get() {
|
|
133
|
-
return _webMercatorUtils.getViewMatrix;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
Object.defineProperty(exports, "getProjectionMatrix", {
|
|
137
|
-
enumerable: true,
|
|
138
|
-
get: function get() {
|
|
139
|
-
return _webMercatorUtils.getProjectionMatrix;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
Object.defineProperty(exports, "getProjectionParameters", {
|
|
143
|
-
enumerable: true,
|
|
144
|
-
get: function get() {
|
|
145
|
-
return _webMercatorUtils.getProjectionParameters;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
var _webMercatorViewport = _interopRequireDefault(require("./web-mercator-viewport"));
|
|
150
|
-
|
|
151
|
-
var _getBounds = _interopRequireDefault(require("./get-bounds"));
|
|
152
|
-
|
|
153
|
-
var _fitBounds = _interopRequireDefault(require("./fit-bounds"));
|
|
154
|
-
|
|
155
|
-
var _normalizeViewportProps = _interopRequireDefault(require("./normalize-viewport-props"));
|
|
156
|
-
|
|
157
|
-
var _flyToViewport = _interopRequireWildcard(require("./fly-to-viewport"));
|
|
158
|
-
|
|
159
|
-
var _webMercatorUtils = require("./web-mercator-utils");
|
|
160
|
-
|
|
161
|
-
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); }
|
|
162
|
-
|
|
163
|
-
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; }
|
|
164
|
-
//# sourceMappingURL=index.js.map
|
package/dist/es5/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAGA;;AACA;;AACA;;AACA;;AAEA","sourcesContent":["// Classic web-mercator-project\nexport {default} from './web-mercator-viewport';\nexport {default as WebMercatorViewport} from './web-mercator-viewport';\n\nexport {default as getBounds} from './get-bounds';\nexport {default as fitBounds} from './fit-bounds';\nexport {default as normalizeViewportProps} from './normalize-viewport-props';\nexport {default as flyToViewport, getFlyToDuration} from './fly-to-viewport';\n\nexport {\n MAX_LATITUDE,\n lngLatToWorld,\n worldToLngLat,\n worldToPixels,\n pixelsToWorld,\n zoomToScale,\n scaleToZoom,\n altitudeToFovy,\n fovyToAltitude,\n getMeterZoom,\n unitsPerMeter,\n getDistanceScales,\n addMetersToLngLat,\n getViewMatrix,\n getProjectionMatrix,\n getProjectionParameters\n} from './web-mercator-utils';\n\n/** Types */\nexport type {FitBoundsOptions} from './fit-bounds';\nexport type {DistanceScales} from './web-mercator-utils';\n"],"file":"index.js"}
|
package/dist/es5/math-utils.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createMat4 = createMat4;
|
|
7
|
-
exports.transformVector = transformVector;
|
|
8
|
-
exports.mod = mod;
|
|
9
|
-
exports.lerp = lerp;
|
|
10
|
-
exports.clamp = clamp;
|
|
11
|
-
exports.log2 = void 0;
|
|
12
|
-
|
|
13
|
-
var _vec = require("gl-matrix/vec4");
|
|
14
|
-
|
|
15
|
-
function createMat4() {
|
|
16
|
-
return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function transformVector(matrix, vector) {
|
|
20
|
-
var result = (0, _vec.transformMat4)([], vector, matrix);
|
|
21
|
-
(0, _vec.scale)(result, result, 1 / result[3]);
|
|
22
|
-
return result;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function mod(value, divisor) {
|
|
26
|
-
var modulus = value % divisor;
|
|
27
|
-
return modulus < 0 ? divisor + modulus : modulus;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function lerp(start, end, step) {
|
|
31
|
-
return step * end + (1 - step) * start;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function clamp(x, min, max) {
|
|
35
|
-
return x < min ? min : x > max ? max : x;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function ieLog2(x) {
|
|
39
|
-
return Math.log(x) * Math.LOG2E;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var log2 = Math.log2 || ieLog2;
|
|
43
|
-
exports.log2 = log2;
|
|
44
|
-
//# sourceMappingURL=math-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/math-utils.ts"],"names":["createMat4","transformVector","matrix","vector","result","mod","value","divisor","modulus","lerp","start","end","step","clamp","x","min","max","ieLog2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cesContent":["import {transformMat4, scale} from 'gl-matrix/vec4';\n\n// Helper, avoids low-precision 32 bit matrices from gl-matrix mat4.create()\nexport function createMat4(): number[] {\n return [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n}\n\n// Transforms a vec4 with a projection matrix\nexport function transformVector(matrix: number[], vector: number[]): number[] {\n const result = transformMat4([] as number[], vector, matrix);\n scale(result, result, 1 / result[3]);\n return result;\n}\n\nexport function mod(value: number, divisor: number): number {\n const modulus = value % divisor;\n return modulus < 0 ? divisor + modulus : modulus;\n}\n\nexport function lerp(start: number, end: number, step: number): number {\n return step * end + (1 - step) * start;\n}\n\nexport function clamp(x: number, min: number, max: number): number {\n return x < min ? min : x > max ? max : x;\n}\n\nfunction ieLog2(x: number): number {\n return Math.log(x) * Math.LOG2E;\n}\n// Handle missing log2 in IE 11\nexport const log2 = Math.log2 || ieLog2;\n"],"file":"math-utils.js"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = normalizeViewportProps;
|
|
7
|
-
|
|
8
|
-
var _webMercatorUtils = require("./web-mercator-utils");
|
|
9
|
-
|
|
10
|
-
var _mathUtils = require("./math-utils");
|
|
11
|
-
|
|
12
|
-
var TILE_SIZE = 512;
|
|
13
|
-
|
|
14
|
-
function normalizeViewportProps(props) {
|
|
15
|
-
var width = props.width,
|
|
16
|
-
height = props.height,
|
|
17
|
-
_props$pitch = props.pitch,
|
|
18
|
-
pitch = _props$pitch === void 0 ? 0 : _props$pitch;
|
|
19
|
-
var longitude = props.longitude,
|
|
20
|
-
latitude = props.latitude,
|
|
21
|
-
zoom = props.zoom,
|
|
22
|
-
_props$bearing = props.bearing,
|
|
23
|
-
bearing = _props$bearing === void 0 ? 0 : _props$bearing;
|
|
24
|
-
|
|
25
|
-
if (longitude < -180 || longitude > 180) {
|
|
26
|
-
longitude = (0, _mathUtils.mod)(longitude + 180, 360) - 180;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (bearing < -180 || bearing > 180) {
|
|
30
|
-
bearing = (0, _mathUtils.mod)(bearing + 180, 360) - 180;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var minZoom = (0, _mathUtils.log2)(height / TILE_SIZE);
|
|
34
|
-
|
|
35
|
-
if (zoom <= minZoom) {
|
|
36
|
-
zoom = minZoom;
|
|
37
|
-
latitude = 0;
|
|
38
|
-
} else {
|
|
39
|
-
var halfHeightPixels = height / 2 / Math.pow(2, zoom);
|
|
40
|
-
var minLatitude = (0, _webMercatorUtils.worldToLngLat)([0, halfHeightPixels])[1];
|
|
41
|
-
|
|
42
|
-
if (latitude < minLatitude) {
|
|
43
|
-
latitude = minLatitude;
|
|
44
|
-
} else {
|
|
45
|
-
var maxLatitude = (0, _webMercatorUtils.worldToLngLat)([0, TILE_SIZE - halfHeightPixels])[1];
|
|
46
|
-
|
|
47
|
-
if (latitude > maxLatitude) {
|
|
48
|
-
latitude = maxLatitude;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
width: width,
|
|
55
|
-
height: height,
|
|
56
|
-
longitude: longitude,
|
|
57
|
-
latitude: latitude,
|
|
58
|
-
zoom: zoom,
|
|
59
|
-
pitch: pitch,
|
|
60
|
-
bearing: bearing
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=normalize-viewport-props.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/normalize-viewport-props.ts"],"names":["TILE_SIZE","normalizeViewportProps","props","width","height","pitch","longitude","latitude","zoom","bearing","minZoom","halfHeightPixels","Math","pow","minLatitude","maxLatitude"],"mappings":";;;;;;;AAAA;;AACA;;AAGA,IAAMA,SAAS,GAAG,GAAlB;;AAkBe,SAASC,sBA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AAW,GAAG,qCAAc,CAAC,CAAD,EAAIf,SAAS,GAAGW,gBAAhB,CAAd,EAAiD,CAAjD,CAApB;;AACA,UAAIJ,QAAQ,GAAGQ,WAAf,EAA4B;AAC1BR,QAAAA,QAAQ,GAAGQ,WAAX;AACD;AACF;AACF;;AAED,SAAO;AAACZ,IAAAA,KAAK,EAALA,KAAD;AAAQC,IAAAA,MAAM,EAANA,MAAR;AAAgBE,IAAAA,SAAS,EAATA,SAAhB;AAA2BC,IAAAA,QAAQ,EAARA,QAA3B;AAAqCC,IAAAA,IAAI,EAAJA,IAArC;AAA2CH,IAAAA,KAAK,EAALA,KAA3C;AAAkDI,IAAAA,OAAO,EAAPA;AAAlD,GAAP;AACD","sourcesContent":["import {worldToLngLat} from './web-mercator-utils';\nimport {mod, log2} from './math-utils';\n\n// defined by mapbox-gl\nconst TILE_SIZE = 512;\n\n/** Description of viewport */\nexport type ViewportProps = {\n width: number;\n height: number;\n longitude: number;\n latitude: number;\n zoom: number;\n pitch?: number;\n bearing?: number;\n};\n\n/**\n * Apply mathematical constraints to viewport props\n * @param props\n */\n// eslint-disable-next-line complexity\nexport default function normalizeViewportProps(props: ViewportProps): ViewportProps {\n const {width, height, pitch = 0} = props;\n let {longitude, latitude, zoom, bearing = 0} = props;\n\n // Normalize degrees\n if (longitude < -180 || longitude > 180) {\n longitude = mod(longitude + 180, 360) - 180;\n }\n if (bearing < -180 || bearing > 180) {\n bearing = mod(bearing + 180, 360) - 180;\n }\n\n // Constrain zoom and shift center at low zoom levels\n const minZoom = log2(height / TILE_SIZE);\n if (zoom <= minZoom) {\n zoom = minZoom;\n latitude = 0;\n } else {\n // Eliminate white space above and below the map\n const halfHeightPixels = height / 2 / Math.pow(2, zoom);\n const minLatitude = worldToLngLat([0, halfHeightPixels])[1];\n if (latitude < minLatitude) {\n latitude = minLatitude;\n } else {\n const maxLatitude = worldToLngLat([0, TILE_SIZE - halfHeightPixels])[1];\n if (latitude > maxLatitude) {\n latitude = maxLatitude;\n }\n }\n }\n\n return {width, height, longitude, latitude, zoom, pitch, bearing};\n}\n"],"file":"normalize-viewport-props.js"}
|