libre-routing
Version:
This library was generated with [Nx](https://nx.dev).
24 lines • 826 B
JavaScript
import bboxClip from '@turf/bbox-clip';
import { expose } from 'comlink';
import { calculatePos, getDistinctSegments } from './line-diff';
let chunks = [];
const api = {
createChunks(data) {
const fc = data.routesShapeGeojson
.data;
// @ts-ignore
chunks = getDistinctSegments(fc.features);
},
recalculatePos({ bbox: { ne, sw }, popup }) {
const bboxChunks = chunks
.map((chunk) => {
return bboxClip(chunk, [sw.lng, sw.lat, ne.lng, ne.lat]);
})
.filter(({ geometry: { coordinates } }) => coordinates.length > 0);
const points = calculatePos(bboxChunks);
const allInBbox = points.length === chunks.length;
return { points, allInBbox };
},
};
expose(api);
//# sourceMappingURL=annotation.worker.js.map