GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Maps, GIS and field navigation / testcode / sandbox/202609052028/atlas/source

Menu Bar and 6 more files

A JavaScript file in the source folder of Testcode that draws engine graph and uses data from the ventus-grid-engine, data-federation-map-for-GlobalGrid2050-all-repos and spiders repositories.

620 lines of JavaScript and HTML and Python from testcode, vedic-, ventus-grid-engine, in 7 files. Topic: Maps, GIS and field navigation. Section 723 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Menu Bar render · testcode / sandbox/202609052028/atlas/source/menu-bar.js lines 1209–1478
  2. Sandbox — Atlas Page render · testcode / sandbox/202609060459/atlas/index.html lines 1–108
  3. Teleprinter Bootstrap render · testcode / sandbox/202609060503/atlas/teleprinter-bootstrap.js lines 1–21
  4. Atlas Composition Contract transform · testcode / sandbox/capsules/atlas-composition-contract.mjs lines 1–12
  5. Offshore Route Browser render · testcode / sandbox/tools/offshore-route.browser.cjs lines 1–71
  6. VEDIC Verify Reuse Routes ingest · vedic- / tools/verify_reuse_routes.py lines 1–38
  7. Geo Area geodesy · ventus-grid-engine / engine/geo-area.js lines 1–100

Menu Bar

A JavaScript file in the source folder of Testcode that draws engine graph and uses data from the ventus-grid-engine, data-federation-map-for-GlobalGrid2050-all-repos and spiders repositories.

rendertestcode / sandbox/202609052028/atlas/source/menu-bar.js · lines 1209–1478 of 1478 · version 2026-09-05 20:28 (continued from section 721) · Not reached from any entry point (candidate for review) · pattern appendEngineModules (shared by 10 files)

What it does
It draws engine graph. Defines 42 functions or classes, including array, cleanText, layerKey, layerLabel, layerGroup. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Inputs & outputs
In: data source: ventus-grid-engine data; data source: data-federation-map-for-globalgrid2050-all-repos data; data source: spiders data; JSON file engine-graph.json; form fields (user input). Out: downloaded file gridatlas-; canvas drawing.
What it achieves
It cleans text (`cleanText`), syncs attrib clearance (`syncAttribClearance`) and syncs layer (`syncLayer`). V9.94 proved that the conventional menu is the right shape and the wrong implementation can still strand the product. It responds to click, keydown and afterprint events.
Why it matters
No other file in the estate was found to import it.
Application
testcode · sandbox/202609052028/atlas/source · script
Uses
Spider Full Po Test (estate URL), Data — Grid Studies Public Page (estate URL)
Used by
none found
Produces
array, cleanText, layerKey, layerLabel, layerGroup, inventory, required, installStyle, syncAttribClearance, closeAll, syncLayer, syncAll
Defines here
adoptLate, install, loudFailure, start
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
testcode@a8a215982b13d6e2f6019b40bf0bef5755719773 sandbox/202609052028/atlas/source/menu-bar.js:1209-1478 · blob 187a2694983ffab91c0421fb5c5d9bddf35804b7 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: experimental · users: none · canonical: unreached_review
      coarse = false;
    }
    var width = Number(window.innerWidth);
    var narrow = isFinite(width) && width > 0 && width <= 700;
    return coarse || narrow;
  }

  function adoptLate(doc) {
    if (!bar) return;
    move(panels.View, doc.getElementById('gridatlas-gb-conditions'));
    move(panels.About, doc.getElementById('gridatlas-version-ledger'));
    move(panels.View, doc.getElementById('btn-fullscreen-exit'), 'Exit full screen');

    var curtain = doc.getElementById('fs-curtain-tab');
    if (curtain && !bar.contains(curtain)) {
      curtain.setAttribute('role', 'button');
      curtain.setAttribute('tabindex', '0');
      curtain.setAttribute('aria-label', 'Open the fullscreen layer curtain');
      move(panels.Grid, curtain);
    }

    var tray = doc.getElementById('gridatlas-mobile-tray');
    if (tray) {
      array(tray.querySelectorAll('button')).forEach(function (button) {
        if (chipStaysOnMap(button)) return;   // one tap on a phone, not two
        var route = trayRoute(button);
        if (route) move(panels[route], button);
        else button.hidden = true;       // Tools only revealed the controls now in menus
      });
    }

    move(panels.Scope, doc.getElementById('btn-gridpoint'));

    var disclaimer = doc.querySelector('.disclaimer-box');
    var shoutout = doc.querySelector('.podcast-shoutout');
    move(panels.About, disclaimer);
    move(panels.About, shoutout);

    state.estate_links = appendEstateLinks(panels.About);
    appendEngineModules(panels.File);
    state.export_controls = appendExport(panels.File, doc);
    state.studies = appendStudies(panels.View);

    /* The map attribution moves off the map and into About, LAST, in small
       print.
       ----------------------------------------------------------------------
       Measured live at generation 202609042123, 2026-09-05: .custom-map-attrib
       rendered at x=15 y=47, 401x24 px -- a boxed band immediately under the
       menu bar, over the top-left of the map, which is where a reader arriving
       on a deep link looks first. On a 393x852 phone it wrapped to two lines
       and the architect photographed the consequence: opening EDIT drew
       "Status Colours" UNDERNEATH the attribution box, the two overlapping in
       the same space. His instruction, verbatim: "Attribution bar clashes move
       that to about and in small print at the bottom".

       The credit is owed and is not dropped: it is the same node, moved once,
       text intact, so OpenStreetMap, CARTO and Open Charge Map are still named
       on the page and one tap away. It is appended AFTER the estate links, and
       re-appended on every later adoption pass, so a late DOM rebuild cannot
       leave it above the controls again. appendChild on a node already in the
       panel moves it to the end rather than duplicating it. */
    var attrib = doc.querySelector('.custom-map-attrib');
    if (attrib) {
      if (!bar || !bar.contains(attrib)) move(panels.About, attrib);
      else if (panels.About.lastElementChild !== attrib) panels.About.appendChild(attrib);
      /* The `lastElementChild` test is not tidiness, it is the difference
         between this working and crashing the tab. adoptLate runs from a
         MutationObserver, so an unconditional appendChild here IS a mutation,
         which re-enters adoptLate, which appends again: a feedback loop that
         crashed the renderer outright under the 393x852 arrival gate, while
         the previous generation passed the same gate in the same harness.
         Once the node is already last, this is a no-op and the loop closes. */
    }

    /* The real .scada-brand (VENTUS, again) and .status-legend move once,
       into the restored SCADA panel's head, during install() below -- not
       hidden as a "duplicate" and not here, so a late DOM rebuild cannot
       repeatedly fight over one node's location. */

    /* The panel's own show/hide control stays REACHABLE. It was hidden here as
       "superseded; measured inert", and it is neither: the stylesheet rule
       above was hiding the panel it moved, so its effect could not be seen.
       With the panel restored this is the only control that opens and closes
       it, and hiding it would leave a phone with a collapsed panel and nothing
       to open it with -- which is the fault this generation exists to end. */
    var dashToggle = doc.getElementById('gridatlas-dash-toggle');
    if (dashToggle) dashToggle.hidden = false;

    var stack = doc.querySelector('.map-controls');
    if (stack) {
      var leftovers = array(stack.querySelectorAll('button,input,select,textarea,a'))
        .filter(function (node) { return !node.hidden; });
      if (leftovers.length === 0) stack.setAttribute('data-gridatlas-menu-emptied', '1');
    }

    MENUS.forEach(function (name) {
      state.panel_counts[name] = panels[name] ? panels[name].children.length : 0;
    });
  }

  function install(doc) {
    if (state.installed || doc.getElementById(BAR_ID)) return true;
    var ready = required(doc);
    state.engine_layer_controls = ready.found.engine.length;
    state.pipeline_layer_controls = ready.found.pipeline.length;
    state.layer_controls = ready.found.controls.length;
    if (ready.missing.length) {
      state.waiting_for = ready.missing.slice();
      return false;
    }

    installStyle(doc);
    bar = buildBar(doc);
    buildLayerControls(ready.found);

    // Search stays on the map throughout initialization.
    if (ready.nodes.search) ready.nodes.search.setAttribute("data-testcode-search", "persistent");
    move(panels.File, ready.nodes.exportButton);
    move(panels.Edit, ready.nodes.statusButton);
    move(panels.View, ready.nodes.fullscreenButton);
    move(panels.Scope, ready.nodes.radiusButton);
    move(panels.Scope, ready.nodes.radiusAreaButton);
    move(panels.Scope, ready.nodes.zoneButton);
    move(panels.Scope, ready.nodes.measureButton);

    /* The VENTUS masthead: fused into the bar's own centre (see buildBar),
       never a closed panel -- the architect's "VENTUS branding has been
       lost" was this node being moved into a collapsed About panel, and
       the measured "flash then vanish" (present for ~1.5s, then torn out)
       was that same move happening after the raw v8 page had already
       painted it once. Moving it here, into brandSlot, keeps it visible
       through the whole transition: raw markup, then fused into the bar,
       never hidden in between. */
    move(brandSlot, ready.nodes.header);

    /* The restored SCADA panel's head: the real .scada-brand (VENTUS,
       again, exactly as v8 rendered it) and .status-legend, moved once --
       not cloned, not hidden as a duplicate. gridHead sits above gridBody
       (built by buildLayerControls) and never enters its column flow. */
    move(gridHead, doc.querySelector('.scada-brand'));
    move(gridHead, doc.querySelector('.status-legend'));

    ready.nodes.host.insertBefore(bar, ready.nodes.host.firstChild);
    doc.documentElement.classList.add('gridatlas-menu-hosted');
    syncAttribClearance(doc);
    if (typeof ResizeObserver === 'function') {
      var barResize = new ResizeObserver(function () {
        syncAttribClearance(doc);
        if (openPanelRefs) clampPanel(doc, openPanelRefs.menu, openPanelRefs.panel);
      });
      barResize.observe(bar);
      state.attrib_clearance_source = 'ResizeObserver';
    } else if (doc.defaultView && typeof doc.defaultView.addEventListener === 'function') {
      /* No ResizeObserver: a viewport resize is the only other way the
         bar's own height changes (the @media breakpoint), so fall back to
         watching that. */
      doc.defaultView.addEventListener('resize', function () {
        syncAttribClearance(doc);
        if (openPanelRefs) clampPanel(doc, openPanelRefs.menu, openPanelRefs.panel);
      });
      state.attrib_clearance_source = 'resize-listener';
    }

    /* One document click listener and one change listener, installed once.
       The retry path cannot multiply effects. */
    doc.addEventListener('click', function (event) {
      if (!bar.contains(event.target)) {
        if (!forwardingLayerChoice) closeAll();
      }
      else if (event.target && /^(BUTTON|INPUT)$/.test(event.target.tagName || '')) {
        if (event.target.type !== 'text'
          && !event.target.classList.contains('gm-title')
          && !event.target.hasAttribute('data-gridatlas-layer-proxy')) {
          window.setTimeout ? window.setTimeout(closeAll, 0) : closeAll();
        }
      }
    });
    doc.addEventListener('change', function (event) {
      var key = layerKey(event.target);
      if (key && layerProxies[key]) syncLayer(key);
    });
    state.listeners = 2;

    adoptLate(doc);
    closeAll();
    state.installed = true;
    state.waiting_for = [];
    state.failure = null;
    state.one_identity_surface = true;
    state.mobile_sheet_hit_target_guard = true;
    state.layer_status_mirrored = true;
    state.layer_menu_stays_open = true;

    if (typeof MutationObserver === 'function') {
      observer = new MutationObserver(function () {
        adoptLate(doc);
        syncAll();
      });
      observer.observe(doc.body, { childList: true, subtree: true, characterData: true });
    }
    return true;
  }

  state.install = function () { return install(document); };
  state.closeAll = closeAll;

  function loudFailure(doc) {
    if (state.installed || doc.getElementById(FAILURE_ID)) return;
    var found = inventory(doc);
    state.failure = 'menu not installed: expected 60 engine + 3 Pipeline News layer controls; found '
      + found.engine.length + ' + ' + found.pipeline.length;
    if (window.console && typeof window.console.error === 'function') {
      window.console.error('[GRIDATLAS MENU] ' + state.failure);
    }
    var alert = doc.createElement('div');
    alert.id = FAILURE_ID;
    alert.setAttribute('role', 'alert');
    alert.textContent = state.failure + '. Original controls remain available.';
    alert.style.cssText = 'position:fixed;left:8px;right:8px;top:8px;z-index:10030;'
      + 'padding:8px;background:#280b0b;color:#ffd0d0;border:1px solid #b44;'
      + 'font:11px/1.4 monospace';
    (doc.body || doc.documentElement).appendChild(alert);
  }

  function start() {
    /* Cartridge proofs and prerenderers can provide a deliberately partial
       document. Treat that exactly like any other missing dependency: publish
       the refusal and leave the owner's interface untouched. In particular,
       do not start the 40-second browser retry loop against a non-DOM stub. */
    if (!document.documentElement || typeof document.createElement !== 'function') {
      state.failure = 'menu not installed: full document unavailable';
      return;
    }
    var probe = document.createElement('div');
    if (!probe || typeof probe.setAttribute !== 'function' || !probe.classList) {
      state.failure = 'menu not installed: full DOM element API unavailable';
      return;
    }
    if (install(document)) return;
    if (typeof window.setInterval !== 'function'
      || typeof window.clearInterval !== 'function') return;
    timer = window.setInterval(function () {
      state.tries += 1;
      if (install(document)) {
        window.clearInterval(timer);
        timer = null;
      } else if (state.tries >= MAX_TRIES) {
        window.clearInterval(timer);
        timer = null;
        loudFailure(document);
      }
    }, 250);
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', start, { once: true });
  } else {
    start();
  }
}());

;(() => {
 const style=document.createElement('style');style.textContent=`
 .search-bar-wrapper{display:flex!important;position:absolute!important;top:64px!important;left:12px!important;right:12px!important;width:auto!important;max-width:520px!important;z-index:1100!important;margin:0!important;transform:none!important}
 .search-bar-wrapper input{min-height:48px!important;font-size:16px!important;width:100%!important;box-sizing:border-box}
 .testcode-identity{position:fixed;right:12px;bottom:64px;z-index:2000;background:#08161fee;color:#aaf6ff;padding:8px;border:1px solid #36616a;font:12px monospace;text-decoration:none}
 @media print{.testcode-identity,.search-bar-wrapper{display:none!important}}
 `;document.head.append(style);
 const link=document.createElement('a');link.className='testcode-identity';link.href='/testcode/202609052028/';link.textContent='Test Code · 202609052028';document.body.append(link);
})();

Sandbox — Atlas Page

A web page in Testcode that works with escape attribute (`escapeAttribute`) and sha256 hex (`sha256Hex`), using SHA-256.

rendertestcode / sandbox/202609060459/atlas/index.html · lines 1–108 of 108 · version 2026-09-06 04:59 · Entry point · pattern escapeAttribute (shared by 6 files)

What it does
It draws its content. Defines invariant, escapeAttribute, sha256Hex, fail. Uses libraries ${escapeAttribute(blobUrl)}, ' + escapeAttribute(teleprinterUrl) + '. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. README: "The publication checkout is sparse: `index.html` and the complete `uk_renewables_pipeline/` tree."
Inputs & outputs
In: JSON file current.json. Out: web page.
Downstream impact
It is itself an entry point (page); no other file was found loading it.
What it achieves
It is built from the invariant step (`invariant`), the escape attribute helper (`escapeAttribute`) and the sha256 hex helper (`sha256Hex`). Test Code Atlas. It reads `./current.json`.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
testcode · sandbox/202609060459/atlas · page
Uses
${escapeAttribute(blobUrl)}, ' + escapeAttribute(teleprinterUrl) + '
Used by
mentioned in Standalone (comment link)
Produces
invariant, escapeAttribute, sha256Hex, fail
Defines here
invariant, escapeAttribute, sha256Hex, fail
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
testcode@a8a215982b13d6e2f6019b40bf0bef5755719773 sandbox/202609060459/atlas/index.html:1-108 · blob 4877bbedc7da9f84cb4fad8f72e5499ccf8ea55a · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: experimental · users: none · canonical: duplicate_candidate
<!doctype html>
<html lang="en">
<head><link rel="icon" href="data:,">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>Test Code Atlas 202609060459</title>
  <style>
    html,body{height:100%;margin:0;background:#000;color:#00ffff;font:13px monospace}
    #gridatlas-loader{display:grid;place-items:center;height:100%;padding:24px;text-align:center}
    #gridatlas-loader strong{color:#ffae00}
  </style>
</head>
<body data-gridatlas-router="loading">
  <main id="gridatlas-loader"><div><strong>GRIDATLAS</strong><br>verifying immutable shell and cartridges…</div></main>
  <script type="module">
    const SCRIPT_CLOSE = '</scr' + 'ipt>';
    const loader = document.getElementById('gridatlas-loader');

    function invariant(condition, message) {
      if (!condition) throw new Error(message);
    }

    function escapeAttribute(value) {
      return String(value).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;');
    }

    async function sha256Hex(bytes) {
      const digest = await crypto.subtle.digest('SHA-256', bytes);
      return [...new Uint8Array(digest)].map(value => value.toString(16).padStart(2, '0')).join('');
    }

    function fail(error) {
      console.error('[GRIDATLAS COMPOSER]', error);
      document.body.dataset.gridatlasRouter = 'failed';
      loader.innerHTML = `<div><strong>GRIDATLAS COMPOSITION FAILED</strong><br>${String(error?.message || error).replace(/[<>&]/g, '')}<br><small>The immutable shell was not changed.</small></div>`;
    }

    try {
      const currentResponse = await fetch('./current.json', { cache: 'no-store' });
      invariant(currentResponse.ok, `current.json HTTP ${currentResponse.status}`);
      const current = await currentResponse.json();
      invariant(current?.schema === 'gridatlas.current.v2', 'unsupported current.json schema');
      invariant(current?.architecture === 'IMMUTABLE_SHELL_PLUS_HASHED_CARTRIDGES', 'architecture contract mismatch');
      invariant(Array.isArray(current.cartridge_order) && Array.isArray(current.cartridges), 'cartridge registry malformed');

      const shellUrl = new URL(current.shell.index, window.location.href);
      const shellBase = new URL(current.shell.base, window.location.href).href;
      const shellResponse = await fetch(shellUrl, { cache: 'no-store' });
      invariant(shellResponse.ok, `immutable shell HTTP ${shellResponse.status}`);
      let html = await shellResponse.text();
      invariant(/<head\b/i.test(html) && /<body\b/i.test(html), 'immutable shell is not HTML');
      html = html.replace(/<head([^>]*)>/i, match => `${match}\n<base href="${escapeAttribute(shellBase)}">`);

      const byId = new Map(current.cartridges.map(item => [item.id, item]));
      const loaded = [];
      const scriptTagPattern = new RegExp('<script\\b[^>]*\\bsrc=(["\\\'])([^"\\\']+)\\1[^>]*>\\s*<\\/script>', 'gi');

      for (const id of current.cartridge_order) {
        const cartridge = byId.get(id);
        invariant(cartridge, `missing cartridge ${id}`);
        invariant(cartridge.type === 'script', `${id}: unsupported cartridge type`);
        invariant(cartridge.slot === 'replace-script', `${id}: unsupported cartridge slot`);
        invariant(typeof cartridge.replace_script === 'string' && cartridge.replace_script, `${id}: replace_script missing`);
        invariant(/^[a-f0-9]{64}$/.test(cartridge.sha256 || ''), `${id}: invalid SHA-256`);

        const cartridgeUrl = new URL(cartridge.path, window.location.href);
        const response = await fetch(cartridgeUrl, { cache: 'no-store' });
        invariant(response.ok, `${id}: HTTP ${response.status}`);
        const bytes = await response.arrayBuffer();
        invariant(await sha256Hex(bytes) === cartridge.sha256, `${id}: SHA-256 mismatch`);
        const blobUrl = URL.createObjectURL(new Blob([bytes], { type: 'text/javascript' }));

        let replaced = false;
        html = html.replace(scriptTagPattern, (full, quote, src) => {
          if (replaced || String(src).split('/').pop() !== cartridge.replace_script) return full;
          replaced = true;
          return `<script data-gridatlas-cartridge="${escapeAttribute(id)}" src="${escapeAttribute(blobUrl)}">${SCRIPT_CLOSE}`;
        });
        invariant(replaced, `${id}: shell slot ${cartridge.replace_script} not found`);
        loaded.push({ id, sha256: cartridge.sha256, blob_url: blobUrl });
      }

      const publicState = JSON.stringify({
        schema: current.schema,
        generation: current.generation,
        release_id: current.release_id,
        architecture: current.architecture,
        shell: current.shell,
        cartridge_order: current.cartridge_order,
        loaded_cartridges: loaded.map(item => ({ id: item.id, sha256: item.sha256 }))
      }).replace(/</g, '\\u003c');
      const stateScript = `<script>window.__GRIDATLAS_ATLAS__=${publicState};document.documentElement.dataset.gridatlasGeneration=${JSON.stringify(current.generation)};${SCRIPT_CLOSE}`;
      html = html.replace(/<body([^>]*)>/i, match => `${match}\n${stateScript}`);

      html = html.replace(/<head>/i, '<head><link rel="icon" href="data:,">');
      const teleprinterUrl = new URL('./teleprinter-bootstrap.js', window.location.href).href;
      const teleprinterScript = '<script type="module" src="' + escapeAttribute(teleprinterUrl) + '">' + SCRIPT_CLOSE;
      html = /<\/body>/i.test(html) ? html.replace(/<\/body>/i, teleprinterScript + '$&') : html + teleprinterScript;

      document.open();
      document.write(html);
      document.close();
    } catch (error) {
      fail(error);
    }
  </script>
</body>
</html>

Teleprinter Bootstrap

A JavaScript module in the atlas folder of Testcode that draws atlas pin, atlas code, solar and battery storage (BESS).

Set aside from the main view: 90% of its lines are the same as testcode/202609060503/atlas/teleprinter-bootstrap.js (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 90% of lines shared with Teleprinter Bootstrap; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 testcode/202609060503/atlas/teleprinter-bootstrap.js:1-21 b3829f682e4f189f62dcaf6499f4efb8b5277678
  • sha256 3e94204fb1da2ce561977cec80e0c34a7eb2274f6536f0eab2beb63111c9f821
  • target sha256 0b38175018e2cb66d83c41de52c39ac46e659d8853587e287aef90918b16f341
  • group of 2 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

rendertestcode / sandbox/202609060503/atlas/teleprinter-bootstrap.js · lines 1–21 of 21 · version 2026-09-06 05:03 · Not reached from any entry point (candidate for review)

What it does
It draws atlas pin, atlas code, solar and battery storage (BESS). Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: solar, battery storage (BESS).
Inputs & outputs
In: JSON file atlas-source-pin.json; JSON file atlas-source-code.manifest.json.
What it achieves
No statement of purpose was found in the file, a README line naming it, or its name.
Why it matters
No other file in the estate was found to import it.
Application
testcode · sandbox/202609060503/atlas · JavaScript module
Uses
Map Controls Layout (import), /testcode/202609051906/teleprinter/controls.js, /testcode/202609051906/teleprinter/layer-quick-controls.js, /testcode/202609051906/teleprinter/layers-panel-policy.js, /testcode/202609051906/teleprinter/layout-command.js, /testcode/202609052015/tool-layers/host.js
Used by
none found
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
testcode@a8a215982b13d6e2f6019b40bf0bef5755719773 sandbox/202609060503/atlas/teleprinter-bootstrap.js:1-21 · blob e871d70a931e4c9fcca2d4078aab3f109dd551c3 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: experimental · users: none · canonical: unreached_review
import { mountTeleprinter } from '/testcode/202609051906/teleprinter/controls.js';
import { mountLayerQuickControls } from '/testcode/202609051906/teleprinter/layer-quick-controls.js';
mountLayerQuickControls();
import { mountLayersPanelPolicy } from '/testcode/202609051906/teleprinter/layers-panel-policy.js';
mountLayersPanelPolicy();
import { mountLayoutCommand } from '/testcode/202609051906/teleprinter/layout-command.js';
import { mountToolLayers } from '/testcode/202609052015/tool-layers/host.js';
mountToolLayers([{"id":"gis-sld-financial-sandbox","title":"GIS SLD Financial Sandbox","entry":"../layer-apps/solar-bess-topology-v7/gis-sld-financial-sandbox/index.html","owner":{"repository":"https://github.com/Ventusltd/unnamed-01.git","commit":"9fe7b2d920aaa11e95380de39b33fd98f04e9696","release":"202609051855","manifestSha256":"90190a0846717b5203305a8c08301fb26ed58e015b992272e0999272091a0916"}  … [line shortened here: 2,710 characters; full line on GitHub]
const base = new URL('/testcode/202609051906/teleprinter/', location.origin);
try {
  const response = await fetch(new URL('atlas-source-pin.json', base), { cache: 'no-store', credentials: 'same-origin', redirect: 'error' });
  if (!response.ok) throw new Error('Source code is still being prepared.');
  const pin = await response.json();
  if (pin.generation !== '202609051906' || pin.app !== 'atlas' || !/^[a-f0-9]{40}$/.test(pin.commit) || pin.repository !== 'https://github.com/Ventusltd/testcode') throw new Error('The source code version could not be checked.');
  mountTeleprinter({ printButtons: 'button[data-gm-export]', appName: "GridAtlas", manifestUrl: new URL('atlas-source-code.manifest.json', base), textUrl: new URL('atlas-source-code.txt', base), expectedCommit: pin.commit, expectedRepository: pin.repository });
} catch (error) {
  const note = document.createElement('p'); note.setAttribute('role', 'status'); note.textContent = 'Print options: ' + error.message; document.body.append(note);
}

import {mountMapControlsLayout} from './map-controls-layout.js';
mountMapControlsLayout();

Atlas Composition Contract

A JavaScript module in the capsules folder of Testcode. It validates atlas composition (`validateAtlasComposition`).

transformtestcode / sandbox/capsules/atlas-composition-contract.mjs · lines 1–12 of 12 · Not reached from any entry point (candidate for review) · pattern validateAtlasComposition (shared by 2 files)

What it does
It calculates its inputs. Defines validateAtlasComposition.
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Downstream impact
Used directly by 1 file: Build Composition Guard (testcode).
What it achieves
A composition must name every core cartridge exactly once before loading the shell.
Why it matters
Run by Build Composition Guard.
Application
testcode · sandbox/capsules · JavaScript module
Uses
none found
Used by
run by Build Composition Guard (script call)
Produces
validateAtlasComposition
Defines here
validateAtlasComposition
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
testcode@a8a215982b13d6e2f6019b40bf0bef5755719773 sandbox/capsules/atlas-composition-contract.mjs:1-12 · blob 0de7dd627ad482e344e5711fd0edd24da6b654a5 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: experimental · users: none · canonical: unreached_review
/** A composition must name every core cartridge exactly once before loading the shell. */
export function validateAtlasComposition(current) {
  const required=['streaming-parquet-bridge','uk-gazetteer-flyto','substation-intelligence','sld-sandbox'];
  const registry=current?.cartridges,order=current?.cartridge_order;
  if(!Array.isArray(registry)||!Array.isArray(order))throw Error('Cartridge registry and order must be arrays');
  const ids=registry.map(cartridge=>cartridge?.id);
  if(ids.some(id=>typeof id!=='string'||!id.trim())||order.some(id=>typeof id!=='string'||!id.trim()))throw Error('Every cartridge must have a non-empty ID');
  if(new Set(ids).size!==ids.length||new Set(order).size!==order.length)throw Error('Duplicate cartridge IDs are not allowed');
  if(ids.length!==order.length||order.some(id=>!ids.includes(id)))throw Error('Cartridge registry and execution order must contain the same IDs');
  for(const id of required)if(!ids.includes(id))throw Error('Required cartridge missing: '+id);
  return true;
}

Offshore Route Browser

A JavaScript module in the tools folder of Testcode.

rendertestcode / sandbox/tools/offshore-route.browser.cjs · lines 1–71 of 71 · Entry point

What it does
It loads data. Defines save. Uses libraries node:fs, node:path, node:http, node:child_process, C:/Users/vikra/OneDrive/Documents/GitHub/gridatlas-main-202609050200/node_modules/playwright. Side effects: changes the web page (DOM); reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
Inputs & outputs
Out: JSON file results.json.
Downstream impact
Used directly by 1 file: Offshore Route Workflow (testcode).
What it achieves
Defines `save`.
Why it matters
Run by Offshore Route Workflow.
Application
testcode · sandbox/tools · JavaScript module
Uses
node:fs, node:path, node:http, node:child_process, C:/Users/vikra/OneDrive/Documents/GitHub/gridatlas-main-202609050200/node_modules/playwright
Used by
run by Offshore Route Workflow (workflow run)
Produces
save
Defines here
save
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
testcode@a8a215982b13d6e2f6019b40bf0bef5755719773 sandbox/tools/offshore-route.browser.cjs:1-71 · blob 51cf1c9f35681c9e914d9b3e1b22b8cfddf2978c · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom, filesystem, process · domain stage: experimental · users: none · canonical: unknown
const fs = require('node:fs');
const path = require('node:path');
const http = require('node:http');
const {execFileSync} = require('node:child_process');
let playwright;
try {playwright = require(process.env.PLAYWRIGHT_MODULE || 'playwright');}
catch (error) {
  if (process.env.PLAYWRIGHT_MODULE) throw error;
  playwright = require('C:/Users/vikra/OneDrive/Documents/GitHub/gridatlas-main-202609050200/node_modules/playwright');
}
const root = path.resolve(__dirname, '../..');
const generation = process.env.TEST_GENERATION;
if (!/^\d{12}$/.test(generation || '')) throw Error('TEST_GENERATION must identify an immutable candidate');
const output = path.resolve(process.env.TEST_OUTPUT || 'offshore-route-artifacts');
fs.mkdirSync(output, {recursive:true});
const report = {generation, profiles:[], sourceMode:'Actual composed files; no request interception or source substitution', limitations:['Chrome phone emulation is not physical-device evidence.','Straight lines are mapped measurements, not surveyed export routes.']};
const server = http.createServer((req,res) => {
  const pathname = decodeURIComponent(new URL(req.url,'http://localhost').pathname);
  const relative = pathname.startsWith('/testcode/') ? '/sandbox/' + pathname.slice(10) : pathname;
  let file = path.resolve(root, '.' + relative);
  if (!file.startsWith(root + path.sep)) return res.writeHead(403).end();
  try {
    if (fs.statSync(file).isDirectory()) file=path.join(file,'index.html');
    const repoPath=path.relative(root,file).split(path.sep).join('/');
    const bytes=repoPath.startsWith('sandbox/202609051906/')
      ? execFileSync('git',['show','HEAD:'+repoPath],{cwd:root,maxBuffer:64*1024*1024}) : fs.readFileSync(file);
    res.writeHead(200,{'Content-Type':({'.html':'text/html','.js':'text/javascript','.mjs':'text/javascript','.json':'application/json','.css':'text/css'})[path.extname(file)]||'application/octet-stream'}).end(bytes);
  } catch {res.writeHead(404).end();}
});
function save(){fs.writeFileSync(path.join(output,'results.json'),JSON.stringify(report,null,2)+'\n');}
(async()=>{
  await new Promise(resolve=>server.listen(0,'127.0.0.1',resolve));
  const base=process.env.TEST_BASE||`http://127.0.0.1:${server.address().port}/testcode/${generation}/atlas/`;
  report.base=base;
  const browser=await playwright.chromium.launch({headless:true,...(process.env.CHROME_CHANNEL==='chromium'?{}:{channel:process.env.CHROME_CHANNEL||'chrome'})});
  report.browser=browser.version();
  try {
    for(const profile of [{name:'desktop',viewport:{width:1440,height:900}},{name:'phone',viewport:{width:393,height:852},isMobile:true,hasTouch:true}]) {
      const {name,...options}=profile;
      const context=await browser.newContext(options);
      try {
        const page=await context.newPage();
        const result={name,errors:[],checks:[]};report.profiles.push(result);
        page.on('pageerror',e=>result.errors.push(e.message));
        await page.goto(base+'?repd_ref=9873&technology=wind_offshore&latitude=56.4431397&longitude=-1.4664021&zoom=12',{waitUntil:'domcontentloaded',timeout:60000});
        await page.waitForFunction(()=>document.querySelector('.neon-answer')?.textContent.includes('Offshore export route unassessed'),null,{timeout:60000});
        result.card=await page.locator('.neon-answer').innerText();
        result.actualGeneration=await page.evaluate(()=>window.__GRIDATLAS_ATLAS__?.generation);
        await page.locator('[data-gridatlas-corridor="1"]').click({timeout:15000});
        result.sheet=await page.locator('#gridatlas-corridor-sheet').innerText();
        result.checks.push({name:'correct candidate',pass:result.actualGeneration===generation},
          {name:'straight measurement retained',pass:result.card.includes('78.96 km straight')&&result.sheet.includes('78.96 km straight')},
          {name:'unsupported highway estimate absent',pass:!/~98\.3|98\.3 km corridor|times 1\.245/.test(result.card+result.sheet)},
          {name:'offshore scope shown inline and expanded',pass:result.card.includes('Offshore export route unassessed')&&result.sheet.includes('Offshore export route unassessed')});
        await page.screenshot({path:path.join(output,name+'-offshore.png')});
        await page.locator('[data-gridatlas-corridor-close="1"]').click();
        result.checks.push({name:'route sheet closes',pass:!(await page.locator('#gridatlas-corridor-sheet').isVisible())});
        await page.goto(base+'?repd_ref=14926&technology=solar&latitude=51.779&longitude=-1.337&zoom=12',{waitUntil:'domcontentloaded',timeout:60000});
        await page.waitForFunction(()=>document.querySelector('.neon-answer')?.textContent.includes('km straight'),null,{timeout:60000});
        result.onshoreCard=await page.locator('.neon-answer').innerText();
        result.checks.push({name:'onshore corridor remains available',pass:/corridor estimate/.test(result.onshoreCard)&&!result.onshoreCard.includes('Offshore export route unassessed')},
          {name:'no uncaught script errors',pass:result.errors.length===0});
        await page.screenshot({path:path.join(output,name+'-onshore.png')});
        result.pass=result.checks.every(c=>c.pass);save();console.log(name,JSON.stringify(result.checks));
      }finally{await context.close();}
    }
  }finally{await browser.close();}
})().catch(error=>{report.error=error.stack;process.exitCode=1;}).finally(()=>{
  report.finishedUTC=new Date().toISOString();save();server.close();
  if(report.profiles.length!==2||report.profiles.some(p=>!p.pass))process.exitCode=1;
});

VEDIC Verify Reuse Routes

A Python command-line tool in the tools folder using data from the stars and kuiper-belt repositories. It is built from the pinned step (`pinned`) and the public step (`public`).

ingestvedic- / tools/verify_reuse_routes.py · lines 1–38 of 38 · Entry point · pattern public (shared by 2 files)

What it does
It fetches data. Defines pinned, public, main. Uses libraries hashlib, urllib.request. Side effects: makes network requests.
Why it exists in the grid workflow
Domain stage field_execution (path word 'routes'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
Inputs & outputs
In: data source: stars data; data source: kuiper-belt data.
Downstream impact
Used directly by 1 file: VEDIC Anatomy Workflow (vedic-).
What it achieves
Read-only CI checks of the existing Modular Star and Kuiper reuse routes.
Why it matters
Run by VEDIC Anatomy Workflow.
Application
vedic- · tools · Python CLI
Uses
VEDIC Validate Translation (import), Code (estate URL), hashlib, urllib.request
Used by
run by VEDIC Anatomy Workflow (workflow run)
Produces
pinned, public, main
Defines here
pinned, public, main
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
vedic-@1c95ee78c2dd3f1f72c0fd5a5f6e247aaf1624e0 tools/verify_reuse_routes.py:1-38 · blob bf1f9f1d3611e34e493d0c5ce1b87b6be4d0197d · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: ingest · effects: network · domain stage: field_execution · users: EPC_contractor, landowner_planner, ai_agent · canonical: unknown
"""Read-only CI checks of the existing Modular Star and Kuiper reuse routes."""
import hashlib
from urllib.request import Request, urlopen
from validate_translation import fetch

STARS = ("Ventusltd/stars", "ebf2bf2be0386fcf488735560152d765b046e85e", "code.html", "c27d5d8b6bf533a5e5487a9382e3958d5d9c8df2")
KUIPER = ("Ventusltd/kuiper-belt", "e8b04bea0d369e422cd6313981f1d51cbc4347b9", "see-through/202611020012/README.md", "1d2c8e2e2678f05a0b3f09e79c75d2b9d9011cbb")
KUIPER_APP = ("Ventusltd/kuiper-belt", "e8b04bea0d369e422cd6313981f1d51cbc4347b9", "see-through/202611020012/index.html", "b069ce1d879eec5c8f0c8bc4fe12e10a3dadd1c1")

def pinned(record):
    repo, commit, path, blob = record
    raw = fetch(repo, commit, path)
    assert len(raw) <= 1_000_000
    assert hashlib.sha1(b"blob " + str(len(raw)).encode() + b"\0" + raw).hexdigest() == blob, path
    return raw

def public(url):
    with urlopen(Request(url, headers={"User-Agent":"VEDIC-code-reuse-verifier","Cache-Control":"no-cache"}),timeout=30) as r:
        assert r.status == 200, url
        body = r.read(1_000_001)
        assert 0 < len(body) <= 1_000_000
        return body

def main():
    public_stars = public("https://ventusltd.github.io/stars/code.html")
    stars=pinned(STARS)
    readme=pinned(KUIPER)
    kuiper=pinned(KUIPER_APP)
    for marker in (b"Copy the code", b"Copy an import line", b"?family=", b"function search(q)"):
        assert marker in stars, marker
        assert marker in public_stars, marker
    assert b"#repo=gridatlas" in readme
    assert b'descent.js' in kuiper
    assert b'descent.js' in public("https://ventusltd.github.io/kuiper-belt/see-through/202611020012/")
    print("PASS: pinned producer contracts and public Modular Star/Kuiper reuse routes; no family or standalone claim")

if __name__ == "__main__":
    main()

Geo Area

A JavaScript module in Ventus Grid Engine that works with polygon area km2 (`polygonAreaKm2`) and polyline perimeter km (`polylinePerimeterKm`), using haversine.

geodesyventus-grid-engine / engine/geo-area.js · lines 1–100 of 100 · Entry point · pattern polygonAreaKm (shared by 3 files)

What it does
It calculates its inputs. Defines conversions, polygonAreaKm2, polylinePerimeterKm, circleCapAreaKm2.
Why it exists in the grid workflow
Domain stage site_feasibility (topic 'maps-gis'): substation-to-site feasibility (terrain, LiDAR and connection evidence before design), a journey named in Ventus Ltd's brief.
Downstream impact
Used directly by 5 files: Grid Engine — Solar Farm Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060318-solar-farm/); Geodesy Proof (ventus-grid-engine); Build Graph (ventus-grid-engine, https://ventusltd.github.io/ventus-grid-engine/genome/); Grid Engine — Site Geometry Page (globalgrid2050, https://globalgrid2050.com/grid_engine/202609060238-site-geometry/); and 1 more. Reached from 4 other entry points, including Homepage V090 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v090.html); Homepage V091 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v091.html); Homepage V093 (globalgrid2050, https://globalgrid2050.com/homepage_versions/homepage_v093.html).
What it achieves
It is built from the conversions step (`conversions`), the polygon area km2 helper (`polygonAreaKm2`) and the polyline perimeter km helper (`polylinePerimeterKm`). Polygon area, perimeter, and spherical-cap area.
Why it matters
Loaded by the Solar Farm page in GlobalGrid2050 at https://globalgrid2050.com/grid_engine/202609060318-solar-farm/ and 2 other pages. Also imported by Geodesy Proof and Build Graph.
Application
ventus-grid-engine · engine · JavaScript module
VEDIC
AREA (GG2050-VEDIC-000017): Ventus Grid Engine / Geometry · Mathematics / Spherical geometry. ordered_points, radius_km → area_record
VEDIC
LENGTH (GG2050-VEDIC-000018): Ventus Grid Engine / Geometry · Mathematics / Spherical geometry. ordered_points, closed, radius_km → length_km
VEDIC
AREA (GG2050-VEDIC-000019): Ventus Grid Engine / Geometry · Mathematics / Spherical geometry. geodesic_radius_km, earth_radius_km → area_record
Uses
Geo Core (import)
Used by
linked from Grid Engine — Solar Farm Page (link), imported by Geodesy Proof (import), named by URL in Build Graph (estate URL), linked from Grid Engine — Site Geometry Page (link), named by URL in Ventus Grid Engine — Genome Page (estate URL)
Produces
polygonAreaKm2, polylinePerimeterKm, circleCapAreaKm2
Defines here
conversions, polygonAreaKm2, polylinePerimeterKm, circleCapAreaKm2
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
ventus-grid-engine@ad566356a44e006682e956483d569f31ddbb9630 engine/geo-area.js:1-100 · blob 7ea5a369b25319a42d417158ad927cbb24cbcfc8 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: site_feasibility · users: IPP_developer, landowner_planner · canonical: production_core
/* geo-area — polygon area, perimeter, and spherical-cap area.
 *
 * This module is the resolution of "three area implementations in one file".
 * From globalgrid2050/repd_grid_atlasv8/ventus-corev8engine.js at HEAD
 * 7d00781b6993b9038a1a8bedf2c88a4eb0109ad4:
 *
 *   A  lines 134-149  _zoneDrawCalcArea               shoelace-on-sphere
 *   B  lines 481-490  inline in updateMeasureDisplay  shoelace-on-sphere
 *   C  lines 576-582  inline in doRadiusAreaMeasure   spherical cap
 *
 * A and B were checked numerically, not by eye: on a true 1 km x 1 km square
 * at 55N both return 1.00000000 km2, and on a 5-point irregular polygon near
 * London both return 0.30664823 km2 — identical to 8 decimal places. They are
 * the same formula, copy-pasted. They collapse into polygonAreaKm2 below.
 *
 * They disagreed in exactly one place: acres. A divided by 4046.85642 m2/acre
 * (exact); B multiplied by 247.105 acres/km2 (rounded). On the London polygon
 * that is 75.774428 ac vs 75.774311 ac. Harmless in magnitude, but it is a
 * second inconsistency riding on the first, and it disappears here because
 * there is now one conversion table.
 *
 * C is NOT merged. It answers a different question — the area enclosed by a
 * fixed geodesic radius, not by an arbitrary polygon — and it is correct:
 * checked against pi*r^2 it agrees to 5 significant figures at 1 km and
 * departs to 0.94983 of the planar answer at 5000 km, which is the sphere
 * behaving like a sphere. Merging C into A/B would be wrong, so it stays a
 * separately named function. Honest naming over a tidy-looking API.
 */

import { EARTH_RADIUS_KM, haversine } from './geo-core.js';

/* One conversion table, used by every area result in this repo. */
const M2_PER_ACRE  = 4046.85642;   // exact, international acre
const KM2_PER_MI2  = 0.386102;     // as V8 shipped it
const M2_PER_PITCH = 7140;         // a football pitch, as V8 defined it

function conversions(areaKm2, perimKm) {
    const areaM2 = areaKm2 * 1e6;
    return {
        areaKm2,
        areaM2,
        areaHa:  areaM2 / 10000,
        areaAc:  areaM2 / M2_PER_ACRE,
        areaMi2: areaKm2 * KM2_PER_MI2,
        perimKm,
        pitches: areaM2 / M2_PER_PITCH
    };
}

/**
 * Area and perimeter of a closed polygon on the sphere.
 *
 * Verbatim shoelace-on-sphere from ventus-corev8engine.js:134-149. Points are
 * [lon, lat] pairs in degrees, in order, NOT explicitly closed — the formula
 * wraps with (i + 1) % n itself.
 *
 * Fewer than 3 points is not an error and not NaN: it is zero area, which is
 * what a 2-point "polygon" actually encloses. V8 returned zeros here, so does this.
 */
export function polygonAreaKm2(pts, radiusKm = EARTH_RADIUS_KM) {
    if (!Array.isArray(pts) || pts.length < 3) return conversions(0, 0);
    let area = 0;
    const R = radiusKm;
    for (let i = 0; i < pts.length; i++) {
        const j  = (i + 1) % pts.length;
        const xi = pts[i][0] * Math.PI / 180, yi = pts[i][1] * Math.PI / 180;
        const xj = pts[j][0] * Math.PI / 180, yj = pts[j][1] * Math.PI / 180;
        area += (xj - xi) * (2 + Math.sin(yi) + Math.sin(yj));
    }
    const areaKm2 = Math.abs(area) * R * R / 2;
    return conversions(areaKm2, polylinePerimeterKm(pts, true, radiusKm));
}

/**
 * Length along a sequence of points, in km. From the perimeter loop at
 * ventus-corev8engine.js:146 and the Measure tool length accumulation at
 * 469/479 — the same loop, written twice.
 */
export function polylinePerimeterKm(pts, closed = false, radiusKm = EARTH_RADIUS_KM) {
    if (!Array.isArray(pts) || pts.length < 2) return 0;
    let km = 0;
    const last = closed ? pts.length : pts.length - 1;
    for (let i = 0; i < last; i++) {
        const j = (i + 1) % pts.length;
        km += haversine(pts[i][0], pts[i][1], pts[j][0], pts[j][1], radiusKm);
    }
    return km;
}

/**
 * Area of a spherical cap of geodesic radius `km` — the area actually enclosed
 * by a radius circle drawn on the earth. Verbatim from
 * ventus-corev8engine.js:576-582. Kept separate from polygonAreaKm2 on purpose:
 * it is not the same question and the two are not interchangeable.
 */
export function circleCapAreaKm2(km, radiusKm = EARTH_RADIUS_KM) {
    const R = radiusKm;
    const areaKm2 = 2 * Math.PI * R * R * (1 - Math.cos(km / R));
    return conversions(areaKm2, 2 * Math.PI * R * Math.sin(km / R));
}