@orca-fe/x-map
Version:
37 lines (36 loc) • 1.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toSimpleViewport = exports.path2Bounds = void 0;
/**
* 将经纬度列表转换为 bounds
* @param posList 经纬度列表
* @returns bounds
*/
const path2Bounds = (posList) => {
const b = posList.reduce(({ maxLng, minLng, maxLat, minLat }, [lng, lat]) => ({
maxLng: Math.max(maxLng, lng),
minLng: Math.min(minLng, lng),
maxLat: Math.max(maxLat, lat),
minLat: Math.min(minLat, lat),
}), {
maxLng: -Infinity,
minLng: Infinity,
maxLat: -Infinity,
minLat: Infinity,
});
return [
[b.minLng, b.minLat],
[b.maxLng, b.maxLat],
];
};
exports.path2Bounds = path2Bounds;
const toSimpleViewport = (viewport) => ({
rotate: viewport.bearing,
pitch: viewport.pitch,
lng: viewport.longitude,
lat: viewport.latitude,
zoom: viewport.zoom,
width: viewport.width,
height: viewport.height,
});
exports.toSimpleViewport = toSimpleViewport;