优化线路图
This commit is contained in:
@@ -782,6 +782,41 @@
|
|||||||
const endCoords = getShiftedCoords(route.dest);
|
const endCoords = getShiftedCoords(route.dest);
|
||||||
|
|
||||||
if (startCoords && endCoords) {
|
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({
|
finalSeries.push({
|
||||||
type: 'lines',
|
type: 'lines',
|
||||||
coordinateSystem: 'geo',
|
coordinateSystem: 'geo',
|
||||||
@@ -798,7 +833,7 @@
|
|||||||
lineStyle: {
|
lineStyle: {
|
||||||
color: 'rgba(99, 102, 241, 0.3)',
|
color: 'rgba(99, 102, 241, 0.3)',
|
||||||
width: 2,
|
width: 2,
|
||||||
curveness: 0.2 + (index * 0.1) // Slightly different curves for clarity
|
curveness: finalCurve
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
formatter: () => {
|
formatter: () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user