优化线条
This commit is contained in:
@@ -976,18 +976,26 @@
|
|||||||
const pts = [start, end].slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
const pts = [start, end].slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
||||||
const isForward = (start === pts[0]);
|
const isForward = (start === pts[0]);
|
||||||
|
|
||||||
// Simplified calculation to reduce crossings
|
// Normalization and special routing rules
|
||||||
// Maintaining a consistent direction for single lines ensures that parallel paths stay parallel
|
const lowS = (route.source || '').toLowerCase().trim();
|
||||||
|
const lowD = (route.dest || '').toLowerCase().trim();
|
||||||
|
const isSeattleJapan = ( (lowS === 'seattle' || lowS === 'us seattle') && lowD === 'japan' ) ||
|
||||||
|
( (lowD === 'seattle' || lowD === 'us seattle') && lowS === 'japan' );
|
||||||
|
|
||||||
let finalCurve = 0;
|
let finalCurve = 0;
|
||||||
if (count === 1) {
|
if (isSeattleJapan) {
|
||||||
// Subtle consistent curve for single routes
|
// Special rule: Seattle ↔ Japan route curves upward (North)
|
||||||
|
// For Seattle -> Japan (Westbound): Right is North (+).
|
||||||
|
// For Japan -> Seattle (Eastbound): Right is South (+), so North is (-).
|
||||||
|
const isWestbound = (lowS === 'seattle' || lowS === 'us seattle');
|
||||||
|
finalCurve = isWestbound ? 0.3 : -0.3;
|
||||||
|
} else if (count === 1) {
|
||||||
|
// Subtle consistent curve for single routes to maintain parallelism
|
||||||
finalCurve = 0.12;
|
finalCurve = 0.12;
|
||||||
} else {
|
} else {
|
||||||
// Symmetrical fan-out for multiple lines between the same points
|
// Symmetrical fan-out for multiple lines between the same points
|
||||||
// This spreads them cleanly into "eye" shapes without biased clustering
|
|
||||||
const magnitude = 0.12 + Math.floor(i / 2) * 0.12;
|
const magnitude = 0.12 + Math.floor(i / 2) * 0.12;
|
||||||
const spread = (i % 2 === 0) ? magnitude : -magnitude;
|
const spread = (i % 2 === 0) ? magnitude : -magnitude;
|
||||||
// Ensure visual consistency regardless of the data direction (A->B or B->A)
|
|
||||||
finalCurve = isForward ? spread : -spread;
|
finalCurve = isForward ? spread : -spread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user