列车精确定位代码调整

列车的状态信息调整
去掉仿真里的拖动鼠标生成包围框
This commit is contained in:
joylink_cuiweidong 2020-03-12 14:41:53 +08:00
parent b7ee3e5f6e
commit 56126bdbf3
9 changed files with 328 additions and 260 deletions

View File

@ -98,13 +98,13 @@ export default class TrainBody extends Group {
}) : '';
const serviceNumber = style.Train.trainServer.serviceNumberPrefix + (model.serviceNumber || style.Train.trainServer.defaultServiceNumber) + '';// 服务号(表号)
const tripNumber = style.Train.trainTarget.tripNumberPrefix + (style.Train.trainTarget.defaultDirectionCode
?(model.directionCode||style.Train.trainTarget.defaultDirectionCode) + (model.tripNumber || style.Train.trainTarget.defaultTripNumber)
:model.tripNumber || style.Train.trainTarget.defaultTripNumber) + ''; // 车次号
const targetCode = style.Train.trainNumber.targetCodePrefix + (model.targetCode || style.Train.trainNumber.defaultTargetCode) + ''; // 目的地码
? (model.directionCode || style.Train.trainTarget.defaultDirectionCode) + (model.tripNumber || style.Train.trainTarget.defaultTripNumber)
: model.tripNumber || style.Train.trainTarget.defaultTripNumber) + ''; // 车次号
const targetCode = style.Train.trainNumber.targetCodePrefix + (model.destinationCode || style.Train.trainNumber.defaultTargetCode) + ''; // 目的地码
const groupNumber = style.Train.trainTargetNumber.groupNumberPrefix + (model.groupNumber || style.Train.trainTargetNumber.defaultGroupNumber) + ''; // 车组号
this.textTrainServer = new ETextName({
zlevel: model.zlevel,
z: model.z+1,
z: model.z + 1,
x: parseInt(model.point.x + style.Train.trainServer.trainServerOffset.x),
y: parseInt(model.point.y + style.Train.trainServer.trainServerOffset.y),
text: serviceNumber.substring(serviceNumber.length - style.Train.trainServer.serviceNumberPrefix.length),
@ -116,7 +116,7 @@ export default class TrainBody extends Group {
});
this.textTrainTarget = new ETextName({
zlevel: this.model.zlevel,
z: this.model.z+1,
z: this.model.z + 1,
x: parseInt(model.point.x + model.style.Train.trainTarget.trainTargetOffset.x),
y: parseInt(model.point.y + model.style.Train.trainTarget.trainTargetOffset.y),
text: tripNumber.substring(tripNumber.length - style.Train.trainTarget.tripNumberPrefix.length),
@ -128,7 +128,7 @@ export default class TrainBody extends Group {
});
this.textTrainNumber = new ETextName({
zlevel: model.zlevel,
z: model.z+1,
z: model.z + 1,
x: parseInt(model.point.x + style.Train.trainNumber.trainNumberOffset.x),
y: parseInt(model.point.y + style.Train.trainNumber.trainNumberOffset.y),
text: targetCode.substring(targetCode.length - 3),
@ -143,7 +143,7 @@ export default class TrainBody extends Group {
});
this.textTrainTargetNumber = new ETextName({
zlevel: model.zlevel,
z: model.z+1,
z: model.z + 1,
x: parseInt(model.point.x - style.Train.trainBody.lrPadding),
y: parseInt(model.point.y + style.Train.trainBody.upPadding),
text: groupNumber.substring(groupNumber.length - 3),
@ -174,20 +174,20 @@ export default class TrainBody extends Group {
this.trainBodyBox && this.trainBodyBox.setStyle('fill', color);
}
setTextTrainServerColor(color) {
this.textTrainServer&&this.textTrainServer.setStyle('textFill', color);
this.textTrainServer&&this.textTrainServer.setStyle('textStroke', color);
this.textTrainServer && this.textTrainServer.setStyle('textFill', color);
this.textTrainServer && this.textTrainServer.setStyle('textStroke', color);
}
setTextTrainTargetColor(color) {
this.textTrainTarget&&this.textTrainTarget.setStyle('textFill', color);
this.textTrainTarget&&this.textTrainTarget.setStyle('textStroke', color);
this.textTrainTarget && this.textTrainTarget.setStyle('textFill', color);
this.textTrainTarget && this.textTrainTarget.setStyle('textStroke', color);
}
setTextTrainNumberColor(color) {
this.textTrainNumber&&this.textTrainNumber.setStyle('textFill', color);
this.textTrainNumber&&this.textTrainNumber.setStyle('textStroke', color);
this.textTrainNumber && this.textTrainNumber.setStyle('textFill', color);
this.textTrainNumber && this.textTrainNumber.setStyle('textStroke', color);
}
setTextTrainTargetNumberColor(color) {
this.textTrainTargetNumber&&this.textTrainTargetNumber.setStyle('textFill', color);
this.textTrainTargetNumber&&this.textTrainTargetNumber.setStyle('textStroke', color);
this.textTrainTargetNumber && this.textTrainTargetNumber.setStyle('textFill', color);
this.textTrainTargetNumber && this.textTrainTargetNumber.setStyle('textStroke', color);
}
setHShow(isShow) {
if (this.textH) {

View File

@ -43,6 +43,7 @@ class Jlmap {
const width = opts.dom.clientWidth;
const height = opts.dom.clientHeight;
this.zoomOnMouseWheel = opts.options.zoomOnMouseWheel;
this.previewOrMapDraw = opts.showConfig.previewOrMapDraw;
this.$zr = zrender.init(opts.dom, deepAssign({ renderer, devicePixelRatio, width, height }, opts.config));
@ -137,6 +138,7 @@ class Jlmap {
this.$mouseController.disable();
} else {
opts['zoomOnMouseWheel'] = this.zoomOnMouseWheel;
opts['previewOrMapDraw'] = this.previewOrMapDraw;
this.$mouseController.enable(opts);
}

View File

@ -54,6 +54,7 @@ class MouseController extends Eventful {
this._moveOnMouseMove = opts.moveOnMouseMove || true;
this._zoomOnMouseWheel = opts.zoomOnMouseWheel || false;
this._preventDefaultMouseMove = opts.preventDefaultMouseMove || true;
this._previewOrMapDraw = opts.previewOrMapDraw || false;
this.disable();
@ -121,7 +122,7 @@ class MouseController extends Eventful {
this._preventDefaultMouseMove && eventTool.stop(e.event);
this.trigger(this.events.__Pan, { dx, dy, oldX, oldY, newX: this._x, newY: this._y });
} else if (e.which === 3 && this._zoomOnMouseWheel) {
} else if (e.which === 3 && this._zoomOnMouseWheel && this._previewOrMapDraw) {
this.handleMouseMoveRight({x: e.offsetX, y: e.offsetY});
}
}

View File

@ -27,9 +27,9 @@ class EMouse extends Group {
}
let text = '';
if (LangStorage.getLang() == 'en') {
text = ` The planned train: ${trainType} \n Table No.: ${this.device.model.serviceNumber} \n Train Trip No.: ${this.device.model.tripNumber}\n Destination: ${this.device.model.targetCode ? this.device.model.targetCode : ''}\n Train No.: ${this.device.model.groupNumber}\n Early or late: ${destinationText}\n Direction: ${this.device.model.directionType == '02' ? 'up' : 'down'}\n Crew No.: \n Start Station: \n Terminal Station: \n Occupied Track: ${this.device.model.sectionModel ? this.device.model.sectionModel.name : ''}\n Current Station: \n Train-ground communication: normal \n Operation Speed level: 4 \n Detained: ${!this.device.model.hold ? 'Normal' : 'Detained'}\n \n 跳停状态: ${!this.device.model.jump ? 'Normal' : 'Skip to continue moving'}Stationary: ${!this.device.model.stop ? 'No' : 'Yes'}\n Blocked: No \n Speed: ${this.device.model.speed || 0} km/h \n Authorized Distance: ${this.device.model.maLen || 0} m`;
text = ` The planned train: ${trainType} \n Table No.: ${this.device.model.serviceNumber} \n Train Trip No.: ${this.device.model.tripNumber}\n Destination: ${this.device.model.destinationCode ? this.device.model.destinationCode : ''}\n Train No.: ${this.device.model.groupNumber}\n Early or late: ${destinationText}\n Direction: ${this.device.model.directionType == '02' ? 'up' : 'down'}\n Crew No.: \n Start Station: \n Terminal Station: \n Occupied Track: ${this.device.model.sectionModel ? this.device.model.sectionModel.name : ''}\n Current Station: \n Train-ground communication: normal \n Operation Speed level: 4 \n Detained: ${!this.device.model.hold ? 'Normal' : 'Detained'}\n \n 跳停状态: ${!this.device.model.jump ? 'Normal' : 'Skip to continue moving'}Stationary: ${!this.device.model.stop ? 'No' : 'Yes'}\n Blocked: No \n Speed: ${this.device.model.speed || 0} km/h \n Authorized Distance: ${this.device.model.maLen || 0} m`;
} else {
text = `列车类型: ${trainType} \n\0\0\0\0号: ${this.device.model.serviceNumber}\n\0\0号: ${this.device.model.tripNumber}\n目的地号: ${this.device.model.targetCode ? this.device.model.targetCode : ''}\n\0\0号: ${this.device.model.groupNumber}\n\0\0点: ${destinationText}\n运行方向: ${this.device.model.directionType == '02' ? '上行' : '下行'}\n乘务组号: \n起点站名: \n终点站名: \n占用轨道: ${this.device.model.sectionModel ? this.device.model.sectionModel.name : ''}\n所在车站: \n车地通信: 正常\n运行等级: 4\n扣车状态: ${ !this.device.model.hold ? '正常' : '扣车'}\n 跳停状态: ${!this.device.model.jump ? '正常' : '跳停'} \n停稳状态: ${!this.device.model.stop ? '未停稳' : '停稳'}\n阻塞状态: 无\n列车速度: ${this.device.model.speed || 0} km/h\n列车移动授权距离: ${this.device.model.maLen || 0} m`;
text = `列车类型: ${trainType} \n\0\0\0\0号: ${this.device.model.serviceNumber}\n\0\0号: ${this.device.model.tripNumber}\n目的地号: ${this.device.model.destinationCode ? this.device.model.destinationCode : ''}\n\0\0号: ${this.device.model.groupNumber}\n\0\0点: ${destinationText}\n运行方向: ${this.device.model.directionType == '02' ? '上行' : '下行'}\n乘务组号: \n起点站名: \n终点站名: \n占用轨道: ${this.device.model.sectionModel ? this.device.model.sectionModel.name : ''}\n所在车站: \n车地通信: 正常\n运行等级: 4\n扣车状态: ${ !this.device.model.hold ? '正常' : '扣车'}\n 跳停状态: ${!this.device.model.jump ? '正常' : '跳停'} \n停稳状态: ${!this.device.model.stop ? '未停稳' : '停稳'}\n阻塞状态: 无\n列车速度: ${this.device.model.speed || 0} km/h\n列车移动授权距离: ${this.device.model.maLen || 0} m`;
}
// 文字描述
this.arrowText = new Text({

View File

@ -21,9 +21,9 @@ export default class ETriangle extends Group {
points:[[model.point.x + 10 * right, model.point.y], [model.point.x, model.point.y - 6], [model.point.x, model.point.y + 6]]
},
style: {
stroke:'#FFFF00',
stroke:'#00FF00',
lineWidth: 0.5,
fill: '#FFFF00'
fill: '#00FF00'
}
});
this.add(this.angle);

View File

@ -102,7 +102,7 @@ export default class TrainBody extends Group {
const tripNumber = style.Train.trainTarget.tripNumberPrefix + (style.Train.trainTarget.defaultDirectionCode
? (model.directionCode || style.Train.trainTarget.defaultDirectionCode) + (model.tripNumber || style.Train.trainTarget.defaultTripNumber)
: model.tripNumber || style.Train.trainTarget.defaultTripNumber) + ''; // 车次号
const targetCode = style.Train.trainNumber.targetCodePrefix + (model.targetCode || style.Train.trainNumber.defaultTargetCode) + ''; // 目的地码
const targetCode = style.Train.trainNumber.targetCodePrefix + (model.destinationCode || style.Train.trainNumber.defaultTargetCode) + ''; // 目的地码
const groupNumber = style.Train.trainTargetNumber.groupNumberPrefix + (model.groupNumber || style.Train.trainTargetNumber.defaultGroupNumber) + ''; // 车组号
this.textTrainServer = new ETextName({
zlevel: model.zlevel,

View File

@ -18,6 +18,7 @@ export default class Train extends Group {
this.z = 40;
this.size = 0;
this.section = null;
this.nextPointIndex = 1;
this.fontSize = style.Train.common.useSelfText ? style.Train.common.nameFontSize || style.Train.common.trainTextFontSize : model.nameFontSize || style.Train.common.nameFontSize || style.Train.common.trainTextFontSize;
this.newScale = this.fontSize / style.Train.common.trainTextFontSize;
this.nameFormat = style.Train.common.useSelfFormat ? style.Train.trainBody.trainNameFormat : model.nameFormat || style.Train.trainBody.trainNameFormat;
@ -68,7 +69,7 @@ export default class Train extends Group {
destinationStatus: model.destinationStatus,
serviceNumber: model.serviceNumber,
tripNumber: model.tripNumber,
targetCode: model.targetCode,
destinationCode: model.destinationCode,
groupNumber: model.groupNumber,
directionType: model.directionType,
directionCode: model.directionCode,
@ -105,6 +106,7 @@ export default class Train extends Group {
scale: this.newScale
});
if (style.Section.trainPosition.display) {
const data = this.model.physicalCode;
const oldmodel = store.getters['map/getDeviceByCode'](data);
const leftPoint = oldmodel.points[0];
@ -112,6 +114,21 @@ export default class Train extends Group {
const right = this.model.right == 1 ? 1 : 0;
this.startX = leftPoint.x + (1 - right) * (rightPoint.x - leftPoint.x);
this.startY = leftPoint.y + (1 - right) * (rightPoint.y - leftPoint.y);
// 算出折线的长度
this.lineLength = 0;
this.currentAdd = 0;
let oldPoint = null;
oldmodel.points.forEach((point)=>{
if (oldPoint) {
const temp = Math.sqrt(
Math.pow(point.x - oldPoint.x, 2) +
Math.pow(point.y - oldPoint.y, 2),
);
this.lineLength += temp;
}
oldPoint = point;
});
// this.animatePoint = {x:this.startX, y:this.startY};
this.triangle = new ETriangle({
style: this.style,
zlevel: this.zlevel,
@ -120,6 +137,7 @@ export default class Train extends Group {
point:{x:this.startX, y:this.startY}
});
this.add(this.triangle);
}
this.add(this.trainB);
this.add(this.trainL);
@ -136,14 +154,62 @@ export default class Train extends Group {
updateSection() {
const train = this.model;
if (train.physicalCode && train.offsetp) {
if (train.physicalCode && train.offsetp && this.triangle) {
const data = train.physicalCode;
const oldmodel = store.getters['map/getDeviceByCode'](data);
// 待处理(多个点的问题)
// const points = train.right == 1 ? oldmodel.points : oldmodel.points.reverse();
const points = oldmodel.points;
// 目标距离
let targetDistance = Math.sqrt(
Math.pow(points[this.nextPointIndex - 1].x - points[this.nextPointIndex].x, 2) +
Math.pow(points[this.nextPointIndex - 1].y - points[this.nextPointIndex].y, 2),
);
// // 当前距离
// const currentDistance = Math.sqrt(
// Math.pow(points[this.nextPointIndex - 1].x - this.animatePoint.x, 2) +
// Math.pow(points[this.nextPointIndex - 1].y - this.animatePoint.y, 2),
// );
const currentDistance = this.lineLength * train.offsetp - this.currentAdd;
// let cureent this.lineLength * train.offsetp
// 利用运动距离与目标距离, 判断运动的点是否超过下一个目标点, 超过了就重置下一个点
if (currentDistance >= targetDistance) {
// this.animatePoint = {
// x: points[this.nextPointIndex].x,
// y: points[this.nextPointIndex].y
// };
this.nextPointIndex++;
this.currentAdd += targetDistance;
targetDistance = Math.sqrt(
Math.pow(points[this.nextPointIndex - 1].x - points[this.nextPointIndex].x, 2) +
Math.pow(points[this.nextPointIndex - 1].y - points[this.nextPointIndex].y, 2),
);
}
if (this.nextPointIndex > points.length - 1) {
const leftPoint = oldmodel.points[0];
const rightPoint = oldmodel.points[oldmodel.points.length - 1];
if (this.triangle) {
this.startX = leftPoint.x + (rightPoint.x - leftPoint.x) * train.offsetp;
this.startY = leftPoint.y + (rightPoint.y - leftPoint.y) * train.offsetp;
} else {
// debugger;
// this.lineLength * train.offsetp
// if (this.currentLength > targetDistance) {
// this.currentLength = this.currentLength - targetDistance;
// this.nextPointIndex++;
// targetDistance = Math.sqrt(
// Math.pow(points[this.nextPointIndex - 1].x - points[this.nextPointIndex].x, 2) +
// Math.pow(points[this.nextPointIndex - 1].y - points[this.nextPointIndex].y, 2),
// );
// }
debugger;
const rate = (this.lineLength * train.offsetp - this.currentAdd) / targetDistance;
this.startX = points[this.nextPointIndex - 1].x + (points[this.nextPointIndex].x - points[this.nextPointIndex - 1].x) * rate;
this.startY = points[this.nextPointIndex - 1].y + (points[this.nextPointIndex].y - points[this.nextPointIndex - 1].y) * rate;
// this.animatePoint.x = this.startX;
// this.animatePoint.y = this.startY;
}
const point = {x:this.startX, y:this.startY};
this.triangle.point = point;
this.triangle.updateTriangle(point, train.right);
@ -151,7 +217,6 @@ export default class Train extends Group {
this.dirty();
}
}
}
// 恢复颜色状态
recover() {

View File

@ -1,7 +1,7 @@
<template>
<div>
<pop-menu ref="popMenu" :menu="menu" />
<train-init-plan ref="trainInitPlan"/>
<train-init-plan ref="trainInitPlan" />
<notice-info ref="noticeInfo" />
</div>
</template>

View File

@ -158,11 +158,11 @@ export default {
};
//
const path = window.location.href;
let mouseWheelFlag = false;
const mouseWheelFlag = true;
let previewOrMapDraw = false;
if (path.includes('design/userlist/map/draw') || path.includes('design/usermap/map/draw')) {
mouseWheelFlag = true;
}
// if (path.includes('design/userlist/map/draw') || path.includes('design/usermap/map/draw')) {
// mouseWheelFlag = true;
// }
if (path.indexOf('map/draw') !== -1 || path.indexOf('mapPreviewNew') !== -1) {
previewOrMapDraw = true;
}