调整道岔生成逻辑
This commit is contained in:
parent
7ec4a2db59
commit
249bef4802
@ -185,29 +185,45 @@ export function parser(data, skinCode, showConfig) {
|
||||
}
|
||||
let sectionCStar, sectionCEnd;
|
||||
if (handleResetPoint(rnodeSection.points)) {
|
||||
sectionCStar = rnodeSection.points[0];
|
||||
sectionCStar = rnodeSection.points[rnodeSection.points.length - 2];
|
||||
sectionCEnd = rnodeSection.points[1];
|
||||
} else {
|
||||
sectionCStar = rnodeSection.points[1];
|
||||
sectionCEnd = rnodeSection.points[0];
|
||||
sectionCEnd = rnodeSection.points[rnodeSection.points.length - 2];
|
||||
}
|
||||
let intersectionStar, intersectionEnd;
|
||||
if (handleResetPoint(cnodeSection.points)) {
|
||||
intersectionStar = cnodeSection.points[0];
|
||||
intersectionEnd = cnodeSection.points[cnodeSection.points.length - 1];
|
||||
} else {
|
||||
intersectionStar = cnodeSection.points[cnodeSection.points.length - 1];
|
||||
intersectionEnd = cnodeSection.points[0];
|
||||
}
|
||||
if (cnodeSection.points[0].x == lnodeSection.points[lnodeSection.points.length - 1].x && cnodeSection.points[0].y == lnodeSection.points[lnodeSection.points.length - 1].y) {
|
||||
mapDevice[elem.code].intersection = {
|
||||
x: cnodeSection.points[0].x,
|
||||
y: cnodeSection.points[0].y
|
||||
x: intersectionStar.x,
|
||||
y: intersectionStar.y
|
||||
// x: cnodeSection.points[0].x,
|
||||
// y: cnodeSection.points[0].y
|
||||
};
|
||||
mapDevice[elem.code].skew = {
|
||||
x: sectionCStar.x,
|
||||
y: sectionCStar.y
|
||||
// x: rnodeSection.points[rnodeSection.points.length - 2].x,
|
||||
// y: rnodeSection.points[rnodeSection.points.length - 2].y
|
||||
};
|
||||
} else if (cnodeSection.points[cnodeSection.points.length - 1].x == lnodeSection.points[0].x && cnodeSection.points[cnodeSection.points.length - 1].y == lnodeSection.points[0].y) {
|
||||
mapDevice[elem.code].intersection = {
|
||||
x: cnodeSection.points[cnodeSection.points.length - 1].x,
|
||||
y: cnodeSection.points[cnodeSection.points.length - 1].y
|
||||
x: intersectionEnd.x,
|
||||
y: intersectionEnd.y
|
||||
// x: cnodeSection.points[cnodeSection.points.length - 1].x,
|
||||
// y: cnodeSection.points[cnodeSection.points.length - 1].y
|
||||
};
|
||||
mapDevice[elem.code].skew = {
|
||||
x: sectionCEnd.x,
|
||||
y: sectionCEnd.y
|
||||
// x: rnodeSection.points[1].x,
|
||||
// y: rnodeSection.points[1].y
|
||||
};
|
||||
}
|
||||
|
||||
@ -264,7 +280,7 @@ export function parser(data, skinCode, showConfig) {
|
||||
|
||||
// 重置坐标点
|
||||
function handleResetPoint(points) {
|
||||
return (points[points.length - 1].x >= points[0].x) && (points[points.length - 1].y >= points[0].y);
|
||||
return (points[points.length - 1].x >= points[0].x);
|
||||
}
|
||||
|
||||
// 同步绘制数据到原始数据
|
||||
|
@ -260,33 +260,33 @@ export default {
|
||||
const end_x = endModel.points[0].x;
|
||||
const start_y = startModel.points[startModel.points.length - 1].y;
|
||||
const end_y = endModel.points[0].y;
|
||||
// if (end_x > start_x) {
|
||||
if (this.createModel.leftSectionCode === this.createModel.rightSectionCode) {
|
||||
this.$messageBox('左关联区段不能和右关联区段相同');
|
||||
return;
|
||||
if (end_x > start_x) {
|
||||
if (this.createModel.leftSectionCode === this.createModel.rightSectionCode) {
|
||||
this.$messageBox('左关联区段不能和右关联区段相同');
|
||||
return;
|
||||
}
|
||||
if (start_x === end_x && start_y === end_y) {
|
||||
this.$messageBox('左关联区段终点不能和右关联区段起点相同');
|
||||
return;
|
||||
}
|
||||
model.points = [
|
||||
{ x: start_x, y: start_y },
|
||||
{ x: end_x, y: end_y }
|
||||
];
|
||||
const models = [];
|
||||
model.leftSectionCode = this.createModel.leftSectionCode;
|
||||
startModel.rightSectionCode = model.code;
|
||||
endModel.leftSectionCode = model.code;
|
||||
model.rightSectionCode = this.createModel.rightSectionCode;
|
||||
models.push(model);
|
||||
models.push(startModel);
|
||||
models.push(endModel);
|
||||
this.$emit('updateMapModel', models);
|
||||
} else {
|
||||
this.$messageBox('画图顺序应左往右绘制, 请求重新定义左右关联区段');
|
||||
this.createModel.rightSectionCode = '';
|
||||
this.createModel.leftSectionCode = '';
|
||||
}
|
||||
if (start_x === end_x && start_y === end_y) {
|
||||
this.$messageBox('左关联区段终点不能和右关联区段起点相同');
|
||||
return;
|
||||
}
|
||||
model.points = [
|
||||
{ x: start_x, y: start_y },
|
||||
{ x: end_x, y: end_y }
|
||||
];
|
||||
const models = [];
|
||||
model.leftSectionCode = this.createModel.leftSectionCode;
|
||||
startModel.rightSectionCode = model.code;
|
||||
endModel.leftSectionCode = model.code;
|
||||
model.rightSectionCode = this.createModel.rightSectionCode;
|
||||
models.push(model);
|
||||
models.push(startModel);
|
||||
models.push(endModel);
|
||||
this.$emit('updateMapModel', models);
|
||||
// } else {
|
||||
// this.$messageBox('画图顺序应左往右绘制, 请求重新定义左右关联区段');
|
||||
// this.createModel.rightSectionCode = '';
|
||||
// this.createModel.leftSectionCode = '';
|
||||
// }
|
||||
},
|
||||
// 创建区段
|
||||
create() {
|
||||
|
Loading…
Reference in New Issue
Block a user