fix(traffic): retain line identity across clipping

This commit is contained in:
German Khokhlov committed 2026-11-03 15:14:20 +04:00
1 parent 2e9c146060
commit 342d960582
3 files changed
+97 -14

No files matched your search

+5 -2
View File
@@ -112,6 +112,7 @@ function pairedSampleShare(segment, index) {
}
const length = cum[cum.length - 1];
if (!(length > 0)) return 0;
const line = segment.line || segment;
let paired = 0;
let i = 1;
for (const share of PAIRED_SIDE_SAMPLES) {
@@ -126,8 +127,10 @@ function pairedSampleShare(segment, index) {
xs[i - 1] + dx * t,
ys[i - 1] + dy * t,
reverse,
// A line that doubles back beside itself is not its own pair.
(piece) => (piece.flow === segment ? 0 : PAIRED_SIDE_RADIUS_M),
// A line that doubles back beside itself, even clipped into pieces,
// is not its own pair.
(piece) =>
(piece.flow.line || piece.flow) === line ? 0 : PAIRED_SIDE_RADIUS_M,
).best
)
paired++;