/* Mapbox GL JS is Copyright © 2020 Mapbox and subject to the Mapbox Terms of Service ((https://www.mapbox.com/legal/tos/). */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.mapboxgl = factory());
}(this, (function () { 'use strict';
/* eslint-disable */
var shared, worker, mapboxgl;
// define gets called three times: one for each chunk. we rely on the order
// they're imported to know which is which
function define(_, chunk) {
if (!shared) {
shared = chunk;
} else if (!worker) {
worker = chunk;
} else {
var workerBundleString = "self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; (" + shared + ")(sharedChunk); (" + worker + ")(sharedChunk); self.onerror = null;"
var sharedChunk = {};
shared(sharedChunk);
mapboxgl = chunk(sharedChunk);
if (typeof window !== 'undefined') {
mapboxgl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }));
}
}
}
define(['exports'], function (exports) { 'use strict';
var version = "2.7.0-dev";
var unitbezier = UnitBezier;
function UnitBezier(p1x, p1y, p2x, p2y) {
this.cx = 3 * p1x;
this.bx = 3 * (p2x - p1x) - this.cx;
this.ax = 1 - this.cx - this.bx;
this.cy = 3 * p1y;
this.by = 3 * (p2y - p1y) - this.cy;
this.ay = 1 - this.cy - this.by;
this.p1x = p1x;
this.p1y = p2y;
this.p2x = p2x;
this.p2y = p2y;
}
UnitBezier.prototype.sampleCurveX = function (t) {
return ((this.ax * t + this.bx) * t + this.cx) * t;
};
UnitBezier.prototype.sampleCurveY = function (t) {
return ((this.ay * t + this.by) * t + this.cy) * t;
};
UnitBezier.prototype.sampleCurveDerivativeX = function (t) {
return (3 * this.ax * t + 2 * this.bx) * t + this.cx;
};
UnitBezier.prototype.solveCurveX = function (x, epsilon) {
if (typeof epsilon === 'undefined')
epsilon = 0.000001;
var t0, t1, t2, x2, i;
for (t2 = x, i = 0; i < 8; i++) {
x2 = this.sampleCurveX(t2) - x;
if (Math.abs(x2) < epsilon)
return t2;
var d2 = this.sampleCurveDerivativeX(t2);
if (Math.abs(d2) < 0.000001)
break;
t2 = t2 - x2 / d2;
}
t0 = 0;
t1 = 1;
t2 = x;
if (t2 < t0)
return t0;
if (t2 > t1)
return t1;
while (t0 < t1) {
x2 = this.sampleCurveX(t2);
if (Math.abs(x2 - x) < epsilon)
return t2;
if (x > x2) {
t0 = t2;
} else {
t1 = t2;
}
t2 = (t1 - t0) * 0.5 + t0;
}
return t2;
};
UnitBezier.prototype.solve = function (x, epsilon) {
return this.sampleCurveY(this.solveCurveX(x, epsilon));
};
var pointGeometry = Point;
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype = {
clone: function () {
return new Point(this.x, this.y);
},
add: function (p) {
return this.clone()._add(p);
},
sub: function (p) {
return this.clone()._sub(p);
},
multByPoint: function (p) {
return this.clone()._multByPoint(p);
},
divByPoint: function (p) {
return this.clone()._divByPoint(p);
},
mult: function (k) {
return this.clone()._mult(k);
},
div: function (k) {
return this.clone()._div(k);
},
rotate: function (a) {
return this.clone()._rotate(a);
},
rotateAround: function (a, p) {
return this.clone()._rotateAround(a, p);
},
matMult: function (m) {
return this.clone()._matMult(m);
},
unit: function () {
return this.clone()._unit();
},
perp: function () {
return this.clone()._perp();
},
round: function () {
return this.clone()._round();
},
mag: function () {
return Math.sqrt(this.x * this.x + this.y * this.y);
},
equals: function (other) {
return this.x === other.x && this.y === other.y;
},
dist: function (p) {
return Math.sqrt(this.distSqr(p));
},
distSqr: function (p) {
var dx = p.x - this.x, dy = p.y - this.y;
return dx * dx + dy * dy;
},
angle: function () {
return Math.atan2(this.y, this.x);
},
angleTo: function (b) {
return Math.atan2(this.y - b.y, this.x - b.x);
},
angleWith: function (b) {
return this.angleWithSep(b.x, b.y);
},
angleWithSep: function (x, y) {
return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
},
_matMult: function (m) {
var x = m[0] * this.x + m[1] * this.y, y = m[2] * this.x + m[3] * this.y;
this.x = x;
this.y = y;
return this;
},
_add: function (p) {
this.x += p.x;
this.y += p.y;
return this;
},
_sub: function (p) {
this.x -= p.x;
this.y -= p.y;
return this;
},
_mult: function (k) {
this.x *= k;
this.y *= k;
return this;
},
_div: function (k) {
this.x /= k;
this.y /= k;
return this;
},
_multByPoint: function (p) {
this.x *= p.x;
this.y *= p.y;
return this;
},
_divByPoint: function (p) {
this.x /= p.x;
this.y /= p.y;
return this;
},
_unit: function () {
this._div(this.mag());
return this;
},
_perp: function () {
var y = this.y;
this.y = this.x;
this.x = -y;
return this;
},
_rotate: function (angle) {
var cos = Math.cos(angle), sin = Math.sin(angle), x = cos * this.x - sin * this.y, y = sin * this.x + cos * this.y;
this.x = x;
this.y = y;
return this;
},
_rotateAround: function (angle, p) {
var cos = Math.cos(angle), sin = Math.sin(angle), x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y), y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
this.x = x;
this.y = y;
return this;
},
_round: function () {
this.x = Math.round(this.x);
this.y = Math.round(this.y);
return this;
}
};
Point.convert = function (a) {
if (a instanceof Point) {
return a;
}
if (Array.isArray(a)) {
return new Point(a[0], a[1]);
}
return a;
};
var window$1 = typeof self !== 'undefined' ? self : {};
const DEG_TO_RAD = Math.PI / 180;
const RAD_TO_DEG = 180 / Math.PI;
function degToRad(a) {
return a * DEG_TO_RAD;
}
function radToDeg(a) {
return a * RAD_TO_DEG;
}
const TILE_CORNERS = [
[
0,
0
],
[
1,
0
],
[
1,
1
],
[
0,
1
]
];
function furthestTileCorner(bearing) {
const alignedBearing = (bearing + 45 + 360) % 360;
const cornerIdx = Math.round(alignedBearing / 90) % 4;
return TILE_CORNERS[cornerIdx];
}
function easeCubicInOut(t) {
if (t <= 0)
return 0;
if (t >= 1)
return 1;
const t2 = t * t, t3 = t2 * t;
return 4 * (t < 0.5 ? t3 : 3 * (t - t2) + t3 - 0.75);
}
function getBounds(points) {
let minX = Infinity;
let minY = Infinity;
let maxX = -Infinity;
let maxY = -Infinity;
for (const p of points) {
minX = Math.min(minX, p.x);
minY = Math.min(minY, p.y);
maxX = Math.max(maxX, p.x);
maxY = Math.max(maxY, p.y);
}
return {
min: new pointGeometry(minX, minY),
max: new pointGeometry(maxX, maxY)
};
}
function getAABBPointSquareDist(min, max, point) {
let sqDist = 0;
for (let i = 0; i < 2; ++i) {
const v
评论0