mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 03:14:00 +00:00
fix(traffic): keep a TomTom side from pairing with its own pieces
A one_side line that doubles back within 5 m of itself, such as a turnaround drawn as one line, matched its own return leg and took a two-way half share with no partner. Flow index pieces now carry their source line, and a radiusFor of 0 leaves a piece out of nearest(), so pairing skips the line's own pieces. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
1cd4dde26d
commit
9caa0947b6
3 files changed
+14
-3
No files matched your search
@@ -126,7 +126,8 @@ function pairedSampleShare(segment, index) {
|
||||
xs[i - 1] + dx * t,
|
||||
ys[i - 1] + dy * t,
|
||||
reverse,
|
||||
() => PAIRED_SIDE_RADIUS_M,
|
||||
// A line that doubles back beside itself is not its own pair.
|
||||
(piece) => (piece.flow === segment ? 0 : PAIRED_SIDE_RADIUS_M),
|
||||
).best
|
||||
)
|
||||
paired++;
|
||||
|
||||
@@ -163,6 +163,14 @@ test('a TomTom side paired along only part of its length keeps its share', () =>
|
||||
assert.equal(weightOfFlow(partner(-97.7434)), 1);
|
||||
assert.equal(weightOfFlow(partner(-97.7428)), 0.5);
|
||||
});
|
||||
test('a TomTom side that doubles back beside itself is not its own pair', () => {
|
||||
// East along `coordinates`, then back west about 1 m north.
|
||||
const hairpin = {
|
||||
...flow,
|
||||
coords: [...coordinates, [-97.742, 30.26701], [-97.744, 30.26701]],
|
||||
};
|
||||
assert.equal(flowSegmentsToRoads([hairpin])[0].densityWeight ?? 1, 1);
|
||||
});
|
||||
test('bearing and distance reject nearby crossing and separate OSM roads', () => {
|
||||
const parallel = {
|
||||
...main,
|
||||
|
||||
Reference in new issue
Block a user