From 5fedaa299ba01ac032f4b4ff4215cbde41f5f58b Mon Sep 17 00:00:00 2001 From: CN-JS-HuiBai Date: Mon, 6 Apr 2026 01:23:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BA=BF=E8=B7=AF=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/app.js | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/public/js/app.js b/public/js/app.js index f8ba033..53374e7 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -782,6 +782,41 @@ const endCoords = getShiftedCoords(route.dest); if (startCoords && endCoords) { + // Calculate direction and distance + const dx = endCoords[0] - startCoords[0]; + const dy = endCoords[1] - startCoords[1]; + + // Identify major regions + const src = (route.source || '').toLowerCase(); + const dst = (route.dest || '').toLowerCase(); + + const isUS = (n) => n.includes('united states') || n.includes('us ') || n.includes('seattle') || n.includes('san francisco') || n.includes('los angeles') || n.includes('new york') || n.includes('chicago'); + const isJapan = (n) => n.includes('japan') || n.includes('tokyo'); + const isAsia = (n) => n.includes('china') || n.includes('hong kong') || n.includes('singapore') || n.includes('korea') || n.includes('seoul') || n.includes('japan') || n.includes('tokyo') || n.includes('shanghai') || n.includes('beijing'); + const isEurope = (n) => n.includes('germany') || n.includes('uk') || n.includes('france') || n.includes('london') || n.includes('frankfurt') || n.includes('paris') || n.includes('united kingdom'); + + // Determine base curveness to always bend North (Upward) for major East-West routes + // In this map: dx < 0 (Westward) -> negative curveness bends North + // dx > 0 (Eastward) -> positive curveness bends North + let baseCurve = 0.2; + if (dx < 0) baseCurve = -0.2; + + // Special case: Trans-Pacific (US <-> Japan/Asia) - usually deeper curve + if ((isUS(src) && isAsia(dst)) || (isAsia(src) && isUS(dst))) { + baseCurve = (dx < 0 ? -0.35 : 0.35); + } + // Trans-Atlantic (US <-> Europe) - use coordinates to detect + else if ((isUS(src) && isEurope(dst)) || (isEurope(src) && isUS(dst))) { + baseCurve = (dx < 0 ? -0.25 : 0.25); + } + // Intra-Asia or shorter routes - flatter curve + else if (Math.abs(dx) < 50) { + baseCurve = (dx < 0 ? -0.15 : 0.15); + } + + // Add variation for multiple lines to same destination + const finalCurve = baseCurve + (index * 0.04 * (baseCurve > 0 ? 1 : -1)); + finalSeries.push({ type: 'lines', coordinateSystem: 'geo', @@ -798,7 +833,7 @@ lineStyle: { color: 'rgba(99, 102, 241, 0.3)', width: 2, - curveness: 0.2 + (index * 0.1) // Slightly different curves for clarity + curveness: finalCurve }, tooltip: { formatter: () => {