GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Solar and storage design / globalgrid2050 / solar-design-studio/202609270330-site-world-v3/world

Solar Design Studio — Site World V3 Page and 1 more file

A web page in GlobalGrid2050 that draws bill of quantities, cables, substations and postcodes. Published at https://globalgrid2050.com/solar-design-studio/202609270402-site-world-v3/.

666 lines of HTML and JavaScript from globalgrid2050, in 2 files. Topic: Solar and storage design. Section 149 of 2044.

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

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

In this section

  1. Road transform · globalgrid2050 / solar-design-studio/202609270330-site-world-v3/world/road.mjs lines 1–311
  2. Solar Design Studio — Site World V3 Page render · globalgrid2050 / solar-design-studio/202609270402-site-world-v3/index.html lines 1–355

Road

A JavaScript module in the world folder of GlobalGrid2050 that works with A roads, using BS EN 13108-1.

transformglobalgrid2050 / solar-design-studio/202609270330-site-world-v3/world/road.mjs · lines 1–311 of 311 · version 2026-09-27 03:30 · Not reached from any entry point (candidate for review) · pattern designLevel (shared by 2 files)

What it does
It calculates A roads. Defines 20 functions or classes, including createRoad, pointAt, segAt, zAt, level.
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: A roads.
Downstream impact
Used directly by 3 files: Boq Assumptions (globalgrid2050); Design Earthworks (globalgrid2050); Design Earthworks (globalgrid2050).
What it achieves
It is built from the point at helper (`pointAt`), the seg at helper (`segAt`) and the z at helper (`zAt`). An access road as a function over the ground, never a stored mesh (the sibling of `trench.mjs`).
Why it matters
Imported by Boq Assumptions and Design Earthworks.
Application
globalgrid2050 · solar-design-studio/202609270330-site-world-v3/world · JavaScript module
Uses
Earthworks (import)
Used by
imported by Boq Assumptions (import), imported by Design Earthworks (import), imported by Design Earthworks (import), mentioned in Standalone (comment link)
Produces
SURFACES, DEFAULTS, createRoad, composeRoadGround
Defines here
createRoad, pointAt, segAt, zAt, level, designLevel, gradeAt, fallAt, finishedAt, edgeOfLimit, locate, inBox, batter, roadHeight, earthworksOf, earthworksAt, onRoad, earthworksOn, jitter, composeRoadGround
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/202609270330-site-world-v3/world/road.mjs:1-311 · blob 01be5fded03eb46c07f2c845274735c54f04b6a5 · 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
// road.mjs: an access road as a function over the ground, never a stored mesh (the sibling of trench.mjs).
//
// Local metres: x east, y north, z up. The ground is any function groundAt(x, y).
// A road is a centreline in plan, a carriageway width, a surface build-up and a crossfall. Its design
// level follows the ground along the centreline, smoothed: grade points (PVIs) sit at equal spacing,
// each at the mean ground level over its spacing (the two ends tie in to the ground), joined by straight
// grades with a symmetric parabolic vertical curve at every interior grade point. A designer may give
// the grade points instead (profile: [[chainage, level], ...]).
// Across the road the finished surface falls from the centreline by the crossfall (a crown) or falls
// one way. The earthworks surface is the formation (finished level less the build-up) under the
// carriageway, and a side slope (batter) from each finished edge until it meets the ground: down at
// 1 in fillSlope where the road stands above the ground, up at 1 in cutSlope where it sits below.
// Lines for drawing (edges, batters, steep runs) are in road-lines.mjs.
// Offsets are measured to the nearest point of the centreline, so the outside of a bend is rounded.
// Ends are square; the ends tie in to the ground, so there is no step there.
//
// Sources and assumed values (assumed = typical, to be confirmed by the designer for a real scheme):
// - Crossfall 2.5 % from the centre of a single carriageway: DMRB CD 109 (Highway link design).
// - Crossfall 4 % on an unbound (gravel) surface: ASSUMED, steeper than CD 109 to shed water off stone.
// - Maximum gradient 1 in 10 (10 %): ASSUMED design limit for heavy delivery vehicles. NatureScot,
//   "Constructed tracks in the Scottish Uplands" (2015), gives 8 % to 10 % for tracks used by heavy
//   vehicles; Approved Document B allows 1 in 4 only for fire appliance access, far too steep here.
// - Layer build-ups below: ASSUMED typical light-duty values. Mix names follow BS EN 13108-1 / PD 6691;
//   Type 1 unbound mixture is the Specification for Highway Works, Series 800, clause 803.
// - Side slopes 1 in 2 for both fill and cut: ASSUMED for firm soils, no geotechnical data held; the same
//   value the pad cartridge assumes, so a road and a pad meet on one batter.
// - Grade-point spacing 20 m and vertical curve length 20 m: ASSUMED; they set how closely the road hugs
//   the ground. Neither is a design speed check.
//
// No DOM. Pure functions of their inputs. Batters, the daylight search, the volume integration and the ground with
// roads in it come from the shared earthworks engine (lib/earthworks.mjs), which the trench and pad cartridges use too.

import { inv, batterZ, composeGround as compose } from './lib/earthworks.mjs';

export const SURFACES = Object.freeze({
  tarmac: Object.freeze({
    crossfall: 0.025,
    layers: Object.freeze([
      Object.freeze({ name: 'surface course', material: 'AC 10 close surf', thickness: 0.04 }),
      Object.freeze({ name: 'binder course', material: 'AC 20 dense bin', thickness: 0.06 }),
      Object.freeze({ name: 'sub-base', material: 'Type 1 unbound mixture', thickness: 0.15 }),
    ]),
  }),
  gravel: Object.freeze({
    crossfall: 0.04,
    layers: Object.freeze([
      Object.freeze({ name: 'wearing course', material: 'crushed rock 0/32 (to dust)', thickness: 0.1 }),
      Object.freeze({ name: 'sub-base', material: 'Type 1 unbound mixture', thickness: 0.25 }),
    ]),
  }),
});
export const DEFAULTS = Object.freeze({
  width: 4, surface: 'gravel', fall: 'crown', maxGradient: 0.1, spacing: 20, curveLength: 20,
  fillSlope: 2, cutSlope: 2, step: 1, cell: 0.25,
});
const EPS = 1e-9;
const MAX_REACH = 80; // metres beyond the edge a batter may run before it is reported as not meeting the ground

/**
 * createRoad({ path, groundAt, width, surface, crossfall, fall, maxGradient, spacing, curveLength,
 *              fillSlope, cutSlope, profile, step, cell })
 * path: [[x, y], ...], at least two distinct points. groundAt is required: the design follows it.
 * fall: 'crown' (both ways from the centre), 'left' or 'right' (one way, towards that side).
 */
export function createRoad(opts = {}) {
  const o = { ...DEFAULTS, ...opts };
  const { path, groundAt, width, fall, maxGradient, fillSlope, cutSlope, step, cell } = o;
  if (!Array.isArray(path)) throw new Error('road: path must be an array of [x, y]');
  if (typeof groundAt !== 'function') throw new Error('road: groundAt must be a function');
  if (!(width > 0)) throw new Error('road: width must be positive');
  const spec = SURFACES[o.surface];
  if (!spec) throw new Error(`road: surface must be one of ${Object.keys(SURFACES).join(', ')}`);
  if (!['crown', 'left', 'right'].includes(fall)) throw new Error('road: fall must be crown, left or right');
  if (!(fillSlope > 0) || !(cutSlope > 0)) throw new Error('road: side slopes must be positive');
  if (!(maxGradient > 0)) throw new Error('road: maxGradient must be positive');
  const crossfall = o.crossfall ?? spec.crossfall;
  const build = spec.layers.reduce((t, l) => t + l.thickness, 0);
  const half = width / 2;

  const pts = [];
  for (const p of path) {
    const q = [Number(p[0]), Number(p[1])];
    const last = pts[pts.length - 1];
    if (!last || Math.hypot(q[0] - last[0], q[1] - last[1]) > 1e-6) pts.push(q);
  }
  if (pts.length < 2) throw new Error('road: path needs two distinct points');
  const segs = [];
  let L = 0;
  for (let i = 0; i < pts.length - 1; i++) {
    const [ax, ay] = pts[i], [bx, by] = pts[i + 1], len = Math.hypot(bx - ax, by - ay);
    const dx = (bx - ax) / len, dy = (by - ay) / len;
    segs.push({ ax, ay, dx, dy, nx: -dy, ny: dx, len, s0: L });
    L += len;
  }
  const length2d = L;
  const pointAt = (s) => {
    const c = Math.min(Math.max(s, 0), L);
    for (const g of segs) if (c <= g.s0 + g.len + EPS || g === segs[segs.length - 1]) {
      const t = Math.min(Math.max(c - g.s0, 0), g.len);
      return [g.ax + g.dx * t, g.ay + g.dy * t];
    }
    return pts[pts.length - 1];
  };

  const segAt = (s) => segs.find((g) => s <= g.s0 + g.len + EPS) || segs[segs.length - 1];

  // ---- vertical alignment: grade points, straight grades, parabolic curves
  let pvi;
  if (o.profile) {
    pvi = o.profile.map(([s, z]) => [Number(s), Number(z)]).sort((a, b) => a[0] - b[0]);
    if (pvi.length < 2 || pvi.some(([s, z]) => !Number.isFinite(s) || !Number.isFinite(z)))
      throw new Error('road: profile needs two or more finite [chainage, level] points');
    if (Math.abs(pvi[0][0]) > 1e-6 || Math.abs(pvi[pvi.length - 1][0] - L) > 1e-6)
      throw new Error('road: profile must run from chainage 0 to the end of the path');
  } else {
    const n = Math.max(1, Math.round(L / o.spacing)), d = L / n;
    const zAt = (s) => { const [x, y] = pointAt(s); return groundAt(x, y); };
    pvi = [];
    for (let i = 0; i <= n; i++) {
      const s = i * d;
      if (i === 0 || i === n) { pvi.push([s, zAt(s)]); continue; }
      const k = Math.max(4, Math.ceil(d / step));    // mean over [s - d/2, s + d/2], midpoint rule
      let sum = 0;
      for (let j = 0; j < k; j++) sum += zAt(s - d / 2 + (j + 0.5) * d / k);
      pvi.push([s, sum / k]);
    }
  }
  const grades = [];
  for (let i = 0; i < pvi.length - 1; i++) {
    const ds = pvi[i + 1][0] - pvi[i][0];
    if (!(ds > 1e-6)) throw new Error('road: profile chainages must increase');
    grades.push((pvi[i + 1][1] - pvi[i][1]) / ds);
  }
  // Each interior curve is at most as long as the shorter grade either side, so curves never overlap.
  const curves = [];
  for (let i = 1; i < pvi.length - 1; i++) {
    const Lc = Math.min(o.curveLength, pvi[i][0] - pvi[i - 1][0], pvi[i + 1][0] - pvi[i][0]);
    if (Lc > 0) curves.push({ i, s: pvi[i][0], Lc, g1: grades[i - 1], g2: grades[i] });
  }
  function level(s) { // [design level, grade] at chainage s on the centreline
    const c = Math.min(Math.max(s, 0), L);
    for (const v of curves) {
      const x = c - (v.s - v.Lc / 2);
      if (x >= 0 && x <= v.Lc) {
        const r = (v.g2 - v.g1) / v.Lc;
        return [pvi[v.i][1] - v.g1 * v.Lc / 2 + v.g1 * x + r * x * x / 2, v.g1 + r * x];
      }
    }
    let i = 0;
    while (i < grades.length - 1 && c > pvi[i + 1][0]) i++;
    return [pvi[i][1] + grades[i] * (c - pvi[i][0]), grades[i]];
  }
  const designLevel = (s) => level(s)[0];
  const gradeAt = (s) => level(s)[1];
  // Finished level at chainage s and offset off (positive to the left of the direction of travel).
  const fallAt = (off) => (fall === 'crown' ? Math.abs(off) : fall === 'left' ? off : -off) * crossfall;
  const finishedAt = (s, off) => designLevel(s) - fallAt(off);

  // ---- gradient check on the design profile
  const nS = Math.max(1, Math.ceil(L / step)), stations = [];
  for (let k = 0; k <= nS; k++) stations.push(k * L / nS);
  let maxDiff = 0;
  for (const s of stations) { const [x, y] = pointAt(s); maxDiff = Math.max(maxDiff, Math.abs(designLevel(s) - groundAt(x, y))); }
  // The grade diagram is piecewise linear and reaches every tangent grade at a curve end, so the steepest
  // grade is exactly the steepest tangent; the curve ends join the stations so no steep run is missed.
  const maxGrade = grades.reduce((m, g) => Math.max(m, Math.abs(g)), 0);
  const checks = [...new Set([...stations, ...curves.flatMap((c) => [c.s - c.Lc / 2, c.s + c.Lc / 2])])].sort((a, b) => a - b);
  const steepSections = [];
  let open = null;
  for (const s of checks) {
    const g = gradeAt(s);
    if (Math.abs(g) > maxGradient + 1e-12) {
      if (!open) open = { from: s, to: s, maxGrade: 0 };
      open.to = s; open.maxGrade = Math.max(open.maxGrade, Math.abs(g));
    } else if (open) { steepSections.push(open); open = null; }
  }
  if (open) steepSections.push(open);
  // Straight grades are exact: widen each flagged run to where the grade really crosses the limit.
  for (const sec of steepSections) sec.from = edgeOfLimit(sec.from, -1);
  for (const sec of steepSections) sec.to = edgeOfLimit(sec.to, 1);
  function edgeOfLimit(s, dir) {
    let a = s, b = Math.min(Math.max(s + dir * L / nS, 0), L);
    if (Math.abs(gradeAt(b)) > maxGradient) return b;
    for (let k = 0; k < 40; k++) { const m = (a + b) / 2; if (Math.abs(gradeAt(m)) > maxGradient) a = m; else b = m; }
    return a;
  }

  const ratio = Math.max(fillSlope, cutSlope);
  const reach = Math.min(half + ratio * (maxDiff + build + crossfall * half + 2) * 2, half + MAX_REACH);
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
  for (const [x, y] of pts) { minX = Math.min(minX, x); maxX = Math.max(maxX, x); minY = Math.min(minY, y); maxY = Math.max(maxY, y); }
  const bbox = { minX: minX - reach, minY: minY - reach, maxX: maxX + reach, maxY: maxY + reach };

  // Nearest point of the centreline: chainage, signed offset, foot. null past a square end.
  function locate(x, y) {
    let best = null;
    for (let i = 0; i < segs.length; i++) {
      const g = segs[i], px = x - g.ax, py = y - g.ay, t = px * g.dx + py * g.dy;
      if ((i === 0 && t < -EPS) || (i === segs.length - 1 && t > g.len + EPS)) {
        if (!best) best = { d: Infinity, end: true };
        continue;
      }
      const tc = Math.min(Math.max(t, 0), g.len), fx = g.ax + g.dx * tc, fy = g.ay + g.dy * tc;
      const d = Math.hypot(x - fx, y - fy);
      if (!best || d < best.d - EPS) {
        let off = px * g.nx + py * g.ny;
        if (tc !== t) off = Math.sign(off || 1) * d;  // round the outside of a bend
        best = { d, s: g.s0 + tc, off, fx, fy, end: false };
      }
    }
    // A point beyond an end whose nearest in-range foot is farther than the end itself is past the end.
    return best && !best.end && Number.isFinite(best.d) ? best : null;
  }
  const inBox = (x, y) => x >= bbox.minX && x <= bbox.maxX && y >= bbox.minY && y <= bbox.maxY;

  // Batter surface d metres beyond an edge at level zE, against ground g: fill down, cut up, else ground.
  const invCut = inv(cutSlope), invFill = inv(fillSlope);
  const batter = (zE, d, g) => batterZ(g, zE, d, invCut, invFill);

  // Finished surface: what walkers and the drone stand on. g is the ground function to build on.
  function roadHeight(x, y, g = groundAt) {
    const ground = g(x, y);
    if (!inBox(x, y)) return ground;
    const p = locate(x, y);
    if (!p || Math.abs(p.off) > reach) return ground;
    if (Math.abs(p.off) <= half + 1e-9) return finishedAt(p.s, p.off);
    const side = Math.sign(p.off), zE = finishedAt(p.s, side * half);
    return batter(zE, Math.abs(p.off) - half, ground);
  }
  // Earthworks surface at a located point: the formation under the carriageway, the batters beside it.
  function earthworksOf(p, gz) {
    if (Math.abs(p.off) <= half) return finishedAt(p.s, p.off) - build;
    const side = Math.sign(p.off);
    return batter(finishedAt(p.s, side * half), Math.abs(p.off) - half, gz);
  }
  // The same for a plan point; NaN where the road does not touch the ground.
  function earthworksAt(x, y, g = groundAt) {
    const p = inBox(x, y) ? locate(x, y) : null;
    return !p || Math.abs(p.off) > reach ? NaN : earthworksOf(p, g(x, y));
  }
  function onRoad(x, y) {
    const p = inBox(x, y) ? locate(x, y) : null;
    return !!p && Math.abs(p.off) <= half;
  }

  // Cut and fill between the ground and the earthworks surface, one jittered sample per cell. The
  // jitter (a fixed hash of the cell) keeps the sum unbiased and stops a road that runs along the grid
  // axes from aliasing its edges, where the formation steps up to the batter, onto the cell rows.
  function earthworksOn(g = groundAt) {
    const nx = Math.ceil((bbox.maxX - bbox.minX) / cell), ny = Math.ceil((bbox.maxY - bbox.minY) / cell);
    let cut = 0, fill = 0, area = 0;
    for (let j = 0; j < ny; j++) for (let i = 0; i < nx; i++) {
      const x = bbox.minX + (i + jitter(i, j, 0)) * cell, y = bbox.minY + (j + jitter(i, j, 1)) * cell;
      const p = locate(x, y);
      if (!p || Math.abs(p.off) > reach) continue;
      const gz = g(x, y), d = gz - earthworksOf(p, gz);
      if (d > 0) cut += d; else fill -= d;
      if (d !== 0) area++;
    }
    const a = cell * cell;
    return { cutM3: cut * a, fillM3: fill * a, footprintM2: area * a };
  }

  // Where a finished edge sits below the ground just beyond it, the crossfall sheds water against the
  // cut batter: that run needs a side drain. Runs of at least one station, per side, in chainage metres.
  const drainSections = [];
  for (const side of [1, -1]) {
    let run = null;
    for (const s of stations) {
      const [cx, cy] = pointAt(s), gs = segAt(s), off = side * (half + 0.1);
      const inCut = finishedAt(s, side * half) < groundAt(cx + gs.nx * off, cy + gs.ny * off) - 1e-6;
      if (inCut) { if (!run) run = { side: side > 0 ? 'left' : 'right', from: s, to: s }; run.to = s; }
      else if (run) { drainSections.push(run); run = null; }
    }
    if (run) drainSections.push(run);
  }

  // Length along the finished centreline and the pavement materials, layer by layer.
  let length3d = 0;
  for (let k = 1; k < stations.length; k++) {
    const [ax, ay] = pointAt(stations[k - 1]), [bx, by] = pointAt(stations[k]);
    length3d += Math.hypot(bx - ax, by - ay, designLevel(stations[k]) - designLevel(stations[k - 1]));
  }
  const materials = spec.layers.map((l) => ({ ...l, volumeM3: l.thickness * width * length3d }));

  const road = {
    path: pts.map((p) => [...p]), width, surface: o.surface, crossfall, fall, maxGradient, fillSlope, cutSlope,
    buildUp: build, length2d, length3d, bbox, reach, pvi: pvi.map((p) => [...p]),
    curves: curves.map((c) => ({ s: c.s, length: c.Lc, g1: c.g1, g2: c.g2 })),
    maxGrade, steepSections, drainSections, materials, groundAt,
    pointAt, designLevel, gradeAt, finishedAt, locate, onRoad, roadHeight, earthworksAt, earthworksOn,
  };
  let ew = null;
  for (const k of ['cutM3', 'fillM3', 'footprintM2']) {
    Object.defineProperty(road, k, { enumerable: true, get: () => (ew ?? (ew = earthworksOn(groundAt)))[k] });
  }
  return road;
}

// A fixed pseudo-random offset in [0, 1) for cell (i, j), component k (an integer hash, no state).
function jitter(i, j, k) {
  let h = Math.imul(i + 0x9e37, 0x85ebca6b) ^ Math.imul(j + 0x7f4a, 0xc2b2ae35) ^ Math.imul(k + 1, 0x27d4eb2f);
  h = Math.imul(h ^ (h >>> 15), 0x2c1b3c6d); h = Math.imul(h ^ (h >>> 12), 0x297a2d39); h ^= h >>> 15;
  return (h >>> 0) / 4294967296;
}

/**
 * composeRoadGround(groundAt, roads) -> a new heightAt with every road built on the ground (lib/earthworks.mjs).
 * Where roads overlap, the one on the carriageway wins; between batters, the first road listed wins.
 */
export const composeRoadGround = (groundAt, roads) => compose(groundAt, { roads: [...roads] });

Solar Design Studio — Site World V3 Page

A web page in GlobalGrid2050 that draws bill of quantities, cables, substations and postcodes. Published at https://globalgrid2050.com/solar-design-studio/202609270402-site-world-v3/.

Set aside from the main view: 92% of its lines are the same as solar-design-studio/202609271853-site-world/index.html (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 92% of lines shared with Solar Design Studio — Site World Page; read that one first. All set-aside files, with reasons. Nothing was deleted.

Evidence
  • line-jaccard 0.9246 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609271853-site-world/index.html:1-363 43c86335e901381d30d0030d841f3f2a5a3183de
  • sha256 e49d33112610fa63ab55a0a196b8bde3fef6e7ef196ee76ef488486fa3257373
  • target sha256 73e3e357d52a70345427514552c2caf3abbeca7762f0c549bd52f85f07085a50
  • group of 2 (identity.json near-copy edges >= 0.9)
  • canonical rule: reachable, newest stamp, core repo, most lines

renderglobalgrid2050 / solar-design-studio/202609270402-site-world-v3/index.html · lines 1–355 of 355 · version 2026-09-27 04:02 · Entry point

What it does
It draws bill of quantities, cables, substations and postcodes. Side effects: changes the web page (DOM); makes network requests.
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, substations, postcodes.
Inputs & outputs
In: user-supplied file (file picker); form fields (user input). Out: CSV file bill-of-quantities.csv; downloaded file bill-of-quantities.csv; web page; SVG drawing. Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid).
Downstream impact
It is itself an entry point, published at https://globalgrid2050.com/solar-design-studio/202609270402-site-world-v3/.
What it achieves
Every module the first frame imports is fetched with the page, all at once, not one import level at a time; the manifest.
Why it matters
No other file in the estate was found to import it; it is an entry point.
Application
globalgrid2050 · solar-design-studio/202609270402-site-world-v3 · page
Uses
Substrate (modulepreload), Links (modulepreload), Bng (modulepreload), Origin (modulepreload), Camera (modulepreload), Views (modulepreload), Frame Gate (modulepreload), Device Budget (modulepreload), and 15 more
Used by
none found
Produces
none declared
Defines here
none
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-design-studio/202609270402-site-world-v3/index.html:1-355 · blob c9ae359670898542e99df17b1e97be4aa5804d92 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
<!doctype html>
<html lang="en-GB">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>Site world</title>
<link rel="icon" href="data:,">
<!-- Every module the first frame imports is fetched with the page, all at once, not one import level at a time; the
     manifest, the lib's texts and the ground's two layers are asked for now too (layers.mjs takes each once and still
     checks its hash against the manifest). Review E; tests/first-frame.test.mjs keeps these lists true. -->
<link rel="modulepreload" href="world/substrate.mjs"><link rel="modulepreload" href="world/links.mjs"><link rel="modulepreload" href="world/bng.mjs">
<link rel="modulepreload" href="world/origin.mjs"><link rel="modulepreload" href="world/camera.mjs"><link rel="modulepreload" href="world/views.mjs">
<link rel="modulepreload" href="world/frame-gate.mjs"><link rel="modulepreload" href="world/device-budget.mjs"><link rel="modulepreload" href="world/lines.mjs">
<link rel="modulepreload" href="world/input.mjs"><link rel="modulepreload" href="world/layers.mjs"><link rel="modulepreload" href="world/arrival.mjs">
<link rel="modulepreload" href="world/attribution.mjs"><link rel="modulepreload" href="world/sites-ui.mjs"><link rel="modulepreload" href="world/layers-panel.mjs">
<link rel="modulepreload" href="world/wcs-terrain.mjs"><link rel="modulepreload" href="world/layers/terrain.mjs"><link rel="modulepreload" href="world/lift.mjs">
<link rel="modulepreload" href="world/fade.mjs"><link rel="modulepreload" href="world/lib/index.mjs"><link rel="modulepreload" href="world/lib/earthworks.mjs">
<link rel="modulepreload" href="world/lib/tiles.mjs"><link rel="modulepreload" href="world/lib/drape.mjs">
<script>window.__early = new Map(['manifest.json', 'lib/tiles.mjs', 'lib/drape.mjs', 'lib/earthworks.mjs', 'layers/terrain.mjs',
  'layers/ground-grid.mjs'].map(p => { const u = new URL('world/' + p, location.href).href;
  return [u, fetch(u, { cache: 'no-cache' }).catch(e => ({ ok: false, status: e.message }))]; }));</script>
<style>
  :root { --bg: #0a0a0a; --line: #9cdbff; --text: #cfe9ff; --dim: #6f8ea6; --panel: rgba(10, 10, 10, 0.86); --edge: #1c2c3a;
    --foot: 20px; --btn: 30px; }
  html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 12px/1.45 system-ui, sans-serif; overflow: hidden; }
  button, select { font: inherit; }
  #view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
  #where { position: fixed; left: 10px; bottom: calc(var(--foot) + 8px); color: var(--dim); pointer-events: none; }
  #help-toggle { position: fixed; right: 10px; bottom: calc(var(--foot) + 6px); min-height: 28px; border-radius: 4px; padding: 0 10px;
    background: var(--panel); color: var(--dim); border: 1px solid var(--edge); cursor: pointer; }
  #help-toggle[aria-expanded="true"] { color: var(--text); border-color: var(--line); }
  .panel { position: fixed; box-sizing: border-box; background: var(--panel); border: 1px solid var(--edge); border-radius: 6px;
    padding: 10px 12px; overflow: auto; }
  .panel[hidden] { display: none; }
  /* right: 76px leaves the drone lift buttons (56 px at right 10 px) clear of Controls */
  #help { right: 76px; bottom: calc(var(--foot) + 42px); width: min(380px, calc(100vw - 86px)); max-height: calc(100vh - var(--foot) - 110px); }
  #help dl, #design dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0 0 8px; }
  #help dt, #design dt { color: var(--text); white-space: nowrap; }
  #help dd, #design dd { margin: 0; color: var(--dim); }
  #help .fold > summary { cursor: pointer; color: var(--text); font-weight: 600; min-height: var(--btn); display: flex; align-items: center; }
  /* Wide screens: How to use and the controls side by side, so neither has to scroll. */
  @media (min-width: 900px) and (pointer: fine) { #help:not([hidden]) { width: min(640px, calc(100vw - 86px)); display: grid;
    grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; } }
  #help h3 { margin: 8px 0 4px; font-size: 11px; font-weight: 600; color: var(--text); }
  #help p, #help ol, #help ul.basis { margin: 0 0 6px; } #help ol, #help ul.basis { padding-left: 18px; color: var(--dim); }
  #help b { color: var(--text); font-weight: 600; } #help dl.dash-help dt { min-width: 44px; }
  @media (pointer: coarse) { #help .mouse { display: none; } } @media (pointer: fine) { #help .touch { display: none; } }
  #help .credit { margin: 8px 0 0; padding: 0; list-style: none; color: var(--dim); font-size: 10px; }
  #help .credit a { color: var(--dim); }
  #layers .lp.in-help { position: static; width: auto; max-height: none; overflow: visible; background: none; border: 0;
    border-top: 1px solid var(--edge); border-radius: 0; padding: 8px 0 0; margin: 8px 0 0; }
  #layers .sun-time { border: 0; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; }
  #layers .sun-time[hidden] { display: none; }
  #layers .sun-time legend { color: var(--dim); font-size: 11px; padding: 0; }
  #layers .sun-time label { display: grid; gap: 2px; color: var(--dim); }
  #layers .sun-time input { min-height: var(--btn); background: #111; color: var(--text); border: 1px solid var(--edge); border-radius: 4px; }
  #layers .sun-time .note { margin: 0; color: var(--dim); font-size: 11px; }
  #dash { position: fixed; top: 8px; right: 8px; display: flex; gap: 4px; }
  #dash button, #design button, #help button { background: var(--panel); color: var(--dim); border: 1px solid var(--edge); border-radius: 4px;
    padding: 5px 9px; cursor: pointer; min-height: var(--btn); }
  #dash button[aria-pressed="true"], #dash button[aria-expanded="true"], #design button[aria-pressed="true"],
    #help button[aria-pressed="true"] { color: #fff; border-color: var(--line); }
  #design button:disabled { opacity: 0.45; cursor: default; }
  #layers { top: calc(var(--btn) + 20px); right: 8px; width: min(360px, calc(100vw - 16px)); max-height: calc(100vh - 120px); }
  #layers .lp > h2 { display: none; } /* the panel header names it, beside the GridAtlas link */
  #layers .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; }
  #layers h2 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; color: var(--dim); text-transform: uppercase; }
  #layers button { background: var(--panel); color: var(--text); border: 1px solid var(--edge); border-radius: 4px;
    padding: 5px 9px; cursor: pointer; min-height: var(--btn); }
  #layers button[aria-pressed="true"] { color: #fff; border-color: var(--line); }
  #layers dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0 0 8px; }
  #layers dt { color: var(--text); white-space: nowrap; } #layers dd { margin: 0; color: var(--dim); overflow-wrap: anywhere; }
  #help .row { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 8px; }
  #headset-row:has(> #headset[hidden]) { display: none; } /* shown only where a headset session is supported */
  #design .note { margin: 0 0 8px; color: var(--dim); font-size: 11px; overflow-wrap: anywhere; }
  #design .note:empty { display: none; }
  #design input[type="text"] { box-sizing: border-box; width: 100%; background: #111; color: var(--text);
    border: 1px solid var(--edge); border-radius: 4px; min-height: var(--btn); margin: 0 0 8px; }
  #design input[type="text"][hidden] { display: none; }
  #design .fold { margin: 0 0 8px; }
  #design .fold > summary { cursor: pointer; color: var(--text); min-height: var(--btn); display: flex; align-items: center; }
  #design .phase-slider input { width: 100%; min-height: var(--btn); margin: 0; }
  #design .phase-slider-label { color: var(--text); font-size: 11px; margin: 0 0 4px; }
  #find .site-section { margin: 8px 0 0; }
  #find .site-select { display: grid; gap: 4px; color: var(--dim); font-size: 11px; }
  #find .site-select select { min-height: var(--btn); background: #111; color: var(--text); border: 1px solid var(--edge); border-radius: 4px; }
  #tour-caption { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--foot) + 44px); max-width: min(480px, 60vw);
    padding: 4px 10px; background: var(--panel); border: 1px solid var(--edge); border-radius: 4px; color: var(--text); pointer-events: none; }
  #tour-caption[hidden] { display: none; }
  #design { top: calc(var(--btn) + 20px); right: 8px; width: min(300px, calc(100vw - 16px)); max-height: calc(100vh - 120px); }
  #design .row { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 8px; }
  #design button:disabled { opacity: 0.45; cursor: default; }
  #design label { display: grid; gap: 2px; margin: 0 0 8px; color: var(--dim); }
  #design label[hidden], #design a[hidden] { display: none; }
  #design a.btn { display: inline-flex; align-items: center; min-height: var(--btn); padding: 0 9px; box-sizing: border-box;
    color: var(--text); border: 1px solid var(--edge); border-radius: 4px; text-decoration: none; }
  #design select { background: #111; color: var(--text); border: 1px solid var(--edge); border-radius: 4px; min-height: var(--btn); max-width: 100%; }
  #design-readout dd { color: var(--text); font-variant-numeric: tabular-nums; }
  #design-readout .warn, #spec-status.warn, #plant-status.warn, #block-status.warn { color: #ff8a7a; }
  #plant-readout dd, #block-readout dd { color: var(--text); font-variant-numeric: tabular-nums; }
  #block-stage { color: var(--text); margin: 0 0 6px; }
  #design input[type=number] { background: #111; color: var(--text); border: 1px solid var(--edge); border-radius: 4px; min-height: var(--btn); }
  #spec-status { color: var(--dim); margin: 0; font-size: 12px; }
  #design figure { margin: 0 0 8px; } #design figure[hidden] { display: none; }
  #design svg { display: block; width: 100%; height: 90px; }
  #design svg polyline { fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
  #design svg .ground { stroke: var(--line); } #design svg .floor { stroke: #ffc773; stroke-dasharray: 4 3; }
  #design svg text { fill: var(--dim); font-size: 12px; }
  #design figcaption { color: var(--dim); font-size: 10px; }
  #find.find-panel { top: calc(var(--btn) + 20px); right: 8px; }
  #lift { position: fixed; right: 10px; bottom: 50%; display: flex; flex-direction: column; gap: 6px; transform: translateY(50%); }
  #lift[hidden] { display: none; }
  #design:not([hidden]) ~ #lift { right: calc(min(300px, 100vw - 16px) + 18px); } /* Up/Down stay beside an open Design panel */
  #layers:not([hidden]) ~ #lift { right: calc(min(360px, 100vw - 16px) + 18px); } /* and beside an open Layers panel */
  #lift button { width: 56px; height: 44px; background: var(--panel); color: var(--text); border: 1px solid var(--edge);
    border-radius: 6px; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
  #lift button:active { border-color: var(--line); }
  #ground-feet { display: block; color: var(--text); opacity: 0.8; } #ground-feet[hidden] { display: none; }
  #ground-readout { border-top: 1px solid var(--edge); padding-top: 6px; margin: 0 0 8px; } #ground-readout[hidden] { display: none; }
  #ground-readout h3 { font-size: 12px; font-weight: 600; margin: 0 0 4px; }
  #ground-readout dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; }
  #ground-readout dt { color: var(--text); } #ground-readout dd { margin: 0; color: var(--dim); overflow-wrap: anywhere; }
  #ground-readout dd.warn { color: #ffb27a; } #ground-readout ul { margin: 2px 0 0; padding-left: 14px; }
  #ground-readout a { color: var(--line); }
  #help .lp { position: static; width: auto; max-height: none; overflow: visible; background: none; border: 0; border-top: 1px solid var(--edge);
    border-radius: 0; padding: 6px 0 0; margin: 0 0 8px; }
  #layer-details { margin: 0 0 8px; color: var(--dim); } #layer-details > summary { cursor: pointer; min-height: var(--btn); display: flex; align-items: center; }
  #where-detail { margin: 0 0 6px; color: var(--dim); font-variant-numeric: tabular-nums; }
  #design .hint { margin: 0 0 8px; color: var(--text); }
  #design[data-state="choose"] #design-draw, #design[data-state="choose"] #design-readout,
  #design[data-state="result"] #design-draw { display: none; }
  #design-options[hidden] { display: none; }
  /* Design sections as tabs (Build, Measure, Plant, Share): one short panel at a time, most of all on a phone. */
  #design .tabs { flex-wrap: nowrap; } #design .tabs button { flex: 1; min-width: 0; }
  #design .tabs button[aria-selected="true"] { color: var(--text); border-color: var(--line); }
  #design .dtab[hidden] { display: none; }
  /* Small cards over the world: the first step, and the place just found. Hidden while any panel is open. */
  /* Centred along the top, clear of the plan inset (top left) and the dash (top right). */
  .card { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); width: min(340px, calc(100vw - 16px)); box-sizing: border-box; display: flex;
    align-items: stretch; gap: 4px; background: var(--panel); border: 1px solid var(--edge); border-radius: 6px; padding: 4px; }
  .card[hidden], body[data-panel] .card { display: none; }
  .card button { background: none; border: 0; color: var(--text); cursor: pointer; min-height: var(--btn); border-radius: 4px; }
  .card button:hover { background: rgba(156, 219, 255, 0.08); }
  #start-go { flex: 1; text-align: left; padding: 4px 8px; }
  .card .close { min-width: var(--btn); font-size: 16px; color: var(--dim); }
  #place > div { flex: 1; padding: 4px 8px; display: grid; gap: 2px; }
  #place-name { color: #fff; } #place-grid, #place-terrain { color: var(--dim); } #place-terrain:empty { display: none; }
  /* While Design is open, the joypad, Up and Down step aside so taps land on the ground or the panel. */
  body[data-panel="design"] #pad, body[data-panel="design"] #lift { display: none !important; }
  @media (max-width: 900px) and (pointer: fine) { .card { top: calc(var(--btn) + 20px); } }
  @media (pointer: fine) { body[data-panel="help"] #lift { display: none; } } /* keys still fly the drone */
  #status { color: var(--dim); font-size: 11px; overflow-wrap: anywhere; }
  #attribution { position: fixed; left: 0; right: 0; bottom: 0; height: var(--foot); box-sizing: border-box; padding: 3px 10px 4px;
    font-size: 10px; line-height: 13px; color: var(--dim); background: rgba(10, 10, 10, 0.72); pointer-events: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #attribution .short { display: none; }
  #pad { position: fixed; left: 24px; bottom: calc(var(--foot) + 36px); width: 120px; height: 120px; border-radius: 50%; touch-action: none;
    border: 1px solid var(--edge); background: rgba(156, 219, 255, 0.04); display: none; }
  #pad span { position: absolute; left: 36px; top: 36px; width: 48px; height: 48px; border-radius: 50%;
    border: 1px solid var(--line); background: rgba(156, 219, 255, 0.12); pointer-events: none; }
  @media (max-width: 900px) { #attribution .full { display: none; } #attribution .short { display: inline; } }
  /* Narrow screens: the credit may take two lines; everything above the footer moves up with --foot. */
  @media (max-width: 600px) { :root { --foot: max(33px, var(--foot-fit, 33px)); } #attribution { white-space: normal; height: auto; } }
  @media (pointer: fine) { #help dl.touch { display: none; } }
  /* Touch screens: 44 px targets; panels open as a sheet under the dash so the joypad, Up and Down stay clear. */
  @media (pointer: coarse) {
    :root { --btn: 44px; }
    #pad { display: block; }
    #help dl.keys, #design dl.keys { display: none; }
    #where { bottom: auto; top: calc(var(--btn) + 16px); right: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    #dash button { min-width: 48px; }
    #design button, #design a.btn, #help button, #layers button { min-width: 44px; }
    #help-toggle { min-height: 44px; min-width: 44px; bottom: calc(var(--foot) + 8px); }
    #lift, #design:not([hidden]) ~ #lift, #layers:not([hidden]) ~ #lift { right: 10px; bottom: calc(var(--foot) + 64px); transform: none; }
    #help, #design, #layers, #find.find-panel { top: calc(var(--btn) + 40px); left: 8px; right: 8px; bottom: auto; width: auto;
      max-height: calc(100vh - var(--btn) - 40px - var(--foot) - 180px); overflow: auto; }
    #find.find-panel input { height: 44px; }
    .card { top: calc(var(--btn) + 40px); left: 8px; transform: none; width: auto; right: 8px; max-width: 420px; }
    /* Design is a short sheet along the bottom: tools, one line of guidance, Undo / Done / Clear; results after Done. */
    /* the ground above stays clear to tap; a taller footer (--foot-fit) shortens the sheet, never lifts it */
    #design { top: auto; bottom: calc(var(--foot) + 4px); max-height: min(35vh, calc(35vh + 33px - var(--foot))); }
    /* While drawing, the sheet keeps the hint, the tool in use (tap it again to choose another), Options and Undo / Done / Clear. */
    #design[data-state="draw"] > :not(#design-hint):not(#design-draw):not(.dtab) { display: none; }
    #design[data-state="draw"] .dtab > :not([role="group"][aria-label$="tool"]):not(#design-options):not(#works-option-box) { display: none; }
    #design[data-state="draw"] [data-tool][aria-pressed="false"] { display: none; }
    #design[data-state="draw"] #design-readout, #design[data-state="draw"] #design-profile-box,
    #design[data-state="draw"] #design-keys, #design[data-state="choose"] #design-keys { display: none; }
    #design[data-state="result"] #design-keys { display: none; }
    #design-draw { flex-wrap: nowrap; } #design-draw button { flex: 1; }
    body[data-panel="design"] #help-toggle { display: none; }
    #help .credit a, #layers .credit a { display: flex; align-items: center; min-height: 40px; }
  }
</style>
</head>
<body>
<canvas id="view" tabindex="0" aria-label="Site world. Move with W and S or the joypad, turn with A and D; look by dragging."></canvas>
<div id="where" role="status"><span id="where-line"></span><span id="ground-feet" hidden></span></div>
<nav id="dash" aria-label="View">
  <button type="button" data-view="standing" aria-pressed="true">Walk</button>
  <button type="button" data-view="aerial" aria-pressed="false">Drone</button>
  <button type="button" id="find-toggle" aria-expanded="false" aria-controls="find">Find</button>
  <button type="button" id="design-toggle" aria-expanded="false" aria-controls="design">Design</button>
  <button type="button" id="layers-toggle" aria-expanded="false" aria-controls="layers">Layers</button>
</nav>
<section id="layers" class="panel" hidden aria-labelledby="layers-title">
  <header class="head"><h2 id="layers-title">Layers</h2>
    <button type="button" id="to-gridatlas" title="Open GridAtlas at this spot">Open in GridAtlas</button></header>
  <div id="layers-slot"></div>
</section>
<p id="tour-caption" role="status" hidden></p>
<section id="design" class="panel" hidden aria-label="Design" data-state="choose">
  <div class="row tabs" role="tablist" aria-label="Design sections">
    <button type="button" role="tab" id="design-tab-build-btn" data-tab="build" aria-selected="true" aria-controls="design-tab-build">Build</button>
    <button type="button" role="tab" id="design-tab-measure-btn" data-tab="measure" aria-selected="false" aria-controls="design-tab-measure" tabindex="-1">Measure</button>
    <button type="button" role="tab" id="design-tab-plant-btn" data-tab="plant" aria-selected="false" aria-controls="design-tab-plant" tabindex="-1">Plant</button>
    <button type="button" role="tab" id="design-tab-share-btn" data-tab="share" aria-selected="false" aria-controls="design-tab-share" tabindex="-1">Share</button>
  </div>
  <p id="design-hint" class="hint" role="status">Choose a design tool</p>
  <div class="dtab" role="tabpanel" id="design-tab-build" data-tab="build" aria-labelledby="design-tab-build-btn">
    <div class="row" role="group" aria-label="Design tool">
      <button type="button" data-tool="trench" aria-pressed="false">Trench</button>
      <button type="button" data-tool="cable" aria-pressed="false">Cable</button>
      <button type="button" id="design-options-toggle" aria-expanded="false" aria-controls="design-options">Options</button>
    </div>
    <div class="row" role="group" aria-label="Earthworks tool">
      <button type="button" data-tool="road" aria-pressed="false">Road</button>
      <button type="button" data-tool="pad" aria-pressed="false">Pad</button>
      <button type="button" data-tool="fence" aria-pressed="false">Fence</button>
      <button type="button" data-tool="piles" aria-pressed="false">Pile row</button>
      <button type="button" data-tool="hdd" aria-pressed="false">Drilled crossing</button>
    </div>
    <label id="works-option-box" hidden><span id="works-option-label">Option</span> <select id="works-option"></select></label>
    <div id="design-options" hidden>
      <label>Trench section <select id="trench-section"></select></label>
      <label>Cable (voltage and size) <select id="cable-type"></select></label>
    </div>
    <div class="row">
      <button type="button" id="design-to-substation" disabled
        title="Draws a straight first draft from the last point to the nearest substation">Route to nearest substation</button>
    </div>
    <details class="fold" id="phases-fold"><summary>Construction phases</summary>
      <div id="phases-box"></div>
      <p id="phases-check" class="note"></p>
    </details>
  </div>
  <div class="dtab" role="tabpanel" id="design-tab-measure" data-tab="measure" aria-labelledby="design-tab-measure-btn" hidden>
    <div class="row" role="group" aria-label="Schedules">
      <button type="button" id="design-drums">Drum schedule</button>
      <button type="button" id="design-boq">Bill of quantities</button>
      <a id="works-csv" class="btn" hidden download="bill-of-quantities.csv">Download CSV</a>
    </div>
    <figure id="design-profile-box" hidden>
      <svg id="design-profile" role="img" aria-label="Level profile along the route"></svg>
      <figcaption>Ground level (solid) and trench floor (dashed) along the route</figcaption>
    </figure>
  </div>
  <div class="dtab" role="tabpanel" id="design-tab-plant" data-tab="plant" aria-labelledby="design-tab-plant-btn" hidden>
    <div id="design-spec"></div>
    <div id="ground-readout" hidden aria-live="polite"></div>
  </div>
  <div class="dtab" role="tabpanel" id="design-tab-share" data-tab="share" aria-labelledby="design-tab-share-btn" hidden>
    <div class="row" role="group" aria-label="File">
      <button type="button" id="project-save" title="Download the design as a .json file">Save</button>
      <button type="button" id="project-open" title="Open a design or tour .json file">Open</button>
      <button type="button" id="project-share" title="Put the design in a link you can send">Share</button>
      <button type="button" id="project-print" title="Plan sheet with the current view">Print</button>
    </div>
    <input type="file" id="project-file" accept=".json,application/json" hidden>
    <input type="text" id="project-link" readonly hidden aria-label="Share link">
    <p id="project-note" class="note" aria-live="polite"></p>
    <details class="fold" id="tour-fold"><summary>Tour</summary>
      <div class="row">
        <button type="button" id="tour-record" aria-pressed="false">Record</button>
        <button type="button" id="tour-play" aria-pressed="false" disabled>Play</button>
        <button type="button" id="tour-save" disabled>Save tour</button>
      </div>
    </details>
  </div>
  <div class="row" id="design-draw">
    <button type="button" id="design-undo">Undo</button>
    <button type="button" id="design-finish">Done</button>
    <button type="button" id="design-clear">Clear</button>
  </div>
  <dl id="design-readout" aria-live="polite"></dl>
  <p id="design-disclaimer" class="note">Estimates for early design. Confirm with the network operator and a qualified engineer.</p>
  <dl id="design-keys"></dl>
</section>
<div id="start" class="card" hidden>
  <button type="button" id="start-go">Town, postcode or planning reference — e.g. Cirencester</button>
  <button type="button" id="start-close" class="close" aria-label="Dismiss">×</button>
</div>
<div id="place" class="card" hidden role="status">
  <div><strong id="place-name"></strong><span id="place-grid"></span><span id="place-terrain"></span></div>
  <button type="button" id="place-close" class="close" aria-label="Close">×</button>
</div>
<div id="lift" hidden>
  <button type="button" data-lift="1" aria-label="Fly up">Up</button>
  <button type="button" data-lift="-1" aria-label="Fly down">Down</button>
</div>
<div id="pad" aria-label="Joypad: up to move forward, sideways to turn"><span></span></div>
<button id="help-toggle" type="button" aria-expanded="false" aria-controls="help">Controls</button>
<section id="help" class="panel" hidden aria-label="Controls and how to use">
  <details class="fold" id="help-how"><summary>How to use</summary>
  <p id="help-what">Walk and fly real UK ground, then draw trenches and cable routes and read lengths, spoil and levels.</p>
  <ol class="steps">
    <li><b>Find</b> a postcode or planning reference.</li>
    <li>Look at the grid on the ground: overhead lines, towers and substations.</li>
    <li><b>Design</b> a cable route: choose Cable, <span class="mouse">click</span><span class="touch">tap</span> points on the ground,
      then Finish.</li>
  </ol>
  <h3>Buttons</h3>
  <dl class="dash-help">
    <dt>Walk</dt><dd>stand on the ground at eye height (1.7 m)</dd>
    <dt>Drone</dt><dd>fly above the ground; <span class="mouse">Space up, Q down</span><span class="touch">hold Up or Down</span></dd>
    <dt>Find</dt><dd>go to a project, postcode, planning reference or lat, lon</dd>
    <dt>Design</dt><dd>draw trenches, cables, roads, pads, fences, pile rows and drilled crossings; schedules and quantities</dd>
    <dt>Layers</dt><dd>what is loaded here and its state</dd>
  </dl>
  <h3>What the numbers rest on</h3>
  <ul class="basis">
    <li>Ground: <span id="help-ground">EA LIDAR Composite DTM 1 m, ±15 cm</span></li>
    <li>Levels: <span id="help-datum">metres above Ordnance Datum Newlyn</span></li>
    <li>Values not measured are marked <i>assumed</i> where they appear.</li>
    <li><b>Desktop study only:</b> not a survey or a design. Confirm on site before use.</li>
  </ul>
  </details>
  <div class="ctl">
  <h3>Moving</h3>
  <dl class="keys">
    <dt>W / S</dt><dd>forward and back (or up / down arrows)</dd>
    <dt>A / D</dt><dd>turn left and right (or left / right arrows)</dd>
    <dt>Drag</dt><dd>look around</dd>
    <dt>Shift</dt><dd>hold to move slowly and precisely</dd>
    <dt>F</dt><dd>drone on and off · Space up, Q down · flies low enough to pass under tables</dd>
  </dl>
  <dl class="touch">
    <dt>Joypad</dt><dd>up to go forward, sideways to turn</dd>
    <dt>Drag</dt><dd>anywhere else to look around</dd>
  </dl>
  <div class="row" id="help-links">
    <span id="headset-row"><button type="button" id="headset" aria-pressed="false" hidden>Headset view</button></span>
    <button type="button" id="raycast" aria-pressed="false" hidden
      title="Draws the measured ground solid, with sun shadows, on this device's graphics card (WebGL2). Off by default.">Solid ground (GPU)</button>
  </div>
  <details id="layer-details"><summary>Layer details</summary><p id="where-detail"></p><div id="status"></div></details>
  <ul id="credits" class="credit"><li>Terrain: Environment Agency LIDAR Composite DTM 1 m · © Environment Agency copyright and/or
    database right 2022. All rights reserved. · Open Government Licence v3.0</li></ul>
  </div>
</section>
<footer id="attribution"><span class="full" id="credit-full">Terrain: Environment Agency LIDAR Composite DTM 1 m ·
  © Environment Agency copyright and/or database right 2022. All rights reserved. · Open Government Licence v3.0</span><span
  class="short" id="credit-short">Terrain © Environment Agency 2022 · OGL v3.0</span></footer>
<script type="module" src="world/substrate.mjs"></script>
</body>
</html>