@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.
Files changed (70) hide show
  1. package/dist/assert.d.ts +1 -1
  2. package/dist/assert.d.ts.map +1 -1
  3. package/dist/{esm/assert.js → assert.js} +1 -1
  4. package/dist/assert.js.map +1 -0
  5. package/dist/fit-bounds.d.ts +1 -1
  6. package/dist/fit-bounds.d.ts.map +1 -1
  7. package/dist/{esm/fit-bounds.js → fit-bounds.js} +4 -4
  8. package/dist/fit-bounds.js.map +1 -0
  9. package/dist/fly-to-viewport.d.ts +1 -1
  10. package/dist/fly-to-viewport.d.ts.map +1 -1
  11. package/dist/{esm/fly-to-viewport.js → fly-to-viewport.js} +3 -3
  12. package/dist/fly-to-viewport.js.map +1 -0
  13. package/dist/get-bounds.d.ts +2 -2
  14. package/dist/get-bounds.d.ts.map +1 -1
  15. package/dist/{esm/get-bounds.js → get-bounds.js} +5 -5
  16. package/dist/get-bounds.js.map +1 -0
  17. package/dist/index.cjs +630 -0
  18. package/dist/index.d.ts +7 -6
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +8 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/math-utils.js.map +1 -0
  23. package/dist/normalize-viewport-props.d.ts +1 -1
  24. package/dist/normalize-viewport-props.d.ts.map +1 -1
  25. package/dist/{esm/normalize-viewport-props.js → normalize-viewport-props.js} +3 -3
  26. package/dist/normalize-viewport-props.js.map +1 -0
  27. package/dist/{esm/web-mercator-utils.js → web-mercator-utils.js} +2 -2
  28. package/dist/web-mercator-utils.js.map +1 -0
  29. package/dist/web-mercator-viewport.d.ts +1 -1
  30. package/dist/web-mercator-viewport.d.ts.map +1 -1
  31. package/dist/{esm/web-mercator-viewport.js → web-mercator-viewport.js} +5 -5
  32. package/dist/web-mercator-viewport.js.map +1 -0
  33. package/package.json +6 -5
  34. package/src/assert.ts +1 -1
  35. package/src/fit-bounds.ts +2 -2
  36. package/src/fly-to-viewport.ts +2 -1
  37. package/src/get-bounds.ts +5 -4
  38. package/src/index.ts +8 -6
  39. package/src/normalize-viewport-props.ts +1 -1
  40. package/src/web-mercator-utils.ts +1 -1
  41. package/src/web-mercator-viewport.ts +3 -3
  42. package/dist/es5/assert.js +0 -13
  43. package/dist/es5/assert.js.map +0 -1
  44. package/dist/es5/fit-bounds.js +0 -73
  45. package/dist/es5/fit-bounds.js.map +0 -1
  46. package/dist/es5/fly-to-viewport.js +0 -151
  47. package/dist/es5/fly-to-viewport.js.map +0 -1
  48. package/dist/es5/get-bounds.js +0 -59
  49. package/dist/es5/get-bounds.js.map +0 -1
  50. package/dist/es5/index.js +0 -164
  51. package/dist/es5/index.js.map +0 -1
  52. package/dist/es5/math-utils.js +0 -44
  53. package/dist/es5/math-utils.js.map +0 -1
  54. package/dist/es5/normalize-viewport-props.js +0 -63
  55. package/dist/es5/normalize-viewport-props.js.map +0 -1
  56. package/dist/es5/web-mercator-utils.js +0 -271
  57. package/dist/es5/web-mercator-utils.js.map +0 -1
  58. package/dist/es5/web-mercator-viewport.js +0 -328
  59. package/dist/es5/web-mercator-viewport.js.map +0 -1
  60. package/dist/esm/assert.js.map +0 -1
  61. package/dist/esm/fit-bounds.js.map +0 -1
  62. package/dist/esm/fly-to-viewport.js.map +0 -1
  63. package/dist/esm/get-bounds.js.map +0 -1
  64. package/dist/esm/index.js +0 -8
  65. package/dist/esm/index.js.map +0 -1
  66. package/dist/esm/math-utils.js.map +0 -1
  67. package/dist/esm/normalize-viewport-props.js.map +0 -1
  68. package/dist/esm/web-mercator-utils.js.map +0 -1
  69. package/dist/esm/web-mercator-viewport.js.map +0 -1
  70. /package/dist/{esm/math-utils.js → math-utils.js} +0 -0
package/dist/assert.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export default function assert(condition: unknown, message?: string): void;
1
+ export declare function assert(condition: unknown, message?: string): void;
2
2
  //# sourceMappingURL=assert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAIzE"}
1
+ {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAGA,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAIjE"}
@@ -1,4 +1,4 @@
1
- export default function assert(condition, message) {
1
+ export function assert(condition, message) {
2
2
  if (!condition) {
3
3
  throw new Error(message || '@math.gl/web-mercator: assertion failed.');
4
4
  }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/assert.ts"],"names":["assert","condition","message","Error"],"mappings":"AAGA,OAAO,SAASA,MAAT,CAAgBC,SAAhB,EAAoCC,OAApC,EAA4D;AACjE,MAAI,CAACD,SAAL,EAAgB;AACd,UAAM,IAAIE,KAAJ,CAAUD,OAAO,IAAI,0CAArB,CAAN;AACD;AACF","sourcesContent":["// Replacement for the external assert method to reduce bundle size\n// Note: We don't use the second \"message\" argument in calling code,\n// so no need to support it here\nexport function assert(condition: unknown, message?: string): void {\n if (!condition) {\n throw new Error(message || '@math.gl/web-mercator: assertion failed.');\n }\n}\n"],"file":"assert.js"}
@@ -45,6 +45,6 @@ declare type ViewportProps = {
45
45
  * @param options fit bounds parameters
46
46
  * @returns - latitude, longitude and zoom
47
47
  */
48
- export default function fitBounds(options: FitBoundsOptions): ViewportProps;
48
+ export declare function fitBounds(options: FitBoundsOptions): ViewportProps;
49
49
  export {};
50
50
  //# sourceMappingURL=fit-bounds.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fit-bounds.d.ts","sourceRoot":"","sources":["../src/fit-bounds.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,oBAAY,gBAAgB,GAAG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BAAY,OAAO,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,aAAK,aAAa,GAAG;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,aAAa,CAiDlE"}
@@ -1,7 +1,7 @@
1
- import assert from './assert';
2
- import { log2, clamp } from './math-utils';
3
- import { MAX_LATITUDE, lngLatToWorld, worldToLngLat } from './web-mercator-utils';
4
- export default function fitBounds(options) {
1
+ import { assert } from "./assert.js";
2
+ import { log2, clamp } from "./math-utils.js";
3
+ import { MAX_LATITUDE, lngLatToWorld, worldToLngLat } from "./web-mercator-utils.js";
4
+ export function fitBounds(options) {
5
5
  const {
6
6
  width,
7
7
  height,
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/fit-bounds.ts"],"names":["assert","log2","clamp","MAX_LATITUDE","lngLatToWorld","worldToLngLat","fitBounds","options","width","height","bounds","minExtent","maxZoom","offset","west","south","east","north","padding","getPaddingObject","nw","se","size","Math","max","abs","targetSize","left","right","top","bottom","scaleX","scaleY","offsetX","offsetY","center","centerLngLat","zoom","min","Number","isFinite","longitude","latitude"],"mappings":"SAAQA,M;SACAC,I,EAAMC,K;SACNC,Y,EAAcC,a,EAAeC,a;AAqDrC,OAAO,SAASC,SAAT,CAAmBC,OAAnB,EAA6D;AAClE,QAAM;AACJC,IAAAA,KADI;AAEJC,IAAAA,MAFI;AAGJC,IAAAA,MAHI;AAIJC,IAAAA,SAAS,GAAG,CAJR;AAKJC,IAAAA,OAAO,GAAG,EALN;AAMJC,IAAAA,MAAM,GAAG,CAAC,CAAD,EAAI,CAAJ;AANL,MAOFN,OAPJ;AAS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AAA,KAAK,EAAEV;AAJF,KAAP;AAMD;;AAGDlB,EAAAA,MAAM,CACJuC,MAAM,CAACC,QAAP,CAAgBtB,OAAO,CAACW,GAAxB,KACEU,MAAM,CAACC,QAAP,CAAgBtB,OAAO,CAACY,MAAxB,CADF,IAEES,MAAM,CAACC,QAAP,CAAgBtB,OAAO,CAACS,IAAxB,CAFF,IAGEY,MAAM,CAACC,QAAP,CAAgBtB,OAAO,CAACU,KAAxB,CAJE,CAAN;AAOA,SAAOV,OAAP;AACD","sourcesContent":["import {assert} from './assert';\nimport {log2, clamp} from './math-utils';\nimport {MAX_LATITUDE, lngLatToWorld, worldToLngLat} from './web-mercator-utils';\n\n/**\n * Options for fitBounds\n * @param width - viewport width\n * @param height - viewport height\n * @param bounds - [[lon, lat], [lon, lat]]\n * @param minExtent - The width/height of the bounded area will never be smaller than this\n * @param padding - The amount of padding in pixels\n * to add to the given bounds. Can also be an object with top, bottom, left and right\n * properties defining the padding.\n * @param options.offset= - The center of the given bounds relative to the map's center,\n */\nexport type FitBoundsOptions = {\n width: number;\n height: number;\n bounds: [[number, number], [number, number]];\n minExtent?: number; // 0.01 would be about 1000 meters (degree is ~110KM)\n maxZoom?: number; // ~x4,000,000 => About 10 meter extents\n // options\n padding?: number | Padding;\n offset?: number[];\n};\n\n/**\n * An object describing the padding to add to the bounds.\n * @property top - Padding from top in pixels to add to the given bounds\n * @property bottom - Padding from bottom in pixels to add to the given bounds\n * @property left - Padding from left in pixels to add to the given bounds\n * @property right - Padding from right in pixels to add to the given bounds\n */\nexport type Padding = {\n top: number;\n bottom: number;\n left: number;\n right: number;\n};\n\ntype ViewportProps = {\n longitude: number;\n latitude: number;\n zoom: number;\n};\n\n/**\n * Returns map settings {latitude, longitude, zoom}\n * that will contain the provided corners within the provided width.\n *\n * > _Note: Only supports non-perspective mode._\n *\n * @param options fit bounds parameters\n * @returns - latitude, longitude and zoom\n */\nexport function fitBounds(options: FitBoundsOptions): ViewportProps {\n const {\n width,\n height,\n bounds,\n minExtent = 0, // 0.01 would be about 1000 meters (degree is ~110KM)\n maxZoom = 24, // ~x4,000,000 => About 10 meter extents\n offset = [0, 0]\n } = options;\n\n const [[west, south], [east, north]] = bounds;\n const padding = getPaddingObject(options.padding);\n\n const nw = lngLatToWorld([west, clamp(north, -MAX_LATITUDE, MAX_LATITUDE)]);\n const se = lngLatToWorld([east, clamp(south, -MAX_LATITUDE, MAX_LATITUDE)]);\n\n // width/height on the Web Mercator plane\n const size = [\n Math.max(Math.abs(se[0] - nw[0]), minExtent),\n Math.max(Math.abs(se[1] - nw[1]), minExtent)\n ];\n\n const targetSize = [\n width - padding.left - padding.right - Math.abs(offset[0]) * 2,\n height - padding.top - padding.bottom - Math.abs(offset[1]) * 2\n ];\n\n assert(targetSize[0] > 0 && targetSize[1] > 0);\n\n // scale = screen pixels per unit on the Web Mercator plane\n const scaleX = targetSize[0] / size[0];\n const scaleY = targetSize[1] / size[1];\n\n // Find how much we need to shift the center\n const offsetX = (padding.right - padding.left) / 2 / scaleX;\n const offsetY = (padding.top - padding.bottom) / 2 / scaleY;\n\n const center = [(se[0] + nw[0]) / 2 + offsetX, (se[1] + nw[1]) / 2 + offsetY];\n\n const centerLngLat = worldToLngLat(center);\n const zoom = Math.min(maxZoom, log2(Math.abs(Math.min(scaleX, scaleY))));\n\n assert(Number.isFinite(zoom));\n\n return {\n longitude: centerLngLat[0],\n latitude: centerLngLat[1],\n zoom\n };\n}\n\n// Helpers\nfunction getPaddingObject(padding: number | Padding = 0): Padding {\n if (typeof padding === 'number') {\n return {\n top: padding,\n bottom: padding,\n left: padding,\n right: padding\n };\n }\n\n // Make sure all the required properties are set\n assert(\n Number.isFinite(padding.top) &&\n Number.isFinite(padding.bottom) &&\n Number.isFinite(padding.left) &&\n Number.isFinite(padding.right)\n );\n\n return padding;\n}\n"],"file":"fit-bounds.js"}
@@ -10,7 +10,7 @@ export declare type FlytoTransitionOptions = {
10
10
  * It implements “Smooth and efficient zooming and panning.” algorithm by
11
11
  * "Jarke J. van Wijk and Wim A.A. Nuij"
12
12
  */
13
- export default function flyToViewport(startProps: ViewportProps, endProps: ViewportProps, t: number, options?: FlytoTransitionOptions): {
13
+ export declare function flyToViewport(startProps: ViewportProps, endProps: ViewportProps, t: number, options?: FlytoTransitionOptions): {
14
14
  longitude: number;
15
15
  latitude: number;
16
16
  zoom: number;
@@ -1 +1 @@
1
- {"version":3,"file":"fly-to-viewport.d.ts","sourceRoot":"","sources":["../src/fly-to-viewport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAU9D,oBAAY,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,UAAU,EAAE,aAAa,EACzB,QAAQ,EAAE,aAAa,EACvB,CAAC,EAAE,MAAM,EACT,OAAO,CAAC,EAAE,sBAAsB,GAC/B;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAsCA;AAGD,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,aAAa,EACzB,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CAaR"}
1
+ {"version":3,"file":"fly-to-viewport.d.ts","sourceRoot":"","sources":["../src/fly-to-viewport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAU9D,oBAAY,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,aAAa,EACzB,QAAQ,EAAE,aAAa,EACvB,CAAC,EAAE,MAAM,EACT,OAAO,CAAC,EAAE,sBAAsB,GAC/B;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAuCA;AAGD,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,aAAa,EACzB,QAAQ,EAAE,aAAa,EACvB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CAaR"}
@@ -1,5 +1,5 @@
1
- import { lerp } from './math-utils';
2
- import { scaleToZoom, zoomToScale, lngLatToWorld, worldToLngLat } from './web-mercator-utils';
1
+ import { lerp } from "./math-utils.js";
2
+ import { scaleToZoom, zoomToScale, lngLatToWorld, worldToLngLat } from "./web-mercator-utils.js";
3
3
  import * as vec2 from 'gl-matrix/vec2';
4
4
  const EPSILON = 0.01;
5
5
  const VIEWPORT_TRANSITION_PROPS = ['longitude', 'latitude', 'zoom'];
@@ -7,7 +7,7 @@ const DEFAULT_OPTS = {
7
7
  curve: 1.414,
8
8
  speed: 1.2
9
9
  };
10
- export default function flyToViewport(startProps, endProps, t, options) {
10
+ export function flyToViewport(startProps, endProps, t, options) {
11
11
  const {
12
12
  startZoom,
13
13
  startCenterXY,
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/fly-to-viewport.ts"],"names":["lerp","scaleToZoom","zoomToScale","lngLatToWorld","worldToLngLat","vec2","EPSILON","VIEWPORT_TRANSITION_PROPS","DEFAULT_OPTS","curve","speed","flyToViewport","startProps","endProps","t","options","startZoom","startCenterXY","uDelta","w0","u1","S","rho","rho2","r0","getFlyToTransitionParams","viewport","key","startValue","endValue","s","w","Math","cosh","u","tanh","sinh","scaleIncrement","newZoom","newCenterWorld","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":"SAAQA,I;SACAC,W,EAAaC,W,EAAaC,a,EAAeC,a;AACjD,OAAO,KAAKC,IAAZ,MAAsB,gBAAtB;AAIA,MAAMC,OAAO,GAAG,IAAhB;AACA,MAAMC,yBAAyB,GAAG,CAAC,WAAD,EAAc,UAAd,EAA0B,MAA1B,CAAlC;AACA,MAAMC,YAAY,GAAG;AACnBC,EAAAA,KAAK,EAAE,KADY;AAEnBC,EAAAA,KAAK,EAAE;AAFY,CAArB;AAkBA,OAAO,SAASC,aAAT,CACLC,UADK,EAELC,QAFK,EAGLC,CAHK,EAILC,OAJK,EASL;AAGA,QAAM;AAACC,IAAAA,SAAD;AAAYC,IAAAA,aAAZ;AAA2BC,IAAAA,MAA3B;AAAmCC,IAAAA,EAAnC;AAAuCC,IAAAA,EAAvC;AAA2CC,IAAAA,CAA3C;AAA8CC,IAAAA,GAA9C;AAAmDC,IAAAA,IAAnD;AAAyDC,IAAAA;AAAzD,MAA+DC,wBAAwB,CAC3Fb,UAD2F,EAE3FC,QAF2F,EAG3FE,OAH2F,CAA7F;;AAOA,MAAIK,EAAE,GAAGd,OAAT,EAAkB;AAChB,UAAMoB,QAAQ,GAAG,EAAjB;;AACA,SAAK,MAAMC,GAAX,IAAkBpB,yBAAlB,EAA6C;AAC3C,YAAMqB,UAAU,GAAGhB,UAAU,CAACe,GAAD,CAA7B;AACA,YAAME,QAAQ,GAAGhB,QAAQ,CAACc,GAAD,CAAzB;AAEAD,MAAAA,QAAQ,CAACC,GAAD,CAAR,GAAgB3B,IAAI,CAAC4B,UAAD,EAAaC,QAAb,EAAuBf,CAAvB,CAApB;AACD;;AAED,WAAOY,QAAP;AACD;;AAED,QAAMI,CAAC,GAAGhB,CAAC,GAAGO,CAAd;AAEA,QAAMU,CAAC,GAAGC,IAAI,CAACC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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 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 // @ts-ignore-error properties are populated dynamically\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"}
@@ -1,3 +1,3 @@
1
- import type WebMercatorViewport from './web-mercator-viewport';
2
- export default function getBounds(viewport: WebMercatorViewport, z?: number): number[][];
1
+ import type { WebMercatorViewport } from './web-mercator-viewport';
2
+ export declare function getBounds(viewport: WebMercatorViewport, z?: number): number[][];
3
3
  //# sourceMappingURL=get-bounds.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-bounds.d.ts","sourceRoot":"","sources":["../src/get-bounds.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,mBAAmB,MAAM,yBAAyB,CAAC;AAS/D,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,QAAQ,EAAE,mBAAmB,EAAE,CAAC,GAAE,MAAU,GAAG,MAAM,EAAE,EAAE,CAyB1F"}
1
+ {"version":3,"file":"get-bounds.d.ts","sourceRoot":"","sources":["../src/get-bounds.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,yBAAyB,CAAC;AAWjE,wBAAgB,SAAS,CAAC,QAAQ,EAAE,mBAAmB,EAAE,CAAC,GAAE,MAAU,GAAG,MAAM,EAAE,EAAE,CAyBlF"}
@@ -1,8 +1,8 @@
1
- import { worldToLngLat } from './web-mercator-utils';
2
- import * as vec2 from 'gl-matrix/vec2';
3
- import { transformVector } from './math-utils';
1
+ import { lerp as vec2_lerp } from 'gl-matrix/vec2';
2
+ import { worldToLngLat } from "./web-mercator-utils.js";
3
+ import { transformVector } from "./math-utils.js";
4
4
  const DEGREES_TO_RADIANS = Math.PI / 180;
5
- export default function getBounds(viewport, z = 0) {
5
+ export function getBounds(viewport, z = 0) {
6
6
  const {
7
7
  width,
8
8
  height,
@@ -37,7 +37,7 @@ function unprojectOnFarPlane(viewport, x, targetZ) {
37
37
  const coord1 = transformVector(pixelUnprojectionMatrix, [x, viewport.height, 1, 1]);
38
38
  const z = targetZ * viewport.distanceScales.unitsPerMeter[2];
39
39
  const t = (z - coord0[2]) / (coord1[2] - coord0[2]);
40
- const coord = vec2.lerp([], coord0, coord1, t);
40
+ const coord = vec2_lerp([], coord0, coord1, t);
41
41
  const result = worldToLngLat(coord);
42
42
  result.push(targetZ);
43
43
  return result;
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/get-bounds.ts"],"names":["lerp","vec2_lerp","worldToLngLat","transformVector","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","result","push"],"mappings":"AACA,SAAQA,IAAI,IAAIC,SAAhB,QAAgC,gBAAhC;SAEQC,a;SACAC,e;AAER,MAAMC,kBAAkB,GAAGC,IAAI,CAACC,EAAL,GAAU,GAArC;AAOA,OAAO,SAASC,SAAT,CAAmBC,QAAnB,EAAkDC,CAAS,GAAG,CAA9D,EAA6E;AAElF,QAAM;AAACC,IAAAA,KAAD;AAAQC,IAAAA,MAAR;AAAgBC,IAAAA;AAAhB,MAA6BJ,QAAnC;AACA,QAAMK,YAAY,GAAG;AAACC,IAAAA,OAAO,EAAEL;AAAV,GAArB;AACA,QAAMM,UAAU,GAAGH,SAAS,CAAC,CAAC,CAAD,EAAID,MAAJ,CAAD,EAAcE,YAAd,CAA5B;AACA,QAAMG,WAAW,GAAGJ,SAAS,CAAC,CAACF,KAAD,EAAQC,MAAR,CAAD,EAAkBE,YAAlB,CAA7B;AACA,MAAII,OAAJ;AACA,MAAIC,QAAJ;AAEA,QAAMC,OAAO,GAAGX,QAAQ,CAACY,IAAT,GACZ,MAAMZ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,KAAmBC,MAAM,CAAC,CAAD,CAAN,GAAYD,MAAM,CAAC,CAAD,CAArC,CAAV;AACA,QAAMK,KAAK,GAAGhC,SAAS,CAAC,EAAD,EAAK2B,MAAL,EAAaC,MAAb,EAAqBG,CAArB,CAAvB;AAEA,QAAME,MAAM,GAAGhC,aAAa,CAAC+B,KAAD,CAA5B;AACAC,EAAAA,MAAM,CAACC,IAAP,CAAYrB,OAAZ;AACA,SAAOoB,MAAP;AACD","sourcesContent":["/* eslint-disable camelcase */\nimport {lerp as vec2_lerp} from 'gl-matrix/vec2';\nimport type {WebMercatorViewport} from './web-mercator-viewport';\nimport {worldToLngLat} from './web-mercator-utils';\nimport {transformVector} from './math-utils';\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 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"}