//MapCanvas.js 里废弃的函数,暂时保留在这里,方便后续如有需要再恢复
|
|
// function getMappingInfo(point) {
|
// let angle, path, vector, x, y;
|
// this.allSmoothList.find((smoothList) => {
|
// const smoothLength = smoothList.length;
|
// const existPath = smoothList.find((currentPath, i) => {
|
// const prevPath = smoothList[(i - 1 + smoothLength) % smoothLength];
|
// if (currentPath.type === "line") {
|
// const prevPathEndPoint =
|
// prevPath.type === "arc"
|
// ? {
|
// x: prevPath.arcEndX,
|
// y: prevPath.arcEndY,
|
// }
|
// : prevPath;
|
// return this.isPointOnSegment(point, prevPathEndPoint, currentPath);
|
// } else {
|
// const start = {
|
// x: currentPath.arcStartX,
|
// y: currentPath.arcStartY,
|
// };
|
// const middle = {
|
// x: currentPath.arcMiddleX,
|
// y: currentPath.arcMiddleY,
|
// };
|
// const end = { x: currentPath.arcEndX, y: currentPath.arcEndY };
|
// return (
|
// this.isPointOnSegment(point, start, middle) ||
|
// this.isPointOnSegment(point, middle, end)
|
// );
|
// }
|
// });
|
// if (!existPath) {
|
// return false;
|
// }
|
// path = existPath;
|
// vector = this.normalizeVector(existPath, point);
|
// if (existPath.type === "arc") {
|
// x = existPath.x + vector.x * existPath.radius;
|
// y = existPath.y + vector.y * existPath.radius;
|
// angle = Math.atan2(vector.y, vector.x);
|
// } else {
|
// x = point.x;
|
// y = point.y;
|
// angle = null;
|
// }
|
// return true;
|
// });
|
// return {
|
// angle,
|
// path,
|
// x,
|
// y,
|
// vector,
|
// };
|
// }
|
|
// setDeviceInfo(type, res) {
|
// const deviceTypeInfo = this.DEVICE_MAP[type];
|
// let devices = Array.isArray(res) ? res : res && res.code === 200 ? res.data : null;
|
// if (!devices) {
|
// return;
|
// }
|
// for (var i = 0; i < devices.length; i++) {
|
// const device = devices[i];
|
// const id = parseInt(device[deviceTypeInfo.idName]);
|
// const sprite = deviceTypeInfo.pixiMap.get(id);
|
// if (!sprite) {
|
// continue;
|
// }
|
// // 找到sprite了就更新颜色和文字
|
// const taskNo = device.taskNo;
|
// if (taskNo != null && taskNo > 0) {
|
// sprite.textObj.text = id + '(' + taskNo + ')';
|
// } else {
|
// sprite.textObj.text = String(id);
|
// }
|
// this.applyEditorLikeTrackDeviceTextStyle(sprite.textObj);
|
// const status = device[deviceTypeInfo.statusInfo.name];
|
// const statusColor = deviceTypeInfo.statusInfo.getStatus(status);
|
// deviceTypeInfo.statusInfo.updateTextureColor(sprite, statusColor);
|
|
// const oldSprite = {
|
// ...sprite,
|
// x: sprite.x,
|
// y: sprite.y,
|
// mappingInfo: { ...sprite.mappingInfo }
|
// };
|
// // 后端传过来的是左上角的点,这里取中心点
|
// device.width = sprite.width;
|
// device.height = sprite.height;
|
// const sourcePoint = {
|
// x: device.x + device.width / 2,
|
// y: device.y + device.height / 2
|
// };
|
// const mappingInfo = this.getMappingInfo({ ...device, ...sourcePoint });
|
// sprite.mappingInfo = mappingInfo;
|
// sprite.time = Date.now();
|
// if (!oldSprite.time) {
|
// sprite.x = sprite.mappingInfo.x;
|
// sprite.y = sprite.mappingInfo.y;
|
// sprite.rotation = sprite.mappingInfo.rotate;
|
// sprite.path = sprite.mappingInfo.path;
|
// sprite.vector = sprite.mappingInfo.vector;
|
// continue;
|
// }
|
// // const curveDistance = this.getCurveDistance(
|
// // oldSprite.mappingInfo,sprite.mappingInfo,
|
// // oldSprite.mappingInfo.path,sprite.mappingInfo.path,
|
// // oldSprite.mappingInfo.angle,sprite.mappingInfo.angle
|
// // );
|
// const curveDistance = G.calcDistance(oldSprite.mappingInfo, sprite.mappingInfo);
|
// const deltaTime = (sprite.time - oldSprite.time) / 1000 || 0;
|
// if (deltaTime > 0 && deltaTime <= 10 && curveDistance > 0) {
|
// // 保存本次帧间隔,供 ticker 判断数据新鲜度
|
// sprite.lastDeltaTime = deltaTime;
|
// // 用指数移动平均(α=0.35)代替窗口均值,对速度变化响应更快
|
// const v = curveDistance / deltaTime;
|
// const alpha = 0.35;
|
// sprite.maV =
|
// typeof sprite.maV === 'number' && isFinite(sprite.maV)
|
// ? sprite.maV * (1 - alpha) + v * alpha
|
// : v;
|
// }
|
// if (curveDistance < EPSILON) {
|
// // 已无剩余路程或新数据与当前目标一致:必须收尾并移除 ticker,否则会一直跑
|
// this.finishDeviceMotion(sprite);
|
// } else {
|
// sprite.isFinish = false;
|
// if (sprite.ticker) {
|
// // 已有插值回调:mappingInfo 已在上方更新,继续追新目标;勿 return(会中断其它设备)
|
// continue;
|
// }
|
// const Gm = window.BasMapTrackGeometry;
|
// const trackElForMove =
|
// this.map2 && sprite.pathId != null
|
// ? this.map2.find((item) => item && item.id === sprite.pathId)
|
// : null;
|
// const pathListForMove =
|
// trackElForMove &&
|
// trackElForMove.pathList &&
|
// trackElForMove.pathList.length
|
// ? trackElForMove.pathList
|
// : null;
|
// if (!pathListForMove || !Gm) {
|
// this.finishDeviceMotion(sprite);
|
// continue;
|
// }
|
// const fn = () => {
|
// if (sprite.isFinish) {
|
// return;
|
// }
|
// const restDistance = G.calcDistance(sprite, sprite.mappingInfo);
|
// if (restDistance <= EPSILON) {
|
// this.finishDeviceMotion(sprite);
|
// return;
|
// }
|
// const dtMs =
|
// this.pixiApp && this.pixiApp.ticker && typeof this.pixiApp.ticker.deltaMS === 'number'
|
// ? this.pixiApp.ticker.deltaMS
|
// : 16.667;
|
// const dt = Math.max(0, dtMs) / 1000;
|
// if (dt <= 0) {
|
// return;
|
// }
|
// const baseV =
|
// typeof sprite.maV === 'number' && isFinite(sprite.maV) && sprite.maV > 0
|
// ? sprite.maV
|
// : Math.max(sprite.width * 2, 20);
|
// // 数据新鲜度判断:
|
// // 服务器帧间隔内有新数据到来 → 全速追目标(不减速,避免下一帧"追赶抖动")
|
// // 数据停止推送 → 线性减速收敛到终点
|
// const msSinceUpdate = sprite.time ? Date.now() - sprite.time : 0;
|
// const typicalIntervalMs = (sprite.lastDeltaTime || 1) * 1000;
|
// const isStale = msSinceUpdate > typicalIntervalMs * 1.5;
|
// const easing = isStale ? Math.min(1.0, restDistance / Math.max(sprite.width, 1)) : 1.0;
|
// const smoothDistance = Math.min(restDistance, dt * baseV * easing);
|
// const path = sprite.path;
|
// const movePoint =
|
// trackElForMove &&
|
// trackElForMove.type === 'annulus' &&
|
// Gm.snapToAnnulusOuterPath
|
// ? Gm.snapToAnnulusOuterPath(sprite.x, sprite.y, path)
|
// : sprite;
|
// const angle = Math.atan2(sprite.y - path.y, sprite.x - path.x);
|
// const p = Gm.getPositionAfterMove({
|
// point: movePoint,
|
// pathList: pathListForMove,
|
// path,
|
// deltaDistance: smoothDistance,
|
// angle
|
// });
|
// let px = p.x;
|
// let py = p.y;
|
// if (
|
// trackElForMove &&
|
// trackElForMove.type === 'annulus' &&
|
// Gm.centerAnnulusBandPoint
|
// ) {
|
// const c = Gm.centerAnnulusBandPoint(trackElForMove, p.x, p.y, p.path);
|
// px = c.x;
|
// py = c.y;
|
// }
|
// sprite.path = p.path;
|
// sprite.x = px;
|
// sprite.y = py;
|
// sprite.rotation = this.getRotate(p, p.path);
|
// const restDistanceAfter = G.calcDistance(
|
// { x: sprite.x, y: sprite.y },
|
// sprite.mappingInfo
|
// );
|
// if (restDistanceAfter <= EPSILON || smoothDistance >= restDistance) {
|
// this.finishDeviceMotion(sprite);
|
// return;
|
// }
|
// };
|
// sprite.ticker = fn;
|
// this.pixiApp.ticker.add(sprite.ticker);
|
// }
|
// }
|
// this.scheduleAdjustLabels();
|
// },
|
|
// const list = [{
|
// x: 853.92,
|
// y: 457
|
// }, {
|
// x: 953.92,
|
// y: 457
|
// }, {
|
// x: 1053.92,
|
// y: 457
|
// }, {
|
// x: 1153.92,
|
// y: 457
|
// }, {
|
// x: 1253.92,
|
// y: 457
|
// }, {
|
// x: 1353.92,
|
// y: 457
|
// }, {
|
// x: 1453.92,
|
// y: 457
|
// }, {
|
// x: 1553.92,
|
// y: 457
|
// }, {
|
// x: 1653.92,
|
// y: 457
|
// }];
|
// const raw = {
|
// crnStatus: 'machine-auto',
|
// offset: 1,
|
// crnId: 15,
|
// pathId: 'el_1775197504724'
|
// };
|