In this section
- Standalone geodesy · stars / library/standalone.mjs lines 5440–6139
Standalone
A JavaScript module in the library folder of Stars that maps Renewable Energy Planning Database (REPD) master and heavy emitters UK, using SHA-256, and uses data from the GridAtlas repository.
Set aside from the main view: A comment at the top of the file says a tool wrote it. (noise-generated, proposed by noise.py). All set-aside files, with reasons. Nothing was deleted.
Evidence
- line 2 comment: // Generated by the modular star 2026-12-05T23:26:43.596Z. Each export is one family's earliest-seen copy, unchanged; the comment links its source.
geodesystars / library/standalone.mjs · lines 5440–6139 of 12585 (continued from section 1562) · Entry point · pattern segmentConductors (shared by 2 files)
- What it does
- It maps REPD master, heavy emitters UK, notice and substations. Defines 1111 functions or classes, including f1586_invariant, f8767_representativePoint, f8768_voltagesKv, f8772_voltageOf, f8773_ratingsOf. Side effects: changes the web page (DOM); reads or writes files; makes network requests; uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain terms in the code: substations, 750kV, 400kV, 275kV, 132kV, 66kV.
- Inputs & outputs
- In: data source: gridatlas data; JSON file repd_master.json; JSON file heavy_emitters_uk.json; JSON file notice.json; form fields (user input). Out: canvas drawing. Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326. Voltage levels named: 750kV, 400kV, 275kV, 132kV, 66kV, 33kV, 1.5kV, 1500V.
- Downstream impact
- Used directly by 4 files: Code (stars, https://ventusltd.github.io/stars/code.html); Proof (stars); Modular Star Workflow (stars); Testcode — Code Record Page (globalgrid2050, https://globalgrid2050.com/testcode/202609141754/code-record/). Reached from 383 other entry points, including Code Generator — Index Page (code-generator, https://ventusltd.github.io/code-generator/); Generate (code-generator, https://ventusltd.github.io/code-generator/); 404 (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/404.html).
- What it achieves
- It snaps coordinate (`snapCoordinate`), paints cursor (`paintCursor`) and sets plan (`setPlan`). Compiled library of self-contained JavaScript functions that appear in two or more places across Ventusltd code. Its code works with 33 kV, 132 kV and 275 kV. It responds to abort events.
- Why it matters
- Loaded by the Code page at https://ventusltd.github.io/stars/code.html and 1 other page. Run by Proof and Modular Star Workflow.
- Application
- stars · library · JavaScript module
- 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
- VEDIC
- VOLTAGE (GG2050-VEDIC-000003): GridAtlas / Geodesy · Computer science / Data normalisation. voltage_properties → kilovolt_list
- Uses
- GlobalGrid2050 — Renewable Energy Planning Database (REPD) Grid Atlas v8 Page (estate URL), Declared Connections (estate URL)
- Used by
- named by URL in Code (estate URL), run by Proof (script call), run by Modular Star Workflow (workflow run), named by URL in Testcode — Code Record Page (estate URL)
- Produces
- f1586_invariant, f8767_representativePoint, f8768_voltagesKv, f8772_voltageOf, f8773_ratingsOf, f8775_parametersOf, f5168_escapeHTML, f8321_suppliedArrivalFields, f8850__anonymous_, f8786_crossing, f8788_legality, f8789_startNodes
- Defines here
- voltageOf, bandKey, ratingsOf, physicalUnits, parametersOf, index, land, siteOf, graph, resolve, at, f175933__anonymous_, assetCoordinate, statedMw, assetId, collectAssetContext, get, add, f175937__anonymous_, freezeDocumentContext, documentOrigin, documentContextFor, f177818_coordinate, f177841_createRouteFollower, valid, f178079_point, f135184_settle, f135185_measureBundle, f135187_compacted, f135371_gh
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- stars@030ebc202d35959fecd162327892f671d1d9a0cc library/standalone.mjs:5440-6139 · blob fc3d8c8b93e14d4a56b8a26da47071d60bc5bc4d · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, network, storage · domain stage: unknown · users: none · canonical: unknown
* registration are removed. `index()` and its helpers are otherwise
* unchanged — verified verbatim against
* gridatlas/atlas/modules/202609012245-network-topology.js at HEAD
* 64268fd06a0da54ddffbcdaaaee382e314e829f7 (see sources/provenance.json).
*/
const ACCEPTS = 'data-grid-gb.transmission-network.v1';
const NOT_AN_ASSESSMENT =
'Counts, lengths, ratings and impedances are what the network operator '
+ 'publishes about this site. None of them states whether any project can '
+ 'connect here, which depends on queue position, committed connections, '
+ 'consent and commercial terms that no published appendix contains.';
const IMPEDANCE_BASIS =
'R, X and B are percentages on a 100 MVA base, as published. They are '
+ 'network parameters, not a solved power flow.';
const UNDECLARED = 'undeclared';
/* A node's voltage is trusted only where the product says the site
declares it. Everything else is undeclared — never inferred from the
digit in the node code, which is a derived convention the product
itself marks as undocumented. */
function voltageOf(node) {
if (!node) return null;
if (node.voltage_consistent_with_site !== true) return null;
return Number.isFinite(node.voltage_kv) ? node.voltage_kv : null;
}
const bandKey = (kv) => (kv == null ? UNDECLARED : String(kv));
function ratingsOf(row) {
const seasons = { winter: row.winter_mva, spring: row.spring_mva,
summer: row.summer_mva, autumn: row.autumn_mva };
const published = {};
for (const [season, value] of Object.entries(seasons)) {
if (Number.isFinite(value)) published[season] = value;
}
return Object.keys(published).length ? published : null;
}
/* A published branch is seen once from EACH of its ends, so a site that
owns both ends of a branch publishes it twice. See source comment
(network-topology.js:96-124) for the Cowley 5-vs-10 case that motivated
this. Pairs are keyed by the two node names so a branch seen from both
directions is counted once, and one seen from only one direction (what
a voltage-filtered query sees of an internal machine) is also counted
once. */
function physicalUnits(records) {
const pairs = new Map();
for (const record of records) {
const near = String(record.from_node);
const far = String(record.to_node);
const forward = near < far;
const key = forward ? near + ' ' + far : far + ' ' + near;
if (!pairs.has(key)) pairs.set(key, { forward: 0, reverse: 0 });
const seen = pairs.get(key);
if (forward) seen.forward += 1; else seen.reverse += 1;
}
let units = 0;
for (const seen of pairs.values()) {
units += (seen.forward && seen.reverse)
? Math.max(seen.forward, seen.reverse)
: seen.forward + seen.reverse;
}
return units;
}
function parametersOf(row) {
const published = {};
for (const [key, field] of [['r_pct', 'r_pct_100mva'], ['x_pct', 'x_pct_100mva'],
['b_pct', 'b_pct_100mva']]) {
if (Number.isFinite(row[field])) published[key] = row[field];
}
return Object.keys(published).length ? published : null;
}
/**
* @param product the parsed data-grid-gb transmission-network payload
* @returns an index, or null if the schema is not the one this reads
*/
function index(product) {
if (!product || product.schema !== ACCEPTS) return null;
const nodes = new Map();
for (const node of product.nodes || []) {
if (node && node.node) nodes.set(node.node, node);
}
const sitesByCode = new Map();
const sitesByName = new Map();
for (const site of product.sites || []) {
if (!site || !site.code) continue;
sitesByCode.set(String(site.code).toUpperCase(), site);
if (site.name) sitesByName.set(String(site.name).toUpperCase().trim(), site);
}
/* Branches are indexed by the node they land on, both ends, because a
circuit is a fact about both of its sites. */
const byNode = new Map();
function land(nodeName, entry) {
if (!nodeName) return;
if (!byNode.has(nodeName)) byNode.set(nodeName, []);
byNode.get(nodeName).push(entry);
}
for (const [kind, rows] of [['circuit', product.circuits],
['transformer', product.transformers], ['planned_change', product.planned_changes]]) {
for (const row of rows || []) {
if (!row) continue;
land(row.node_1, { kind, row, near: 'node_1', far: 'node_2' });
land(row.node_2, { kind, row, near: 'node_2', far: 'node_1' });
}
}
function siteOf(nodeName) {
const node = nodes.get(nodeName);
return node ? node.site_code : null;
}
/* The adjacency, handed out rather than rebuilt. Every accessor here is
a READ of the structures at() already uses, so a traversal cannot
disagree with a one-hop view about which nodes exist, which site a
node belongs to, or whether a node's voltage is trustworthy.
planned_change rows are excluded from edges: a change published for
2029 is not a path a current can take today. They remain available
through at(). */
function graph() {
return {
schema: 'gridatlas.module.network-topology.graph.v1',
has: (name) => nodes.has(name),
nodeVoltageKv: (name) => voltageOf(nodes.get(name)),
nodeSiteCode: (name) => {
const node = nodes.get(name);
return node ? node.site_code : null;
},
/* circuits and transformers only — see above */
edgesAt: (name) => (byNode.get(name) || [])
.filter((entry) => entry.kind !== 'planned_change'),
nodesOfSite: (code) => {
const wanted = String(code || '').toUpperCase();
const out = [];
for (const node of nodes.values()) {
if (String(node.site_code || '').toUpperCase() === wanted) out.push(node.node);
}
return out.sort();
},
siteByCode: (code) => sitesByCode.get(String(code || '').toUpperCase()) || null,
ratingsOf,
parametersOf
};
}
function resolve(key) {
if (!key) return null;
const wanted = String(key).toUpperCase().trim();
return sitesByCode.get(wanted) || sitesByName.get(wanted) || null;
}
/**
* Everything published about one site, grouped by the voltage of the
* node each branch lands on. Never a site-wide range.
*
* @param key site code or exact site name
* @param options { voltageKv } to restrict to one voltage
*/
function at(key, options) {
const site = resolve(key);
if (!site) return null;
const wantedKv = options && Number.isFinite(options.voltageKv)
? options.voltageKv : null;
const siteNodes = [];
for (const node of nodes.values()) {
if (node.site_code !== site.code) continue;
const kv = voltageOf(node);
if (wantedKv != null && kv !== wantedKv) continue;
siteNodes.push({ node: node.node, voltage_kv: kv });
}
siteNodes.sort((a, b) => a.node.localeCompare(b.node));
const byVoltage = new Map();
const neighbours = new Map();
for (const entry of siteNodes) {
for (const landing of byNode.get(entry.node) || []) {
const farNode = landing.row[landing.far];
const farSiteCode = siteOf(farNode);
const farSite = farSiteCode ? sitesByCode.get(farSiteCode) : null;
const internal = farSiteCode === site.code;
const key2 = bandKey(entry.voltage_kv);
if (!byVoltage.has(key2)) {
byVoltage.set(key2, { voltage_kv: entry.voltage_kv,
circuits: [], transformers: [], planned_changes: [] });
}
const band = byVoltage.get(key2);
const published = {
from_node: entry.node,
to_node: farNode,
to_site_code: farSiteCode,
to_site_name: farSite ? farSite.name : null,
within_this_site: internal,
transmission_owner: landing.row.transmission_owner || null,
parameters_pct_100mva: parametersOf(landing.row),
ratings_mva: ratingsOf(landing.row)
};
if (landing.kind === 'circuit') {
published.circuit_type = landing.row.circuit_type || null;
if (Number.isFinite(landing.row.ohl_km)) published.ohl_km = landing.row.ohl_km;
if (Number.isFinite(landing.row.cable_km)) published.cable_km = landing.row.cable_km;
band.circuits.push(published);
} else if (landing.kind === 'transformer') {
if (Number.isFinite(landing.row.rating_mva)) published.rating_mva = landing.row.rating_mva;
delete published.ratings_mva;
band.transformers.push(published);
} else {
published.year = landing.row.year || null;
published.status = landing.row.status || null;
published.asset = landing.row.asset || null;
band.planned_changes.push(published);
}
/* A neighbour is another SITE this site's circuits reach. An
internal branch is not a neighbour, and a planned change is
not a neighbour either — it has not been built. */
if (landing.kind === 'circuit' && !internal && farSiteCode) {
if (!neighbours.has(farSiteCode)) {
neighbours.set(farSiteCode, {
site_code: farSiteCode,
site_name: farSite ? farSite.name : null,
circuits: 0
});
}
neighbours.get(farSiteCode).circuits += 1;
}
}
}
const voltages = [...byVoltage.entries()]
.sort((a, b) => {
if (a[0] === UNDECLARED) return 1;
if (b[0] === UNDECLARED) return -1;
return Number(b[0]) - Number(a[0]);
})
.map(([, band]) => band);
return {
schema: 'gridatlas.module.network-topology.v1',
source: ACCEPTS,
site: {
code: site.code,
name: site.name,
transmission_owner: site.transmission_owner || null,
voltages_kv: Array.isArray(site.voltages_kv) ? site.voltages_kv.slice() : []
},
requested_voltage_kv: wantedKv,
nodes: siteNodes,
by_voltage: voltages,
neighbours: [...neighbours.values()].sort((a, b) => b.circuits - a.circuits),
counts: {
nodes: siteNodes.length,
circuits: physicalUnits(voltages.flatMap(band => band.circuits)),
transformers: physicalUnits(voltages.flatMap(band => band.transformers)),
planned_changes: physicalUnits(voltages.flatMap(band => band.planned_changes)),
circuit_landings: voltages.reduce((sum, band) => sum + band.circuits.length, 0),
transformer_landings: voltages.reduce((sum, band) => sum + band.transformers.length, 0),
planned_change_landings: voltages.reduce((sum, band) => sum + band.planned_changes.length, 0),
neighbour_sites: neighbours.size
},
counts_are_units: 'A site holds both ends of a transformer and of any '
+ 'internal circuit, so the same branch lands twice. The counts above '
+ 'are physical units; the landing tallies beside them are what the '
+ 'per-voltage lists contain.',
impedance_basis: IMPEDANCE_BASIS,
not_an_assessment: NOT_AN_ASSESSMENT
};
}
return {
schema: 'gridatlas.module.network-topology.v1',
source: ACCEPTS,
counts: {
sites: sitesByCode.size,
nodes: nodes.size,
branch_landings: byNode.size
},
site: resolve,
at,
graph
};
}
const schema = 'gridatlas.module.network-topology.v1';
return Object.freeze({ACCEPTS,NOT_AN_ASSESSMENT,IMPEDANCE_BASIS,UNDECLARED,ratingsOf,physicalUnits,parametersOf,index,schema});
};
// Family #175933 · element #175933 · 2 places in 2 repositories · https://github.com/Ventusltd/gridatlas/blob/f944f8dcbc09cd09c0895f0126682ec241cd576f/atlas/modules/202611180026-grid-vicinity.js#L147-L204
export const f175933__anonymous_ = () => {
/** Read-only context from existing Atlas source owners. No fetching or electrical inference. */
const ASSET_CONTEXT_CATEGORIES = Object.freeze([
['generation','REPD generation context'],['storage','REPD storage context'],['datacentre','Data-centre listings'],
['conventional','Listed conventional power context'],['demand-context','Other potential demand context']
]);
const assetCoordinate = at => Array.isArray(at)&&at.length>=2&&at.slice(0,2).every(v=>typeof v==='number'&&Number.isFinite(v))&&Math.abs(at[0])<=180&&Math.abs(at[1])<=90&&(at[0]!==0||at[1]!==0);
const statedMw = value => {const v=value&&typeof value==='object'?value.value:value;if(typeof v!=='number'&&typeof v!=='string')return null;if(typeof v==='string'&&!/^\d+(?:\.\d+)?$/.test(v.trim()))return null;const n=Number(v);return Number.isFinite(n)&&n>0?n:null;};
const assetId = value => (typeof value==='string'||typeof value==='number')&&String(value).trim()&&String(value).length<=256?String(value).trim():null;
function assetPrecision(p){for(const [field,value]of[['location.precision',p.location?.precision],['coordinate_precision',p.coordinate_precision],['location_precision',p.location_precision]])if(typeof value==='string'&&value.trim())return{precision:value,precisionField:field,approximateLocation:/approx|centroid|postcode|settlement|area/i.test(value)};return{precision:null,precisionField:null,appro … [line shortened here: 423 characters; full line on GitHub]
function collectAssetContext({map,registry={},origin,radiusKm,geodesy,limit=200}={}){
const at=origin?.at;
if(!assetCoordinate(at)||!Number.isInteger(radiusKm)||radiusKm<1||radiusKm>50)throw Error('Located origin and integer radius 1-50 km are required.');
if(!geodesy?.distanceKm||!geodesy?.representativePoint)throw Error('Canonical Atlas geodesy is required.');
if(!Number.isInteger(limit)||limit<1||limit>200)throw Error('Asset result limit must be 1-200.');
const categories=ASSET_CONTEXT_CATEGORIES.map(([id,label])=>({id,label,availability:'NOT_LOADED',source:null,count:0,loadedRecords:0,truncated:false,rows:[]}));
const get=id=>categories.find(c=>c.id===id),seen=new Map(categories.map(c=>[c.id,new Set()]));
function add(category,row){
const c=get(category);c.loadedRecords++;
if(!assetCoordinate(row.at))return;
// Source IDs deduplicate records; coincident coordinates alone never merge facilities.
const key=row.id===null?null:row.source+'|'+row.id;
if(key!==null){if(seen.get(category).has(key))return;seen.get(category).add(key);}
const km=geodesy.distanceKm(at[0],at[1],row.at[0],row.at[1]);
if(!Number.isFinite(km)||km<0||km>radiusKm)return;
c.rows.push({...row,at:row.at.slice(0,2),km,demandMw:null,facilityVerified:null,connection:null});
}
let features=null;
try{const data=map?.getSource?.('src-repd')?.serialize?.().data;if(data?.type==='FeatureCollection'&&Array.isArray(data.features)&&data.features.length)features=data.features;}catch{/* Explicit NOT_LOADED below; no replacement fetch. */}
if(features){
for(const id of ['generation','storage'])Object.assign(get(id),{availability:'LOADED',source:'Existing loaded src-repd GeoJSON'});
features.forEach((f,i)=>{
const p=f?.properties||{},point=geodesy.representativePoint(f?.geometry),tech=String(p.tech||p.technology||p.technology_type||'Not stated');
const category=/^(?:bess(?:[_ -].*)?|battery(?:[_ -].*)?|storage|flywheel|caes)$/i.test(tech)?'storage':'generation';
const ref=assetId(p.repd_ref??p.ref_id),id=ref??assetId(p.id??f?.id);
add(category,{id,originId:ref&&/^\d+$/.test(ref)?'repd:'+ref:null,name:String(p.name||'Unnamed REPD record'),at:point,kind:category,status:String(p.status||'Not stated'),technology:tech,
capacityMw:statedMw(p.capacity_mw??p.capacity),capacityBasis:typeof p.capacity_basis==='string'?p.capacity_basis:'REGISTER_STATED_POWER_BASIS_NOT_DECLARED',
metrics:{itLoadMw:null,gridConnectionMw:null,unclassifiedMw:null},...assetPrecision(p),source:'src-repd',sourceRow:i});
});
}
const owner=registry.ukOfftakers?.state, data=owner?.data, dots=Array.isArray(data?.dots)?data.dots:null;
if(dots){
for(const id of ['datacentre','conventional','demand-context'])Object.assign(get(id),{availability:'LOADED',source:id==='conventional'?'Loaded potential-offtaker power-station listing; not the full conventional dataset':'Existing loaded off-taker owner records'});
dots.forEach((r,i)=>{
const p=r?.p||{},category=r?.k==='c'?'datacentre':r?.k==='b'?'conventional':['a','d','s','e'].includes(r?.k)?'demand-context':null;if(!category)return;
const id=assetId(p.id??r.id),size=p.size_metric;
const capacity=category==='conventional'?(typeof size?.unit==='string'&&/^MW(?:\b|_)/.test(size.unit)?statedMw(size.value):statedMw(p.mw)):null;
add(category,{id,originId:id,name:String(r.n||p.name||'Unnamed listed site'),at:r.a,kind:category,status:String(p.status||'Not stated'),technology:String(p.technology||p.fuel||r.sub||'Not stated'),
capacityMw:capacity,capacityBasis:capacity===null?null:'SOURCE_STATED_POWER_NOT_CURRENT_OUTPUT',metrics:category==='datacentre'?{itLoadMw:statedMw(p.it_load_mw),gridConnectionMw:statedMw(p.grid_connection_mw),unclassifiedMw:statedMw(p.unclassified_mw)}:{itLoadMw:null,gridConnectionMw:null,unclassifiedMw:null},
...assetPrecision(p),source:category==='datacentre'&&r.dc?'ukOfftakers.data-centre-pipeline':'ukOfftakers.loaded-listing',sourceRow:i});
});
}
for(const c of categories){c.rows.sort((a,b)=>a.km-b.km||a.name.localeCompare(b.name,'en')||String(a.id).localeCompare(String(b.id),'en'));c.count=c.rows.length;c.truncated=c.count>limit;c.rows=c.rows.slice(0,limit);}
return{categories,radiusKm,connectionsInferred:0,limitations:['Loaded source records only; NOT_LOADED is not zero nearby assets.','Register power, IT load and connection figures remain separate; demand and present output are unknown.','A supplied location and source ID do not verify a facility or its connections; source precision is retained.']};
}
return collectAssetContext;
};
// Family #175937 · element #175937 · 2 places in 2 repositories · https://github.com/Ventusltd/gridatlas/blob/f944f8dcbc09cd09c0895f0126682ec241cd576f/atlas/modules/202611180026-grid-vicinity.js#L205-L302
export const f175937__anonymous_ = () => {
/** Existing documentary context only. No fetch, name matching or spatial joins. */
function freezeDocumentContext(value) {
if (value && typeof value === 'object') { for (const child of Object.values(value)) freezeDocumentContext(child); Object.freeze(value); }
return value;
}
const DOCUMENT_CONTEXT_PROVENANCE = freezeDocumentContext({
declaredModule: {
repository: 'Ventusltd/gridatlas', commit: 'b52693aaf513e63240acd8ab99a698df5b738cc6',
path: 'atlas/modules/202609012128-declared-connections.js', bytes: 15461,
sha256: 'a44520ebd644e725f644e7f3aea76839982c82d577022ac04583c5bc3346a371',
sourceUrl: 'https://github.com/Ventusltd/gridatlas/blob/b52693aaf513e63240acd8ab99a698df5b738cc6/atlas/modules/202609012128-declared-connections.js'
},
noticeProducer: {
repository: 'Ventusltd/globalgrid2050', commit: '07bff3a6d1cdc4d845062cafa1cf49161b135c96',
path: 'automation/grid_notice_ui/20261117-v938/notice.json', bytes: 5300,
sha256: 'bef90e1a64e4f1921c62f85ee61d636d1fe02fcebd30ea1570a7b3bfd49f5148',
factsSha256: 'f9802c96444c21e84b328d612475353861c8053cde31f55196d1ea5862918afb',
sourceUrl: 'https://github.com/Ventusltd/globalgrid2050/blob/07bff3a6d1cdc4d845062cafa1cf49161b135c96/automation/grid_notice_ui/20261117-v938/notice.json',
reviewReferences: ['https://github.com/Ventusltd/neural-link-between-agents/issues/42#issuecomment-6953350836', 'https://github.com/Ventusltd/neural-link-between-agents/issues/42#issuecomment-6953404444']
}
});
const DOCUMENT_CONTEXT_NOTICES = freezeDocumentContext([{
id: 'government:EN020026:consented:2026-10-30', title: 'Sea Link development consent',
applicationRef: 'EN020026', status: 'NARROW_FACTS_REVIEWED_NO_ASSET_ASSOCIATION',
sourceUrl: 'https://www.gov.uk/government/publications/sea-link-development-consent-order-planning-act-2008',
sourceTitle: 'Department for Energy Security and Net Zero: Sea Link development consent order',
date: {value: '2026-10-30', precision: 'DAY'},
statement: 'Government decision records development consent for the Suffolk–Kent transmission proposal. Its planned transmission upper bound is 2,000 MW; current capacity, commissioning and available headroom are unknown.',
scope: 'Standalone official planning context. No association with the selected asset or its vicinity has been established.',
plannedMetric: {value: 2000, unit: 'MW', kind: 'planned_transmission_upper_bound'},
currentCapacityMw: null, commissioned: null, connection: null, repdRef: null, coordinates: null,
verifiedAssetJoins: 0,
rightsScope: 'government_html_facts_only_no_images_or_third_party_material',
licenceUrl: 'https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/',
sources: [
{title: 'Planning Inspectorate: Sea Link development consent decision announced', url: 'https://www.gov.uk/government/news/sea-link-development-consent-decision-announced',
publishedDate: {value: '2026-10-30', precision: 'DAY'}, sourceUpdatedAt: null,
archivedReceipt: {retrievedAt: '2026-11-17T15:48:11Z', bytes: 68432, sha256: 'b9ba26b90820292e0b181da7993d2d3a2180fc2de0ac53cc6239adeb4cccfaeb'},
currentObservation: {retrievedAt: '2026-11-18T00:35:01.291330Z', bytes: 68432, sha256: 'b404ca2c91a4b84def5c521ceccab617c4b3bda860d40d2da32fd3e9298f599a', scope: 'Decision day and stated OGL footer reconfirmed; current HTML differs from archived receipt.'}},
{title: 'Department for Energy Security and Net Zero: Sea Link development consent order', url: 'https://www.gov.uk/government/publications/sea-link-development-consent-order-planning-act-2008',
publishedDate: {value: '2026-10-30', precision: 'DAY'}, sourceUpdatedAt: null,
archivedReceipt: {retrievedAt: '2026-11-17T15:48:11Z', bytes: 69536, sha256: 'c26f93aa307740f8b4ec8ad150b152fb6d30e77f201e5bc31a6da52bba16e0d0'},
currentObservation: {retrievedAt: '2026-11-18T00:35:01.437596Z', bytes: 69536, sha256: 'f15b12f35fa4fd1364894d550d3f053dfa680550ad7d83a56fa5b794624e4084', scope: 'Decision day and stated OGL footer reconfirmed; current HTML differs from archived receipt.'}}
]
}]);
function documentOrigin(origin) {
if (!origin || !['repd', 'datacentre', 'substation'].includes(origin.type) || typeof origin.id !== 'string'
|| !origin.id || origin.id.length > 256 || /[\s\u0000-\u001f\u007f]/.test(origin.id)) return null;
return {type: origin.type, id: origin.id};
}
function documentContextFor(origin, {declaredConnections} = {}) {
const identity = documentOrigin(origin), matchedRecords = [];
const limitations = [
'No independently verified asset-to-upgrade or asset-to-notice crosswalk is supplied by this adapter.',
'A published declaration or planning consent does not establish construction, energisation, a surveyed route, electrical connection, power flow or available capacity.',
'The standalone Sea Link notice is not linked to the selected asset, nearby substations or a distance radius.'
];
// Read the canonical already-published owner table; do not fork its records or
// attach works to a nearby/name-matching substation. Its status stays verbatim.
const ref = identity?.type === 'repd' && /^repd:[1-9]\d*$/.test(identity.id) ? identity.id.slice(5) : null;
const canonical = declaredConnections?.schema === 'gridatlas.module.declared-connections.v1' ? declaredConnections.records : null;
const declaration = ref && canonical && Object.hasOwn(canonical, ref) ? canonical[ref] : null;
if (declaration && typeof declaration.source === 'string') {
const statement = [declaration.works, declaration.poc_works, declaration.via].filter(v => typeof v === 'string' && v).join('; ');
if (statement) matchedRecords.push({
id: 'existing-atlas-declaration:' + ref, originId: identity.id,
title: 'Existing published declaration for REPD ' + ref,
sourceUrl: DOCUMENT_CONTEXT_PROVENANCE.declaredModule.sourceUrl, sourceTitle: declaration.source,
statement, status: 'EXISTING_PUBLISHED_DECLARATION_UNREVALIDATED',
scope: 'Existing published declaration; source citation not revalidated here. Exact REPD key only; not an independently verified asset-to-document association.',
matchBasis: 'EXACT_REPD_KEY_IN_CANONICAL_OWNER_MODULE', verifiedAssetAssociation: false,
date: null, datePrecision: 'UNKNOWN',
declaredStatus: declaration.poc_status ?? null,
// Preserve the original owner's fields and classification separately from
// this adapter's review status. Never infer an absent status or date.
declaration: Object.fromEntries(['works', 'poc_works', 'substation', 'circuit', 'via', 'source', 'poc_status', 'poc_status_note', 'poc_kind', 'kv']
.filter(k => Object.hasOwn(declaration, k)).map(k => [k, declaration[k]]))
});
}
if (!identity) limitations.unshift('No supported stable source identity was supplied; names and coordinates were not used to create a match.');
else if (!matchedRecords.length) limitations.unshift('No exact existing documentary declaration is available for this source identity.');
return freezeDocumentContext({
schema: 'gridatlas.vicinity.document-context.v1', origin: identity,
status: matchedRecords.length ? 'EXISTING_DECLARATION_ONLY' : 'NO_EXACT_ASSET_DOCUMENT_CONTEXT',
matchedRecords, unassociatedNotices: DOCUMENT_CONTEXT_NOTICES,
verifiedAssetJoins: 0, realConnectionsInferred: 0,
counts: {existingDeclarations: matchedRecords.length, unassociatedNotices: 1, governmentDocuments: 2, verifiedAssetJoins: 0},
limitations, provenance: DOCUMENT_CONTEXT_PROVENANCE
});
}
return documentContextFor;
};
// Family #177818 · element #177818 · 2 places in 2 repositories · https://github.com/Ventusltd/satnav/blob/ea69138ca5d5a9632233220e5cbe1cd3f1c83432/preview/9698781539e549deaa6ecaa4a2b34610c1f9fd29/nav/place.mjs#L3-L6
export const f177818_coordinate = function coordinate(value,max) {
if(typeof value!=='string'||!value.trim()||!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(value.trim())) throw new Error('invalid coordinate');
const n=Number(value); if(!Number.isFinite(n)||Math.abs(n)>max) throw new Error('coordinate out of range');return n;
};
// Family #177841 · element #177841 · 2 places in 2 repositories · https://github.com/Ventusltd/compass/blob/e200c888acbcc7af59d7cc38b29806e90b0a50db/upstream/tools/satnav/line/route-follower.mjs#L3-L21
export const f177841_createRouteFollower = function createRouteFollower(geometry,maths){
const valid=p=>Array.isArray(p)&&p.length===2&&p.every(Number.isFinite)&&Math.abs(p[0])<=180&&Math.abs(p[1])<=90;
if(geometry?.type!=="LineString"||!Array.isArray(geometry.coordinates)||geometry.coordinates.length<2||geometry.coordinates.length>20000||!geometry.coordinates.every(valid))throw Error("INVALID_LINE");
const {distanceKm,distanceToSegmentKm,initialBearingDeg}=maths;
const coords=geometry.coordinates.map(p=>p.slice()),segments=[];let total=0;
for(let i=0;i<coords.length-1;i++){const a=coords[i],b=coords[i+1],length=distanceKm(...a,...b)*1000;if(!Number.isFinite(length)||length>1000)throw Error("SEGMENT_REQUIRES_DENSIFICATION");if(length>0){segments.push({a,b,length,start:total,index:i});total+=length;}}
if(!segments.length)throw Error("EMPTY_ROUTE");
return function locate(fix,nowMs){
if(!valid([fix?.longitude,fix?.latitude])||!Number.isFinite(fix?.accuracyM)||fix.accuracyM<0||!Number.isFinite(fix?.timestampMs)||!Number.isFinite(nowMs))return {status:"invalid"};
const age=nowMs-fix.timestampMs;if(age<0||age>10000)return {status:"stale"};
if(fix.accuracyM>30)return {status:"uncertain",reason:"GPS_ACCURACY"};
const hits=segments.map(s=>{const h=distanceToSegmentKm(fix.longitude,fix.latitude,...s.a,...s.b);return {s,h,distance:h.km*1000,progress:s.start+h.t*s.length};}).sort((a,b)=>a.distance-b.distance||a.s.index-b.s.index);
const best=hits[0];
if(hits.some(h=>h.distance<=best.distance+Math.max(5,fix.accuracyM)&&Math.abs(h.progress-best.progress)>Math.max(30,2*fix.accuracyM)))return {status:"uncertain",reason:"AMBIGUOUS_ROUTE_POSITION"};
let signedCrossTrackM=null;
if(best.h.t>0&&best.h.t<1){const direction=initialBearingDeg(...best.s.a,...best.s.b),offset=initialBearingDeg(...best.h.foot,fix.longitude,fix.latitude);signedCrossTrackM=best.distance<1e-6?0:Math.sign(Math.sin((offset-direction)*Math.PI/180))*best.distance;}
return {status:"ok",segmentIndex:best.s.index,nearest:best.h.foot,offsetM:best.distance,signedCrossTrackM,progressM:best.progress,remainingM:Math.max(0,total-best.progress),totalM:total,offRoute:best.distance-fix.accuracyM>25,accuracyM:fix.accuracyM,fixAgeMs:age,trackingOnly:true};
};
};
// Family #178079 · element #178079 · 2 places in 2 repositories · https://github.com/Ventusltd/compass/blob/e200c888acbcc7af59d7cc38b29806e90b0a50db/upstream/tools/satnav/line/position-overlay.mjs#L3-L7
export const f178079_point = (role, coordinates) => ({
type: 'Feature',
properties: { role },
geometry: { type: 'Point', coordinates },
});
// Family #135184 · element #135184 · 67 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/releases/003100000000-kuiper-shell/conductor-round.html#L78-L97
export const f135184_settle = function settle(n, d, D, iters) {
const R = D/2 - d/2, m = Math.min(n, Math.floor(Math.PI / Math.asin(d / (2*R)))), w = [];
for (let j = 0; j < m; j++) { const a = 2*Math.PI*j/m; w.push([R*Math.cos(a), R*Math.sin(a)]); }
const Ri = Math.max(0, R - d), k = n - m, N = iters === undefined ? 9000 : iters, soft = N*0.7;
for (let i = 0; i < k; i++) { const r = Ri*Math.sqrt((i + 0.5)/k), a = i*2.399963229728653; w.push([r*Math.cos(a), r*Math.sin(a)]); }
for (let it = 0; it < N; it++) {
const reach = it < soft ? d*(1 + 0.22*(1 - it/soft)) : d; let moved = 0;
for (let i = 0; i < n; i++) for (let j = Math.max(i + 1, m); j < n; j++) {
let dx = w[j][0] - w[i][0], dy = w[j][1] - w[i][1], q = dx*dx + dy*dy;
if (q < reach*reach) { let s = Math.sqrt(q); if (s < 1e-9) { dx = Math.cos(i); dy = Math.sin(i); s = 1; }
const ux = dx/s, uy = dy/s, push = s < d ? d - s : (reach - s)*0.12;
if (i < m) { w[j][0] += ux*push; w[j][1] += uy*push; }
else { w[i][0] -= ux*push/2; w[i][1] -= uy*push/2; w[j][0] += ux*push/2; w[j][1] += uy*push/2; }
if (s < d) moved += push; }
}
for (let i = m; i < n; i++) { const s = Math.hypot(w[i][0], w[i][1]); if (s > R) { w[i][0] *= R/s; w[i][1] *= R/s; } }
if (it >= soft && moved < 1e-7*d) break;
}
return w;
};
// Family #135185 · element #135185 · 67 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/releases/003100000000-kuiper-shell/conductor-round.html#L98-L109
export const f135185_measureBundle = function measureBundle(w, d, D) {
const n = w.length, R = D/2 - d/2; let minGap = Infinity, out = 0, rim = 0;
for (let i = 0; i < n; i++) { const s = Math.hypot(w[i][0], w[i][1]); if (s > R + 1e-6*d) out++; if (s > R - 0.1*d) rim++;
for (let j = i + 1; j < n; j++) minGap = Math.min(minGap, Math.hypot(w[j][0] - w[i][0], w[j][1] - w[i][1])); }
let lo = Infinity, hi = 0;
for (let k = 0; k < 16; k++) { const a = Math.PI*k/16, ux = Math.cos(a), uy = Math.sin(a); let p = -Infinity, q = Infinity;
for (const [x, y] of w) { const t = x*ux + y*uy; p = Math.max(p, t); q = Math.min(q, t); } lo = Math.min(lo, p - q + d); hi = Math.max(hi, p - q + d); }
let bare = 0; const G = 90; // the largest bare patch: the biggest circle that fits between wires, inside the wall
for (let a = 0; a <= G; a++) for (let b = 0; b <= G; b++) { const x = (2*a/G - 1)*D/2, y = (2*b/G - 1)*D/2, s = Math.hypot(x, y); if (s > D/2) continue;
let near = D/2 - s; for (const [u, v] of w) near = Math.min(near, Math.hypot(u - x, v - y) - d/2); bare = Math.max(bare, near); }
return { closest_over_d:+(minGap/d).toFixed(4), outside_wall:out, on_rim:rim, rim_capacity:Math.floor(Math.PI/Math.asin(d/(2*R))), ovality:+((hi - lo)/hi).toFixed(4), widest_mm:+hi.toFixed(3), largest_bare_patch_over_d:+(2*bare/d).toFixed(3) };
};
// Family #135187 · element #135187 · 67 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/releases/003100000000-kuiper-shell/conductor-round.html#L132-L140
export const f135187_compacted = function compacted(c, o){
const a = Math.PI*o.d*o.d/4, f = c.compactFill, q = Math.sqrt(f), cells = []; let r0 = Math.sqrt(a/(Math.PI*f)), area = a;
cells.push({ centre:true, r:o.d/2 });
for (let k = 1; k <= c.layers; k++) { const r1 = Math.sqrt(r0*r0 + 6*k*a/(Math.PI*f)), dr = r1 - r0, rm = (r0 + r1)/2, dth = 2*Math.PI/(6*k);
for (let j = 0; j < 6*k; j++) { const th = dth*j + (k%2 ? 0 : dth/2); cells.push({ ra:rm - dr*q/2, rb:rm + dr*q/2, ta:th - dth*q/2, tb:th + dth*q/2, rm, th });
area += ((rm + dr*q/2)**2 - (rm - dr*q/2)**2)/2 * dth*q; }
r0 = r1; }
return { cells, metalArea:area, outerR:r0 };
};
// Family #135371 · element #135371 · 81 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/kuiper-card.js#L20-L25
export const f135371_gh = function gh(o){
if (!o || !o.owner || !o.repo || !o.commit) return null;
const base = 'https://github.com/' + o.owner + '/' + o.repo;
if (!o.path) return base + '/commit/' + o.commit;
return base + '/blob/' + o.commit + '/' + o.path + (o.line ? '#L' + o.line : '');
};
// Family #135569 · element #135569 · 694 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/kuiper-programs.js#L38-L49
export const f135569_closestPair = function closestPair(pos){
const m = pos.length / 2; if (m < 2) return Infinity;
let x0 = 1e300, x1 = -1e300, y0 = 1e300, y1 = -1e300;
for (let q = 0; q < pos.length; q += 2) { x0 = Math.min(x0, pos[q]); x1 = Math.max(x1, pos[q]); y0 = Math.min(y0, pos[q+1]); y1 = Math.max(y1, pos[q+1]); }
const cell = Math.max(1e-9, Math.sqrt(Math.max(1e-18, (x1 - x0) * (y1 - y0)) / m)), grid = new Map();
let best = Infinity;
for (let j = 0; j < m; j++) { const gx = Math.floor((pos[2*j] - x0) / cell), gy = Math.floor((pos[2*j+1] - y0) / cell);
for (let dx = -1; dx <= 1; dx++) for (let dy = -1; dy <= 1; dy++) { const cellm = grid.get((gx + dx) + ':' + (gy + dy)); if (!cellm) continue;
for (const k of cellm) { const d = Math.hypot(pos[2*j] - pos[2*k], pos[2*j+1] - pos[2*k+1]); if (d < best) best = d; } }
const key = gx + ':' + gy; (grid.get(key) || grid.set(key, []).get(key)).push(j); }
return best;
};
// Family #135242 · element #135242 · 30 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/i0073/releases/003100000000-kuiper-shell/conductor.html#L75-L82
export const f135242_FOOTSRC = function FOOTSRC(c){
const out = [];
if (c.dMaxSrc) out.push(c.dMaxSrc);
if (c.minWiresSrc) out.push(c.minWiresSrc);
if (c.minWiresCompactedSrc) out.push(c.minWiresCompactedSrc);
if (c.RmaxSrc) out.push(c.RmaxSrc + (c.rhoSrc ? ' · ' + c.rhoSrc : '') + (c.DpubSrc ? ' · diameter: ' + c.DpubSrc : ''));
return out.length ? ' · <b>sources</b> · ' + out.join(' · ') : '';
};
// Family #135598 · element #135598 · 22 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/renderer.html#L409-L411
export const f135598__anonymous_ = p => ({ path:p[0], repo:p[1], k0:+p[2], lines:+p[3], file:p[4], commit:p[5],
here:p[6] === 'yes', owner:p[7], unix:+p[8], toolApp:p[9] || '',
page:p[10] ? { address:p[10], title:p[11] || '' } : null });
// Family #135581 · element #135581 · 20 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/assemble.mjs#L38-L42
export const f135581_ease = function ease(u) {
if (!(u > 0)) return 0;
if (u >= 1) return 1;
return u < 0.5 ? 4 * u * u * u : 1 - Math.pow(-2 * u + 2, 3) / 2;
};
// Family #135585 · element #135585 · 20 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/assemble.mjs#L80-L87
export const f135585_ring = function ring(n, { radius = 1 } = {}) {
const t = new Float32Array(n * 2);
for (let j = 0; j < n; j++) {
const th = j / Math.max(1, n) * 2 * Math.PI;
t[2 * j] = radius * Math.cos(th); t[2 * j + 1] = radius * Math.sin(th);
}
return t;
};
// Family #136785 · element #136785 · 642 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/kuiper-programs.js#L2478-L2496
export const f136785_sldPieces = function sldPieces(net){
const P = [], subs = net.site.subs, n = subs.length, kmMax = Math.max(...subs.map(s => s.km));
const line = (tag, d, x0, y0, x1, y1) => P.push({ tag, d, kind:'line', x0, y0, x1, y1, len:Math.hypot(x1 - x0, y1 - y0) });
const ring = (tag, d, cx, cy, r) => P.push({ tag, d, kind:'ring', cx, cy, r, len:2 * Math.PI * r });
ring('grid', 0, 0, 0.88, 0.07);
line('poc', 0.07, 0, 0.80, 0, 0.62); line('poc', 0.25, -0.07, 0.61, 0.07, 0.61);
line('board', 0.27, 0, 0.59, 0, 0.44);
line('bus', 0.45, -0.92, 0.42, 0.92, 0.42); line('bus', 0.45, -0.92, 0.395, 0.92, 0.395);
line('gen', 0.45, -0.62, 0.445, -0.62, 0.57); ring('gen', 0.6, -0.62, 0.65, 0.075);
subs.forEach((s, i) => { const x = n === 1 ? 0 : -0.8 + 1.6 * i / (n - 1), dx = 0.45 + Math.abs(x), L = 0.12 + 0.2 * s.km / kmMax;
const t = 'f' + s.n, yT = 0.37 - L;
line(t, dx, x, 0.37, x, yT);
ring(t, dx + L, x, yT - 0.06, 0.05); ring(t, dx + L + 0.1, x, yT - 0.175, 0.05);
const yL = yT - 0.235; line(t, dx + L + 0.2, x, yL, x, yL - 0.12);
line('load' + s.n, dx + L + 0.32, x - 0.045, yL - 0.13, x, yL - 0.2); line('load' + s.n, dx + L + 0.32, x + 0.045, yL - 0.13, x, yL - 0.2);
if (s.n === net.site.pv_on) { const sx = x + (x > 0.5 ? -0.13 : 0.13); line('pv', dx + L + 0.26, x + Math.sign(sx - x) * 0.015, yL - 0.05, sx - Math.sign(sx - x) * 0.05, yL - 0.05);
ring('pv', dx + L + 0.4, sx, yL - 0.05, 0.045); ring('pv', dx + L + 0.4, sx, yL - 0.05, 0.016); } });
return P;
};
// Family #136789 · element #136789 · 642 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/kuiper-programs.js#L2528-L2537
export const f136789_sldFinal = function sldFinal(net, tag){
const r = net.r, c = net.c, vs = Object.values(r.V), vBad = Math.max(...vs) > c.volts_high_pu || Math.min(...vs) < c.volts_low_pu;
return tag.map(t => {
if (t === 'grid') return 0.95; if (t === 'poc') return net.over ? 2 : 0.95; if (t === 'board') return 0.9; if (t === 'bus') return vBad ? 2 : 0.95;
if (t === 'gen') return net.genOn ? 1 : -1; if (t === 'pv') return net.pvShare > 0 ? 1 : -1;
const k = +t.replace(/\D/g, ''), load = r.tx_loading_pct['lv' + k];
if (load === undefined) return -1; // a disconnected substation
if (t[0] === 'l') return (net.off.includes('pvload') && k === net.site.pv_on) ? -1 : 0.85;
return load > 100 ? 2 : 0.3 + 0.65 * Math.min(1, load / 100); });
};
// Family #136795 · element #136795 · 642 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/kuiper-programs.js#L3698-L3724
export const f136795_netPieces = function netPieces(net){
const P = [], subs = net.subs, n = subs.length, kids = {}; subs.forEach(s => (kids[s.parent] = kids[s.parent] || []).push(s.n));
const col = {}, depth = {}; let c = 0;
(function walk(p, d){ for (const k of (kids[p] || [])) { col[k] = c++; depth[k] = d; walk(k, d + 1); } })(0, 1);
const maxD = Math.max(...Object.values(depth)), dy = Math.min(0.17, 1.05 / maxD), X = k => n === 1 ? 0 : -0.9 + 1.8 * col[k] / (n - 1), Y = k => 0.37 - dy * (depth[k] - 1) - 0.05;
const line = (tag, d, x0, y0, x1, y1) => { const len = Math.hypot(x1 - x0, y1 - y0); if (len > 1e-6) P.push({ tag, d, kind:'line', x0, y0, x1, y1, len }); return d + len; };
const ring = (tag, d, cx, cy, r) => P.push({ tag, d, kind:'ring', cx, cy, r, len:2 * Math.PI * r });
ring('grid', 0, 0, 0.9, 0.06); let d0 = line('poc', 0.06, 0, 0.83, 0, 0.66); line('poc', d0, -0.06, 0.65, 0.06, 0.65); d0 = line('board', d0, 0, 0.63, 0, 0.45);
line('bus', d0, -0.95, 0.43, 0.95, 0.43); line('bus', d0, -0.95, 0.405, 0.95, 0.405);
const teeD = { 0: d0 };
const sym = (tagT, tagL, tagP, d, x, y, s, r) => { // transformer, load and any solar, hanging from (x, y)
let dd = line(tagT, d, x, y - 0.012, x, y - 0.04); ring(tagT, dd, x, y - 0.04 - r, r); ring(tagT, dd + 0.05, x, y - 0.04 - 3 * r - 0.012, r);
const yl = y - 0.04 - 4 * r - 0.024; dd = line(tagT, dd + 0.1, x, yl, x, yl - 0.05);
line(tagL, dd, x - 0.03, yl - 0.06, x, yl - 0.105); line(tagL, dd, x + 0.03, yl - 0.06, x, yl - 0.105);
if (s.pv_kw > 0) { const sx = x + 0.06; line(tagP, dd, x + 0.012, yl - 0.025, sx - 0.03, yl - 0.025); ring(tagP, dd + 0.05, sx, yl - 0.025, 0.026); ring(tagP, dd + 0.05, sx, yl - 0.025, 0.009); }
if (net.generator_at === s.n && net.generator_kw > 0) { const gx = x - 0.06; line('gen', dd, x - 0.012, yl - 0.025, gx + 0.03, yl - 0.025); ring('gen', dd + 0.05, gx, yl - 0.025, 0.028); } };
if (net.generator_at === 0 && net.generator_kw > 0) { line('gen', d0, -0.75, 0.455, -0.75, 0.56); ring('gen', d0 + 0.15, -0.75, 0.62, 0.06); }
const r = Math.min(0.032, 0.6 / n / 2.4 + 0.012);
(function walk(p){ for (const k of (kids[p] || [])) { const s = subs[k - 1], x = X(k), y = Y(k), t = 'hv' + k; let d;
if (p === 0) d = line(t, teeD[0] + Math.abs(x), x, 0.393, x, y);
else { d = line(t, teeD[p], X(p) + 0.012, Y(p), x, Y(p)); d = line(t, d, x, Y(p) - 0.012, x, y); }
teeD[k] = d; sym('tx' + k, 'load' + k, 'pv' + k, d, x, y, s, r); walk(k); } })(0);
let far = 0; for (const p of P) far = Math.max(far, p.kind === 'ring' ? Math.hypot(p.cx, p.cy) + p.r : Math.max(Math.hypot(p.x0, p.y0), Math.hypot(p.x1, p.y1)));
const k = 0.98 / Math.max(0.98, far); // the whole drawing inside the disc
for (const p of P) { if (p.kind === 'ring') { p.cx *= k; p.cy *= k; p.r *= k; } else { p.x0 *= k; p.y0 *= k; p.x1 *= k; p.y1 *= k; } p.len *= k; }
return P;
};
// Family #136900 · element #136900 · 610 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/kuiper-programs.js#L1795-L1808
export const f136900_searchCommands = function searchCommands(commands, text) {
const words = String(text === undefined || text === null ? '' : text).toLowerCase().split(/\s+/).filter(Boolean);
const out = [];
if (!Array.isArray(commands)) return out;
for (let i = 0; i < commands.length && out.length < 200; i++) {
const c = commands[i];
if (!c) continue;
const hay = ((c.family || '') + ' ' + (c.kind || '') + ' ' + (c.name || '') + ' ' + (c.sentence || '')).toLowerCase();
let all = true;
for (let w = 0; w < words.length; w++) if (hay.indexOf(words[w]) < 0) { all = false; break; }
if (all) out.push(c);
}
return out;
};
// Family #136901 · element #136901 · 610 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/kuiper-programs.js#L1879-L1884
export const f136901_fireKey = function fireKey(c){
const r = c && c.row, cmd = String((c && c.command) || '');
if (!r || typeof r !== 'object') return cmd;
const seed = /"seed"\s*:\s*(-?\d+)/.exec(cmd), variant = /"variant"\s*:\s*(\d+)/.exec(cmd);
return [seed ? seed[1] : '?', variant ? variant[1] : '0', r.p_kw, r.vmax_pu, r.vmin_pu, r.worst_tx_pct, r.flags].join('|');
};
// Family #136903 · element #136903 · 610 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/kuiper-programs.js#L1892-L1897
export const f136903_plainName = function plainName(c){
if (c && c.name) return String(c.name);
const s = String((c && c.sentence) || (c && c.command) || '');
const at = s.indexOf(':');
return at > 8 ? s.slice(0, at) : s;
};
// Family #136904 · element #136904 · 610 places in 1 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/kuiper-grid/drawing/kuiper-programs.js#L1901-L1913
export const f136904_curateCommands = function curateCommands(list, want){
const out = [], taken = new Set();
for (const c of list) {
const m = /^A ([a-z-]+(?: network)?) of (\d+)/.exec(String(c.sentence || ''));
const shape = m ? m[1] : (c.family || 'other'), n = m ? +m[2] : 0;
const band = n <= 3 ? 'small' : (n <= 8 ? 'middling' : 'large');
const key = shape + '|' + band + '|' + (c.kind || c.family || '');
if (taken.has(key)) continue;
taken.add(key); out.push(c);
if (out.length >= want) break;