逻辑区段始终点偏移
This commit is contained in:
parent
9991c50bb4
commit
e8e63f2976
@ -281,23 +281,28 @@ export default {
|
|||||||
},
|
},
|
||||||
setLogicOffset() {
|
setLogicOffset() {
|
||||||
const models = [];
|
const models = [];
|
||||||
|
// 正常情况下logicSectionCodeList下逻辑区段为从左向右
|
||||||
this.sectionList.forEach(section => {
|
this.sectionList.forEach(section => {
|
||||||
let startPoint = section.points[0];
|
let startPoint = section.points[0].x + 's' + section.points[0].y;
|
||||||
let startOffset = 0;
|
let startOffset = 0;
|
||||||
if (section.logicSectionCodeList) {
|
const sectionMap = {};
|
||||||
|
if (section.logicSectionCodeList && section.logicSectionCodeList.length) {
|
||||||
section.logicSectionCodeList.forEach(sectionCode => {
|
section.logicSectionCodeList.forEach(sectionCode => {
|
||||||
const logicSection = this.$store.getters['map/getDeviceByCode'](sectionCode);
|
const logicSection = this.$store.getters['map/getDeviceByCode'](sectionCode);
|
||||||
if (logicSection.points[0].x === startPoint.x && logicSection.points[0].y === startPoint.y) {
|
sectionMap[logicSection.points[0].x + 's' + logicSection.points[0].y] = logicSection;
|
||||||
const model = deepAssign({}, logicSection);
|
|
||||||
model.logicSectionStartOffset = startOffset;
|
|
||||||
model.logicSectionEndOffset = section.lengthFact - startOffset;
|
|
||||||
models.push(model);
|
|
||||||
startOffset += logicSection.lengthFact;
|
|
||||||
startPoint = logicSection.points[logicSection.points.length - 1];
|
|
||||||
} else {
|
|
||||||
console.log('error', logicSection, section );
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
while (sectionMap[startPoint]) {
|
||||||
|
const model = deepAssign({}, sectionMap[startPoint]);
|
||||||
|
model.logicSectionStartOffset = startOffset;
|
||||||
|
model.logicSectionEndOffset = (section.lengthFact * 1000 - startOffset * 1000) / 1000;
|
||||||
|
models.push(model);
|
||||||
|
if (!model.lengthFact) {
|
||||||
|
const length = section.lengthFact / section.logicSectionCodeList.length;
|
||||||
|
model.lengthFact = length.toFixed(3);
|
||||||
|
}
|
||||||
|
startOffset = (startOffset * 1000 + model.lengthFact * 1000) / 1000;
|
||||||
|
startPoint = model.points[model.points.length - 1].x + 's' + model.points[model.points.length - 1].y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.$emit('updateMapModel', models, 'five');
|
this.$emit('updateMapModel', models, 'five');
|
||||||
|
Loading…
Reference in New Issue
Block a user