sectionLink问题调整

This commit is contained in:
fan 2023-08-09 15:27:38 +08:00
parent 2d52847289
commit d30734eef3
2 changed files with 24 additions and 14 deletions

View File

@ -185,7 +185,7 @@ export class SectionLink extends JlGraphic implements ILineGraphic {
if (!k2 || !k1) {
throw new Error('未获取到link两侧公里标');
}
this._linkLength = k2 - k1;
this._linkLength = Math.abs(k2 - k1);
}
return this._linkLength;
}

View File

@ -168,17 +168,17 @@ export class SectionLinkDraw extends GraphicDrawAssistant<
const forkP2 = new Point(turnout.position.x, turnout.position.y);
const points: IPointData[] = [forkP1];
const refTurnout1 = this.buildRelatedRef(
turnout.id,
rrDeviceType.Turnout,
port
);
const refTurnout2 = this.buildRelatedRef(
pRef.id,
rrDeviceType.Turnout,
pRef.devicePort
);
const refSimT1 = this.buildSimpleRef(turnout.id, srDeviceType.Turnout);
const refSimT2 = this.buildSimpleRef(pRef.id, srDeviceType.Turnout);
const refTurnout2 = this.buildRelatedRef(
turnout.id,
rrDeviceType.Turnout,
port
);
const refSimT1 = this.buildSimpleRef(pRef.id, srDeviceType.Turnout);
const refSimT2 = this.buildSimpleRef(turnout.id, srDeviceType.Turnout);
if (forkP1.x > forkP2.x) {
sectionLink.datas.aSimRef = refSimT2;
sectionLink.datas.bSimRef = refSimT1;
@ -361,12 +361,17 @@ export class SectionLinkDraw extends GraphicDrawAssistant<
* @param curLinks
* @param sectionLink
*/
recognizeAndCreateLink(curLinks: string[], sectionLink: SectionLink) {
recognizeAndCreateLink(
curLinks: string[],
sectionLink: SectionLink
): boolean {
const id1 = sectionLink.datas.aSimRef?.id;
const id2 = sectionLink.datas.bSimRef?.id;
if (!curLinks.includes(id1 + '_' + id2)) {
this.storeGraphic(sectionLink);
return true;
}
return false;
}
/**
* link
@ -402,18 +407,22 @@ export class SectionLinkDraw extends GraphicDrawAssistant<
axle1
);
gSectionList.push(g.id);
this.recognizeAndCreateLink(curLinks, link);
const addFlag = this.recognizeAndCreateLink(curLinks, link);
if (addFlag) {
this.cacheAxleLinkRelation(axleRefLink, axleCounting.id, link.id);
this.cacheAxleLinkRelation(axleRefLink, axle1.id, link.id);
}
}
} else if (g.type === Turnout.Type) {
const link = this.generateByTurnoutAxle(
g as Turnout,
device.devicePort,
axleCounting
);
this.recognizeAndCreateLink(curLinks, link);
const addFlag = this.recognizeAndCreateLink(curLinks, link);
if (addFlag) {
this.cacheAxleLinkRelation(axleRefLink, axleCounting.id, link.id);
}
this.cacheTurnoutPort(tpMap, g.id, device.devicePort);
}
});
@ -469,6 +478,7 @@ class LinkPolylineEditPlugin extends PolylineEditPlugin {
labels: VectorText[] = [];
constructor(g: ILineGraphic, options?: IEditPointOptions) {
super(g, options);
console.log(g._datas);
this.name = LinkPolylineEditPlugin.Name;
this.initLabels();
}