Skip to content

Conversation

@anisometropie
Copy link

@anisometropie anisometropie commented Oct 29, 2025

Description

in the migration #538, numberOfStops is removed from the model. The PR allows to to import old files still containings it.

During loadNetzgrafikDto, we now replace numberOfStops with actual nodes in the graph.

closes #592
closes OpenRailAssociation/osrd#13286

some unit tests likely to fail until the whole migration is done

Issues

#592

Checklist

  • This PR contains a description of the changes I'm making
  • I've read the Contribution Guidelines
  • I've added tests for changes or features I've introduced
  • I documented any high-level concepts I'm introducing in documentation/
  • CI is currently green and this is ready for review

@anisometropie anisometropie reopened this Oct 29, 2025
@anisometropie anisometropie marked this pull request as ready for review October 29, 2025 12:49
Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! Overall looks good, just a few comments below.

Comment on lines +953 to +957
const interpolatedPosition = new Vec2D(
node1.getPositionX() + (node2.getPositionX() - node1.getPositionX()) * 0.5,
node1.getPositionY() + (node2.getPositionY() - node1.getPositionY()) * 0.5,
);
nodeIntermediate.setPosition(interpolatedPosition.getX(), interpolatedPosition.getY());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would find it slightly nicer to perform the action of setting the new intermediate node position in the caller. I find it surprising that this function moves any node.

Copy link
Author

@anisometropie anisometropie Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really sure would it make sense to create a node in this function and delegate the responsibility of setting its position to whomever is calling.

this function creates one node from two that already have a position. it would make sense to create a node that also have a position.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I thought this function wasn't creating any new node? Isn't the node ID passed as the last argument of this function? Isn't addEmptyNode() invoked by the caller?

If this function creates a new node, it would indeed make sense to set its position here as well. If this function doesn't create a new node, it would make more sense to not mutate any node from here.

Does that make sense?

Copy link

@clarani clarani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, LGTM overall, but I'm not a specialist of this codebase :)

Comment on lines 114 to 122
for (let i = 0; i < trainrunSection.numberOfStops; i++) {
const newNode = this.nodeService.addEmptyNode();
const {trainrunSection2} = this.trainrunSectionService.replaceIntermediateStopWithNode(
currentSection.id,
0,
newNode.getId(),
);
currentSection = trainrunSection2.getDto();
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind create a function in the trainrunSectionService to add an intermediate stop on it ? I think it might be useful for the future PRs. Thanks 🙏

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that,s already what replaceIntermediateStopWithNode does.

does you mean moving the entire replaceLegacyNumberOfStopsWithRealNodes into trainrunSectionService ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum I think it's fine like this in the end 👍

Copy link

@clarani clarani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants