In this section
- Substation Finder — Si Page geodesy · code-generator / apps/substation-finder/Si/index.html lines 1911–2610
Substation Finder — Si Page
A map page in Code Generator that maps grid 400kV, grid 275kV, grid 220kV and grid 132kV, using haversine. Published at https://ventusltd.github.io/code-generator/apps/substation-finder/Si/.
geodesycode-generator / apps/substation-finder/Si/index.html · lines 1911–2610 of 5013 (continued from section 295) · Entry point · pattern enterFullscreen (shared by 2 files)
- What it does
- It maps grid 400kV, grid 275kV, grid 220kV and grid 132kV. Defines 104 functions or classes, including deepFreeze, escapeHTML, normalizeStatus, enterFullscreen, exitFullscreen. Side effects: changes the web page (DOM); reads or writes files; makes network requests.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'substation'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: 400kV, 275kV, 220kV, 132kV, 66kV, 11kV.
- Inputs & outputs
- In: GeoJSON file grid_400kv.geojson; GeoJSON file grid_275kv.geojson; GeoJSON file grid_220kv.geojson; GeoJSON file grid_132kv.geojson; GeoJSON file grid_66kv.geojson; GeoJSON file grid_11kv_ukpn.geojson; GeoJSON file grid_substations.geojson; GeoJSON file power_plants.geojson. Out: JSON file manifest_v4.json; web page; interactive map. Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326. Voltage levels named: 400kV, 275kV, 220kV, 132kV, 66kV, 11kV.
- Downstream impact
- It is itself an entry point, published at https://ventusltd.github.io/code-generator/apps/substation-finder/Si/.
- What it achieves
- It normalizes status (`normalizeStatus`), toggles curtain (`toggleCurtain`) and gets radius (`getRadiusValue`). Its `snapLines` function gives line features whose first and last vertices are moved onto the nearest substation point within tolerance; other geometry unchanged from line features and substation point features (VEDIC: snap line ends to substations). Its code works with 132 kV, 220 kV and 275 kV. It responds to fullscreenchange, webkitfullscreenchange and click events.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- code-generator · apps/substation-finder/Si · page
- VEDIC
- SNAP LINE ENDS TO SUBSTATIONS (GG2050-VEDIC-000106): GridAtlas / Substations · Geospatial data processing. line_features, substation_point_features → Line features whose first and last vertices are moved onto the nearest substation point within tolerance; other geometry unchanged.
- Uses
- https://cdn.jsdelivr.net/npm/maplibre-gl@3.6.2/dist/maplibre-gl.css, https://cdn.jsdelivr.net/npm/maplibre-gl@3.6.2/dist/maplibre-gl.js, https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css, https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.js, https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.4.1/papaparse.min.js
- Used by
- mentioned in Standalone (comment link)
- Produces
- deepFreeze, escapeHTML, normalizeStatus, enterFullscreen, exitFullscreen, toggleCurtain, getRadiusValue, validateRadiusInput, fmt, updateMeasureDisplay, updateMeasureLayers, clearMeasure
- Defines here
- getLayerConfig, getSourceIdForLayer, hydrateLayer, REPDUpdater, deepFreeze
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- code-generator@3897d83efcd0259d21dce87704b0c33118fe2c2e apps/substation-finder/Si/index.html:1911-2610 · blob 4e9b8b6a923698ac72c91325688593fcae31ffb3 · GitHub at these lines
- State
- achieves: code · context: readme_derived · stage: output · effects: dom, filesystem, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unknown
bmGroup.className = 'key-group';
bmGroup.innerHTML = `
<div class="key-title">Basemap</div>
<label class="key-item"><input type="radio" name="bm" value="dark" checked> Dark</label>
<label class="key-item"><input type="radio" name="bm" value="sat"> Satellite</label>
`;
fragment.appendChild(bmGroup);
container.appendChild(fragment);
container.addEventListener('change', e => {
if (e.target.type === 'checkbox' && e.target.dataset.layerId) {
const layerId = e.target.dataset.layerId;
const isVisible = e.target.checked;
if (map.getLayer(`l-${layerId}`)) {
map.setLayoutProperty(`l-${layerId}`, 'visibility', isVisible ? 'visible' : 'none');
}
if (map.getLayer(`l-${layerId}-glow`)) {
map.setLayoutProperty(`l-${layerId}-glow`, 'visibility', isVisible ? 'visible' : 'none');
}
if (isVisible) hydrateLayer(layerId);
} else if (e.target.name === 'bm') {
map.setLayoutProperty('l-sat', 'visibility', e.target.value === 'sat' ? 'visible' : 'none');
}
});
const input = document.getElementById('search-input');
const btn = document.getElementById('search-btn');
const resultsEl = document.getElementById('search-results');
input.addEventListener('input', () => searchProjects(input.value));
input.addEventListener('keydown', e => {
if (e.key === 'Enter') searchProjects(input.value);
if (e.key === 'Escape') resultsEl.style.display = 'none';
});
btn.addEventListener('click', () => searchProjects(input.value));
document.getElementById('map').addEventListener('click', () => { resultsEl.style.display = 'none'; });
}
function getLayerConfig(layerId) {
return GRID_CONFIG.flatMap(g => g.layers).find(l => l.id === layerId);
}
function getSourceIdForLayer(layerId) {
if (REPD_IDS.includes(layerId)) return 'src-repd';
return `src-${layerId}`;
}
async function hydrateLayer(layerId) {
const state = RUNTIME_STATE[layerId];
if (!state || state.loaded || state.loading) return;
state.loading = true;
updateUIState(layerId, 'LOAD');
const layerConfig = getLayerConfig(layerId);
if (!layerConfig) { updateUIState(layerId, 'FAIL'); state.loading = false; return; }
await networkQueue.add(async () => {
try {
let features = await fetchAndParseGeoJSON(layerConfig.url);
if (features.length === 0) { updateUIState(layerId, 'EMPTY'); state.loading = false; return; }
if (layerConfig.isSubs) globalSubsData = features;
if (layerConfig.snap && globalSubsData) features = snapLines(features, globalSubsData);
const sourceId = getSourceIdForLayer(layerId);
const source = map.getSource(sourceId);
if (!source) { console.error(`[SOURCE MISSING] ${sourceId}`); updateUIState(layerId, 'FAIL'); state.loading = false; return; }
source.setData({ type: 'FeatureCollection', features });
state.loaded = true;
state.loading = false;
updateUIState(layerId, 'OK');
if (REPD_IDS.includes(layerId)) {
REPD_IDS.forEach(id => {
if (RUNTIME_STATE[id]) {
RUNTIME_STATE[id].loaded = true;
RUNTIME_STATE[id].loading = false;
updateUIState(id, 'OK');
}
});
}
} catch (err) {
console.error(`[LAYER FAILED] ${layerId}:`, err);
state.loading = false;
updateUIState(layerId, 'FAIL');
}
});
}
map.on('load', () => {
buildDOM();
map.addSource('sat-s', {
type: 'raster',
tiles: ['https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'],
tileSize: 256
});
map.addLayer({ id: 'l-sat', type: 'raster', source: 'sat-s', layout: { visibility: 'none' } });
const allLayerIds = [];
GRID_CONFIG.forEach(group => {
group.layers.forEach(layer => {
if (REPD_IDS.includes(layer.id)) return;
map.addSource(`src-${layer.id}`, { type: 'geojson', data: { type: 'FeatureCollection', features: [] } });
const layerObject = {
id: `l-${layer.id}`,
type: layer.type === 'line' ? 'line' : 'circle',
source: `src-${layer.id}`,
layout: { visibility: 'none' },
paint: layer.type === 'line'
? { 'line-color': layer.color, 'line-width': layer.width }
: { 'circle-color': layer.color, 'circle-radius': layer.radius, 'circle-stroke-width': 1, 'circle-stroke-color': '#000' }
};
if (layer.filter) layerObject.filter = layer.filter;
map.addLayer(layerObject);
allLayerIds.push(`l-${layer.id}`);
});
});
map.addSource('src-repd', { type: 'geojson', data: { type: 'FeatureCollection', features: [] } });
REPD_IDS.forEach(id => {
const layer = getLayerConfig(id);
if (id === 'solar_roof') {
map.addLayer({
id: `l-${id}-glow`, type: 'circle', source: 'src-repd',
filter: ['all', layer.filter, ['>=', ['coalesce', ['get', 'capacity'], 0], 1.0]],
layout: { visibility: 'none' },
paint: {
'circle-color': ['interpolate', ['linear'], ['coalesce', ['get', 'capacity'], 0],
1.0, '#ff8c00', 5.0, '#ff6600', 10.0, '#ff4400'],
'circle-radius': ['interpolate', ['linear'], ['coalesce', ['get', 'capacity'], 0],
1.0, 26, 2.0, 30, 5.0, 36, 10.0, 44],
'circle-opacity': 0.15, 'circle-blur': 1.0, 'circle-stroke-width': 0
}
});
allLayerIds.push(`l-${id}-glow`);
}
if (id === 'solar') {
map.addLayer({
id: `l-${id}-glow`, type: 'circle', source: 'src-repd',
filter: ['all', layer.filter, ['>=', ['coalesce', ['get', 'capacity'], 0], 4.0]],
layout: { visibility: 'none' },
paint: {
'circle-color': ['interpolate', ['linear'], ['coalesce', ['get', 'capacity'], 0],
4.0, '#ffff00', 20.0, '#ffaa00', 50.0, '#ff4400', 200.0, '#ff0000'],
'circle-radius': ['interpolate', ['linear'], ['coalesce', ['get', 'capacity'], 0],
4.0, 22, 20.0, 32, 50.0, 44, 200.0, 60, 500.0, 80],
'circle-opacity': ['interpolate', ['linear'], ['coalesce', ['get', 'capacity'], 0],
4.0, 0.12, 20.0, 0.18, 50.0, 0.25, 200.0, 0.35],
'circle-blur': 1.0, 'circle-stroke-width': 0
}
});
allLayerIds.push(`l-${id}-glow`);
}
const circlePaint = id === 'solar_roof'
? {
'circle-color': ['interpolate', ['linear'], ['coalesce', ['get', 'capacity'], 0],
0, '#ffcc00', 0.99, '#ffcc00', 1.0, '#ff8c00', 5.0, '#ff6600', 10.0, '#ff4400'],
'circle-radius': ['interpolate', ['linear'], ['coalesce', ['get', 'capacity'], 0],
0, 7, 0.5, 7, 0.99, 8, 1.0, 16, 2.0, 18, 5.0, 22, 10.0, 28],
'circle-stroke-width': ['interpolate', ['linear'], ['coalesce', ['get', 'capacity'], 0],
0, 1, 0.99, 1, 1.0, 2],
'circle-stroke-color': '#000', 'circle-opacity': 0.9
}
: id === 'solar'
? {
'circle-color': ['interpolate', ['linear'], ['coalesce', ['get', 'capacity'], 0],
0, '#ffff00', 20.0, '#ffcc00', 50.0, '#ffaa00', 200.0, '#ff6600', 500.0, '#ff2200'],
'circle-radius': ['interpolate', ['linear'], ['coalesce', ['get', 'capacity'], 0],
0, 8, 10, 10, 50, 13, 200, 17, 500, 22, 1000, 28],
'circle-stroke-width': 1.5, 'circle-stroke-color': '#000', 'circle-opacity': 0.85
}
: {
'circle-color': layer.color,
'circle-radius': ['interpolate', ['linear'], ['coalesce', ['get', 'capacity'], 0],
0, 8, 10, 10, 50, 13, 200, 17, 500, 22, 1000, 28],
'circle-stroke-width': 1.5, 'circle-stroke-color': '#000', 'circle-opacity': 0.85
};
map.addLayer({
id: `l-${id}`, type: 'circle', source: 'src-repd',
filter: layer.filter, layout: { visibility: 'none' }, paint: circlePaint
});
allLayerIds.push(`l-${id}`);
});
map.on('click', e => {
const features = map.queryRenderedFeatures(e.point, { layers: allLayerIds });
if (!features.length) return;
const p = features[0].properties || {};
const name = p.name || p.SiteName || p['Site Name'] || 'Unnamed Asset';
const tech = p.tech || '';
const rawTech = p.raw_tech || tech;
const capacity = parseFloat(p.capacity) || 0;
const status = p.status || '';
const operator = p.operator || '';
const mounting = p.mounting ? ` | ${p.mounting}` : '';
const capStr = capacity ? `${capacity} MW` : '';
const searchBtns = REPD_IDS.includes(tech) ? buildSearchButtons(name, capacity, tech) : '';
new maplibregl.Popup({ maxWidth: '300px' })
.setLngLat(e.lngLat)
.setHTML(`
<div style="font-family:monospace;background:#000;padding:6px">
<b style="color:#00ffff;font-size:13px">${name}</b><br>
<span style="color:#888">${rawTech}${mounting}</span><br>
<span style="color:#ffae00">${capStr}</span>
<span style="color:#666"> | ${status}</span><br>
<span style="color:#555;font-size:10px">${operator}</span>
${searchBtns}
</div>`)
.addTo(map);
});
map.on('mousemove', e => {
const features = map.queryRenderedFeatures(e.point, { layers: allLayerIds });
map.getCanvas().style.cursor = features.length ? 'pointer' : '';
});
GRID_CONFIG.forEach(group => {
group.layers.forEach(layer => { if (layer.preload) hydrateLayer(layer.id); });
});
});
</script>
</body>
</html>
REPD updater added
import pandas as pd
import json
import yaml
import os
import requests
from datetime import datetime
from math import isfinite
from pyproj import Transformer
from bs4 import BeautifulSoup
class REPDUpdater:
"""
VENTUS REPD UPDATER v5.7 | MASTER UNIFIED GEOJSON
Hardened: correct Mounting Type column name, schema validation,
dynamic URL fetching, UK bounds check, case-safe status filter,
EfW/Hydro/AD classification, biomass unit sanity.
"""
REPD_PAGE = "https://www.gov.uk/government/publications/renewable-energy-planning-database-monthly-extract"
UK_LON_MIN, UK_LON_MAX = -9.0, 2.5
UK_LAT_MIN, UK_LAT_MAX = 49.0, 61.0
VIABLE_STATUSES = {
'operational',
'under construction',
'awaiting construction',
'consented',
'planning permission granted',
'planning approved',
'application submitted',
'pre-construction'
}
REQUIRED_COLUMNS = [
'Site Name',
'Technology Type',
'Development Status (short)',
'Installed Capacity (MWelec)',
'X-coordinate',
'Y-coordinate',
'Operator (or Applicant)'
]
OPTIONAL_COLUMNS = [
'Mounting Type for Solar'
]
def __init__(self, registry_path="config/registry.yaml"):
print("📡 VENTUS REPD UPDATER v5.7 | BOOTING SYSTEM...")
try:
with open(registry_path, 'r') as f:
self.config = yaml.safe_load(f)
except FileNotFoundError:
print(f"❌ ERROR: {registry_path} not found.")
exit(1)
self.output_dir = "dist"
self.raw_data_dir = "data"
os.makedirs(self.output_dir, exist_ok=True)
os.makedirs(self.raw_data_dir, exist_ok=True)
self.transformer = Transformer.from_crs("epsg:27700", "epsg:4326", always_xy=True)
# ------------------------------------------------------------------
# Schema validation
# ------------------------------------------------------------------
def validate_schema(self, df):
cols = set(df.columns)
missing_required = [c for c in self.REQUIRED_COLUMNS if c not in cols]
missing_optional = [c for c in self.OPTIONAL_COLUMNS if c not in cols]
if missing_required:
print(f"❌ SCHEMA ERROR — missing required columns: {missing_required}")
print(f" Available columns: {sorted(cols)}")
exit(1)
if missing_optional:
print(f"⚠️ Missing optional columns (degraded output): {missing_optional}")
else:
print(f"✅ Schema valid — all required and optional columns present")
# ------------------------------------------------------------------
# Dynamic URL discovery
# ------------------------------------------------------------------
def discover_latest_url(self):
print("🔍 Discovering latest REPD URL from Gov.uk...")
try:
r = requests.get(self.REPD_PAGE, timeout=30)
r.raise_for_status()
soup = BeautifulSoup(r.text, 'html.parser')
for a in soup.find_all('a', href=True):
href = a['href']
if href.endswith('.csv') and 'repd' in href.lower():
url = href if href.startswith('http') else f"https://www.gov.uk{href}"
print(f"✅ Latest REPD URL: {url}")
return url
print("⚠️ Could not find CSV link — falling back to registry URL")
return None
except Exception as e:
print(f"⚠️ Discovery failed: {e} — falling back to registry URL")
return None
# ------------------------------------------------------------------
# Change detection
# ------------------------------------------------------------------
def already_current(self, url):
manifest_path = f"{self.output_dir}/manifest_v4.json"
if not os.path.exists(manifest_path):
return False
try:
with open(manifest_path) as f:
manifest = json.load(f)
if manifest.get('source_url') == url:
print("✅ REPD unchanged since last sync — skipping pipeline.")
return True
except Exception:
pass
return False
# ------------------------------------------------------------------
# Fetch
# ------------------------------------------------------------------
def fetch_data(self, url):
print(f"📥 FETCHING: {url}")
try:
r = requests.get(url, timeout=60)
r.raise_for_status()
path = f"{self.raw_data_dir}/latest_repd.csv"
with open(path, 'wb') as f:
f.write(r.content)
return path
except Exception as e:
print(f"⚠️ FETCH FAILED: {e}")
return None
# ------------------------------------------------------------------
# Refine
# ------------------------------------------------------------------
def refine_dataset(self, csv_path):
print("🧪 REFINING MASTER DATASET...")
df = pd.read_csv(csv_path, encoding='unicode_escape', on_bad_lines='skip', engine='python')
df.columns = [c.strip() for c in df.columns]
# Schema validation
self.validate_schema(df)
# Detect mounting column — handle both known variants
if 'Mounting Type for Solar' in df.columns:
mounting_col = 'Mounting Type for Solar'
elif 'Mounting Type' in df.columns:
mounting_col = 'Mounting Type'
else:
mounting_col = None
print("⚠️ No mounting type column found — all solar mapped to 'solar'")
print(f"🔍 Mounting column: '{mounting_col}'")
if mounting_col:
print(f"🔍 Mounting values: {df[mounting_col].dropna().unique()}")
print(f"🔍 Tech Types (sample): {df['Technology Type'].dropna().unique()[:20]}")
# Case-safe status filter
df['Development Status (short)'] = (
df['Development Status (short)']
.astype(str).str.strip().str.lower()
)
df = df[df['Development Status (short)'].isin(self.VIABLE_STATUSES)]
print(f"🔍 Rows after status filter: {len(df)}")
features = []
skipped = 0
for _, row in df.iterrows():
try:
# --- Coordinate sanity ---
e = float(row['X-coordinate'])
n = float(row['Y-coordinate'])
if not e or not n or e == 0 or n == 0:
skipped += 1
continue
lon, lat = self.transformer.transform(e, n)
if not (isfinite(lon) and isfinite(lat)):
skipped += 1
continue
# UK bounding box
if not (self.UK_LON_MIN < lon < self.UK_LON_MAX and
self.UK_LAT_MIN < lat < self.UK_LAT_MAX):
skipped += 1
continue
# --- Technology classification ---
tech_raw = str(row.get('Technology Type', '')).strip()
tech_lower = tech_raw.lower()
# Mounting — strip whitespace and lowercase
mounting = ''
if mounting_col:
mounting = str(row.get(mounting_col, '')).strip().lower()
tech_map = 'other'
if 'solar' in tech_lower or 'photovoltaic' in tech_lower:
# 'roof' only → solar_roof
# 'ground & roof', 'ground', 'floating', blank → solar
tech_map = 'solar_roof' if mounting == 'roof' else 'solar'
elif 'wind' in tech_lower:
tech_map = 'wind'
elif 'battery' in tech_lower or 'storage' in tech_lower:
tech_map = 'bess'
elif any(x in tech_lower for x in [
'biomass', 'energy from waste', 'efw', 'incineration',
'anaerobic', 'landfill gas', 'sewage sludge',
'co-firing', 'advanced conversion', 'gasification',
'pyrolysis'
]):
tech_map = 'biomass'
elif 'hydro' in tech_lower:
tech_map = 'hydro'
elif 'tidal' in tech_lower or 'wave' in tech_lower:
tech_map = 'tidal'
elif 'hydrogen' in tech_lower:
tech_map = 'hydrogen'
elif 'flywheel' in tech_lower:
tech_map = 'flywheel'
# --- Capacity with unit sanity ---
try:
capacity = float(row.get('Installed Capacity (MWelec)', 0))
if not isfinite(capacity):
capacity = 0.0
# Physics sanity checks
if tech_map == 'solar_roof' and capacity > 50:
capacity = round(capacity / 1000, 4)
if tech_map == 'biomass' and capacity > 100:
capacity = round(capacity / 1000, 4)
except (ValueError, TypeError):
capacity = 0.0
features.append({
"type": "Feature",
"properties": {
"name": str(row.get('Site Name', 'Unknown')),
"operator": str(row.get('Operator (or Applicant)', 'Unknown')).upper(),
"capacity": capacity,
"status": str(row.get('Development Status (short)', '')).strip(),
"tech": tech_map,
"raw_tech": tech_raw,
"mounting": mounting
},
"geometry": {
"type": "Point",
"coordinates": [round(lon, 6), round(lat, 6)]
}
})
except (ValueError, TypeError):
skipped += 1
continue
print(f"⚠️ Skipped: {skipped}")
tech_counts = {}
for f in features:
t = f['properties']['tech']
tech_counts[t] = tech_counts.get(t, 0) + 1
print(f"📊 Tech distribution: {tech_counts}")
# Warn on 'other' — show what we're dropping
other_count = tech_counts.get('other', 0)
if other_count > 0:
other_techs = set(
f['properties']['raw_tech'] for f in features
if f['properties']['tech'] == 'other'
)
print(f"⚠️ {other_count} features unmapped — raw tech values: {other_techs}")
return {"type": "FeatureCollection", "features": features}
# ------------------------------------------------------------------
# Execute
# ------------------------------------------------------------------
def execute(self):
for layer in self.config['layers']:
if layer['id'] == 'repd' or layer['type'] == 'csv':
# Dynamic discovery — fall back to registry URL
url = self.discover_latest_url() or layer['url']
# Skip if unchanged
if self.already_current(url):
return
local_csv = self.fetch_data(url)
if not local_csv:
return
geojson = self.refine_dataset(local_csv)
output = f"{self.output_dir}/repd_master.json"
with open(output, 'w') as f:
json.dump(geojson, f)
print(f"✅ MASTER SYNC: {len(geojson['features'])} assets.")
manifest = {
"system": "VENTUS_CORE",
"last_sync": datetime.now().isoformat(),
"source_url": url,
"status": "OPERATIONAL"
}
with open(f"{self.output_dir}/manifest_v4.json", 'w') as f:
json.dump(manifest, f, indent=2)
if __name__ == "__main__":
REPDUpdater().execute()
2026-04-03-20:06 Logo added to key and licnese added to root
2/2 heat maps added
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>GlobalGrid2050 | Ventus Core</title>
<link href="https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css" rel="stylesheet" />
<style>
html, body { margin: 0; padding: 0; width: 100%; height: 100%; background: #000; font-family: 'Courier New', monospace; color: white; overflow: hidden; }
.dashboard { display: flex; flex-direction: column; height: 100vh; height: 100dvh; width: 100vw; padding: 4px; gap: 4px; box-sizing: border-box; }
#fatal-banner { display: none; position: fixed; top: 0; left: 0; width: 100%; background: #ff0000; color: #fff; text-align: center; padding: 10px; font-weight: bold; z-index: 9999; text-transform: uppercase; font-size: 12px; letter-spacing: 1px; }
.hud-header { background: #0a0a0a; border: 1px solid #333; border-radius: 6px; padding: 6px 12px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.hud-val { font-size: 16px; font-weight: bold; color: #00ffff; text-shadow: 0 0 5px #00ffff; }
.ventus-brand { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.ventus-main { font-family: -apple-system, sans-serif; font-size: 17px; font-weight: 800; color: #fff; letter-spacing: 5px; text-transform: uppercase; margin-bottom: 2px; }
.ventus-sub { font-family: -apple-system, sans-serif; font-size: 6.5px; color: #888; letter-spacing: 2px; text-transform: uppercase; }
.map-container { position: relative; flex-grow: 1; min-height: 0; border: 1px solid #222; border-radius: 6px; overflow: hidden; background: #0b0e14; }
#map { width: 100%; height: 100%; }
.podcast-shoutout { position: absolute; bottom: 6px; right: 8px; font-family: -apple-system, sans-serif; font-size: 8px; color: #fff; opacity: 0.5; text-align: right; text-transform: uppercase; letter-spacing: 1px; pointer-events: none; z-index: 10; text-shadow: 1px 1px 2px #000; }
.scada-wrapper { background: #050505; border: 1px solid #444; border-radius: 6px; padding: 12px; display: flex; flex-direction: column; flex-shrink: 0; max-height: 38vh; }
.scada-brand { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid #222; flex-shrink: 0; }
.scada-brand-main { font-family: -apple-system, sans-serif; font-size: 11px; font-weight: 800; color: #fff; letter-spacing: 4px; text-transform: uppercase; }
.scada-brand-sub { font-family: -apple-system, sans-serif; font-size: 6px; color: #555; letter-spacing: 2px; text-transform: uppercase; }
.scada-brand-tag { margin-left: auto; font-family: 'Courier New', monospace; font-size: 7px; color: #333; text-transform: uppercase; letter-spacing: 1px; }
.scada-keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; overflow-y: auto; padding-bottom: 5px; }
.key-group { border-left: 2px solid #333; padding-left: 10px; margin-bottom: 4px; }
.key-title { font-size: 10px; color: #66ccff; text-transform: uppercase; margin-bottom: 6px; font-weight: bold; }
.key-item { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 8px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { transform: scale(1.3); margin-right: 4px; accent-color: #00ffff; }
.maplibregl-popup-content { background: #000; color: #00ffff; border: 1px solid #444; font-family: monospace; font-size: 12px; padding: 8px; }
.disclaimer-box { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; text-align: justify; font-size: 9px; line-height: 1.5; color: #666; margin-top: 10px; padding-top: 10px; border-top: 1px solid #222; user-select: none; pointer-events: none; flex-shrink: 0; }
.custom-map-attrib { position: absolute; top: 10px; left: 10px; background: rgba(5, 5, 5, 0.7); color: #888; font-family: 'Courier New', monospace; font-size: 9px; border-radius: 4px; padding: 4px 8px; z-index: 10; border: 1px solid #333; pointer-events: auto; }
.custom-map-attrib a { color: #00ffff; text-decoration: none; }
.custom-map-attrib a:hover { text-decoration: underline; }
.popup-search-btns { display: flex; gap: 6px; margin-top: 8px; }
.popup-btn { flex: 1; padding: 5px 0; font-family: monospace; font-size: 11px; font-weight: bold; border: 1px solid #444; border-radius: 3px; cursor: pointer; text-align: center; text-decoration: none; display: block; transition: border-color 0.15s, color 0.15s; }
.popup-btn-news { background: #0a0a0a; color: #ffae00; border-color: #ffae00; }
.popup-btn-news:hover { background: #ffae00; color: #000; }
.popup-btn-images { background: #0a0a0a; color: #00ffff; border-color: #00ffff; }
.popup-btn-images:hover { background: #00ffff; color: #000; }
</style>
</head>
<body>
<div id="fatal-banner">CRITICAL ERROR: SYSTEM DEPENDENCIES FAILED TO LOAD</div>
<div class="dashboard">
<div class="hud-header">
<div>
<small style="color:#888">SYSTEM TIME</small><br>
<span class="hud-val" id="clock">--:--:--</span><br>
<span id="date" style="font-size: 11px; color: #888;">--/--/----</span>
</div>
<div class="ventus-brand">
<div class="ventus-main">Ventus</div>
<div class="ventus-sub">Cables & Connectivity®</div>
</div>
<div style="text-align:right"><small style="color:#888">2050 TARGET</small><br><span class="hud-val" id="days" style="color:#ff9d00">-- DAYS</span></div>
</div>
<div class="map-container">
<div id="map"></div>
<div class="custom-map-attrib">
Data © <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener noreferrer">OpenStreetMap contributors | openstreetmap.org</a> | © CARTO
</div>
<div class="podcast-shoutout">In support of The Future of Solar Photovoltaics podcast<br>& all participants to date</div>
</div>
<div class="scada-wrapper">
<div class="scada-brand">
<div>
<div class="scada-brand-main">Ventus</div>
<div class="scada-brand-sub">Cables & Connectivity®</div>
</div>
<div class="scada-brand-tag">globalgrid2050.com | open infrastructure intelligence</div>
</div>
<div class="scada-keys" id="scada-ui-container"></div>
<div class="disclaimer-box">
This interface is based on publicly available and open source infrastructure data, including public energy datasets such as REPD where applicable. It is presented for analytical and visualisation purposes only and does not include live operational or other non public operational data.
</div>
</div>
</div>
<script src="https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.js"></script>
<script>
'use strict';
if (typeof maplibregl === 'undefined') {
document.getElementById('fatal-banner').style.display = 'block';
throw new Error('CRITICAL: MapLibre failed to load.');
}
function deepFreeze(obj) {
Object.keys(obj).forEach(prop => {
if (typeof obj[prop] === 'object' && obj[prop] !== null) deepFreeze(obj[prop]);
});
return Object.freeze(obj);
}
const GRID_CONFIG = deepFreeze([
{
group: "Topology (GeoJSON)",
layers: [
{ id: "400", label: "400kV", color: "#0054ff", type: "line", width: 2.5, url: "/grid_400kv.geojson", snap: true, preload: true },
{ id: "275", label: "275kV", color: "#ff0000", type: "line", width: 2.0, url: "/grid_275kv.geojson", snap: true, preload: true },
{ id: "220", label: "220kV", color: "#ff9900", type: "line", width: 1.8, url: "/grid_220kv.geojson", snap: true, preload: true },
{ id: "132", label: "132kV", color: "#00cc00", type: "line", width: 1.5, url: "/grid_132kv.geojson", snap: true, preload: true },
{ id: "66", label: "66kV", color: "#b200ff", type: "line", width: 1.2, url: "/grid_66kv.geojson", snap: true, preload: true },
{ id: "subs", label: "Subs", color: "#ffffff", type: "point", radius: 4.5, url: "/grid_substations.geojson", isSubs: true, preload: true }
]
},
{
group: "Assets (GeoJSON)",
layers: [
{ id: "nuc", label: "Nuclear", color: "#39ff14", type: "point", radius: 4.5, url: "/power_plants.geojson", filter: ['==', ['get', 'source'], 'nuclear'], preload: true },
{ id: "gas", label: "Gas", color: "#ff4500", type: "point", radius: 4.5, url: "/power_plants.geojson", filter: ['!=', ['get', 'source'], 'nuclear'], preload: true },
{ id: "ind", label: "Industry", color: "#ff6600", type: "point", radius: 4.5, url: "/industrial_offtakers.geojson", preload: true },
{ id: "dc", label: "Data Ctrs", color: "#00ffff", type: "point", radius: 4.5, url: "/datacentres.geojson", preload: true },
{ id: "air", label: "Airports", color: "#ff00ff", type: "point", radius: 4.5, url: "/airports.geojson", preload: true },
{ id: "rail", label: "Railways", color: "#ffd700", type: "point", radius: 4.5, url: "/railways.geojson", preload: true }
]
},
{
group: "REPD (GeoJSON)",
layers: [
{ id: "solar", label: "Solar PV", color: "#ffff00", type: "point", radius: 8, url: "/dist/repd_master.json", filter: ['==', ['get', 'tech'], 'solar'], preload: false },
{ id: "solar_roof", label: "Solar Roof", color: "#ffcc00", type: "point", radius: 14, url: "/dist/repd_master.json", filter: ['==', ['get', 'tech'], 'solar_roof'], preload: false },
{ id: "wind", label: "Wind", color: "#00ffff", type: "point", radius: 8, url: "/dist/repd_master.json", filter: ['==', ['get', 'tech'], 'wind'], preload: false },
{ id: "bess", label: "BESS", color: "#ffae00", type: "point", radius: 8, url: "/dist/repd_master.json", filter: ['==', ['get', 'tech'], 'bess'], preload: false },
{ id: "biomass", label: "Biomass", color: "#39ff14", type: "point", radius: 8, url: "/dist/repd_master.json", filter: ['==', ['get', 'tech'], 'biomass'], preload: false },
{ id: "tidal", label: "Tidal/Wave", color: "#00bfff", type: "point", radius: 8, url: "/dist/repd_master.json", filter: ['==', ['get', 'tech'], 'tidal'], preload: false },
{ id: "hydrogen", label: "Hydrogen", color: "#ffffff", type: "point", radius: 8, url: "/dist/repd_master.json", filter: ['==', ['get', 'tech'], 'hydrogen'], preload: false },
{ id: "flywheel", label: "Flywheel", color: "#ff69b4", type: "point", radius: 8, url: "/dist/repd_master.json", filter: ['==', ['get', 'tech'], 'flywheel'], preload: false },
{ id: "hydro", label: "Hydro", color: "#00aaff", type: "point", radius: 8, url: "/dist/repd_master.json", filter: ['==', ['get', 'tech'], 'hydro'], preload: false }
]
}
]);
const REPD_IDS = ['solar', 'solar_roof', 'wind', 'bess', 'biomass', 'tidal', 'hydrogen', 'flywheel', 'hydro'];
const SEARCH_THRESHOLD = {
'solar': 50,
'solar_roof': 0.5,
'wind': 50,
'bess': 50,
'biomass': 50,
'tidal': 50,
'hydrogen': 50,
'flywheel': 50,