Atlaslog
Atlaslog / Examples / deck.gl / Business scenarios / Intercontinental Great Circles
deck.gl · Business scenario

Intercontinental Great Circles

28 airports and 110 routes worldwide, drawn by default as spherical shortest paths with GreatCircleLayer; a button switches to ArcLayer straight lines and a checkbox keeps only intercontinental routes.

Open standalone → Chinese notes All business examples
/demos/deckgl-biz-migration-globe.htmlLIVE
single HTML file · CDN dependencies onlyinterface labels are in Chinese

Business context

Air network analysts, route planners and international logistics teams use global route maps to assess hub connectivity and the distribution of intercontinental capacity, and to judge whether a new destination is worth applying for. Data comes from flight schedules, ADS-B tracks and ticketing ODs, aggregated by airport pair; between major global airports there are typically thousands to tens of thousands of routes, each carrying thousands to tens of millions of annual passengers.

Airport coordinates are first unified to one geodetic datum, passenger flows aggregated by airport pair with stopover splits deduplicated, and routes across dates merged into one representative record. GreatCircleLayer is chosen for long-haul routes because it samples along the spherical shortest path, close to real airways; ArcLayer serves flat schematic views, where getHeight at zero produces a Mercator straight for direct comparison of the two geometries.

On a Mercator basemap a great circle looks curved, which is projection distortion rather than a drawing error, and measuring distance along it inflates the result noticeably. Another easy confusion is route count versus flight count: one route is one airport pair that may have several flights a day, and treating them as the same measure overstates network density.

How it works

28 airports are tagged by continent and 110 routes are generated from a seeded source with width 1+sqrt(pax)/120 pixels. GreatCircleLayer consumes only getSourcePosition, getTargetPosition, color and width, sampling vertices along the spherical shortest path; ArcLayer uses the same data with getHeight set to 0, flattening the arc into a straight line for direct comparison of the two geometries.

The divergence is largest over long distances: Beijing–New York as a great circle grazes the Arctic Circle while the Mercator straight crosses the mid-latitude Atlantic, and trans-Pacific routes can even bend in opposite directions. Great circles suit transoceanic routes, closer to real airways and fuel estimates; ArcLayer expresses direction and volume but is not a distance measure. The continent-only checkbox filters on the cont field, keeping the intercontinental share of the 110.

ConfigurationWhat it does
getSourcePositionOrigin airport coordinates
getWidth1+sqrt(pax)/120, line width by passenger volume
widthMinPixels1 px so routes stay visible at global zoom
getHeightArcLayer only; 0 flattens the arc into a straight line

Note. Prefer GreatCircleLayer for transoceanic routes; use ArcLayer when height or a flat schematic is needed, and keep getHeight below 0.1 to avoid exaggerated bending.

Source

demos/deckgl-biz-migration-globe.html
<!--
  示例:洲际航线大圆
  要点:GreatCircleLayer 与 ArcLayer 共用 110 条 OD,按钮切换球面最短路径与经纬度直线
  依赖:deck.gl 9.0 · jsDelivr CDN
-->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta name="robots" content="noindex,follow">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>洲际航线大圆</title>
<style>
  html,body{height:100%;margin:0;background:#0d1117}
  body{display:flex;flex-direction:column;overflow:hidden;
       font:13px/1.6 -apple-system,"Segoe UI","PingFang SC",sans-serif;color:#e6e8ec}
  .bar{position:relative;z-index:5;flex:0 0 auto;padding:8px 12px;background:#161b22;border-bottom:1px solid #252c36;
       display:flex;gap:10px;align-items:center;font-size:12px;color:#8b93a1;flex-wrap:wrap}
  .bar b{color:#58a6ff;font-weight:600}
  .bar label{display:flex;align-items:center;gap:5px;cursor:pointer}
  .bar input[type=checkbox]{accent-color:#4f9ef8}
  .bar button{font:inherit;font-size:12px;padding:3px 10px;border-radius:5px;cursor:pointer;
              border:1px solid #303845;background:#1d2531;color:#c8d2e0}
  .bar button:hover{background:#253040}
  .bar button.on{background:#2c4a7a;border-color:#4f8ad6;color:#dfe9ff}
  .bar .sep{width:1px;height:18px;background:#2a313c;margin:0 4px}
  #cv{flex:1 1 auto;min-height:0;width:100%;display:block}
</style>
</head>
<body>
<div class="bar">
  <span>航线 <b id="n">—</b></span>
  <span class="sep"></span>
  <button data-mode="gc" class="on">大圆</button>
  <button data-mode="arc">弧线</button>
  <span class="sep"></span>
  <label><input id="inter" type="checkbox"> 只看洲际</label>
  <span class="sep"></span>
  <span>28 个机场 · 6 个大洲</span>
</div>
<canvas id="cv"></canvas>
<script src="https://cdn.jsdelivr.net/npm/deck.gl@9.0.35/dist.min.js"></script>
<script>
(function () {
  'use strict';

  if (typeof deck === 'undefined') {
    document.body.innerHTML =
      '<div style="padding:24px;color:#ff8c74">deck.gl 加载失败,请检查能否访问 cdn.jsdelivr.net</div>';
    return;
  }

  function rng(seed) {
    var a = seed >>> 0;
    return function () {
      a = (a + 0x6D2B79F5) >>> 0;
      var t = Math.imul(a ^ (a >>> 15), 1 | a);
      t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
      return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
    };
  }

  var airports = [
    { code: 'PEK', city: '北京', pos: [116.41, 39.90], cont: '亚洲' },
    { code: 'PVG', city: '上海', pos: [121.47, 31.23], cont: '亚洲' },
    { code: 'CAN', city: '广州', pos: [113.26, 23.13], cont: '亚洲' },
    { code: 'HKG', city: '香港', pos: [113.91, 22.32], cont: '亚洲' },
    { code: 'NRT', city: '东京', pos: [140.39, 35.77], cont: '亚洲' },
    { code: 'ICN', city: '首尔', pos: [126.45, 37.46], cont: '亚洲' },
    { code: 'SIN', city: '新加坡', pos: [103.99, 1.36], cont: '亚洲' },
    { code: 'BKK', city: '曼谷', pos: [100.75, 13.69], cont: '亚洲' },
    { code: 'DEL', city: '德里', pos: [77.10, 28.56], cont: '亚洲' },
    { code: 'LHR', city: '伦敦', pos: [-0.45, 51.47], cont: '欧洲' },
    { code: 'CDG', city: '巴黎', pos: [2.55, 49.01], cont: '欧洲' },
    { code: 'FRA', city: '法兰克福', pos: [8.56, 50.03], cont: '欧洲' },
    { code: 'AMS', city: '阿姆斯特丹', pos: [4.76, 52.31], cont: '欧洲' },
    { code: 'MAD', city: '马德里', pos: [-3.57, 40.47], cont: '欧洲' },
    { code: 'FCO', city: '罗马', pos: [12.25, 41.80], cont: '欧洲' },
    { code: 'SVO', city: '莫斯科', pos: [37.41, 55.97], cont: '欧洲' },
    { code: 'JFK', city: '纽约', pos: [-73.78, 40.64], cont: '北美' },
    { code: 'LAX', city: '洛杉矶', pos: [-118.41, 33.94], cont: '北美' },
    { code: 'ORD', city: '芝加哥', pos: [-87.90, 41.98], cont: '北美' },
    { code: 'YYZ', city: '多伦多', pos: [-79.63, 43.68], cont: '北美' },
    { code: 'SFO', city: '旧金山', pos: [-122.38, 37.62], cont: '北美' },
    { code: 'GRU', city: '圣保罗', pos: [-46.47, -23.43], cont: '南美' },
    { code: 'EZE', city: '布宜诺斯艾利斯', pos: [-58.54, -34.82], cont: '南美' },
    { code: 'BOG', city: '波哥大', pos: [-74.15, 4.70], cont: '南美' },
    { code: 'JNB', city: '约翰内斯堡', pos: [28.25, -26.14], cont: '非洲' },
    { code: 'CAI', city: '开罗', pos: [31.41, 30.11], cont: '非洲' },
    { code: 'SYD', city: '悉尼', pos: [151.18, -33.95], cont: '大洋洲' },
    { code: 'AKL', city: '奥克兰', pos: [174.79, -37.01], cont: '大洋洲' }
  ];

  var rand = rng(20261125);
  var routes = [];
  var seen = {};
  var guard = 0;
  while (routes.length < 110 && guard < 4000) {
    guard++;
    var ai = Math.floor(rand() * airports.length);
    var bi = Math.floor(rand() * airports.length);
    if (ai === bi) continue;
    var key = ai + '-' + bi;
    if (seen[key]) continue;
    seen[key] = 1;
    routes.push({
      a: airports[ai],
      b: airports[bi],
      pax: Math.round(300 + Math.pow(rand(), 2.5) * 89700)
    });
  }

  var mode = 'gc';
  var interOnly = false;

  function visible() {
    if (!interOnly) return routes;
    var out = [];
    for (var k = 0; k < routes.length; k++) {
      if (routes[k].a.cont !== routes[k].b.cont) out.push(routes[k]);
    }
    return out;
  }

  function srcColor() { return [64, 154, 255, 210]; }
  function dstColor() { return [255, 158, 64, 225]; }
  function routeWidth(d) { return 1 + Math.sqrt(d.pax) / 120; }

  function buildLayers() {
    var data = visible();
    if (mode === 'gc') {
      return [new deck.GreatCircleLayer({
        id: 'routes-gc',
        data: data,
        getSourcePosition: function (d) { return d.a.pos; },
        getTargetPosition: function (d) { return d.b.pos; },
        getSourceColor: srcColor,
        getTargetColor: dstColor,
        getWidth: routeWidth,
        widthUnits: 'pixels',
        widthMinPixels: 1,
        pickable: true
      })];
    }
    return [new deck.ArcLayer({
      id: 'routes-arc',
      data: data,
      getSourcePosition: function (d) { return d.a.pos; },
      getTargetPosition: function (d) { return d.b.pos; },
      getSourceColor: srcColor,
      getTargetColor: dstColor,
      getWidth: routeWidth,
      widthUnits: 'pixels',
      widthMinPixels: 1,
      getHeight: 0,
      pickable: true
    })];
  }

  var deckgl = new deck.Deck({
    canvas: 'cv',
    width: '100%',
    height: '100%',
    initialViewState: {
      longitude: 20,
      latitude: 12,
      zoom: 1.2,
      pitch: 0,
      bearing: 0
    },
    controller: true,
    layers: buildLayers(),
    getTooltip: function (info) {
      if (!info.object) return null;
      return info.object.a.city + ' → ' + info.object.b.city +
        ' · ' + info.object.pax.toLocaleString() + ' 人次';
    }
  });

  function refreshCount() {
    document.getElementById('n').textContent = visible().length;
  }

  var buttons = document.querySelectorAll('[data-mode]');
  for (var b = 0; b < buttons.length; b++) {
    buttons[b].addEventListener('click', function (e) {
      mode = e.currentTarget.getAttribute('data-mode');
      for (var k = 0; k < buttons.length; k++) {
        buttons[k].classList.toggle('on', buttons[k] === e.currentTarget);
      }
      deckgl.setProps({ layers: buildLayers() });
    });
  }

  document.getElementById('inter').addEventListener('change', function (e) {
    interOnly = e.currentTarget.checked;
    refreshCount();
    deckgl.setProps({ layers: buildLayers() });
  });

  refreshCount();
  window.__deck = deckgl;
})();
</script>
</body>
</html>
Language: this page is in English; the demo keeps Chinese interface labels and code comments. The Chinese page carries the full notes and the same runnable file.

More business examples

deck.gl · APIGreatCircleLayer deck.gl · APIArcLayer deck.gl · APILineLayer