GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Maps, GIS and field navigation / gridatlas / atlas/parts

Place Global Search Renewable Energy Planning Database (REPD) 2026q3 and 3 more files

A JavaScript file in the parts folder of GridAtlas that maps REPD projects, offshore coordinates, postcodes and the REPD register, using SHA-256, and uses data from postcodes.io and OpenStreetMap Nominatim.

635 lines of JavaScript and HTML from gridatlas, in 4 files. Topic: Maps, GIS and field navigation. Section 603 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. Place Global Search Renewable Energy Planning Database (REPD) 2026q3 energy-data · gridatlas / atlas/parts/202611132345-place-global-search-repd-2026q3.js lines 701–913
  2. Preview — Lightning Page render · gridatlas / atlas/preview/lightning/index.html lines 1–115
  3. Weather Module render · gridatlas / atlas/preview/lightning/weather-module.js lines 1–194
  4. Renewable Energy Planning Database (REPD) Address Flyto energy-data · gridatlas / atlas/releases/202608291237-atlas-v9/cartridges/202608290716-repd-address-flyto.mjs lines 1–113

Place Global Search Renewable Energy Planning Database (REPD) 2026q3

A JavaScript file in the parts folder of GridAtlas that maps REPD projects, offshore coordinates, postcodes and the REPD register, using SHA-256, and uses data from postcodes.io and OpenStreetMap Nominatim.

Set aside from the main view: 98% of its lines are the same as atlas/cartridges/202611180026-place-global-search-v9-5.js (gridatlas), which stays. (near-copy-of, proposed by families.py). 98% of lines shared with Place Global Search V9 5; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9819 to gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/cartridges/202611180026-place-global-search-v9-5.js:1-931 c3ef9b6b82b3e983feb93015b168fed3d11322b9
  • sha256 f431f3cc43c6eeb35cc0cbb6d6e02b3cfe6757972190deceb37d7e205aea3b8a
  • target sha256 575721ea584187c2b9b857408a3e6136879d7f6876f1e6d7a0b925051124a49c
  • group of 4 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

energy-datagridatlas / atlas/parts/202611132345-place-global-search-repd-2026q3.js · lines 701–913 of 913 · version 2026-11-13 23:45 (continued from section 602) · Not reached from any entry point (candidate for review) · pattern loadDerivedCoordinates (shared by 4 files)

What it does
It maps REPD projects, offshore coordinates, postcodes and the REPD register. Defines 41 functions or classes, including invariant, arrivalCoordinator, markDeepLinkCancelled, invalidatePendingDeepLink, escapeHtml. Side effects: changes the web page (DOM); makes network requests; uses storage (browser storage, DuckDB or Parquet).
Why it exists in the grid workflow
Domain stage upstream_foresight (path word 'atlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: postcodes, the REPD register.
Inputs & outputs
In: data source: postcodes.io; data source: OpenStreetMap Nominatim; Parquet file repd_projects_202611132345.parquet; JSON file repd_v9_manifest_202611132345.json; JSON file offshore-coordinates.json; DuckDB queries. Out: interactive map. Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid).
What it achieves
It marks deep link cancelled (`markDeepLinkCancelled`), normalises compact (`normaliseCompact`) and parses groups (`parseGroups`). Its `buildWhere` function gives SQL predicate from query text (VEDIC: query). It responds to gridatlas, click and input events.
Why it matters
No other file in the estate was found to import it.
Application
gridatlas · atlas/parts · script
VEDIC
QUERY (GG2050-VEDIC-000046): GridAtlas / Search and Vicinity · Geographic information / Infrastructure screening. query_text → sql_predicate
VEDIC
SCORE (GG2050-VEDIC-000047): GridAtlas / Search and Vicinity · Geographic information / Infrastructure screening. query_text → sql_sort_expression
VEDIC
UK GEOCODE (GG2050-VEDIC-000048): GridAtlas / Search and Vicinity · Geographic information / Infrastructure screening. query_text → uk_location_candidates
Uses
none found
Used by
none found
Produces
invariant, arrivalCoordinator, markDeepLinkCancelled, invalidatePendingDeepLink, escapeHtml, sqlString, normaliseCompact, parseGroups, sha256Hex, verifyManifest, sharedDuckDBRuntime, promise
Defines here
stillOwned, retryExactRepdDeepLink, bindSearch
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/parts/202611132345-place-global-search-repd-2026q3.js:701-913 · blob be62ece3f6867a54bef567c01a292efe9f0a056c · GitHub at these lines
State
achieves: code · context: readme_derived · stage: output · effects: dom, network, storage · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: duplicate_candidate
      if (Number.isInteger(expectedOwnerEpoch)) {
        if (!coordinator.arrivalGate.isCurrent(expectedOwnerEpoch)) return;
        ownerEpoch = expectedOwnerEpoch;
      } else {
        ownerEpoch = coordinator.claimPendingArrival(window.location.search);
      }
      state.deep_link = {
        ...arrival, owner_epoch: ownerEpoch, status: 'RECEIVING',
        resolved: false, mapped: false,
        identity_source: 'ACTIVE_REGISTER_PENDING'
      };
      const stillOwned = () => coordinator.arrivalGate.isCurrent(ownerEpoch);
      const querySerial = ++activeQuerySerial;
      input.value = repdRef;
      const results = await queryOfficialRepd(repdRef, querySerial, stillOwned);
      if (!stillOwned() || querySerial !== activeQuerySerial) return;
      const exact = results.find(result => String(result.repd_ref) === repdRef);
      if (!exact) {
        // A successful query with no exact row is evidence about this active
        // snapshot, not a network failure and not evidence that the supplied
        // project never existed. Keep the link's point and identity separate.
        renderResults(results, resultsEl);
        document.body.dataset.gridatlasRepdRef = repdRef;
        document.body.dataset.gridatlasRepdDeepLink = 'not-in-active-register';
        state.deep_link = {
          ...arrival,
          owner_epoch: ownerEpoch,
          status: 'NOT_IN_ACTIVE_REGISTER',
          resolved: false,
          mapped: false,
          supplied_point_usable: hasSafeMapPoint(arrival),
          identity_source: 'ARRIVAL_LINK',
          official_active_register_match: false,
          statement: 'No exact identity in the active-register snapshot; supplied arrival fields retained.'
        };
        return;
      }
      renderResults(results, resultsEl);
      await waitForCapturedMap();
      if (!stillOwned()) return;

      /* A ref the register does not locate used to be treated worse than a ref
         the register does not contain. The not-in-register branch above keeps
         the supplied arrival point and degrades gracefully; this branch found
         its row, could not map it, and threw - so a project present in the
         register but without a coordinate showed the user a failure card.
         Measured on the live page: between 3 and 8 of 20 MAP links carry no
         coordinate at all, so there was nothing to fall back to either.

         Offshore is where this bites. 8 of 101 offshore rows carry no easting
         or northing, and the Crown Estate leases the seabed under them, so a
         derived point exists for 6 of the 8 in atlas/data/offshore-coordinates.json.
         Using it is honest as long as the card says the coordinate is derived
         and the identity is not: the register named the project, the lease
         located it. */
      const derived = !hasSafeMapPoint(exact) ? await derivedCoordinateFor(repdRef) : null;
      if (derived) {
        exact.longitude = derived.longitude;
        exact.latitude = derived.latitude;
      }
      /* No register point and no lease point. Measured offline on v9.144:
         13432 is in the register, has no coordinate, is in no lease, and
         still reached the invariant below and showed a failure card. A name
         the register confirmed is worth more than a card that says try again,
         so the identity stands and the map does not move. If the link itself
         carried a usable point it is used and labelled as the link's, never
         as the register's. */
      const linkPoint = !hasSafeMapPoint(exact) && hasSafeMapPoint(arrival)
        ? { longitude: arrival.longitude, latitude: arrival.latitude } : null;
      if (linkPoint) {
        exact.longitude = linkPoint.longitude;
        exact.latitude = linkPoint.latitude;
      }
      if (!hasSafeMapPoint(exact)) {
        document.body.dataset.gridatlasRepdRef = repdRef;
        document.body.dataset.gridatlasRepdDeepLink = 'resolved-unmapped';
        state.deep_link = {
          ...arrival,
          owner_epoch: ownerEpoch,
          repd_ref: repdRef,
          status: 'RESOLVED_UNMAPPED',
          resolved: true,
          mapped: false,
          name: exact.name,
          technology: exact.technology,
          capacity_mw: exact.capacity_mw,
          status_value: exact.status,
          identity_source: 'OFFICIAL_ACTIVE_REGISTER',
          official_active_register_match: true,
          coordinate_source: 'NONE',
          coordinate_derived: false,
          coordinate_lease: null,
          coordinate_tenant: null,
          coordinate_statement: 'The register names this project but holds no coordinate for it, and no Crown Estate lease covers it. Identity confirmed; position unknown; the map was not moved.',
          statement: 'Exact identity in the active-register snapshot; no coordinate from any source held.'
        };
        return;
      }
      if (!selectResult(exact, { deepLinkEpoch: ownerEpoch })) return;
      if (!stillOwned()) return;
      invariant(state.last_selection?.repd_ref === repdRef, 'exact REPD selection was not retained');
      invariant(state.last_selection?.mapped === true, 'exact REPD identity did not fly to a safe map point');
      document.body.dataset.gridatlasRepdRef = repdRef;
      document.body.dataset.gridatlasRepdDeepLink = 'resolved';
      state.deep_link = {
        status: 'RESOLVED',
        owner_epoch: ownerEpoch,
        repd_ref: repdRef,
        resolved: true,
        mapped: true,
        /* Identity and coordinate have different provenance and are reported
           separately. The register named this project; where it did not locate
           it, a Crown Estate lease did, and the card must not present the two
           as one fact. */
        coordinate_source: derived ? derived.source : linkPoint ? 'ARRIVAL_LINK' : 'OFFICIAL_ACTIVE_REGISTER',
        coordinate_derived: Boolean(derived),
        coordinate_lease: derived ? derived.lease : null,
        coordinate_tenant: derived ? derived.tenant : null,
        coordinate_statement: derived
          ? 'Position derived from Crown Estate lease geometry because the register carries no coordinate for this project. The identity is the register’s; the position is not.'
          : linkPoint
            ? 'Position taken from the arrival link because the register carries no coordinate for this project and no lease covers it. The identity is the register’s; the position is the link’s.'
            : 'Position as published in the active register.',
        name: exact.name,
        postcode: exact.postcode,
        longitude: exact.longitude,
        latitude: exact.latitude,
        technology: exact.technology,
        capacity_mw: exact.capacity_mw,
        status_value: exact.status,
        identity_source: 'OFFICIAL_ACTIVE_REGISTER',
        official_active_register_match: true
      };
    } catch (error) {
      if (coordinator && Number.isInteger(ownerEpoch)
          && !coordinator.arrivalGate.isCurrent(ownerEpoch)) return;
      const message = String(error?.message || error);
      state.failures.push({ phase: 'exact_repd_deep_link', repd_ref: repdRef, message });
      state.deep_link = {
        ...arrival, owner_epoch: ownerEpoch, status: 'FAILED',
        resolved: false, mapped: false, message,
        identity_source: 'ACTIVE_REGISTER_CHECK_FAILED'
      };
      document.body.dataset.gridatlasRepdDeepLink = 'failed';
      console.error('[V9 EXACT REPD DEEP LINK]', error);
    }
  }

  async function retryExactRepdDeepLink(input, resultsEl, ownerEpoch) {
    const coordinator = arrivalCoordinator();
    invariant(coordinator, 'shared arrival coordinator unavailable for retry');
    invariant(Number.isInteger(ownerEpoch), 'identity retry requires one shared owner epoch');
    if (!coordinator.arrivalGate.isCurrent(ownerEpoch)) return state.deep_link;
    state.identity_retry_count += 1;
    await resetOfficialRuntime();
    if (!coordinator.arrivalGate.isCurrent(ownerEpoch)) return state.deep_link;
    return receiveExactRepdDeepLink(input, resultsEl, ownerEpoch);
  }

  function bindSearch() {
    const input = document.getElementById('search-input');
    const button = document.getElementById('search-btn');
    const resultsEl = document.getElementById('search-results');
    invariant(input && button && resultsEl, 'V8 search controls missing');
    input.setAttribute('placeholder', 'Search project, address, postcode or place...');
    input.setAttribute('aria-label', 'Search project, address, postcode or place');

    input.addEventListener('input', event => {
      event.stopImmediatePropagation();
      invalidatePendingDeepLink('user-search-input');
      clearTimeout(debounceTimer);
      debounceTimer = setTimeout(() => executeSearch(input, resultsEl, false), 180);
    }, true);

    input.addEventListener('keydown', event => {
      if (event.key === 'Enter') {
        event.preventDefault();
        event.stopImmediatePropagation();
        invalidatePendingDeepLink('user-search-submit');
        clearTimeout(debounceTimer);
        executeSearch(input, resultsEl, true);
      } else if (event.key === 'Escape') {
        event.stopImmediatePropagation();
        invalidatePendingDeepLink('user-search-dismiss');
        resultsEl.style.display = 'none';
      }
    }, true);

    button.addEventListener('click', event => {
      event.preventDefault();
      event.stopImmediatePropagation();
      invalidatePendingDeepLink('user-search-submit');
      clearTimeout(debounceTimer);
      executeSearch(input, resultsEl, true);
    }, true);

    state.retry_exact_deep_link = (ownerEpoch) =>
      retryExactRepdDeepLink(input, resultsEl, ownerEpoch);
    state.ready = true;
  }

  window.addEventListener('DOMContentLoaded', () => {
    try {
      bindSearch();
      const input = document.getElementById('search-input');
      const resultsEl = document.getElementById('search-results');
      void receiveExactRepdDeepLink(input, resultsEl);
    } catch (error) {
      state.failures.push({ phase: 'bind', message: String(error?.message || error) });
      console.error('[V9 PLACE SEARCH INIT]', error);
    }
  }, { once: true });
})();

Preview — Lightning Page

A web page in the atlas folder of GridAtlas that works with escape attribute (`escapeAttribute`) and sha256 hex (`sha256Hex`), using SHA-256. Published at https://gridatlas.globalgrid2050.com/atlas/preview/lightning/.

rendergridatlas / atlas/preview/lightning/index.html · lines 1–115 of 115 · 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(weatherBlob) + '. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage upstream_foresight (path word 'atlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. README: "`atlas/index.html` is the stable composer."
Inputs & outputs
In: JSON file current.json. Out: web page.
Downstream impact
It is itself an entry point, published at https://gridatlas.globalgrid2050.com/atlas/preview/lightning/.
What it achieves
It is built from the invariant step (`invariant`), the escape attribute helper (`escapeAttribute`) and the sha256 hex helper (`sha256Hex`). The README says: `atlas/index.html` is the stable composer. It reads `./current.json`.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
gridatlas · atlas/preview/lightning · page
Uses
${escapeAttribute(blobUrl)}, ' + escapeAttribute(weatherBlob) + '
Used by
none found
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
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/preview/lightning/index.html:1-115 · blob 483a097d740eb289e880d2774f6b11e325a3fbde · GitHub at these lines
State
achieves: readme · context: readme_derived · stage: output · effects: dom, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>GridAtlas Lightning · Isolated Preview</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 LIGHTNING PREVIEW</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 });
      }

      // Preview-only weather extension: SHA-256 verified before injection.
      // The extension waits for the ORIGINAL 60+3 menu to install and leaves
      // the immutable UK config, existing menu scripts and handlers untouched.
      invariant(current.weather_module?.path && /^[a-f0-9]{64}$/.test(current.weather_module.sha256 || ''), 'weather module manifest is missing');
      const weatherUrl = new URL(current.weather_module.path, window.location.href);
      const weatherResponse = await fetch(weatherUrl, { cache: 'no-store' });
      invariant(weatherResponse.ok, 'weather module HTTP ' + weatherResponse.status);
      const weatherBytes = await weatherResponse.arrayBuffer();
      invariant(await sha256Hex(weatherBytes) === current.weather_module.sha256, 'weather module SHA-256 mismatch');
      const weatherBlob = URL.createObjectURL(new Blob([weatherBytes], { type: 'text/javascript' }));
      html = html.replace(/<\/body>/i, '<script data-gridatlas-weather="uk-lightning" src="' + escapeAttribute(weatherBlob) + '">' + SCRIPT_CLOSE + '</body>');

      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}`);

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

Weather Module

A JavaScript file in the lightning folder of GridAtlas that maps UK lightning and uses data from the lightning repository. Served with the page at https://gridatlas.globalgrid2050.com/atlas/preview/lightning/.

rendergridatlas / atlas/preview/lightning/weather-module.js · lines 1–194 of 194 · Not reached from any entry point (candidate for review) · pattern setActive (shared by 2 files)

What it does
It maps UK lightning. Defines install, appendToLayers, status, hydrate, setActive. Side effects: changes the web page (DOM); makes network requests.
Why it exists in the grid workflow
Domain stage upstream_foresight (path word 'atlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. README: "It changes ONLY its isolated `streaming-parquet-bridge` to ignore cross-origin files, and injects `weather-module.js` verified by SHA-256."
Inputs & outputs
In: data source: lightning data; GeoJSON file uk_lightning.geojson. Out: interactive map.
What it achieves
It appends layers (`appendToLayers`) and sets active (`setActive`). Public UK Lightning, isolated from the immutable 60+3 control contract. It responds to change events.
Why it matters
No other file in the estate was found to import it.
Application
gridatlas · atlas/preview/lightning · script
Uses
none found
Used by
none found
Produces
install, appendToLayers, status, hydrate, setActive
Defines here
install, appendToLayers, status, hydrate, setActive
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/preview/lightning/weather-module.js:1-194 · blob 0d88665d8a72faae1073ef6ede99ac37f802f553 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/**
 * Public UK Lightning, isolated from the immutable 60+3 control contract.
 * EUMETSAT Meteosat LI L2 optical flashes; NOT confirmed ground strikes.
 *
 * This module NEVER edits ukConfig, the engine's 60 layer controls, the three
 * Pipeline News controls, or their delegated click/keyboard handlers.
 * It waits until GridAtlas installs its own menu, then adds synchronised toggles
 * to both the native Layers panel and Grid menu, with one MapLibre source.
 */
(() => {
  'use strict';
  const DATA_URL='https://raw.githubusercontent.com/Ventusltd/lightning/main/data/uk_lightning.geojson';
  const SOURCE='src-uk_lightning';
  const LAYER='l-uk_lightning';
  const PREFIX='weather:uk_lightning';
  const PANEL='#gridatlas-menu-bar-panel-4 .gm-panel-body';
  const state={schema:'gridatlas.uk-weather-lightning.v2',installed:false,status:'WAIT',
    source:DATA_URL,features:0,source_type:'EUMETSAT satellite optical flashes',
    observations_are_ground_strikes:false,errors:[]};
  window.__GRIDATLAS_WEATHER_LIGHTNING__=state;

  function install() {
    if(state.installed)return true;
    const map=window.__GRIDATLAS_V9_MAP__;
    const menu=window.__GRIDATLAS_MODULES__?.menuBar;
    const body=document.querySelector(PANEL);
    if(!map||!menu?.installed||!body||!map.isStyleLoaded())return false;
    if(!map.getSource(SOURCE)){
      map.addSource(SOURCE,{type:'geojson',data:{type:'FeatureCollection',features:[]}});
    }
    if(!map.getLayer(LAYER)){
      map.addLayer({
        id:LAYER,type:'circle',source:SOURCE,
        layout:{visibility:'none'},
        paint:{
          'circle-color':'#ffdf44',
          'circle-radius':['interpolate',['linear'],['zoom'],4,3,9,5,14,8],
          'circle-stroke-width':1.2,
          'circle-stroke-color':'#251800',
          'circle-opacity':0.95
        }
      });
    }

    // The GridAtlas menu's fixed 60+3 inventory was validated BEFORE this
    // module runs. This toggle has NO data-layer-id or data-pn-layer.
    const group=document.createElement('div');
    group.className='gm-layer-group';
    group.textContent='Weather (GeoJSON)';
    group.setAttribute('data-weather-group','uk_lightning');
    const label=document.createElement('label');
    label.className='gm-layer';
    label.setAttribute('data-gridatlas-layer-key',PREFIX);
    const input=document.createElement('input');
    input.id='gridatlas-weather-lightning-toggle';
    input.type='checkbox';
    input.setAttribute('data-gridatlas-layer-proxy',PREFIX);
    input.setAttribute('data-weather-layer','uk_lightning');
    input.setAttribute('aria-label','Lightning (satellite flashes)');
    const box=document.createElement('span');
    box.className='gm-layer-box';
    box.setAttribute('aria-hidden','true');
    const title=document.createElement('span');
    title.className='gm-layer-name';
    title.id='lbl-uk_lightning';
    title.textContent='Lightning (satellite flashes) [WAIT]';
    label.append(input,box,title);
    // Front-load the public Weather overlay so it is visible immediately
    // when Grid opens on desktop and phone, without scrolling through 63 layers.
    // These independent nodes do not alter any original input or handler.
    body.prepend(group,label);

    // Show the SAME isolated overlay in the actual SCADA LAYERS dashboard
    // and fullscreen curtain, not just in the six-menu Grid dropdown.
    // Original 60 engine + 3 Pipeline News inputs retain their attributes,
    // indices, delegated handlers and fail-closed menu contract.
    const switches=[input];
    const statusLabels=[title];
    function appendToLayers(hostId,kind) {
      const host=document.getElementById(hostId);
      if(!host) return;
      const weatherGroup=document.createElement('div');
      weatherGroup.className='key-group';
      weatherGroup.setAttribute('data-weather-native-group',kind);
      const heading=document.createElement('div');
      heading.className='key-title';
      heading.textContent='Weather (GeoJSON)';
      const row=document.createElement('label');
      row.className='key-item';
      row.setAttribute('data-weather-native-row',kind);
      const cb=document.createElement('input');
      cb.type='checkbox';
      cb.id='gridatlas-weather-lightning-'+kind;
      cb.setAttribute('data-weather-layer','uk_lightning');
      cb.setAttribute('aria-label','Lightning (satellite flashes)');
      // Do NOT set data-layer-id or data-pn-layer. GridAtlas's existing
      // change handlers and menu's 63-control cardinality stay untouched.
      const name=document.createElement('span');
      name.setAttribute('data-weather-label',kind);
      name.style.color='#ffdf44';
      name.textContent='Lightning (satellite flashes) [WAIT]';
      row.append(cb,document.createTextNode(' '),name);
      weatherGroup.append(heading,row);
      host.prepend(weatherGroup);
      switches.push(cb);
      statusLabels.push(name);
    }
    appendToLayers('scada-ui-container','layers');
    appendToLayers('fs-curtain-keys','fullscreen');
    state.controls=switches.length;

    function status(word,details) {
      state.status=word;
      const updated='Lightning (satellite flashes) ['+word+']'+(details?' '+details:'');
      statusLabels.forEach(node=>{node.textContent=updated;});
      switches.forEach(cb=>cb.setAttribute('aria-label',updated));
    }
    let loaded=false;
    let loading=null;
    async function hydrate() {
      if(loaded)return;
      if(loading)return loading;
      status('LOAD');
      loading=(async()=>{
        const response=await fetch(DATA_URL,{cache:'no-store'});
        if(!response.ok)throw new Error('lightning GeoJSON HTTP '+response.status);
        const data=await response.json();
        if(data?.type!=='FeatureCollection'||!Array.isArray(data.features))
          throw new Error('lightning feed is not a GeoJSON FeatureCollection');
        const features=data.features.filter(f=>f?.type==='Feature'
          && f.geometry?.type==='Point'
          && Array.isArray(f.geometry.coordinates)
          && f.geometry.coordinates.length>=2
          && f.geometry.coordinates.slice(0,2).every(Number.isFinite));
        map.getSource(SOURCE).setData({type:'FeatureCollection',features});
        state.features=features.length;
        state.latest_utc=data.metadata?.latest_detection_utc||null;
        state.feed_status=data.metadata?.status||'unknown';
        loaded=true;
        status(features.length?'OK':'EMPTY',features.length?'('+features.length+' flashes)':'(no published observations)');
      })().finally(()=>{loading=null;});
      return loading;
    }

    function setActive(visible) {
      switches.forEach(cb=>{cb.checked=visible;});
      map.setLayoutProperty(LAYER,'visibility',visible?'visible':'none');
      if(visible)hydrate().catch(error=>{
        state.errors.push(String(error?.message||error));
        status('FAIL');
        switches.forEach(cb=>{cb.checked=false;});
        map.setLayoutProperty(LAYER,'visibility','none');
        console.error('[GRIDATLAS WEATHER]',error);
      });
    }
    switches.forEach(cb=>cb.addEventListener('change',()=>setActive(cb.checked)));

    map.on('click',LAYER,e=>{
      if(!input.checked||!e.features?.length)return;
      const p=e.features[0].properties||{};
      const box=document.createElement('div');
      box.style.cssText='font:12px/1.5 monospace;color:#dceeff;background:#07151e;padding:8px;max-width:260px';
      const headline=document.createElement('strong');
      headline.textContent='⚡ Satellite lightning flash';
      headline.style.color='#ffdf44';
      const detail=document.createElement('div');
      detail.textContent=(p.time_utc||'Time unavailable')+' · UTC / source: EUMETSAT MTG LI';
      const note=document.createElement('small');
      note.textContent='Optical lightning detection; not a confirmed ground strike.';
      box.append(headline,detail,note);
      new window.maplibregl.Popup({closeButton:true}).setLngLat(e.lngLat).setDOMContent(box).addTo(map);
    });
    map.on('mouseenter',LAYER,()=>{if(input.checked)map.getCanvas().style.cursor='pointer';});
    map.on('mouseleave',LAYER,()=>{map.getCanvas().style.cursor='';});
    state.installed=true;
    status('WAIT');
    return true;
  }

  const begin=Date.now();
  const timer=setInterval(()=>{
    try {
      if(install()){clearInterval(timer);}
      else if(Date.now()-begin>60000){
        state.errors.push('Weather module did not find installed GridAtlas menu within 60s');
        clearInterval(timer);
      }
    }catch(error){
      state.errors.push(String(error?.message||error));
      console.error('[GRIDATLAS WEATHER] isolated extension failure',error);
      clearInterval(timer);
    }
  },250);
})();

Renewable Energy Planning Database (REPD) Address Flyto

A JavaScript module in the cartridges folder of GridAtlas that normalizes search (`normalizeSearchText`), parses atlas query (`parseAtlasQuery`) and scores record (`scoreRecord`) (units: MW), covering the REPD register and postcodes.

energy-datagridatlas / atlas/releases/202608291237-atlas-v9/cartridges/202608290716-repd-address-flyto.mjs · lines 1–113 of 113 · version 2026-08-29 07:16 · Not reached from any entry point (candidate for review) · pattern searchable (shared by 2 files)

What it does
It draws the REPD register and postcodes. Defines 8 functions or classes, including normalizeSearchText, parseAtlasQuery, searchable, scoreRecord, rankRepdProjects. Side effects: changes the web page (DOM).
Why it exists in the grid workflow
Domain stage upstream_foresight (path word 'atlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: the REPD register, postcodes.
Downstream impact
Used directly by 2 files: Atlas V9 (gridatlas); UI Atlas V9 (gridatlas, https://gridatlas.globalgrid2050.com/ui/site/).
What it achieves
It normalizes search text (`normalizeSearchText`), parses atlas query (`parseAtlasQuery`) and scores record (`scoreRecord`). Defines `normalizeSearchText`, `parseAtlasQuery`, `searchable` and 5 more. It responds to click and keydown events.
Why it matters
Imported by Atlas V9 and UI Atlas V9.
Application
gridatlas · atlas/releases/202608291237-atlas-v9/cartridges · JavaScript module
Uses
none found
Used by
imported by Atlas V9 (import), imported by UI Atlas V9 (import), mentioned in Standalone (comment link)
Produces
ATLAS_V9_REPD_ADDRESS_FLYTO_CONTRACT, normalizeSearchText, parseAtlasQuery, rankRepdProjects, mountRepdAddressFlyTo
Defines here
normalizeSearchText, parseAtlasQuery, searchable, scoreRecord, rankRepdProjects, text, mountRepdAddressFlyTo, run
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/releases/202608291237-atlas-v9/cartridges/202608290716-repd-address-flyto.mjs:1-113 · blob 1442f775d473c60dfdbb5376cfa85a653cb6b346 · GitHub at these lines
State
achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
export const ATLAS_V9_REPD_ADDRESS_FLYTO_CONTRACT = Object.freeze({
  schema: "gridatlas.cartridge.v1",
  generation: "202608290716",
  activation: "core-registry-plus-explicit-user-query",
  payloadRequests: 0,
  externalGeocoderRequests: 0,
  maximumMounts: 1,
  resultClass: "DIRECT_PROJECT_MATCH",
  proximityEstablishesIdentity: false,
  relationshipLabel: "REPD operator or applicant (as published)"
});

const STOP = new Set(["a", "an", "and", "anybody", "anyone", "are", "at", "being", "built", "by", "can", "farm", "for", "in", "involved", "is", "of", "on", "project", "site", "someone", "the", "there", "who"]);

export function normalizeSearchText(value) {
  return String(value || "").normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/&/g, " and ").replace(/[^a-z0-9/]+/g, " ").trim();
}

export function parseAtlasQuery(raw) {
  const normalized = normalizeSearchText(raw);
  const constructionIntent = /\b(?:build|building|built|construction|constructing)\b/.test(normalized);
  const groups = normalized.split(/\s+/).filter(Boolean).filter(token => !STOP.has(token)).map(token => token.split("/").filter(Boolean)).filter(group => group.length);
  return { raw: String(raw || ""), normalized, groups, constructionIntent };
}

function searchable(record) {
  return normalizeSearchText([record.name, record.repd_address_display, record.repd_postcode_raw, record.repd_postcode, record.county, record.region, record.planning_authority, record.planning_application_reference, record.repd_ref, record.technology, record.repd_technology].filter(Boolean).join(" "));
}

function scoreRecord(record, parsed) {
  const haystack = searchable(record);
  const compactHaystack = haystack.replace(/\s/g, "");
  if (!parsed.groups.length || !parsed.groups.every(group => group.some(term => compactHaystack.includes(term.replace(/\s/g, "")) || haystack.includes(term)))) return null;
  const name = normalizeSearchText(record.name);
  const address = normalizeSearchText(record.repd_address_display);
  const postcode = normalizeSearchText(record.repd_postcode).replace(/\s/g, "");
  const county = normalizeSearchText(record.county);
  let score = 0;
  const reasons = new Set();
  for (const group of parsed.groups) {
    const term = group.find(item => compactHaystack.includes(item.replace(/\s/g, "")) || haystack.includes(item)) || group[0];
    const compact = term.replace(/\s/g, "");
    if (String(record.repd_ref) === term) { score += 1000; reasons.add("REPD ID"); }
    if (postcode && postcode === compact) { score += 800; reasons.add("postcode"); }
    if (name === term) { score += 700; reasons.add("project name"); }
    else if (name.startsWith(term) || name.includes(term)) { score += 260; reasons.add("project name"); }
    if (address.includes(term)) { score += 180; reasons.add("official address"); }
    if (county.includes(term)) { score += 130; reasons.add("county"); }
    if (normalizeSearchText(record.planning_authority).includes(term)) { score += 90; reasons.add("planning authority"); }
    if (normalizeSearchText(record.technology + " " + record.repd_technology).includes(term)) { score += 70; reasons.add("technology"); }
  }
  if (parsed.constructionIntent && ["under construction", "awaiting construction", "application submitted"].includes(record.status)) {
    score += record.status === "under construction" ? 160 : record.status === "awaiting construction" ? 120 : 40;
    reasons.add(record.status);
  }
  return { record, score, reasons: [...reasons] };
}

export function rankRepdProjects(records, rawQuery, limit = 20) {
  const parsed = parseAtlasQuery(rawQuery);
  return records.map(record => scoreRecord(record, parsed)).filter(Boolean).sort((a, b) => b.score - a.score || a.record.name.localeCompare(b.record.name) || Number(a.record.repd_ref) - Number(b.record.repd_ref)).slice(0, limit);
}

function text(tag, value, className) {
  const node = document.createElement(tag);
  if (className) node.className = className;
  node.textContent = value;
  return node;
}

export function mountRepdAddressFlyTo({ map, records, root, onSelected = () => {} }) {
  if (!map || !Array.isArray(records) || !root) throw new Error("address fly-to mount contract failed");
  if (root.dataset.mounted === "true") return ATLAS_V9_REPD_ADDRESS_FLYTO_CONTRACT;
  root.dataset.mounted = "true";
  const input = root.querySelector("[data-atlas-query]");
  const button = root.querySelector("[data-atlas-search]");
  const results = root.querySelector("[data-atlas-results]");
  const live = root.querySelector("[data-atlas-live]");
  const run = () => {
    const matches = rankRepdProjects(records, input.value);
    results.replaceChildren();
    live.textContent = `${matches.length} direct REPD project matches`;
    if (!matches.length) {
      results.append(text("p", "No direct official REPD address/project match. Try a postcode, county, planning authority or REPD reference.", "empty-result"));
      return;
    }
    for (const match of matches) {
      const { record } = match;
      const card = document.createElement("article");
      card.className = "result-card";
      card.dataset.resultClass = "DIRECT_PROJECT_MATCH";
      card.append(text("div", "DIRECT PROJECT MATCH · REPD " + record.repd_ref, "result-kicker"));
      card.append(text("h3", record.name));
      card.append(text("p", record.repd_address_display || "Address not supplied by REPD", "result-address"));
      card.append(text("p", [record.repd_postcode || "Postcode not supplied", record.county, record.planning_authority].filter(Boolean).join(" · "), "result-meta"));
      card.append(text("p", `${record.repd_technology || record.technology} · ${record.capacity_mw} MW · ${record.status}`, "result-meta"));
      card.append(text("p", `REPD operator or applicant (as published): ${record.repd_operator_or_applicant || "Not supplied / withheld"}`, "result-applicant"));
      card.append(text("p", `Matched: ${match.reasons.join(", ")}`, "result-reasons"));
      const fly = text("button", "FLY TO PROJECT", "fly-button");
      fly.type = "button";
      fly.addEventListener("click", () => {
        if (![record.longitude, record.latitude].every(Number.isFinite)) return;
        map.flyTo({ center: [record.longitude, record.latitude], zoom: 13, duration: matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : 1400, essential: false });
        onSelected(record);
      });
      card.append(fly);
      results.append(card);
    }
  };
  button.addEventListener("click", run);
  input.addEventListener("keydown", event => { if (event.key === "Enter") run(); });
  return ATLAS_V9_REPD_ADDRESS_FLYTO_CONTRACT;
}