Atlaslog
Atlaslog / Examples / deck.gl / Business scenarios / Signal Strength Heatmap
deck.gl · Business scenario

Signal Strength Heatmap

50,000 sample points carry both RSRP and SINR; switching the metric recomputes the heatmap and the toolbar updates the mean and unit.

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

Business context

Radio optimisation engineers and complaint handlers use it to locate weak coverage, decide whether an area lacks sites or has a parameter problem, and to compare before and after a change. Data comes from drive tests and terminal-reported RSRP and SINR samples with cell identity and time. A provincial capital produces tens of millions of samples per day; after raster downsampling they enter the view, and this example uses 50,000 points and 40 sites.

Samples are attached to the nearest site and modelled with distance decay, and invalid values are dropped. Metrics have different directions: RSRP is negative and lower is worse, so it must be normalised before use as a weight; feeding raw values to HeatmapLayer makes weak areas the brightest. The two metrics have different units, so each keeps its own colour range and toolbar unit, and switching only changes getWeight and colorRange with geometry untouched.

The most common error is an inverted colour range, which turns weak coverage into a red hotspot. The second is reading brightness as coverage rate: kernel density reflects sample density and weight superposition, not whether RSRP meets a threshold. The third is the time window: drive tests concentrate on weekday daytime, so comparing them with all-day traffic data overstates coverage, and the two metrics must share a time basis.

How it works

The 40 sites are scattered across 116.26–116.58, 39.80–40.02 and the 50,000 sample points are assigned to them in turn, with a sqrt-uniform radius inside 2.8 km. Each point first computes a normalised distance decay = d/2800, then RSRP = -70 - decay·52 + noise, landing roughly between -66 and -126 dBm, and SINR = 21 - decay·26 + noise, landing roughly between 25 and -9 dB. HeatmapLayer fixes radiusPixels 22, intensity 1.5 and threshold 0.05, changing only getWeight and colorRange; both ramps run from deep blue-violet at low weight to orange-yellow at high weight.

RSRP is negative, so closer to zero is better, and the weight is written (rsrp + 140)/70, mapping -140 to 0 and -70 to 1; SINR is better when larger, and the weight is written (sinr + 5)/30, mapping -5 to 0 and 25 to 1. Using raw RSRP as the weight turns weak areas into hotspots, exactly reversing the meaning. The two metrics have different units, so the toolbar shows dBm and dB separately and they cannot share one ramp, or the same colour would mean opposite quality under each metric. Reversing the SINR ramp reproduces the direction error and lights up weak coverage as a solid block.

ConfigurationWhat it does
getWeight RSRP(rsrp + 140)/70, normalising negatives so strong signal weighs more
getWeight SINR(sinr + 5)/30, higher values weigh more
radiusPixels 22Kernel radius fixed in pixels; hotspot size unchanged when zooming
Two colorRangesColour range switched with the metric to avoid semantic conflict

Note. Set the RSRP weight to (rsrp + 70)/(-70) and reload: negative values become positive weights and weak coverage replaces strong signal as the red hotspot.

Source

demos/deckgl-biz-telecom-signal.html
<!--
  示例:信号强度热力
  要点:同一批采样点按 RSRP 与 SINR 切换权重,两套色带方向都以高权重为强信号
  依赖: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:12px;align-items:center;font-size:12px;color:#8b93a1;flex-wrap:wrap}
  .bar b{color:#58a6ff;font-weight:600}
  .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>50,000</b></span>
  <span class="sep"></span>
  <button data-metric="rsrp" class="on">RSRP</button>
  <button data-metric="sinr">SINR</button>
  <span>均值 <b id="mean">—</b> <span id="unit">dBm</span></span>
  <span class="sep"></span>
  <span>RSRP 越接近 0 越强 · SINR 越大越好</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 rand = rng(606060);

  var stations = [];
  for (var i = 0; i < 40; i++) {
    stations.push([116.26 + rand() * 0.32, 39.80 + rand() * 0.22]);
  }

  // 距离衰减叠加噪声:RSRP 约 -70 至 -122 dBm,SINR 约 21 至 -5 dB
  var samples = [];
  var sumR = 0;
  var sumS = 0;
  for (var t = 0; t < 50000; t++) {
    var s = stations[t % stations.length];
    var d = Math.sqrt(rand()) * 2800;
    var a = rand() * Math.PI * 2;
    var decay = d / 2800;
    var rsrp = -70 - decay * 52 + (rand() - 0.5) * 8;
    var sinr = 21 - decay * 26 + (rand() - 0.5) * 8;
    sumR += rsrp;
    sumS += sinr;
    samples.push({
      lng: s[0] + Math.cos(a) * d / (111320 * Math.cos(s[1] * Math.PI / 180)),
      lat: s[1] + Math.sin(a) * d / 110540,
      rsrp: rsrp,
      sinr: sinr
    });
  }

  var meanR = sumR / samples.length;
  var meanS = sumS / samples.length;

  // 两个指标量纲与方向不同,统一归一化到 0–1 再交给 HeatmapLayer
  function wRsrp(d) {
    return Math.max(0, Math.min(1, (d.rsrp + 140) / 70));
  }

  function wSinr(d) {
    return Math.max(0, Math.min(1, (d.sinr + 5) / 30));
  }

  var rsrpRange = [
    [14, 28, 60, 150],
    [30, 92, 150, 185],
    [46, 160, 172, 205],
    [140, 205, 120, 220],
    [246, 200, 84, 235],
    [235, 96, 60, 248]
  ];

  var sinrRange = [
    [30, 24, 78, 150],
    [86, 60, 170, 185],
    [64, 150, 220, 205],
    [96, 220, 190, 220],
    [190, 240, 120, 235],
    [255, 226, 100, 248]
  ];

  function buildHeat(metric) {
    return new deck.HeatmapLayer({
      id: 'signal-heat',
      data: samples,
      getPosition: function (d) { return [d.lng, d.lat]; },
      getWeight: metric === 'rsrp' ? wRsrp : wSinr,
      radiusPixels: 22,
      intensity: 1.5,
      threshold: 0.05,
      colorRange: metric === 'rsrp' ? rsrpRange : sinrRange
    });
  }

  var stationLayer = new deck.ScatterplotLayer({
    id: 'signal-stations',
    data: stations,
    getPosition: function (d) { return d; },
    getRadius: 4,
    radiusUnits: 'pixels',
    getFillColor: [14, 22, 32, 235],
    stroked: true,
    getLineColor: [140, 225, 255, 255],
    lineWidthUnits: 'pixels',
    getLineWidth: 1.6
  });

  var metric = 'rsrp';

  var deckgl = new deck.Deck({
    canvas: 'cv',
    width: '100%',
    height: '100%',
    initialViewState: {
      longitude: 116.41,
      latitude: 39.92,
      zoom: 10.4,
      pitch: 0,
      bearing: 0
    },
    controller: true,
    layers: [buildHeat(metric), stationLayer]
  });

  var meanLabel = document.getElementById('mean');
  var unitLabel = document.getElementById('unit');
  meanLabel.textContent = meanR.toFixed(1);
  unitLabel.textContent = 'dBm';

  var buttons = document.querySelectorAll('[data-metric]');
  for (var b = 0; b < buttons.length; b++) {
    buttons[b].addEventListener('click', function (e) {
      metric = e.currentTarget.getAttribute('data-metric');
      for (var k = 0; k < buttons.length; k++) {
        buttons[k].classList.toggle('on', buttons[k] === e.currentTarget);
      }
      meanLabel.textContent = (metric === 'rsrp' ? meanR : meanS).toFixed(1);
      unitLabel.textContent = metric === 'rsrp' ? 'dBm' : 'dB';
      deckgl.setProps({ layers: [buildHeat(metric), stationLayer] });
    });
  }

  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 · APIHeatmapLayer deck.gl · APIScatterplotLayer