In this section
- Xr transform · globalgrid2050 / solar-design-studio/202609270005-site-world-v3/world/xr.mjs lines 1–109
- Boq Assumptions transform · globalgrid2050 / solar-design-studio/202609270056-site-world-v3/world/boq-assumptions.mjs lines 1–68
- Design Import transform · globalgrid2050 / solar-design-studio/202609270056-site-world-v3/world/design-import.mjs lines 1–239
- Ground Readout render · globalgrid2050 / solar-design-studio/202609270056-site-world-v3/world/ground-readout.mjs lines 1–133
Xr
A JavaScript module in the world folder of GlobalGrid2050 that attaches headset (`attachHeadset`). It attaches headset (`attachHeadset`) and is built from the label step (`label`) and the start step (`start`).
transformglobalgrid2050 / solar-design-studio/202609270005-site-world-v3/world/xr.mjs · lines 1–109 of 109 · version 2026-09-27 00:05 · Not reached from any entry point (candidate for review) · pattern layerFor (shared by 2 files)
- What it does
- It calculates its inputs. Defines 10 functions or classes, including attachHeadset, label, start, run, layerFor.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'design'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- What it achieves
- Headset view: an optional WebXR immersive-vr session for the same line world. It responds to click and end events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- globalgrid2050 · solar-design-studio/202609270005-site-world-v3/world · JavaScript module
- Uses
- Views (import), Xr Pose (import)
- Used by
- none found
- Produces
- attachHeadset
- Defines here
- attachHeadset, label, start, run, layerFor, resize, frame, switchView, xyz, quat
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609270005-site-world-v3/world/xr.mjs:1-109 · blob f76e3cf58c0da4e46ec60ad0e87bf48600e14a5a · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
// Headset view: an optional WebXR immersive-vr session for the same line world. No libraries.
// The button stays hidden unless the browser says it can run an immersive-vr session; a session is only
// ever requested from a click. Nothing here runs, and nothing on the flat screen changes, until then.
// Each eye is drawn with the line renderer as the flat screen is: a rotation-only matrix, and every batch
// moved by (its origin - that eye) in doubles. The pose maths lives in xr-pose.mjs and is tested there.
// Controllers: left stick walks and strafes (Walk 8 m/s, Drone 25 m/s, as views.mjs); right stick flicks
// turn in 30 degree snaps (no smooth turning, which unsettles many people); in Drone, right stick up and
// down climbs and descends; A switches Walk and Drone; left grip held moves slowly and precisely.
import { VIEWS, blocked, setView } from './views.mjs';
import {
enterRig, leaveRig, locomote, turnAbout, snapTurn, readControllers, movementInput, toWorld, eyeMatrix,
chooseFrameRate, headsetBudget, adjustHeadset
} from './xr-pose.mjs';
const MAX_DT = 0.1, NEAR = 0.05, FAR = 5000;
// api: { lines, heightAt, solids(), collect(pos), fade, state(), leave(state) }
// collect(pos) returns the batches the layers draw around a world position.
// leave(state) hands the flat screen the viewer's place when the session ends.
export function attachHeadset(button, api, { xr = globalThis.navigator && navigator.xr } = {}) {
if (!button) return null;
button.hidden = true;
if (!xr || typeof xr.isSessionSupported !== 'function' || typeof XRWebGLLayer === 'undefined') return null;
let session = null;
xr.isSessionSupported('immersive-vr').then(ok => { button.hidden = !ok; }, () => { button.hidden = true; });
button.addEventListener('click', () => {
if (session) { session.end().catch(() => {}); return; }
start().catch(e => { button.title = 'Headset view could not start: ' + e.message; session = null; label(); });
});
const label = () => {
button.textContent = session ? 'Leave headset view' : 'Headset view';
button.setAttribute('aria-pressed', String(!!session));
};
async function start() {
// Requested straight from the click, before any other await, so the user gesture still counts.
const s = await xr.requestSession('immersive-vr', { optionalFeatures: ['local-floor'] });
session = s; label();
const gl = api.lines.context();
try {
if (gl.makeXRCompatible) await gl.makeXRCompatible();
let space, lift = 0;
try { space = await s.requestReferenceSpace('local-floor'); }
catch { space = await s.requestReferenceSpace('local'); lift = VIEWS.standing.eye; } // origin at the head
const rate = chooseFrameRate(s.supportedFrameRates);
if (rate && typeof s.updateTargetFrameRate === 'function') await s.updateTargetFrameRate(rate).catch(() => {});
run(s, gl, space, lift);
} catch (e) { s.end().catch(() => {}); throw e; }
}
function run(s, gl, space, lift) {
let budget = headsetBudget(), scale = 0, rig = null, view = api.state().view, armed = true, toggleHeld = false;
let last = null, head = null, orient = null;
const layerFor = k => new XRWebGLLayer(s, gl, { framebufferScaleFactor: k, antialias: true, depth: true, alpha: false });
const resize = () => { if (scale !== budget.scale) { scale = budget.scale; s.updateRenderState({ baseLayer: layerFor(scale), depthNear: NEAR, depthFar: FAR }); } };
resize();
s.addEventListener('end', () => {
if (rig && head) api.leave(leaveRig(rig, head, orient, view));
session = null; label();
});
function frame(t, f) {
s.requestAnimationFrame(frame);
const pose = f.getViewerPose(space), layer = s.renderState.baseLayer;
if (!pose || !layer) return;
head = xyz(pose.transform.position); orient = quat(pose.transform.orientation);
if (!rig) rig = enterRig(api.state(), head, orient, api.heightAt, lift);
const interval = last === null ? 0 : t - last, dt = Math.min(interval / 1000, MAX_DT);
last = t;
const c = readControllers(s.inputSources);
if (c.toggle && !toggleHeld) view = switchView(view, rig, head, orient);
toggleHeld = c.toggle;
const snap = snapTurn(armed, c.right[0]);
armed = snap.armed;
if (snap.turn) rig = turnAbout(rig, head, snap.turn);
rig = locomote(rig, head, orient, movementInput(c, view), dt, view, api.heightAt, api.solids(), lift);
budget = adjustHeadset(budget, interval, s.frameRate);
const batches = api.collect(toWorld(rig, head));
pose.views.forEach((v, i) => {
const vp = layer.getViewport(v);
if (!vp) return;
api.lines.draw(eyeMatrix(v.projectionMatrix, rig, quat(v.transform.orientation)), toWorld(rig, xyz(v.transform.position)),
api.fade, batches, { framebuffer: layer.framebuffer, viewport: [vp.x, vp.y, vp.width, vp.height], clear: i === 0 });
});
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
resize(); // a new eye-buffer size takes effect from the next frame
}
// Switching keeps the head where it is; like the flat screen, no standing up inside a solid.
function switchView(current, r, h, o) {
const next = current === 'aerial' ? 'standing' : 'aerial';
const here = leaveRig(r, h, o, current), moved = setView(here, next, api.heightAt);
return blocked(moved.pos, VIEWS[next].body, api.solids()) ? current : next;
}
s.requestAnimationFrame(frame);
}
label();
return { active: () => !!session };
}
const xyz = p => [p.x, p.y, p.z];
const quat = q => [q.x, q.y, q.z, q.w];Boq Assumptions
A JavaScript module in the world folder of GlobalGrid2050 that works with cables. It is built from the road build up helper (`roadBuildUp`) and the from road helper (`fromRoad`).
transformglobalgrid2050 / solar-design-studio/202609270056-site-world-v3/world/boq-assumptions.mjs · lines 1–68 of 68 · version 2026-09-27 00:56 · Not reached from any entry point (candidate for review)
- What it does
- It calculates cables. Defines roadBuildUp, fromRoad.
- Why it exists in the grid workflow
- Domain stage hv_procurement (path word 'boq'): HV materials procurement, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: cables.
- Downstream impact
- Used directly by 10 files: Drums (globalgrid2050); Boq (globalgrid2050); Design Earthworks (globalgrid2050); Design Ground (globalgrid2050); and 6 more.
- What it achieves
- The default values the bill of quantities falls back on when a design item does not say.
- Why it matters
- Imported by 10 files, including Drums, Boq and Design Earthworks.
- Application
- globalgrid2050 · solar-design-studio/202609270056-site-world-v3/world · JavaScript module
- Uses
- Road (import)
- Used by
- imported by Drums (import), imported by Boq (import), imported by Design Earthworks (import), imported by Design Ground (import), imported by Design UI (import), imported by Help (import), imported by Drums (import), imported by Design Earthworks (import), and 2 more, mentioned in Standalone (comment link)
- Produces
- DISCLAIMER, BASIS, CABLE_ALLOWANCES, CABLE_DEFAULTS, roadBuildUp, ROAD_BUILD_UPS, FENCE_DEFAULTS, BEDDING_DEFAULTS
- Defines here
- roadBuildUp, fromRoad
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609270056-site-world-v3/world/boq-assumptions.mjs:1-68 · blob c524e0d07abf50a8abbf1f7f1d136a81515c00e5 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: hv_procurement · users: EPC_contractor, procurement_buyer · canonical: unreached_review
// boq-assumptions.mjs: the default values the bill of quantities falls back on
// when a design item does not say. Every value here is an assumption, not a rule
// from a standard; rows built from them carry status 'assumed' and say so.
// Replace any of them by putting the value on the design item itself.
//
// Imports only road.mjs (pure), so the bill's road layers are the build-up the world draws. No DOM.
import { SURFACES } from './road.mjs';
// One line on the page and at the head of every exported bill.
export const DISCLAIMER = 'Estimates for early design. Confirm with the network operator and a qualified engineer.';
// What every ground-derived number rests on. Readouts and bill rows quote these words.
export const BASIS = Object.freeze({
ground: 'EA LIDAR Composite DTM 1 m, ±15 cm',
datum: 'metres above Ordnance Datum Newlyn',
spoil: 'bank volume, no bulking',
});
// Cable allowances: ONE set, used by the bill (boq.mjs) and the drum schedule (drums.mjs).
// Each is an assumed value with its name, unit and basis, not a figure from a standard.
export const CABLE_ALLOWANCES = Object.freeze({
terminationM: Object.freeze({ value: 5, unit: 'm per core per end',
basis: 'Assumed: tail into the switchgear or sealing end plus cut-back for preparation.' }),
snakingPct: Object.freeze({ value: 1, unit: '% of 3D route length',
basis: 'Assumed 1 %: lateral snaking, slack and thermal movement; typical practice is 0.5 to 2 %.' }),
});
export const CABLE_DEFAULTS = {
// Single-core AC cables laid as three per circuit (trefoil or flat).
coresPerCircuit: 3,
// Snaking, sag in the trench and cut-off waste, as a share of laid length (CABLE_ALLOWANCES).
slackPct: CABLE_ALLOWANCES.snakingPct.value,
// Tail per core per end for glanding and termination, metres (CABLE_ALLOWANCES).
terminationM: CABLE_ALLOWANCES.terminationM.value,
};
// Road build-ups, top layer first. Thicknesses in millimetres. 'unbound' and 'bound' are the gravel and
// tarmac build-ups road.mjs draws (assumed typical values there too); 'concrete' has no drawn twin.
// roadBuildUp(layers) turns road.mjs layers ({ name, material, thickness in m }) into bill layers, each
// marked assumed because road.mjs itself says its build-ups are assumed typical values.
export const roadBuildUp = (layers) => layers.map((l, i) => ({
key: /sub-base/.test(l.name) ? 'SUBBASE' : `L${i + 1}`,
material: `${l.name}, ${l.material}`, thicknessMm: Math.round(l.thickness * 1000), assumed: true,
}));
const fromRoad = (surface) => roadBuildUp(SURFACES[surface].layers);
export const ROAD_BUILD_UPS = {
unbound: { label: 'gravel access track', layers: fromRoad('gravel'), geotextile: false },
bound: { label: 'tarmac road', layers: fromRoad('tarmac'), geotextile: false },
concrete: {
label: 'concrete hardstanding',
layers: [
{ key: 'CONC', material: 'concrete slab', thicknessMm: 200 },
{ key: 'SUBBASE', material: 'crushed aggregate sub-base (Type 1 class)', thicknessMm: 150 },
],
geotextile: false,
},
};
export const FENCE_DEFAULTS = {
postSpacingM: 3,
};
// Height of the cable or duct envelope the bedding surrounds, when a trench
// section gives neither a duct diameter nor a phase spacing, millimetres.
export const BEDDING_DEFAULTS = {
envelopeMm: 100,
};Design Import
A JavaScript module in the world folder of GlobalGrid2050 that works with cables and solar.
transformglobalgrid2050 / solar-design-studio/202609270056-site-world-v3/world/design-import.mjs · lines 1–239 of 239 · version 2026-09-27 00:56 · Not reached from any entry point (candidate for review) · pattern intervalsAt (shared by 2 files)
- What it does
- It calculates cables and solar. Defines 14 functions or classes, including num, deg, frame, box, closed.
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'design'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: cables, solar, 33kV.
- Inputs & outputs
- Coordinate systems named: WGS84 / EPSG:4326. Voltage levels named: 33kV.
- What it achieves
- It imports design (`importDesign`) and is built from the num step (`num`) and the deg step (`deg`). Turns the GIS, single-line diagram (SLD) & Financial Sandbox GeoJSON export (WGS84 lon/lat) into local-metre geometry for the world viewer.
- Why it matters
- No other file in the estate was found to import it.
- Application
- globalgrid2050 · solar-design-studio/202609270056-site-world-v3/world · JavaScript module
- Uses
- none found
- Used by
- mentioned in Standalone (comment link)
- Produces
- MAX_TABLES, importDesign
- Defines here
- num, deg, frame, box, closed, intervalsAt, intersect, pack, mountingFor, ringsOf, conv, polyLength, importDesign, blocked
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609270056-site-world-v3/world/design-import.mjs:1-239 · blob 857cb19cdd5527d3141982b21d7b9774e132e792 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
// design-import.mjs: turns the GIS, SLD & Financial Sandbox GeoJSON export
// (WGS84 lon/lat) into local-metre geometry for the world viewer.
// Pure: no imports, no DOM. The caller supplies toLocal(lon, lat) -> [x, y]
// (x east, y north, metres). Heights are relative to ground; the caller drapes.
export const MAX_TABLES = 20000;
// Equipment boxes: length along the array axis, width across, height (m).
const EQUIPMENT = {
string_substation: { len: 6.1, wid: 2.5, h: 3.0, kind: 'skid' },
central_inverter: { len: 12.2, wid: 2.5, h: 3.0, kind: 'inverter' },
private_sub: { len: 40, wid: 30, h: 4.0, kind: 'transformer_compound' }
};
const BESS_UNIT = { len: 12.2, wid: 2.5, h: 2.9, gapAlong: 1.5, aisle: 3.5 };
const TABLE_TOP = 2.6, TABLE_UNDER = 0.8, TABLE_GAP = 0.5, EDGE_MARGIN = 2, KEEP_OUT = 4;
const POLY_TYPES = new Set(['array_boundary', 'skid_footprint', 'central_footprint', 'bess_footprint']);
const POINT_TYPES = new Set(['string_substation', 'central_inverter', 'bess_compound', 'poi', 'private_sub', 'export_cable_pin']);
const LINE_TYPES = new Set(['export_cable', '33kv_radial', '33kv_projection_only']);
const num = (v, d) => (Number.isFinite(Number(v)) && v !== null && v !== '' ? Number(v) : d);
const deg = r => r * Math.PI / 180;
// Row frame: bearing b (deg clockwise from north). r = along rows, n = across.
function frame(bearingDeg) {
const b = deg(bearingDeg);
const r = [Math.sin(b), Math.cos(b)];
const n = [Math.cos(b), -Math.sin(b)];
return {
r, n, bearingDeg,
toUV: p => [p[0] * r[0] + p[1] * r[1], p[0] * n[0] + p[1] * n[1]],
toXY: (u, v) => [u * r[0] + v * n[0], u * r[1] + v * n[1]],
yaw: Math.atan2(r[1], r[0])
};
}
// Oriented box -> solid with AABB min/max plus the true footprint quad.
function box(f, cu, cv, len, wid, z0, z1, extra) {
const hl = len / 2, hw = wid / 2;
const quad = [[cu - hl, cv - hw], [cu + hl, cv - hw], [cu + hl, cv + hw], [cu - hl, cv + hw]].map(([u, v]) => f.toXY(u, v));
const xs = quad.map(q => q[0]), ys = quad.map(q => q[1]);
return {
min: [Math.min(...xs), Math.min(...ys), z0], max: [Math.max(...xs), Math.max(...ys), z1],
center: f.toXY(cu, cv), size: [len, wid, z1 - z0], yaw: f.yaw, quad, ...extra
};
}
const closed = quad => [...quad, quad[0]];
// Even-odd crossings of all rings with the line v = const, as sorted intervals.
function intervalsAt(ringsUV, v) {
const xs = [];
for (const ring of ringsUV) {
for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
const [u1, v1] = ring[j], [u2, v2] = ring[i];
if ((v1 <= v && v < v2) || (v2 <= v && v < v1)) xs.push(u1 + (v - v1) * (u2 - u1) / (v2 - v1));
}
}
xs.sort((a, b) => a - b);
const out = [];
for (let i = 0; i + 1 < xs.length; i += 2) out.push([xs[i], xs[i + 1]]);
return out;
}
function intersect(a, b) {
const out = [];
for (const [a0, a1] of a) for (const [b0, b1] of b) {
const lo = Math.max(a0, b0), hi = Math.min(a1, b1);
if (hi > lo) out.push([lo, hi]);
}
return out;
}
// Pack oriented rectangles (len along rows, depth across, pitch between rows)
// inside the rings. onSlot(cu, cv) returns false to stop placing (count only).
function pack(ringsLocal, f, len, depth, pitch, gap, margin, onSlot) {
const rings = ringsLocal.map(r => r.map(f.toUV));
let vMin = Infinity, vMax = -Infinity;
for (const r of rings) for (const p of r) { vMin = Math.min(vMin, p[1]); vMax = Math.max(vMax, p[1]); }
let slots = 0, rows = 0;
for (let v0 = vMin + margin; v0 + depth <= vMax - margin + 1e-9; v0 += pitch) {
const v1 = v0 + depth, vm = (v0 + v1) / 2;
let iv = intersect(intersect(intervalsAt(rings, v0 + 1e-6), intervalsAt(rings, v1 - 1e-6)), intervalsAt(rings, vm));
iv = intersect(iv, intersect(intervalsAt(rings, v0 - margin), intervalsAt(rings, v1 + margin)));
let rowUsed = false;
for (const [lo, hi] of iv) {
const a = lo + margin, b = hi - margin;
const n = Math.floor((b - a + gap) / (len + gap));
if (n < 1) continue;
const start = a + ((b - a) - (n * len + (n - 1) * gap)) / 2;
for (let k = 0; k < n; k++) {
if (onSlot(start + k * (len + gap) + len / 2, vm)) { slots++; rowUsed = true; }
}
}
if (rowUsed) rows++;
}
return { slots, rows };
}
function mountingFor(gcr) {
if (Math.abs(gcr - 0.75) < 0.05 || gcr > 0.7) return 'east_west_dome';
if (gcr <= 0.4) return 'tracker';
return 'fixed_tilt';
}
function ringsOf(geom, toLocal) {
const conv = ring => {
const pts = ring.map(c => toLocal(c[0], c[1]));
if (pts.length > 1) {
const a = pts[0], b = pts[pts.length - 1];
if (a[0] === b[0] && a[1] === b[1]) pts.pop();
}
return pts;
};
if (geom.type === 'Polygon') return [geom.coordinates.map(conv)];
if (geom.type === 'MultiPolygon') return geom.coordinates.map(p => p.map(conv));
return [];
}
function polyLength(pts) {
let s = 0;
for (let i = 1; i < pts.length; i++) s += Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][1] - pts[i - 1][1]);
return s;
}
export function importDesign(geojson, toLocal) {
if (!geojson || geojson.type !== 'FeatureCollection' || !Array.isArray(geojson.features)) throw new Error('importDesign: expected a GeoJSON FeatureCollection');
if (typeof toLocal !== 'function') throw new Error('importDesign: toLocal(lon, lat) is required');
const feats = geojson.features.filter(f => f && f.geometry && f.properties && typeof f.properties.type === 'string');
const skipped = geojson.features.length - feats.length;
const boundaries = feats.filter(f => f.properties.type === 'array_boundary');
const bp = boundaries[0]?.properties || {};
// Array axis: sandbox writes array_rotation_deg on private_sub / export_cable.
const axisFeat = feats.find(f => Number.isFinite(Number(f.properties.array_rotation_deg)) && f.properties.array_rotation_deg !== null);
const axisDeg = num(bp.array_rotation_deg, axisFeat ? Number(axisFeat.properties.array_rotation_deg) : 0);
const gcr = Math.min(0.95, Math.max(0.1, num(bp.tech_ground_coverage_ratio, 0.45) || 0.45));
const mounting = bp.tech_mounting || mountingFor(gcr);
const modL = num(bp.tech_module_length_m, 2.38) || 2.38;
const modW = num(bp.tech_module_width_m, 1.30) || 1.30;
const modWp = num(bp.tech_module_rating_wp, 0);
const perString = Math.max(1, Math.round(num(bp.tech_modules_per_string, 28)));
// Rows east-west (bearing axis+90) for fixed tilt; trackers and east-west
// domes run rows north-south along the axis. Explicit override wins.
const rowBearing = num(bp.row_azimuth_deg, num(bp.tech_row_azimuth_deg,
mounting === 'fixed_tilt' ? axisDeg + 90 : axisDeg));
const fRow = frame(rowBearing), fAxis = frame(axisDeg + 90); // equipment long side across the axis
const portrait = mounting === 'tracker' ? 1 : 2;
const slant = portrait * modL;
const rise = TABLE_TOP - TABLE_UNDER;
const depth = mounting === 'tracker' ? slant : Math.sqrt(Math.max(slant * slant - rise * rise, slant * slant * 0.25));
const pitch = Math.max(depth + 0.5, slant / gcr);
const tableLen = Math.min(60, Math.max(5, perString * (modW + 0.02)));
const modsPerTable = portrait * Math.max(1, Math.floor(tableLen / (modW + 0.02)));
const outlines = [], points = [], cables = [], solids = [];
const unknownTypes = {}, counts = {};
const blocks = [], bessAreas = [], keepOut = [];
for (const f of feats) {
const t = f.properties.type, g = f.geometry;
counts[t] = (counts[t] || 0) + 1;
if (POLY_TYPES.has(t) && (g.type === 'Polygon' || g.type === 'MultiPolygon')) {
for (const rings of ringsOf(g, toLocal)) {
rings.forEach((ring, i) => outlines.push({ type: t === 'array_boundary' ? t : (t === 'bess_footprint' ? t : 'block'), sourceType: t, hole: i > 0, points: closed(ring) }));
if (t === 'skid_footprint' || t === 'central_footprint') blocks.push(rings);
if (t === 'bess_footprint') bessAreas.push(rings);
}
} else if (POINT_TYPES.has(t) && g.type === 'Point') {
const [x, y] = toLocal(g.coordinates[0], g.coordinates[1]);
const p = { type: t, x, y, props: { ...f.properties } };
points.push(p);
const eq = EQUIPMENT[t];
if (eq) {
const [cu, cv] = fAxis.toUV([x, y]);
const s = box(fAxis, cu, cv, eq.len, eq.wid, 0, eq.h, { type: eq.kind, sourceType: t });
solids.push(s);
outlines.push({ type: eq.kind, sourceType: t, points: closed(s.quad) });
keepOut.push({ x, y, r: Math.hypot(eq.len, eq.wid) / 2 + KEEP_OUT });
}
} else if (LINE_TYPES.has(t) && (g.type === 'LineString' || g.type === 'MultiLineString')) {
const parts = g.type === 'LineString' ? [g.coordinates] : g.coordinates;
for (const part of parts) {
const pts = part.map(c => toLocal(c[0], c[1]));
cables.push({ type: t, role: f.properties.role || (t === 'export_cable' ? 'export' : 'radial'), points: pts, lengthM: polyLength(pts), props: { ...f.properties } });
}
} else {
unknownTypes[t + ':' + g.type] = (unknownTypes[t + ':' + g.type] || 0) + 1;
}
}
// BESS containers packed into each bess_footprint (bounded by area).
let bessUnits = 0;
for (const rings of bessAreas) {
pack(rings, fAxis, BESS_UNIT.len, BESS_UNIT.wid, BESS_UNIT.wid + BESS_UNIT.aisle, BESS_UNIT.gapAlong, 3, (cu, cv) => {
if (bessUnits >= 2000) return false;
solids.push(box(fAxis, cu, cv, BESS_UNIT.len, BESS_UNIT.wid, 0, BESS_UNIT.h, { type: 'bess_container', sourceType: 'bess_footprint' }));
bessUnits++;
return true;
});
}
// Solar tables: inside block footprints when present (they tile the net
// array area), otherwise inside each array_boundary.
const regions = blocks.length ? blocks : boundaries.flatMap(b => ringsOf(b.geometry, toLocal));
const tables = { solids: [], outlines: [], count: 0, requested: 0, capped: false, rows: 0, cap: MAX_TABLES,
region: blocks.length ? 'block_footprints' : 'array_boundary', mounting, rowBearingDeg: ((rowBearing % 360) + 360) % 360,
tableLengthM: tableLen, tableDepthM: depth, pitchM: pitch, modulesPerTable: modsPerTable, heightTop: TABLE_TOP, heightUnder: TABLE_UNDER };
const blocked = (cu, cv) => {
const [x, y] = fRow.toXY(cu, cv);
const half = Math.hypot(tableLen, depth) / 2;
return keepOut.some(k => Math.hypot(k.x - x, k.y - y) < k.r + half);
};
for (const rings of regions) {
const res = pack(rings, fRow, tableLen, depth, pitch, TABLE_GAP, blocks.length ? 0.5 : EDGE_MARGIN, (cu, cv) => {
if (blocked(cu, cv)) return false;
tables.requested++;
if (tables.count >= MAX_TABLES) { tables.capped = true; return true; }
const s = box(fRow, cu, cv, tableLen, depth, TABLE_UNDER, TABLE_TOP, { type: 'solar_table' });
tables.solids.push(s);
tables.outlines.push({ type: 'solar_table', points: closed(s.quad) });
tables.count++;
return true;
});
tables.rows += res.rows;
}
const cableLen = {};
for (const c of cables) cableLen[c.role] = (cableLen[c.role] || 0) + c.lengthM;
const modulesPlaced = tables.count * modsPerTable;
const stats = {
features: geojson.features.length, skippedFeatures: skipped, counts, unknownTypes,
axisDeg, gcr, mounting, module: { lengthM: modL, widthM: modW, wp: modWp },
moduleCountDeclared: num(bp.tech_module_count, null), modulesPlaced,
dcMWpDeclared: num(bp.tech_dc_capacity_mwp, null), acMWDeclared: num(bp.tech_ac_capacity_mwac, null),
dcMWpPlaced: modWp ? modulesPlaced * modWp / 1e6 : null,
bessMWh: num(bp.fin_bess_mwh, num(bp.fin_string_bess_mwh, points.find(p => p.type === 'bess_compound')?.props.mwh ?? null)),
bessContainers: bessUnits, tables: tables.count, tablesRequested: tables.requested, tablesCapped: tables.capped,
cableLengthM: cableLen, equipmentSolids: solids.length
};
return { outlines, points, cables, solids, tables, stats };
}Ground Readout
A JavaScript module in the world folder of GlobalGrid2050 that joins names (`joinNames`) and routes rows (`routeRows`). It joins names (`joinNames`) and routes rows (`routeRows`).
renderglobalgrid2050 / solar-design-studio/202609270056-site-world-v3/world/ground-readout.mjs · lines 1–133 of 133 · version 2026-09-27 00:56 · Not reached from any entry point (candidate for review)
- What it does
- It draws its content. Defines 11 functions or classes, including srcName, joinNames, underfootText, mayLink, lengths. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'design'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- What it achieves
- Words for what the ground layer (`layers/ground.mjs`) finds under the walker and along a finished trench or cable route.
- Why it matters
- No other file in the estate was found to import it.
- Application
- globalgrid2050 · solar-design-studio/202609270056-site-world-v3/world · JavaScript module
- Uses
- Measure Format (import)
- Used by
- mentioned in Standalone (comment link)
- Produces
- DESKTOP, NO_THERMAL, underfootText, mayLink, thermalText, routeRows, mountGroundReadout
- Defines here
- srcName, joinNames, underfootText, mayLink, lengths, thermalText, routeRows, listed, mountGroundReadout, el, update
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609270056-site-world-v3/world/ground-readout.mjs:1-133 · blob b4aeb4151908960c841ad5c944f6402f1205a734 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: unreached_review
// Ground readout: words for what the ground layer (layers/ground.mjs) finds under the walker and along a finished
// trench or cable route. Pure functions build the text; mountGroundReadout writes it into the page. Nothing here
// is measured on site: every route readout ends with the desktop-study line. Thermal values are shown only where
// the file carries a sourced record with its status (measured, modelled, scenario/assumed); a thermal value is
// never inferred from a soil or rock type, and where there is none the readout says so.
import { formatLength, formatNumber } from './measure-format.mjs';
export const DESKTOP = 'Desktop study only — not a substitute for ground investigation';
export const NO_THERMAL = 'no sourced value here; not inferred from soil or rock type';
const STATUSES = ['measured', 'modelled', 'scenario', 'assumed'];
const srcName = (sources, key) => {
const s = sources?.[key];
return (s && (s.title || s.name || s.id)) || '';
};
const joinNames = items => [...new Set(items.map(a => a.label))].join(' / ');
// "Under your feet: <superficial> over <bedrock>" and its source. u: layer.underfoot(e, n) or null.
export function underfootText(u) {
if (!u) return '';
const sup = u.superficial == null ? 'superficial deposits not in this file'
: u.superficial.length ? joinNames(u.superficial) : 'no superficial deposit mapped at this scale';
const bed = u.bedrock == null ? 'bedrock not in this file' : u.bedrock.length ? joinNames(u.bedrock) : 'bedrock not mapped here';
const names = [...new Set([u.superficial?.length ? srcName(u.sources, 'superficial') : '', srcName(u.sources, 'bedrock')].filter(Boolean))];
return `Under your feet: ${sup} over ${bed}${names.length ? ` · ${names.join('; ')}` : ''}`;
}
// A borehole log may be linked only over https and when its source allows it: allow_links: true, or scans marked
// link_only (free to view from BGS; linked, never copied), or, when the source says nothing, a BGS page.
export function mayLink(source, url) {
if (typeof url !== 'string') return false;
let u;
try { u = new URL(url); } catch { return false; }
if (u.protocol !== 'https:' || source?.allow_links === false) return false;
return source?.allow_links === true || source?.scans?.link_only === true || /(^|\.)bgs\.ac\.uk$/i.test(u.hostname);
}
const lengths = list => list.map(c => `${c.label} ${formatLength(c.length, 0)}`).join(' · ');
// Thermal lines from sourced records only. Conductivity W/(m K); resistivity is its reciprocal, K m/W.
export function thermalText(records) {
if (!records || !records.length) return NO_THERMAL;
const out = [];
for (const t of records) {
const status = String(t.status || '').toLowerCase();
if (!STATUSES.includes(status) || !t.source) continue; // no status or no source: not shown
const k = Number(t.conductivity);
if (!(k > 0) || t.conductivity_unit !== 'W/(m K)') continue;
const depth = Number.isFinite(t.conditions?.depth_top) && Number.isFinite(t.conditions?.depth_bottom)
? ` at ${formatNumber(t.conditions.depth_top, 2)}–${formatNumber(t.conditions.depth_bottom, 2)} m` : ' (depth not stated)';
out.push(`${formatNumber(k, 2)} W/(m K), ρ ${formatNumber(1 / k, 2)} K m/W, ${status}${depth} · ${t.source}`);
}
return out.length ? out.join('; ') : NO_THERMAL;
}
// Rows [[label, text, links?]] for a finished route. r: layer.alongRoute(path) or null.
export function routeRows(r) {
if (!r) return [];
const rows = [];
const listed = (label, list, key, none) => {
if (list == null) rows.push([label, `${key} not in this file`]);
else rows.push([label, list.length ? lengths(list) : none]);
};
listed('Superficial crossed', r.superficial, 'superficial deposits', 'none mapped at this scale');
listed('Bedrock crossed', r.bedrock, 'bedrock', 'none mapped');
if (r.boreholes == null) rows.push([`Boreholes within ${r.near} m`, 'borehole index not in this file']);
else {
const src = r.sources?.boreholes, links = [];
for (const b of r.boreholes.slice(0, 8)) {
const len = Number.isFinite(b.drilled_length_m) ? `, ${formatNumber(b.drilled_length_m, 1)} m drilled` : '';
// Borehole names often name a house or a school: only the reference, distance and depth are shown (publish review B2).
links.push({ text: `${b.id || 'borehole'} (${formatLength(b.distance, 0)} away${len})`, href: mayLink(src, b.log_url) ? b.log_url : '' });
}
const more = r.boreholes.length > 8 ? ` +${r.boreholes.length - 8} more` : '';
rows.push([`Boreholes within ${r.near} m`, r.boreholes.length ? `${r.boreholes.length}${more}` : 'none in the index', links]);
}
const flags = [];
if (r.mining == null) flags.push('mining areas not in this file');
else if (r.mining.length) flags.push(`crosses ${lengths(r.mining)}`);
if (r.mine_entries == null) flags.push('mine entries not in this file');
else if (r.mine_entries.length) {
const n = r.mine_entries.length, first = r.mine_entries[0], type = first.type ? `, ${first.type}` : '';
flags.push(`${n} mine entr${n === 1 ? 'y' : 'ies'} within ${r.near} m (nearest ${formatLength(first.distance, 0)}${type})`);
}
if (r.mining && !r.mining.length) flags.unshift('none mapped along the route (absence is not proof of no mining)');
rows.push(['Mining', flags.join(' · '), null, !!(r.mining?.length || r.mine_entries?.length)]);
rows.push(['Aquifer', r.aquifers == null ? 'aquifer designation not in this file' : r.aquifers.length ? lengths(r.aquifers) : 'none mapped']);
if (r.spz == null) rows.push(['Source protection', 'source protection zones not in this file']);
else rows.push(['Source protection', r.spz.length ? lengths(r.spz) : 'none along the route', null, r.spz.length > 0]);
rows.push(['Thermal resistivity', thermalText(r.thermal)]);
const used = ['superficial', 'bedrock', 'boreholes', 'mining', 'spz'].map(k => srcName(r.sources, k)).filter(Boolean);
if (used.length) rows.push(['Sources', [...new Set(used)].join('; ')]);
rows.push(['Note', DESKTOP]);
return rows;
}
// Page wiring. deps: { doc, layer() -> the ground layer or null, on() -> bool, where: element for the walking line,
// box: element in the Design panel, finished() -> { key, path: [[e, n], ...] } | null, here() -> { e, n }, walking() }.
export function mountGroundReadout({ doc, layer, on, feet, box, finished, here, walking }) {
let lastRoute = null, lastFeet = '';
const el = (tag, cls, t) => { const e = doc.createElement(tag); if (cls) e.className = cls; if (t != null) e.textContent = t; return e; };
function update() {
const g = on() ? layer() : null, ready = !!(g && g.ready?.());
let line = '';
if (ready && walking()) { const p = here(); line = underfootText(g.underfoot(p.e, p.n)); }
if (line !== lastFeet) { feet.textContent = line; feet.hidden = !line; lastFeet = line; }
const f = ready ? finished() : null, key = f ? `${f.key}` : '';
if (key === lastRoute) return;
lastRoute = key;
box.replaceChildren();
box.hidden = !f;
if (!f) return;
box.appendChild(el('h3', null, 'Ground along the last finished route'));
const dl = el('dl');
for (const [k, v, links, warn] of routeRows(g.alongRoute(f.path))) {
const dd = el('dd', warn ? 'warn' : null, v);
if (links?.length) {
const ul = el('ul');
for (const l of links) {
const li = el('li');
if (l.href) { const a = el('a', null, l.text); a.href = l.href; a.target = '_blank'; a.rel = 'noopener'; li.appendChild(a); }
else li.textContent = l.text;
ul.appendChild(li);
}
dd.appendChild(ul);
}
dl.append(el('dt', null, k), dd);
}
box.appendChild(dl);
}
return { update, reset() { lastRoute = null; lastFeet = null; } };
}