In this section
- G203 Regional Native Viewport geodesy · gridatlas / atlas/modules/g203-regional-native-viewport.js lines 8101–8664
- G203 Vicinity Controls Rescue interaction · gridatlas / atlas/modules/g203-vicinity-controls-rescue.js lines 1–132
G203 Regional Native Viewport
A JavaScript file in the atlas folder of GridAtlas that maps elizabeth line and london underground, using haversine, and uses data from the ventus-grid-engine, data-federation-map-for-GlobalGrid2050-all-repos and spiders repositories.
Set aside from the main view: 99% of its lines are the same as atlas/cartridges/202611180026-substation-intelligence-v9-63.js (gridatlas), which stays. (near-copy-of, proposed by families.py). 98% of lines shared with Substation Intelligence V9 63; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.987 to gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 atlas/cartridges/202611180026-substation-intelligence-v9-63.js:1-8609 c6f9632fdb6e803baae03a54a542fe508431d153
- sha256 7645828021ee561333c34c0ecaad2b46bd87029ca9101601714d7e520bb680b1
- target sha256 88c538b97bf426776cda436151741f17500a2136867d28362407550d72f9038f
- group of 4 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
geodesygridatlas / atlas/modules/g203-regional-native-viewport.js · lines 8101–8664 of 8664 (continued from section 576) · pattern regionalEligible (shared by 3 files)
- What it does
- It maps elizabeth line, london underground, UK metros trams and hs2. Defines 241 functions or classes, including deepFreeze, escapeHTML, normalizeStatus, fmt, haversine. 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. Domain terms in the code: 750kV, 400kV, 275kV, 132kV, 66kV, 33kV.
- Inputs & outputs
- In: data source: ventus-grid-engine data; data source: data-federation-map-for-globalgrid2050-all-repos data; data source: spiders data; data source: npm data; GeoJSON file elizabeth_line.geojson; GeoJSON file london_underground.geojson; GeoJSON file uk_metros_trams.geojson; GeoJSON file hs2.geojson. Out: downloaded file gridatlas-; downloaded file globalgrid2050-grid-atlas-; interactive map; canvas drawing; SVG drawing. Voltage levels named: 750kV, 400kV, 275kV, 132kV, 66kV, 33kV, 11kV.
- Downstream impact
- Used directly by 1 file: G203 Swarm 06 Viewport Lifecycle Test (gridatlas). Reached from 1 other entry point, including GridAtlas PR File Size Guard Workflow (gridatlas).
- What it achieves
- It normalizes status (`normalizeStatus`), toggles zone draw mode (`toggleZoneDrawMode`) and opens popup (`openPopup`). ASSEMBLED by `tools/build-cartridge.mjs` from the parts below. Its code works with 400 kV, 100 MVA and 132 kV. It responds to fullscreenchange, webkitfullscreenchange and click events.
- Why it matters
- Checked by G203 Swarm 06 Viewport Lifecycle Test.
- Application
- gridatlas · atlas/modules · script
- VEDIC
- SNAP LINE ENDS TO SUBSTATIONS (GG2050-VEDIC-000106): GridAtlas / Substations · Geospatial data processing. line_features, substation_point_features → Line features whose first and last vertices are moved onto the nearest substation point within tolerance; other geometry unchanged.
- VEDIC
- MEASURE (GG2050-VEDIC-000001): GridAtlas / Geodesy · Mathematics / Spherical geometry. coordinate_pair, coordinate_pair → distance_km
- VEDIC
- REPRESENT (GG2050-VEDIC-000002): GridAtlas / Geodesy · Computer science / Geometry processing. geojson_geometry → coordinate_pair_or_null
- Uses
- Spider Full Po Test (estate URL), Data — Grid Studies Public Page (estate URL)
- Used by
- referenced by G203 Swarm 06 Viewport Lifecycle Test (new URL import.meta.url)
- Produces
- deepFreeze, escapeHTML, normalizeStatus, fmt, haversine, _zoneDrawGetRadius, _zoneDrawCirclePoints, _zoneDrawCalcArea, _zoneDrawUpdateLayers, _zoneDrawShowPopup, _zoneDrawShowPopupDebounced, _zoneDrawClear
- Defines here
- printSourceCode, statusLine, say, beginPreparing, button, install, normalise, ready, eligible, unitCount
- 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/modules/g203-regional-native-viewport.js:8101-8664 · blob 013cf98a02bb6c09199c357ac96a2b588892c0f4 · 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: production_core
Volume splitting lived here and is gone. Two reasons, and the second is
the serious one.
First, it was the printer imposing a human limit: "a printer prints what
it's given it doesn't rely on human induced limits and it's a digital
printer that doesn't run out of paper 2MB is nothing for vital evidence
like that."
Second, it did not exist. `splitIntoVolumes`, `headerLines` and
`fileBlocks` were REFERENCED here and never defined -- three symbols, each
appearing exactly once in the file -- so this function threw a
ReferenceError on every call and the Print source code button was dead on
the live site. `node --check` passed throughout, because a syntax check
cannot see an undefined identifier. An independent comparison of the two
driver lanes found it; my own CI did not. */
const first = { filename: collected.filename, text: collected.text };
const parts = [first];
const record = {
filename: first.filename,
bytes: new Blob([collected.text]).size,
included: collected.included,
missing: collected.missing.length,
state: collected.state,
via: [],
offered: []
};
/* OURS FIRST. Whatever any platform does or refuses to do below, the reader
is looking at volume 1 with a Copy button under it and one button per
remaining volume. */
if (panel) {
showTeleprintPanel(first.text, first.filename, parts);
record.via.push('panel');
}
/* The whole record. */
try {
downloadText(first.text, first.filename);
record.via.push('download-requested');
} catch (error) {
record.offered.push('download: ' + String((error && error.message) || error));
}
if (prefer === 'share' && typeof navigator !== 'undefined' && navigator.share
&& typeof File === 'function') {
try {
const file = new File([first.text], first.filename, { type: 'text/plain' });
if (!navigator.canShare || navigator.canShare({ files: [file] })) {
await navigator.share({ files: [file], title: first.filename });
record.via.push('share');
} else {
record.offered.push('share: this browser will not share files');
}
} catch (error) {
record.offered.push(error && error.name === 'AbortError'
? 'share: the reader cancelled'
: 'share: ' + String((error && error.message) || error));
}
}
return record;
}
/** Collect and deliver in one call, for callers outside a gesture. */
async function printSourceCode(options = {}) {
const collected = await collectSourceCode(options);
return deliverSourceCode(collected, options);
}
/* WIRING: put the two functions in the File menu, and nowhere else.
--------------------------------------------------------------------------
The reader already knows where printing lives -- they found it once and
printed a sheet from it. A floating button somewhere else would be a second
place to learn, so both controls go into the same EXPORT THIS VIEW group,
next to the print command that is already there.
The two are SEPARATE COMMANDS and are never merged into one "export":
Print PDF a picture of the screen, for a person to look at
Print source code the whole source and its dependencies, for a machine
to read
NOTHING EXISTING IS REPLACED. The older map-only PDF control stays exactly
as it is. Two implementations of the same idea sitting side by side is the
point -- where they disagree, the disagreement is the finding. */
var PANEL_ANCHOR = '#gridatlas-export-print';
var STATUS_ID = 'gridatlas-teleprint-status';
var MAX_TRIES = 80;
function statusLine(anchor) {
var node = document.getElementById(STATUS_ID);
if (node) return node;
node = document.createElement('div');
node.id = STATUS_ID;
node.setAttribute('role', 'status');
node.setAttribute('aria-live', 'polite');
node.style.cssText = 'padding:6px 11px;font:10px/1.4 ui-monospace,'
+ 'SFMono-Regular,Menlo,monospace;color:#9fd6e4;opacity:.9;'
+ 'white-space:normal;max-width:34ch';
if (anchor && anchor.parentNode) anchor.parentNode.appendChild(node);
return node;
}
function say(text) {
var node = document.getElementById(STATUS_ID);
if (node) node.textContent = text;
}
/* The teleprint of the source is prepared when the FILE MENU OPENS, not when
the button is pressed.
Collecting it means reading every resource the browser loaded, which takes
seconds and ends the user gesture. A share sheet or a clipboard write
requested after that gesture has ended is refused, and the reader is told
nothing happened for no reason they can see. Preparing early costs one
speculative pass and makes the press instant. */
var prepared = null;
var preparing = null;
function beginPreparing() {
if (prepared || preparing) return preparing;
preparing = collectSourceCode({ appName: 'GridAtlas' })
.then(function (result) {
prepared = result;
preparing = null;
say('Source ready · ' + result.included + ' files'
+ (result.missing.length ? ' · ' + result.missing.length + ' not readable' : ''));
return result;
})
.catch(function (error) {
preparing = null;
say('Source could not be prepared: ' + (error && error.message));
throw error;
});
return preparing;
}
function button(label, id, onClick) {
var node = document.createElement('button');
node.id = id;
node.setAttribute('type', 'button');
node.setAttribute('data-gm-export', id.replace('gridatlas-', ''));
node.setAttribute('data-teleprint', '1');
node.textContent = label;
node.addEventListener('click', function () { onClick(node); });
return node;
}
function install() {
var anchor = document.querySelector(PANEL_ANCHOR);
if (!anchor || !anchor.parentNode) return false;
if (document.getElementById('gridatlas-teleprint-source')) return true;
var pdf = button('⎙ Print PDF · exactly this screen',
'gridatlas-teleprint-pdf', function (node) {
var was = node.textContent;
say('Capturing the screen…');
printPdf({
note: {
brand: 'VENTUS · GLOBALGRID2050 · GRID ATLAS',
title: document.title,
url: location.href,
stamp: new Date().toISOString().replace('T', ' ').slice(0, 16) + ' UTC',
credit: Array.prototype.map.call(
document.querySelectorAll('.maplibregl-ctrl-attrib-inner'),
function (n) { return n.textContent.trim(); }
).filter(Boolean).join(' | ')
}
}).then(function (receipt) {
/* REPORT THE MEASUREMENT, DO NOT GRADE IT.
------------------------------------------------------------------
This read `scale >= 0.999 ? 'every screen pixel'`. An ultrawide
capture measured 2326 of 2327 columns -- 0.99957 -- so the sheet
announced "every screen pixel" for a record that was one pixel
column short. A threshold dressed as a fact is exactly the habit
this estate has a rule against, and I wrote the rule.
It also read width only, so a frame that was full width and short in
height reported as complete. The claim is now an integer equality on
BOTH axes, decided in screen-frame.js where the numbers are, and
anything less prints the pixel counts rather than a verdict. */
var fidelity = '';
if (receipt.everyScreenPixel) {
fidelity = ' · every screen pixel';
} else if (receipt.screenWidth) {
fidelity = ' · ' + receipt.width + '×' + receipt.height + ' of '
+ receipt.screenWidth + '×' + receipt.screenHeight + ' screen pixels';
}
say('PDF · ' + receipt.width + '×' + receipt.height + ' px, page '
+ receipt.pageWidth + '×' + receipt.pageHeight + fidelity
+ ' · via ' + receipt.method);
node.textContent = was;
}, function (error) {
/* The reader cancelling the screen-share chooser is a decision, not a
fault, and must not be reported as one. */
say(error && /denied|Permission|abort/i.test(String(error.message || error))
? 'Screen capture was not allowed, so nothing was printed.'
: 'Could not print: ' + (error && error.message));
node.textContent = was;
});
});
var source = button('⎙ Print source code · for AI review',
'gridatlas-teleprint-source', function () {
say('Preparing the source…');
Promise.resolve(prepared || beginPreparing()).then(function (collected) {
return deliverSourceCode(collected, { panel: true });
}).then(function (receipt) {
say('Source code · ' + receipt.included + ' files, '
+ receipt.bytes + ' bytes'
+ (receipt.volumesAvailable > 1
? ' · whole file; ' + receipt.volumesAvailable
+ ' volumes available if your chat refuses it'
: '')
+ ' · ' + receipt.via.join(' + ')
+ (receipt.missing ? ' · ' + receipt.missing + ' not readable' : ''));
}, function (error) {
say('Could not print the source: ' + (error && error.message));
});
});
anchor.parentNode.insertBefore(pdf, anchor.nextSibling);
pdf.parentNode.insertBefore(source, pdf.nextSibling);
statusLine(source);
say('Print PDF saves this screen. Print source code saves the code behind it.');
/* Opening File is the signal to start work. Delegated from the document so
it survives the menu being rebuilt. */
document.addEventListener('click', function (event) {
var title = event.target && event.target.closest
? event.target.closest('.gm-title') : null;
if (title && /file/i.test(title.textContent || '')) beginPreparing();
}, true);
return true;
}
/* The export group is built by the menu bar, which itself installs only once
63 layer controls exist. Polling rather than assuming: a fixed delay is a
guess that is wrong on a slow phone and wasteful on a fast desktop. */
if (!install()) {
var tries = 0;
var timer = setInterval(function () {
tries += 1;
if (install() || tries >= MAX_TRIES) clearInterval(timer);
}, 250);
}
}());
/* ══════════════════════════════════════════════════════════════════════
PART 2 - the network, as its operator publishes it
══════════════════════════════════════════════════════════════════════ */
(() => {
'use strict';
const GENERATION = '202609012045';
/* Pinned to a commit and hashed. The reasoning, the table and the
digest arithmetic are in the pinned-products module beside this file;
what matters here is that `main` was the ref and the schema string was
the whole defence, and a schema string is blind to values. */
const PINS = (window.__GRIDATLAS_MODULES__ || {}).pinnedProducts || null;
const PRODUCT_ID = 'connection-points.v3';
const PRODUCT = PINS ? PINS.url(PRODUCT_ID) : null;
const REQUIRED_SCHEMA = 'data-grid-gb.connection-points.v3';
/* Appendix D publishes eight current metrics and they are NOT
interchangeable, so one is quoted and named rather than any of them
being called "the fault level".
Codex, 202609011852: an earlier version of this comment and of the
card said the RMS break current is "the one switchgear is rated
against". That overclaims. Switchgear carries several relevant
ratings - making capacity, short-time withstand, peak withstand -
and this is ONE published breaker-duty metric among the eight. */
const QUOTED_METRIC = 'three_phase_rms_break_current_ka';
const QUOTED_METRIC_LABEL = 'three-phase RMS break current';
const DEG = Math.PI / 180;
const state = {
schema: 'gridatlas.substation-intelligence.v2',
generation: GENERATION,
product: PRODUCT,
loaded: false,
points: 0,
located: 0,
product_schema: null,
quoted_metric: QUOTED_METRIC,
failures: []
};
window.__GRIDATLAS_NETWORK__ = state;
/* ONE geodesy, and it is the module's.
--------------------------------------------------------------
This carried its own haversine using 2*R*asin(sqrt(a)) while the
estate canonical form is R*2*atan2(sqrt(a), sqrt(1-a)). They
agree algebraically and differ in the last place, and the
difference was invisible for as long as this half of the
cartridge was a monolith the all-versions scan could not read.
202609012350 extracted it, the scan found it immediately, and
the answer is not to retype the right form here but to stop
having a second implementation at all. */
const GEODESY = (window.__GRIDATLAS_MODULES__ || {}).geodesy;
if (!GEODESY) throw new Error("substation-intelligence requires the geodesy module");
const distanceKm = GEODESY.distanceKm;
const NOISE = /\b(SUBSTATION|SUB STATION|SUBSTN|GRID|SUPPLY|POINT|GSP|NATIONAL|POWER|STATION|WIND|FARM|WINDFARM|OFFSHORE|ONSHORE|EXTENSION|400KV|275KV|132KV|66KV|33KV|11KV|NGET|SSE|SP|SHE)\b/g;
function normalise(name) {
return String(name || '').toUpperCase()
.replace(/[^A-Z0-9 ]/g, ' ').replace(NOISE, ' ')
.split(/\s+/).filter(Boolean).join(' ');
}
const byName = new Map();
const located = [];
/* Every point, not only the ones that survived the name join. `byName`
keeps the first of a colliding key, so counting from it would report a
smaller network than the operator publishes. */
const published = [];
const ready = (async () => {
try {
if (!PRODUCT) throw new Error('the pinned-products module is not composed, '
+ 'so this cartridge has no pinned ref to read and will not guess one');
const response = await fetch(PRODUCT, { cache: 'no-cache' });
if (!response.ok) throw new Error('HTTP ' + response.status);
const text = await response.text();
const seal = await PINS.verify(PRODUCT_ID, text);
state.product_pin = seal;
if (seal.state === 'MISMATCH') {
state.failures.push(seal.detail
+ '; refusing to answer from bytes this composition has not seen');
return false;
}
const product = JSON.parse(text);
state.product_schema = product?.schema || null;
if (product?.schema !== REQUIRED_SCHEMA) {
state.failures.push('schema is ' + String(product?.schema)
+ ', this cartridge answers only ' + REQUIRED_SCHEMA);
return false;
}
for (const point of product.connection_points || []) {
const key = normalise(point.name);
if (key && !byName.has(key)) byName.set(key, point);
published.push(point);
if (point.location) located.push(point);
}
state.points = (product.connection_points || []).length;
state.located = located.length;
state.counts = product.counts || null;
state.join = product.join || null;
state.source = product.source || null;
state.loaded = true;
return true;
} catch (error) {
state.failures.push('network product: ' + String(error?.message || error));
return false;
}
})();
state.ready = ready;
state.byName = (name) => state.loaded
? (byName.get(normalise(name)) || null) : null;
/* The owner product's coordinates are NOT used for anything a reader
sees. Codex, 202609011852: WBUR's exact-name join binds a different
West Burton 96.42 km from the project, and exact text equality is not
exact identity. The Atlas measures on its own substation payload and
always has; this stays available for callers that want it, marked,
and the card is proven never to print a distance from here. */
state.location_join_is_unverified = true;
state.nearest = (lon, lat, options) => {
if (!state.loaded) return null;
const minimumKv = options?.minimumKv ?? 0;
const limit = options?.limit ?? 1;
const found = [];
for (const point of located) {
if (Math.max(...point.voltages_kv) < minimumKv) continue;
found.push({ point, km: distanceKm(lon, lat, point.location.lon, point.location.lat) });
}
found.sort((a, b) => a.km - b.km);
return limit === 1 ? (found[0] || null) : found.slice(0, limit);
};
/* One line a card can print, built only from what is published, or null
when nothing is. An empty sentence about a substation is worse than
silence. */
/* connectionKv is the voltage the connection is actually made at: the
declared point of connection's class, or the class of the substation
being measured to. Given one, the fault current is quoted at THAT
busbar group rather than across the site.
An outside review put the reason plainly: fault duty at a 400 kV
busbar and at a 132 kV busbar are different physical quantities
governing different switchgear, so a range spanning both is
meaningless to the engineer reading it - and the more correctly the
metric is named, the more readily the eye trusts it. */
/* WHAT A DISTANCE SEARCH COULD SEE, at the voltage it was asked for.
------------------------------------------------------------------
ETYS names substations and does not locate them; the only geometry
this estate holds comes from OpenStreetMap through a GridAtlas
release. So a proportion of what the operator publishes is invisible
to any search by distance, and a card that says "nearest" without
saying that is asserting something it cannot know.
COMPUTED, never written down. The numbers move when the product moves
- Codex's join correction takes located from 502 to 489 - and a
sentence with a literal in it would go quietly false the day the pin
is bumped. This counts the payload that was actually fetched, using
exactly the predicate state.nearest uses to decide what is eligible,
so the denominator on the card is the denominator of the search. */
state.coverage = (minimumKv) => {
if (!state.loaded) return null;
const floor = Number(minimumKv) || 0;
const eligible = (point) => Array.isArray(point.voltages_kv)
&& point.voltages_kv.length
&& Math.max(...point.voltages_kv) >= floor;
const inBand = published.filter(eligible);
const seen = located.filter(eligible);
return {
minimum_kv: floor,
published: inBand.length,
located: seen.length,
unlocated: inBand.length - seen.length,
/* Named rather than computed by the reader, and never graded. */
basis: 'counted from the connection-points payload this session fetched'
};
};
state.summarise = (name, options) => {
const point = state.byName(name);
if (!point) return null;
const connectionKv = options && Number(options.connectionKv);
/* connection-points.v3 publishes `circuits` and `transformers` as
LANDINGS - one per node-end at the site - not as machines. A
transformer's two windings are both at the site by construction, so
almost every transformer is counted twice: Cowley publishes 10 for
its five machines, and 484 of the 525 sites that hold a transformer
are overstated, 2,944 landings against 1,550 units (1.90x).
This cartridge holds no node pairs, so it cannot deduplicate on its
own; the caller may pass `units` derived from the node/branch model
by the network-topology module, which does hold them. Where it does,
the machine count is stated. Where it does not, the published figure
is still shown but is named for what it is, because a landing tally
presented as a machine count is the defect, not the tally. */
/* Number(null) is 0, not NaN, so `Number(units && units.x)` reports a
finite ZERO the moment no units are passed - which is every call
that does not supply them. The proof caught it saying "0 circuits"
for a site publishing eight. Read the field only when there is one. */
const units = (options && options.units) || null;
const unitCount = (field) => {
if (!units) return null;
const value = Number(units[field]);
return Number.isFinite(value) ? value : null;
};
const transformerUnits = unitCount('transformers');
const circuitUnits = unitCount('circuits');
const parts = [];
if (circuitUnits !== null) {
parts.push(circuitUnits + (circuitUnits === 1 ? ' circuit' : ' circuits'));
} else if (point.circuits) {
parts.push(point.circuits + (point.circuits === 1 ? ' circuit' : ' circuits'));
}
if (transformerUnits !== null) {
parts.push(transformerUnits
+ (transformerUnits === 1 ? ' transformer' : ' transformers'));
} else if (point.transformers) {
parts.push(point.transformers + ' transformer winding connections at the site '
+ '(a transformer whose windings are both here is published at each of them, '
+ 'so this is not a count of machines)');
}
const rating = point.circuit_winter_rating_mva;
if (rating) {
/* The product does not split ratings by voltage, and a site with
several voltages will show a range no single circuit could span -
Blackhillock publishes 23 to 1,995 MVA. So it is marked site-wide
wherever it appears, rather than sitting beside a bus-specific
fault figure as though it shared its scope. */
parts.push('circuit winter ratings across the site '
+ rating.min.toLocaleString('en-GB')
+ '\u2013' + rating.max.toLocaleString('en-GB') + ' MVA');
}
/* Prefer the busbar group the connection is made at. Fall back to the
site-wide envelope only when the voltage is unknown or the product
does not publish that group, and say which was used either way. */
const byVoltage = point.fault_current_by_voltage || null;
let peak = point.fault_current?.peak || null;
let faultScope = 'site';
let faultKv = null;
if (Number.isFinite(connectionKv) && byVoltage) {
const key = Object.keys(byVoltage)
.find(k => Math.abs(Number(k) - connectionKv) < 0.5);
if (key && byVoltage[key]?.peak) {
peak = byVoltage[key].peak;
faultScope = 'bus';
faultKv = Number(key);
}
}
const metric = peak?.metrics?.[QUOTED_METRIC];
if (metric) {
parts.push(QUOTED_METRIC_LABEL + ' ' + metric.min.toFixed(1) + '\u2013'
+ metric.max.toFixed(1) + ' ' + metric.unit
+ (faultScope === 'bus'
? ' at the ' + faultKv + ' kV busbars'
: ' across every busbar at this site')
+ ' over ' + peak.scenarios + ' peak-demand rows'
+ (peak.locations?.length ? ' at ' + peak.locations.length
+ (peak.locations.length === 1 ? ' bus' : ' buses') : '')
+ (peak.winters?.length
? ' (' + peak.winters[0] + ' to ' + peak.winters[peak.winters.length - 1] + ')'
: ''));
}
if (point.reactive_compensation?.units) {
parts.push(point.reactive_compensation.units + ' reactive compensation units');
}
if (point.planned_changes) {
const years = point.planned_change_years || [];
parts.push(point.planned_changes + ' changes published for '
+ (years.length ? years[0] + '\u2013' + years[years.length - 1] : 'later years'));
}
if (!parts.length) return null;
/* Everything above is aggregated at SITE CODE, not selected for a
bus. Where a site carries more than one voltage the numbers span
them, so the reader is told that before reading any of them -
otherwise a sentence under a 400 kV point of connection reads as a
400 kV result. West Burton is exactly this case: WBUR1 is 132 kV
and WBUR4 is 400 kV, and its published fault range spans both. */
const voltages = point.voltages_kv || [];
/* Site-wide is now about what remains site-wide. Once the fault
current is quoted at a busbar group, the label must not claim the
whole sentence is site-wide - only the parts that still are. */
const siteWide = voltages.length > 1;
const busLocations = point.fault_current?.peak?.locations || [];
return {
site_code: point.site_code,
transmission_owner: point.transmission_owner,
voltages_kv: voltages,
site_wide: siteWide,
bus_locations: busLocations,
fault_scope: faultScope,
fault_kv: faultKv,
scope_label: faultScope === 'bus'
? ('Fault current is quoted at the ' + faultKv + ' kV busbars, the '
+ 'voltage this connection is made at. Circuit counts, ratings, '
+ 'transformers and planned changes remain site-wide across the '
+ voltages.slice().sort((a, b) => b - a).join('/') + ' kV buses here')
: (siteWide
? ('Site-wide published envelope across the '
+ voltages.slice().sort((a, b) => b - a).join('/') + ' kV buses at this site, '
+ 'not a value for any one bus')
: ('Published for this site, which carries one voltage: '
+ (voltages[0] || '?') + ' kV')),
sentence: parts.join(' \u00b7 '),
metric_named: QUOTED_METRIC_LABEL,
metrics_not_interchangeable: 'Appendix D publishes eight current '
+ 'metrics and they are not interchangeable; this is one published '
+ 'breaker-duty metric, and switchgear carries several relevant '
+ 'ratings besides it.',
attribution: 'NESO Electricity Ten Year Statement 2025, appendices B and D, '
+ 'via Ventusltd/data-grid-gb',
not_an_assessment: 'Published parameters. Not a statement about whether '
+ 'any project can connect here.'
};
};
})();G203 Vicinity Controls Rescue
A JavaScript file in the atlas folder of GridAtlas that works with float layers (`floatLayers`) and full mode (`fullMode`) (units: MW).
interactiongridatlas / atlas/modules/g203-vicinity-controls-rescue.js · lines 1–132 of 132 · Entry point · pattern floatLayers (shared by 2 files)
- What it does
- Defines 8 functions or classes, including answered, floatLayers, wake, fallback, tick. 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.
- Downstream impact
- Used directly by 1 file: GridAtlas PR File Size Guard Workflow (gridatlas).
- What it achieves
- It is built from the answered step (`answered`), the float layers helper (`floatLayers`) and the wake step (`wake`). The V9.194 launcher put this button INSIDE the map-controls stacking context. It responds to visibilitychange, pagehide and click events.
- Why it matters
- Run by GridAtlas PR File Size Guard Workflow.
- Application
- gridatlas · atlas/modules · script
- Uses
- none found
- Used by
- run by GridAtlas PR File Size Guard Workflow (workflow run)
- Produces
- answered, floatLayers, wake, fallback, tick, later, fullMode, reflect
- Defines here
- answered, floatLayers, wake, fallback, tick, later, fullMode, reflect
- 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/modules/g203-vicinity-controls-rescue.js:1-132 · blob 3f6d8c4e6c314383b31449553f8cf3e1c7d2c89b · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
/* GridAtlas V9.196: keep the inherited Grid Engine; repair PDF/tab wake and Layers hit target. */
(function(){
'use strict';
const W=window,D=document,q=new URLSearchParams(W.location.search);
const ref=q.get('repd_ref'),latRaw=q.get('latitude'),lonRaw=q.get('longitude');
if(!/^[1-9]\d{0,11}$/.test(ref||'')||!latRaw?.trim()||!lonRaw?.trim())return;
if(['repd_ref','latitude','longitude'].some(k=>q.getAll(k).length!==1))return;
const lat=Number(latRaw),lon=Number(lonRaw);
if(!Number.isFinite(lat)||!Number.isFinite(lon)||lat<49.5||lat>61.5||lon< -11||lon>3)return;
if(Math.abs(lat-49.766807)<.0001&&Math.abs(lon+7.55716)<.0001)return;
const loc=[lon,lat],name=(q.get('project')||q.get('name')||'REPD '+ref).slice(0,180);
const tech=(q.get('technology')||'').slice(0,80),mw=Number(q.get('capacity_mw'));
const started=Date.now(),qa=W.__GRIDATLAS_VICINITY_LINK_QA__={generation:'202611222325',repd_ref:ref,layers:'pending',grid:'pending',fallback_attempts:0};
function answered(){const e=W.__GRIDATLAS_NEON_LINKS__;return Boolean(e?.arrival_engine?.answered===true||e?.links_drawn>0||e?.declared_connection_framed===true)}
function floatLayers(){
const b=D.getElementById('gridatlas-dash-toggle');if(!b)return;
// The V9.194 launcher put this button INSIDE the map-controls stacking
// context. Its huge z-index could not outrank the project card.
const host=D.fullscreenElement||D.webkitFullscreenElement||D.body;
if(!host)return;
if(D.documentElement.hasAttribute('data-g203-compact-dock')){b.hidden=false;qa.layers='native-compact-dock';return;}
if(b.parentElement!==host)host.appendChild(b);
b.hidden=false;
const menu=D.getElementById('gridatlas-menu-bar'),map=W.__GRIDATLAS_V9_MAP__?.getContainer?.();
const anchor=menu?.getBoundingClientRect?.().bottom??map?.getBoundingClientRect?.().top??0;
const height=Math.max(80,W.innerHeight||D.documentElement.clientHeight||852);
const top=Math.min(Math.max(8,Math.ceil(anchor)+8),Math.max(8,height-54));
for(const [k,v] of Object.entries({position:'fixed',top:top+'px',bottom:'auto',right:'12px',left:'auto','z-index':'2147483646','pointer-events':'auto','touch-action':'manipulation','min-height':'44px'}))b.style.setProperty(k,v,'important');
qa.layers='accessible-floating-toggle';
}
let wakes=0,recovered=false,inflight=false;
function wake(){
const l=W.__GRIDATLAS_NEON_LINKS__;
if(D.visibilityState!=='visible'||answered()||wakes>=2)return;
if(!l?.arrival_attempts||l?.arrival_engine?.reason==='DEFERRED_FOR_VISIBILITY'){
wakes++;D.dispatchEvent(new Event('visibilitychange'));qa.grid='visible-wake-'+wakes;
}
}
async function fallback(){
if(answered()){qa.grid='answered';return}
if(D.visibilityState!=='visible'||Date.now()-started<20000||recovered||inflight)return;
const l=W.__GRIDATLAS_NEON_LINKS__;
if(typeof l?.selectAt!=='function'||l.arrival_engine?.terminal===false)return;
if(['FALSE_ORIGIN','NOT_IN_REGISTER','HANDED_TO_INTERCONNECTORS','IDENTITY_REJECTED'].includes(l.arrival_engine?.reason))return;
recovered=inflight=true;qa.fallback_attempts++;qa.grid='measuring-original-engine';
try{
const ok=await l.selectAt(loc,name,tech,false,Number.isFinite(mw)&&mw>0?mw:null);
qa.grid=ok===true?'original-engine-completed':'original-engine-unavailable';
}catch(error){qa.grid='original-engine-failed';qa.error=String(error?.message||error).slice(0,160)}
finally{inflight=false}
}
function tick(){floatLayers();if(answered()){qa.grid='answered';return}if(Date.now()-started>1500&&wakes===0)wake();void fallback()}
const timer=setInterval(tick,1000);
const later=()=>setTimeout(tick,0);
for(const n of ['focus','pageshow','resize','orientationchange'])W.addEventListener(n,later);
for(const n of ['fullscreenchange','webkitfullscreenchange'])D.addEventListener(n,later);
D.addEventListener('visibilitychange',later);
W.addEventListener('pagehide',()=>clearInterval(timer),{once:true});
tick();
})();
/* V9.197 correction: the native dash toggle controls .scada-wrapper.
* In fullscreen (including Safari's CSS-only fullscreen) that wrapper is
* outside the visible map; the working original control is #fs-curtain-tab.
* Route the same visible floating button into the original curtain handler.
* Never claim that a changed .collapsed Boolean means a layer panel appeared.
*/
(function fullscreenLayerBridge(){
'use strict';
const W=window,D=document;
const fullMode=()=>!!(D.fullscreenElement||D.webkitFullscreenElement||
D.body.classList.contains('fs-active')||
D.getElementById('map-container')?.classList.contains('is-fullscreen'));
let wired=null,origin=null;
const result=W.__GRIDATLAS_LAYER_VISIBILITY_QA__={
generation:'202611222343',mode:'waiting',curtain_clicks:0,fullscreen_panel_visible:false};
function reflect(){
const button=D.getElementById('gridatlas-dash-toggle');
const curtain=D.getElementById('fs-curtain');
const tab=D.getElementById('fs-curtain-tab');
if(!button||!curtain||!tab)return;
const nativeFull=D.fullscreenElement||D.webkitFullscreenElement;
if(nativeFull&&!nativeFull.contains(curtain)){
if(!origin)origin={parent:curtain.parentNode,next:curtain.nextSibling};
nativeFull.appendChild(curtain); // moves original controls/listeners, never clones
}else if(!nativeFull&&origin){
if(origin.next?.parentNode===origin.parent)origin.parent.insertBefore(curtain,origin.next);
else origin.parent.appendChild(curtain);
origin=null;
}
const fullscreen=fullMode();
if(wired!==button){
wired=button;
button.addEventListener('click',event=>{
if(!fullMode())return; // ordinary view keeps original .scada-wrapper logic
event.preventDefault();event.stopImmediatePropagation();
const target=D.getElementById('fs-curtain-tab');
const panel=D.getElementById('fs-curtain');
if(!target||!panel){result.mode='missing-original-curtain';return}
target.click(); // the original GridAtlas engine owns curtainOpen
result.curtain_clicks++;
result.mode='fullscreen-curtain';
result.fullscreen_panel_visible=panel.classList.contains('curtain-open');
reflect();
},true);
}
if(fullscreen){
button.hidden=false;
const shown=curtain.classList.contains('curtain-open');
button.textContent=shown?'▴ HIDE LAYERS':'▾ LAYERS';
button.setAttribute('aria-label',shown?'Hide the fullscreen layers panel':'Show the fullscreen layers panel');
button.setAttribute('aria-pressed',String(shown));
result.mode='fullscreen-curtain';
result.fullscreen_panel_visible=shown;
}else{
result.mode='normal-scada-panel';
result.fullscreen_panel_visible=false;
// The original control still owns ordinary collapse, label and state.
const collapsed=W.__GRIDATLAS_DASH__?.collapsed;
if(typeof collapsed==='boolean'){
button.textContent=collapsed?'▴ LAYERS':'▾ HIDE LAYERS';
button.setAttribute('aria-pressed',String(collapsed));
button.setAttribute('aria-label',collapsed?'Show the layers panel':'Hide the layers panel');
}
}
}
const timer=setInterval(reflect,250);
for(const event of ['focus','pageshow','resize','orientationchange'])W.addEventListener(event,reflect);
for(const event of ['fullscreenchange','webkitfullscreenchange'])D.addEventListener(event,reflect);
W.addEventListener('pagehide',()=>clearInterval(timer),{once:true});
reflect();
})();