@tuoyuan/map-adapter-lib
Version:
地图适配器库
25 lines (24 loc) • 658 B
JavaScript
import { Position as n } from "./Position.js";
class h {
constructor() {
}
static getBounds(t) {
let e = 1 / 0, i = -1 / 0, o = 1 / 0, s = -1 / 0;
for (let r = 0; r < t.length; r++) {
const u = t[r], a = u.latitude, l = u.longitude;
a < e && (e = a), a > i && (i = a), l < o && (o = l), l > s && (s = l);
}
return {
southWest: new n(o, e),
northEast: new n(s, i),
northWest: new n(o, i),
southEast: new n(s, e)
};
}
static getCenter(t) {
return new n((t.southWest.longitude + t.northEast.longitude) / 2, (t.southWest.latitude + t.northEast.latitude) / 2);
}
}
export {
h as Bounds
};