In this section
- GIS Single-Line Diagram (SLD) V5 Map electrical · globalgrid2050 / solar-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-map.js lines 404–427
- GIS Single-Line Diagram (SLD) V5 State electrical · globalgrid2050 / solar-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-state.js lines 1–28
- GIS Single-Line Diagram (SLD) V5 Substations electrical · globalgrid2050 / solar-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-substations.js lines 1–83
- GIS Single-Line Diagram (SLD) V5 UI Core electrical · globalgrid2050 / solar-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-ui-core.js lines 1–127
- GIS Single-Line Diagram (SLD) V5 UI electrical · globalgrid2050 / solar-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-ui.js lines 1–438
GIS Single-Line Diagram (SLD) V5 Map
A JavaScript file in the GIS SLD financial sandbox folder of GlobalGrid2050 that maps atlas grid 66kV line and atlas grid 132kV line. Served with the page at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
electricalglobalgrid2050 / solar-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-map.js · lines 404–427 of 427 (continued from section 89) · Entry point · pattern toggleAtlasV8OperatingAssetLayer (shared by 2 files)
- What it does
- It maps atlas grid 66kV line, atlas grid 132kV line, atlas grid 275kV line and atlas grid 400kV line. Defines 10 functions or classes, including toggleAtlasV8OperatingAssetLayer, toggleAtlasV8GridLayer, initMap, onMapLoad, showPopup. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: 400kV, 275kV, 132kV, 66kV, 33kV.
- Inputs & outputs
- In: JSON file style.json; GeoJSON file grid_66kv.geojson; GeoJSON file grid_132kv.geojson; GeoJSON file grid_275kv.geojson; GeoJSON file grid_400kv.geojson; JSON file repd_master.json. Out: interactive map. Voltage levels named: 400kV, 275kV, 132kV, 66kV, 33kV.
- Downstream impact
- Used directly by 1 file: Solar Battery Energy Storage System (BESS) Topology V6 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/). Reached from 4 other entry points, including GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V6 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/); Solar Battery Energy Storage System (BESS) Topology V6 — Cable Geometry Visualiser Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/cable-geometry-visualiser/); Solar Battery Energy Storage System (BESS) Topology V6 — DC AC LV Topology Review Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/dc-ac-lv-topology-review/). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
- What it achieves
- It toggles atlas v8 grid layer (`toggleAtlasV8GridLayer`) and shows popup (`showPopup`). Defines `toggleAtlasV8OperatingAssetLayer`, `toggleAtlasV8GridLayer`, `initMap` and 7 more.
- Why it matters
- Loaded by the GIS Single-Line Diagram (SLD) Financial Sandbox page at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
- Application
- globalgrid2050 · solar-bess-topology-v6/gis-sld-financial-sandbox · script
- Uses
- none found
- Used by
- loaded by Solar Battery Energy Storage System (BESS) Topology V6 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (script src)
- Produces
- toggleAtlasV8OperatingAssetLayer, toggleAtlasV8GridLayer, initMap, onMapLoad, showPopup, onSubstationClick, onInverterClick, onCableRoutePinClick, onOperatingAssetClick, onPoiClick
- Defines here
- onPoiClick
- 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-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-map.js:404-427 · blob 57b562ff006c7098451eb446d54a979999b2ac1a · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: production_core
const tech = pickProp(prop, ["raw_tech", "tech", "technology", "Technology Type"], "Unknown technology");
const status = pickProp(prop, ["status", "Status"], "Unknown status");
const capacity = pickProp(prop, ["capacity", "capacity_mw", "Installed Capacity (MWelec)", "Capacity (MW)"], "n/a");
showPopup(coords, `
<div style="margin-bottom:5px;color:#00ff88;font-weight:bold;font-size:13px;text-transform:uppercase;">Operating Asset</div>
<div class="popup-row"><span>Name:</span><span class="popup-val" style="color:#fff;">${name}</span></div>
<div class="popup-row"><span>Technology:</span><span class="popup-val" style="color:#fff;">${tech}</span></div>
<div class="popup-row"><span>Status:</span><span class="popup-val" style="color:#fff;">${status}</span></div>
<div class="popup-row"><span>Capacity:</span><span class="popup-val" style="color:#fff;">${capacity} MW</span></div>
`);
}
function onPoiClick(e) {
const prop = e.features[0].properties;
const coords = e.features[0].geometry.coordinates.slice();
const title = prop.type === "poi" ? "Point of Interconnection" : "Customer Substation";
const colour = prop.type === "poi" ? "#ff3333" : "#00ff88";
let html = `<div style="margin-bottom:5px;color:${colour};font-weight:bold;font-size:13px;text-transform:uppercase;">${title}</div>`;
if (prop.selected_substation_name) html += `<div class="popup-row"><span>Name:</span><span class="popup-val" style="color:#fff;">${prop.selected_substation_name}</span></div>`;
if (prop.selected_substation_voltage) html += `<div class="popup-row"><span>Voltage:</span><span class="popup-val" style="color:#fff;">${prop.selected_substation_voltage}</span></div>`;
showPopup(coords, html);
}
// ============================================================GIS Single-Line Diagram (SLD) V5 State
A JavaScript file in the GIS SLD financial sandbox folder of GlobalGrid2050. Served with the page at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
electricalglobalgrid2050 / solar-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-state.js · lines 1–28 of 28 · Entry point
- Why it exists in the grid workflow
- Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow.
- Downstream impact
- Used directly by 1 file: Solar Battery Energy Storage System (BESS) Topology V6 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/). Reached from 4 other entry points, including GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V6 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/); Solar Battery Energy Storage System (BESS) Topology V6 — Cable Geometry Visualiser Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/cable-geometry-visualiser/); Solar Battery Energy Storage System (BESS) Topology V6 — DC AC LV Topology Review Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/dc-ac-lv-topology-review/). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
- What it achieves
- GIS SLD Financial Sandbox V6. State extracted by GridBot feature 004.
- Why it matters
- Loaded by the GIS Single-Line Diagram (SLD) Financial Sandbox page at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
- Application
- globalgrid2050 · solar-bess-topology-v6/gis-sld-financial-sandbox · script
- Uses
- none found
- Used by
- loaded by Solar Battery Energy Storage System (BESS) Topology V6 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (script src)
- 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-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-state.js:1-28 · blob 41b4ff913f22e9e27c4ed949907f16f930eb6e88 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: experimental · users: none · canonical: production_core
"use strict";
// GIS SLD Financial Sandbox V6
// State extracted by GridBot feature 004.
// Must load after config and helpers, and before the inline app script.
const state = {
activeTab: "string",
currentGeoJSON: { type: "FeatureCollection", features: [] },
activeDrawCenter: null,
selectedSubstation: null,
subsVisible: false,
satActive: false,
activePopup: null,
lastStats: null,
lastFinance: { fin_string: null, fin_central: null },
arrayMoveMode: false,
arrayOverrideCenter: null,
arrayRotationDeg: 0,
exportCableLengthKm: 0,
cableRoutePinMode: false,
cableRoutePins: [],
cableRouteCommitted: false,
suppressNextMapFit: false,
// Legacy aliases retained for older export and drawing logic if needed.
cableRouteMode: false,
cableRouteWaypoints: []
};GIS Single-Line Diagram (SLD) V5 Substations
A JavaScript file in the GIS SLD financial sandbox folder of GlobalGrid2050 that fetches substations. Served with the page at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/. It normalises substations (`normaliseSubstations`) and loads substations (`loadSubstations`).
Set aside from the main view: 96% of its lines are the same as feature_requests/005_extract_v2_substation_data/files/solar-bess-topology-v2/gis-sld-v2-substations.js (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 96% of lines shared with GIS Single-Line Diagram (SLD) V5 Substations; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9643 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 feature_requests/005_extract_v2_substation_data/files/solar-bess-topology-v2/gis-sld-v2-substations.js:1-83 914c0ad9fd2b1b3006858ad3b20e5d328252e85d
- sha256 924327348899bf2723da793a65e7d5907006dc6dcdf1c6f1c63d70e9a192d96f
- target sha256 f73fc672ab0d11720a53279d0663d6f2ad9f525d3aa0535608aa7031a72e9c41
- group of 6 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
- re-pointed by apply.py version rule from file 136 to file 259; similarity was measured to file 136
electricalglobalgrid2050 / solar-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-substations.js · lines 1–83 of 83 · Entry point · pattern normaliseSubstations (shared by 7 files)
- What it does
- It fetches substations. Defines normaliseSubstations, loadSubstations. Side effects: makes network requests.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: substations.
- Downstream impact
- Used directly by 1 file: Solar Battery Energy Storage System (BESS) Topology V6 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/). Reached from 4 other entry points, including GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V6 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/); Solar Battery Energy Storage System (BESS) Topology V6 — Cable Geometry Visualiser Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/cable-geometry-visualiser/); Solar Battery Energy Storage System (BESS) Topology V6 — DC AC LV Topology Review Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/dc-ac-lv-topology-review/). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
- What it achieves
- GIS SLD Financial Sandbox V6. Substation data loading extracted by GridBot feature 005.
- Why it matters
- Loaded by the GIS Single-Line Diagram (SLD) Financial Sandbox page at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
- Application
- globalgrid2050 · solar-bess-topology-v6/gis-sld-financial-sandbox · script
- Uses
- none found
- Used by
- loaded by Solar Battery Energy Storage System (BESS) Topology V6 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (script src)
- Produces
- normaliseSubstations, loadSubstations
- Defines here
- normaliseSubstations, loadSubstations
- 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-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-substations.js:1-83 · blob 721e89abb8e55423f9824a94664d34bb00b903bf · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: network · domain stage: experimental · users: ICP_grid_engineer · canonical: production_core
"use strict";
// GIS SLD Financial Sandbox V6
// Substation data loading extracted by GridBot feature 005.
// Must load after config, helpers and state, and before the inline app script.
function normaliseSubstations(raw) {
if (!raw) throw new Error("Empty dataset");
let features = [];
if (raw.type === "FeatureCollection" && Array.isArray(raw.features)) {
features = raw.features;
} else if (Array.isArray(raw)) {
features = raw.map(item => ({
type: "Feature",
geometry: item.geometry || {
type: "Point",
coordinates: [
item.lon ?? item.lng ?? item.longitude ?? item.Longitude ?? item.X,
item.lat ?? item.latitude ?? item.Latitude ?? item.Y
]
},
properties: item.properties || item
}));
} else {
throw new Error("Not a FeatureCollection or array");
}
const cleaned = features
.filter(f => f && f.geometry && f.geometry.type === "Point")
.map(f => {
const c = f.geometry.coordinates.map(Number);
if (!isValidLngLat(c)) return null;
const p = f.properties || {};
return {
type: "Feature",
geometry: { type: "Point", coordinates: [c[0], c[1]] },
properties: {
...p,
name_clean: pickProp(
p,
["name", "Name", "site_name", "SiteName", "Site Name", "substation", "Substation", "substation_name", "Substation Name"],
"Substation"
),
voltage_clean: pickProp(
p,
["voltage", "Voltage", "kv", "kV", "KV", "voltage_kv", "Voltage kV"],
"Unknown"
)
}
};
})
.filter(Boolean);
return { type: "FeatureCollection", features: cleaned };
}
async function loadSubstations() {
setFetchStatus("Loading substations…", false);
try {
const url = SUBSTATIONS_URL + (SUBSTATIONS_URL.includes("?") ? "&" : "?") + "v=" + Date.now();
const res = await fetch(url);
if (!res.ok) throw new Error("HTTP " + res.status);
const raw = await res.json();
const cleaned = normaliseSubstations(raw);
const src = map.getSource("src-subs");
if (src) src.setData(cleaned);
console.log("Substations loaded:", cleaned.features.length);
setFetchStatus(`${cleaned.features.length.toLocaleString()} substations loaded`, false);
setTimeout(() => setFetchStatus("", false), 2500);
} catch (err) {
console.error("Substation load failed:", err);
setFetchStatus(`Substations unavailable: ${err.message}. Check SUBSTATIONS_URL.`, true);
}
}GIS Single-Line Diagram (SLD) V5 UI Core
A JavaScript file in GlobalGrid2050 that renders tech summary and benchmark and updates selected substation display, covering substations. Served with the page at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
electricalglobalgrid2050 / solar-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-ui-core.js · lines 1–127 of 127 · Entry point · pattern updateSelectedSubstationDisplay (shared by 5 files)
- What it does
- It draws substations, battery storage (BESS), 66kV and 132kV. Defines 7 functions or classes, including renderTechSummary, renderBenchmark, updateSelectedSubstationDisplay, recalcAll, atlasV8LegendItem. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: substations, battery storage (BESS), 66kV, 132kV, 400kV, 275kV.
- Inputs & outputs
- Voltage levels named: 400kV, 275kV, 132kV, 66kV, 33kV.
- Downstream impact
- Used directly by 4 files: Solar Battery Energy Storage System (BESS) Topology V6 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/); Solar Battery Energy Storage System (BESS) Topology V7 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v7/gis-sld-financial-sandbox/); Solar Battery Energy Storage System (BESS) Topology V7 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (globalgrid2050, https://globalgrid2050.com/testcode/202609052011/layer-apps/solar-bess-topology-v7/gis-sld-financial-sandbox/); Solar Battery Energy Storage System (BESS) Topology V7 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (testcode). Reached from 149 other entry points, including Iterations — 43 Registry Growth Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/43-registry-growth/); Iterations — 47 Federation Honesty Page (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/iterations/47-federation-honesty/); Demonstration Videos (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v7/docs/demonstration-videos.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
- What it achieves
- It renders tech summary (`renderTechSummary`), renders benchmark (`renderBenchmark`) and updates selected substation display (`updateSelectedSubstationDisplay`). Defines `renderTechSummary`, `renderBenchmark`, `updateSelectedSubstationDisplay` and 4 more. Its code works with 33 kV, 132 kV and 275 kV.
- Why it matters
- Loaded by the GIS Single-Line Diagram (SLD) Financial Sandbox page at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/ and 3 other pages.
- Application
- globalgrid2050 · solar-bess-topology-v6/gis-sld-financial-sandbox · script
- Uses
- none found
- Used by
- loaded by Solar Battery Energy Storage System (BESS) Topology V6 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (script src), loaded by Solar Battery Energy Storage System (BESS) Topology V7 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (script src), loaded by Solar Battery Energy Storage System (BESS) Topology V7 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (script src), loaded by Solar Battery Energy Storage System (BESS) Topology V7 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (script src)
- Produces
- renderTechSummary, renderBenchmark, updateSelectedSubstationDisplay, recalcAll, atlasV8LegendItem, atlasV8AssetLegendItem, updateLegend
- Defines here
- renderTechSummary, renderBenchmark, updateSelectedSubstationDisplay, recalcAll, atlasV8LegendItem, atlasV8AssetLegendItem, updateLegend
- 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-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-ui-core.js:1-127 · blob 10f5809cb909c42198bec054e86037eba2b5594b · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: experimental · users: none · canonical: production_core
"use strict";
// RENDER TECHNICAL SUMMARY
// ============================================================
function renderTechSummary(stats) {
setText("out_module_count", stats.module_count.toLocaleString());
setText("out_dc_capacity", stats.dc_mwp.toFixed(2) + " MWp");
setText("out_ac_capacity", stats.ac_mw.toFixed(2) + " MWac");
setText("out_actual_dcac", stats.dc_ac_ratio.toFixed(2));
setText("out_cb_per_inv", stats.combiner_boxes_per_inverter.toLocaleString());
setText("out_total_cb", stats.total_combiner_boxes.toLocaleString());
setText("out_string_inv_rating", stats.string_inverter_kva ? stats.string_inverter_kva.toFixed(0) + " kVA" : "n/a");
setText("out_inverter_acmax_mva", stats.inverter_acmax_mva ? stats.inverter_acmax_mva.toFixed(2) + " MVA" : "n/a");
setText("out_sub_ac_rating", stats.production_substation_ac_mva.toFixed(2) + " MVA");
setText("out_ring_ac_rating", stats.ring_main_ac_mva.toFixed(2) + " MVA");
setText("out_central_inv_dc_rating", stats.central_inverter_mwdc.toFixed(2) + " MWdc");
setText("out_central_inv_rating", stats.central_inverter_mwac.toFixed(2) + " MWac");
setText("out_cb_dc_kw", stats.combiner_box_dc_kw.toFixed(2) + " kWdc");
setText("out_engineering_warning", stats.engineering_warning || "Check assumptions");
setText("out_net_mod_area", (stats.net_mod_area_m2 / CONSTANTS.M2_PER_ACRE).toFixed(0) + " Acres");
setText("out_net_array_area", (stats.net_array_area_m2 / CONSTANTS.M2_PER_ACRE).toFixed(0) + " Acres");
setText("out_gross_area", (stats.gross_site_area_m2 / CONSTANTS.M2_PER_ACRE).toFixed(0) + " Acres");
setText("out_mod_per_pallet", stats.mods_pallet);
setText("out_pallets", stats.pallets.toLocaleString());
setText("out_mod_per_cont", stats.mods_container);
setText("out_containers", stats.containers.toLocaleString());
setText("out_spare_pct", stats.spares_pct.toFixed(1) + "%");
setText("out_containers_spares", stats.containers_inc_spares.toLocaleString());
const tabClass = state.activeTab === "central" ? "stat-val orange" : "stat-val cyan";
setClass("out_dc_capacity", tabClass);
setClass("out_containers_spares", tabClass);
const cpm = stats.dc_mwp > 0 ? stats.containers_inc_spares / stats.dc_mwp : 0;
setText("out_cont_per_mwp", cpm.toFixed(2));
setClass("out_cont_per_mwp", tabClass);
}
function renderBenchmark() {
const mw = num("ref_mw"), mods = num("ref_modules");
const implied = mw > 0 ? mods / mw : 0;
setText("out_ref_implied", `~ ${Math.round(implied).toLocaleString()} modules/MW`);
}
function updateSelectedSubstationDisplay() {
const s = state.selectedSubstation;
if (!s) {
setText("out_selected_sub_name", "None selected");
setText("out_selected_sub_voltage", "Unknown");
setText("out_selected_sub_lon", "n/a");
setText("out_selected_sub_lat", "n/a");
return;
}
setText("out_selected_sub_name", s.name || "Selected Substation");
setText("out_selected_sub_voltage", s.voltage || "Unknown");
setText("out_selected_sub_lon", s.coordinates ? Number(s.coordinates[0]).toFixed(6) : "n/a");
setText("out_selected_sub_lat", s.coordinates ? Number(s.coordinates[1]).toFixed(6) : "n/a");
}
// ============================================================
// MAIN RECALC
// ============================================================
function recalcAll() {
const stats = computeStats();
state.lastStats = stats;
renderTechSummary(stats);
const prefix = state.activeTab === "string" ? "fin_string" : "fin_central";
const fin = computeFinance(prefix, stats);
state.lastFinance[prefix] = fin;
renderFinance(prefix, fin);
renderFinanceWarnings(prefix, fin, stats);
renderBenchmark();
updateSelectedSubstationDisplay();
}
const recalcDebounced = debounce(recalcAll, CONSTANTS.RECALC_DEBOUNCE_MS);
// ============================================================
// LEGEND
// ============================================================
function atlasV8LegendItem(voltageKey, label, colour, widthPx) {
const visible = atlasV8GridLayerVisibility?.[voltageKey] !== false;
const opacity = visible ? "1" : "0.35";
const suffix = visible ? "" : " OFF";
return `<div class="legend-item" onclick="toggleAtlasV8GridLayer('${voltageKey}')" style="cursor:pointer; opacity:${opacity};" title="Tap to toggle ${label}"><div class="swatch" style="background:transparent; border-bottom: ${widthPx}px solid ${colour};"></div> ${label}${suffix}</div>`;
}
function atlasV8AssetLegendItem(assetKey, label, colour) {
const visible = atlasV8OperatingAssetVisibility?.[assetKey] === true;
const opacity = visible ? "1" : "0.35";
const suffix = visible ? "" : " OFF";
return `<div class="legend-item" onclick="toggleAtlasV8OperatingAssetLayer('${assetKey}'); updateAtlasV8OperatingAssetToggleButtons?.();" style="cursor:pointer; opacity:${opacity};" title="Tap to toggle ${label}"><div class="swatch" style="background:${colour}; border-color:#111;"></div> ${label}${suffix}</div>`;
}
function updateLegend() {
const legend = $("map_legend");
if (!legend) return;
let html = `
<div class="legend-item"><div class="swatch" style="background:#ffffff; border-color:#ff3333;"></div> Atlas Substation Dataset</div>
${atlasV8LegendItem("66kv", "Atlas V8 66 kV Lines", "#66ff66", 2)}
${atlasV8LegendItem("132kv", "Atlas V8 132 kV Lines", "#ffcc00", 2)}
${atlasV8LegendItem("275kv", "Atlas V8 275 kV Lines", "#ff66ff", 3)}
${atlasV8LegendItem("400kv", "Atlas V8 400 kV Lines", "#ff3333", 3)}
${atlasV8AssetLegendItem("solar_operational", "Operating Solar PV", "#00ff88")}
${atlasV8AssetLegendItem("wind_onshore_operational", "Operating Onshore Wind", "#00ffcc")}
${atlasV8AssetLegendItem("wind_offshore_operational", "Operating Offshore Wind", "#0066ff")}
${atlasV8AssetLegendItem("bess_operational", "Operating Battery Storage", "#ff69b4")}
<div class="legend-item"><div class="swatch" style="background:var(--substation);"></div> Point of Interconnection</div>
<div class="legend-item"><div class="swatch" style="background:transparent; border-bottom: 2px dashed var(--substation);"></div> Export Cable</div>
<div class="legend-item"><div class="swatch" style="background:var(--private-sub);"></div> Customer Substation</div>
<div class="legend-item"><div class="swatch" style="background:var(--bess);"></div> BESS Compound</div>
<div class="legend-item"><div class="swatch" style="background:var(--array-blue); opacity: 0.3; border-style: dashed;"></div> Total Array Boundary</div>`;
if (state.activeTab === "string") {
html += `<div class="legend-item"><div class="swatch" style="background:var(--inverter);"></div> String Substation Block</div>
<div class="legend-item"><div class="swatch" style="background:transparent; border-bottom: 2px solid var(--accent);"></div> Radial 33kV Spine</div>`;
} else {
html += `<div class="legend-item"><div class="swatch" style="background:var(--accent-alt);"></div> Central Inverter Block</div>
<div class="legend-item"><div class="swatch" style="background:transparent; border-bottom: 2px solid var(--accent);"></div> Radial 33kV Spine</div>`;
}
legend.innerHTML = html;
}
// ============================================================GIS Single-Line Diagram (SLD) V5 UI
A JavaScript file in the GIS SLD financial sandbox folder of GlobalGrid2050 covering cables and 66kV, using haversine, and uses data from OpenStreetMap Nominatim. Served with the page at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
electricalglobalgrid2050 / solar-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-ui.js · lines 1–438 of 808 · Entry point · pattern updateAtlasV8OperatingAssetToggleButtons (shared by 3 files)
- What it does
- It draws cables, 66kV, 132kV and 275kV. Defines 55 functions or classes, including switchTab, applyLogisticsPreset, autoFillBifacial, updateExportCableLengthDisplay, updateArrayRotationDisplay. Side effects: changes the web page (DOM); makes network requests.
- Why it exists in the grid workflow
- Domain stage experimental (path word 'sandbox'): work its own path marks as experimental (sandbox, prototype, archive or similar words); by this evidence it is not part of a production workflow. Domain terms in the code: cables, 66kV, 132kV, 275kV, 400kV.
- Inputs & outputs
- In: data source: OpenStreetMap Nominatim; form fields (user input). Voltage levels named: 400kV, 275kV, 132kV, 66kV.
- Downstream impact
- Used directly by 1 file: Solar Battery Energy Storage System (BESS) Topology V6 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/). Reached from 4 other entry points, including GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V6 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/); Solar Battery Energy Storage System (BESS) Topology V6 — Cable Geometry Visualiser Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/cable-geometry-visualiser/); Solar Battery Energy Storage System (BESS) Topology V6 — DC AC LV Topology Review Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/dc-ac-lv-topology-review/). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
- What it achieves
- It applies logistics preset (`applyLogisticsPreset`), updates export cable length display (`updateExportCableLengthDisplay`) and updates array rotation display (`updateArrayRotationDisplay`). Defines `switchTab`, `applyLogisticsPreset`, `autoFillBifacial` and 52 more. Its code works with 132 kV, 275 kV and 400 kV. It responds to click, keydown and change events.
- Why it matters
- Loaded by the GIS Single-Line Diagram (SLD) Financial Sandbox page at https://globalgrid2050.com/solar-bess-topology-v6/gis-sld-financial-sandbox/.
- Application
- globalgrid2050 · solar-bess-topology-v6/gis-sld-financial-sandbox · script
- Uses
- none found
- Used by
- loaded by Solar Battery Energy Storage System (BESS) Topology V6 — GIS Single-Line Diagram (SLD) Financial Sandbox Page (script src)
- Produces
- switchTab, applyLogisticsPreset, autoFillBifacial, updateExportCableLengthDisplay, updateArrayRotationDisplay, rotateArrayBy, resetArrayRotation, getCurrentArrayCenter, getArrayNudgeStepKm, clearRouteAfterArrayShift, nudgeArray, updateCableRouteStatus
- Defines here
- switchTab, applyLogisticsPreset, autoFillBifacial, updateExportCableLengthDisplay, updateArrayRotationDisplay, rotateArrayBy, resetArrayRotation, getCurrentArrayCenter, getArrayNudgeStepKm, clearRouteAfterArrayShift, nudgeArray, updateCableRouteStatus, injectExportCableLengthControl, redrawIfTopologyExists, setArrayMoveStatus, toggleArrayMoveMode, resetArrayLocation, placeArrayAtMapPoint, toggleCablePinMode, commitCablePinRoute, undoCablePin, clearCableRoute, addCableRoutePin, startCableRouteMode, finishCableRouteMode, addCableRouteWaypoint, searchLocation, triggerDrawAtCenter, toggleBasemap, toggleSubs
- 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-bess-topology-v6/gis-sld-financial-sandbox/gis-sld-v5-ui.js:1-438 · blob b65b6bce00e25824d99c55aa431aeb71b4883a33 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom, network · domain stage: experimental · users: none · canonical: production_core
"use strict";
// TAB SWITCHING
// ============================================================
function switchTab(tab) {
state.activeTab = tab;
$("tabbtn_string")?.classList.toggle("active", tab === "string");
$("tabbtn_central")?.classList.toggle("active", tab === "central");
$("string_tab")?.classList.toggle("active", tab === "string");
$("central_tab")?.classList.toggle("active", tab === "central");
$("btn_draw")?.classList.toggle("central", tab === "central");
document.querySelectorAll(".central-only").forEach(el => {
el.style.display = tab === "central" ? "flex" : "none";
});
updateLegend();
if (state.activeDrawCenter) computeAndDraw();
else recalcAll();
}
// ============================================================
// LOGISTICS PRESET
// ============================================================
function applyLogisticsPreset(val, suffix) {
const preset = CONSTANTS.LOGISTICS_PRESETS[val];
if (!preset) return;
const pEl = $("mods_pallet" + suffix);
const cEl = $("mods_container" + suffix);
if (pEl) pEl.value = preset.pallet;
if (cEl) cEl.value = preset.container;
recalcAll();
}
// ============================================================
// BIFACIAL AUTO-FILL
// ============================================================
function autoFillBifacial(gcrVal, targetId) {
const bifacial = CONSTANTS.BIFACIAL_BY_GCR[gcrVal] ?? 0;
const el = $(targetId);
if (el) {
el.value = bifacial;
el.dispatchEvent(new Event("input", { bubbles: true }));
}
}
// ============================================================
// SAFE EXPORT CABLE LENGTH CONTROL
// ============================================================
function updateExportCableLengthDisplay() {
const el = $("out_export_cable_length_km");
if (!el) return;
const km = Number.isFinite(state.exportCableLengthKm) ? state.exportCableLengthKm : 0;
el.textContent = km.toFixed(3) + " km";
}
function updateArrayRotationDisplay() {
const el = $("out_array_rotation_deg");
if (!el) return;
const deg = Number.isFinite(state.arrayRotationDeg) ? state.arrayRotationDeg : 0;
el.textContent = (((deg % 360) + 360) % 360).toFixed(0) + "°";
}
function rotateArrayBy(deltaDeg) {
state.arrayRotationDeg = (((state.arrayRotationDeg || 0) + deltaDeg) % 360 + 360) % 360;
state.cableRoutePins = [];
state.cableRouteCommitted = false;
state.cableRouteWaypoints = [];
state.suppressNextMapFit = true;
updateArrayRotationDisplay();
redrawIfTopologyExists();
}
function resetArrayRotation() {
state.arrayRotationDeg = 0;
state.cableRoutePins = [];
state.cableRouteCommitted = false;
state.cableRouteWaypoints = [];
state.suppressNextMapFit = true;
updateArrayRotationDisplay();
redrawIfTopologyExists();
}
function getCurrentArrayCenter() {
if (Array.isArray(state.arrayOverrideCenter)) return state.arrayOverrideCenter;
const boundary = state.currentGeoJSON?.features?.find(f => f.properties?.type === "array_boundary");
if (!boundary || typeof turf === "undefined") return null;
try {
return turf.centroid(boundary).geometry.coordinates;
} catch (err) {
console.warn("Array centroid unavailable", err);
return null;
}
}
function getArrayNudgeStepKm() {
const el = $("array_nudge_step_m");
const metres = el ? parseFloat(el.value) : 25;
const safeMetres = Number.isFinite(metres) && metres > 0 ? metres : 25;
return safeMetres / 1000;
}
function clearRouteAfterArrayShift() {
state.cableRoutePins = [];
state.cableRouteCommitted = false;
state.cableRouteWaypoints = [];
state.cableRoutePinMode = false;
}
function nudgeArray(bearingDeg) {
if (!state.activeDrawCenter) {
setArrayMoveStatus("Draw a grid first, then nudge the array.", false);
return;
}
const center = getCurrentArrayCenter();
if (!center) {
setArrayMoveStatus("Array centre unavailable. Draw the grid again.", false);
return;
}
const moved = turf.destination(turf.point(center), getArrayNudgeStepKm(), bearingDeg, { units: "kilometers" }).geometry.coordinates;
state.arrayOverrideCenter = moved;
state.arrayMoveMode = false;
state.suppressNextMapFit = true;
clearRouteAfterArrayShift();
setArrayMoveStatus("Array nudged. Grid point stayed fixed. Route pins cleared because the customer substation moved.", false);
redrawIfTopologyExists();
}
function updateCableRouteStatus() {
const el = $("cable_route_status");
if (!el) return;
const count = Array.isArray(state.cableRoutePins) ? state.cableRoutePins.length : 0;
if (state.cableRoutePinMode) {
el.textContent = "Pin mode active. Click the map to drop pseudo pylon pins. Pins: " + count;
el.style.color = "#ff9900";
} else if (state.cableRouteCommitted && count > 0) {
el.textContent = "Pinned cable route drawn through " + count + " pins. Atlas haversine length is live.";
el.style.color = "#00ff88";
} else if (count > 0) {
el.textContent = count + " pins dropped. Click Draw Cable to render route through pins.";
el.style.color = "#ff9900";
} else {
el.textContent = "No pins. Export cable is direct until pins are dropped and drawn.";
el.style.color = "var(--muted)";
}
}
function injectExportCableLengthControl() {
if ($("layout_export_extra_km")) return;
const drawBtn = $("btn_draw");
if (!drawBtn || !drawBtn.parentNode) return;
const box = document.createElement("div");
box.className = "stat-box";
box.id = "export_cable_length_box";
box.style.borderColor = "#00ffff";
box.style.background = "rgba(0, 255, 255, 0.05)";
box.style.marginBottom = "15px";
box.innerHTML = `
<h3 style="margin-top:0;color:#00ffff;border-bottom-color:#00ffff;">Grid Connection Length</h3>
<div class="stat-row"><span>Live Export Cable Length:</span><span class="stat-val cyan" id="out_export_cable_length_km">0.000 km</span></div>
<div class="stat-row"><span>Array Rotation:</span><span class="stat-val orange" id="out_array_rotation_deg">0°</span></div>
<div class="input-group"><label>Export Cable Extra Length km</label><input type="number" id="layout_export_extra_km" value="0" step="0.05" min="-0.2"></div>
<div style="font-size:10px;color:var(--muted);line-height:1.4;margin-top:6px;">
Moves the whole array further from or closer to the point of connection along the existing axis. Pin routing measures the final cable route using Atlas style haversine maths.
</div>
<div style="border-top:1px dashed #333;margin:8px 0;"></div>
<button class="btn" id="btn_rotate_left_30" style="background:#222;color:#fff;">Rotate Left 30°</button>
<button class="btn" id="btn_rotate_right_30" style="margin-top:6px;background:#222;color:#fff;">Rotate Right 30°</button>
<button class="btn" id="btn_rotate_right_90" style="margin-top:6px;background:#ff9900;color:#000000;">Rotate 90°</button>
<button class="btn" id="btn_reset_rotation" style="margin-top:6px;">Reset Rotation</button>
<div style="font-size:10px;color:var(--muted);line-height:1.4;margin-top:6px;">
Rotation keeps the grid point fixed and redraws the export cable. Route pins are cleared when rotation changes.
</div>
<div style="border-top:1px dashed #333;margin:8px 0;"></div>
<button class="btn" id="btn_pick_array" style="margin-top:8px;background:#00ffff;color:#001111;">Pick Up Array</button>
<button class="btn" id="btn_reset_array_move" style="margin-top:6px;">Reset Array Location</button>
<div class="input-group" style="margin-top:8px;"><label>Fine Nudge Step metres</label><input type="number" id="array_nudge_step_m" value="25" step="5" min="1"></div>
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:6px;margin-top:8px;align-items:center;">
<span></span><button class="btn" id="btn_nudge_up" style="background:#222;color:#fff;padding:8px;">↑</button><span></span>
<button class="btn" id="btn_nudge_left" style="background:#222;color:#fff;padding:8px;">←</button><button class="btn" id="btn_nudge_down" style="background:#222;color:#fff;padding:8px;">↓</button><button class="btn" id="btn_nudge_right" style="background:#222;color:#fff;padding:8px;">→</button>
</div>
<div id="array_move_status" style="font-size:10px;color:var(--muted);line-height:1.4;margin-top:6px;">
Pick Up Array keeps the grid point fixed. Use arrows for fine field fitting.
</div>
<div style="border-top:1px dashed #333;margin:8px 0;"></div>
<button class="btn" id="btn_drop_cable_pins" style="background:#ff9900;color:#000000;">Drop Cable Pins</button>
<button class="btn" id="btn_draw_cable_route" style="margin-top:6px;background:#00ff88;color:#001111;">Draw Cable Through Pins</button>
<button class="btn" id="btn_undo_cable_pin" style="margin-top:6px;">Undo Last Pin</button>
<button class="btn" id="btn_clear_cable_route" style="margin-top:6px;">Clear Pins and Route</button>
<div id="cable_route_status" style="font-size:10px;color:var(--muted);line-height:1.4;margin-top:6px;">
No pins. Export cable is direct until pins are dropped and drawn.
</div>
`;
drawBtn.parentNode.insertBefore(box, drawBtn);
updateExportCableLengthDisplay();
updateArrayRotationDisplay();
updateCableRouteStatus();
}
function redrawIfTopologyExists() {
if (state.activeDrawCenter) computeAndDraw();
else recalcAll();
}
function setArrayMoveStatus(text, active = false) {
const el = $("array_move_status");
if (el) {
el.textContent = text;
el.style.color = active ? "#00ffff" : "var(--muted)";
}
const btn = $("btn_pick_array");
if (btn) {
btn.textContent = active ? "Click Map to Place" : "Pick Up Array";
btn.style.background = active ? "#ff9900" : "#00ffff";
btn.style.color = active ? "#000000" : "#001111";
}
}
function toggleArrayMoveMode() {
if (!state.activeDrawCenter) {
setArrayMoveStatus("Draw a grid first, then pick up the array.", false);
return;
}
state.cableRoutePinMode = false;
state.arrayMoveMode = !state.arrayMoveMode;
setArrayMoveStatus(
state.arrayMoveMode ? "Move mode active. Click the map where the array centre should move." : "Move mode cancelled.",
state.arrayMoveMode
);
updateCableRouteStatus();
}
function resetArrayLocation() {
state.arrayMoveMode = false;
state.arrayOverrideCenter = null;
clearRouteAfterArrayShift();
state.suppressNextMapFit = true;
setArrayMoveStatus("Array reset to calculated default position.", false);
redrawIfTopologyExists();
}
function placeArrayAtMapPoint(e) {
if (!state.arrayMoveMode) return;
if (!e || !e.lngLat) return;
state.arrayOverrideCenter = [e.lngLat.lng, e.lngLat.lat];
state.arrayMoveMode = false;
state.suppressNextMapFit = true;
clearRouteAfterArrayShift();
setArrayMoveStatus("Array moved. Grid point stayed fixed and export cable length recalculated.", false);
computeAndDraw();
}
function toggleCablePinMode() {
if (!state.activeDrawCenter) {
updateCableRouteStatus();
return;
}
state.arrayMoveMode = false;
state.cableRoutePinMode = !state.cableRoutePinMode;
state.suppressNextMapFit = true;
updateCableRouteStatus();
redrawIfTopologyExists();
}
function commitCablePinRoute() {
state.cableRoutePinMode = false;
state.cableRouteCommitted = Array.isArray(state.cableRoutePins) && state.cableRoutePins.length > 0;
updateCableRouteStatus();
redrawIfTopologyExists();
}
function undoCablePin() {
if (!Array.isArray(state.cableRoutePins) || state.cableRoutePins.length === 0) return;
state.cableRoutePins.pop();
state.cableRouteCommitted = false;
state.suppressNextMapFit = true;
updateCableRouteStatus();
redrawIfTopologyExists();
}
function clearCableRoute() {
state.cableRoutePinMode = false;
state.cableRoutePins = [];
state.cableRouteCommitted = false;
state.cableRouteWaypoints = [];
updateCableRouteStatus();
redrawIfTopologyExists();
}
function addCableRoutePin(e) {
if (!state.cableRoutePinMode) return;
if (!e || !e.lngLat) return;
state.cableRoutePins.push([e.lngLat.lng, e.lngLat.lat]);
state.cableRouteCommitted = false;
state.suppressNextMapFit = true;
updateCableRouteStatus();
redrawIfTopologyExists();
}
// Legacy wrappers retained so old references do not break.
function startCableRouteMode() { toggleCablePinMode(); }
function finishCableRouteMode() { commitCablePinRoute(); }
function addCableRouteWaypoint(e) { addCableRoutePin(e); }
// ============================================================
// LOCATION SEARCH
// ============================================================
async function searchLocation() {
const q = $("loc_search")?.value;
if (!q) return;
try {
const res = await fetch(`https://nominatim.openstreetmap.org/search?format=json&limit=1&q=${encodeURIComponent(q)}`);
const data = await res.json();
if (data && data.length > 0) {
map.flyTo({ center: [parseFloat(data[0].lon), parseFloat(data[0].lat)], zoom: 14 });
}
} catch (e) {
console.error("Geocoding failed:", e);
}
}
// ============================================================
// DRAW BUTTON
// ============================================================
function triggerDrawAtCenter() {
if (!map) return;
state.selectedSubstation = null;
state.activeDrawCenter = [map.getCenter().lng, map.getCenter().lat];
state.arrayOverrideCenter = null;
state.arrayMoveMode = false;
state.cableRoutePinMode = false;
state.cableRoutePins = [];
state.cableRouteCommitted = false;
computeAndDraw();
updateSelectedSubstationDisplay();
setArrayMoveStatus("Grid drawn. Use Pick Up Array or nudge arrows to relocate the array while the grid point stays fixed.", false);
updateCableRouteStatus();
}
// ============================================================
// BASEMAP / SUBS TOGGLES
// ============================================================
function toggleBasemap() {
if (!map || !map.getLayer("l-sat")) return;
state.satActive = !state.satActive;
map.setLayoutProperty("l-sat", "visibility", state.satActive ? "visible" : "none");
const btn = $("btn_basemap");
if (btn) {
btn.textContent = state.satActive ? "DARK MATTER VIEW" : "SATELLITE VIEW";
btn.classList.toggle("active", state.satActive);
}
}
function toggleSubs() {
if (!map || !map.getLayer("l-subs")) return;
state.subsVisible = !state.subsVisible;
map.setLayoutProperty("l-subs", "visibility", state.subsVisible ? "visible" : "none");
const btn = $("btn_subs_toggle");
if (btn) {
btn.textContent = state.subsVisible ? "SUBS ON" : "SUBS OFF";
btn.classList.toggle("active", state.subsVisible);
}
}
function updateAtlasV8GridToggleButtons() {
const labels = { "66kv": "66 kV", "132kv": "132 kV", "275kv": "275 kV", "400kv": "400 kV" };
Object.keys(labels).forEach(voltageKey => {
const btn = $(`btn_atlas_${voltageKey}`);
if (!btn) return;
const visible = atlasV8GridLayerVisibility?.[voltageKey] !== false;
btn.textContent = `${labels[voltageKey]} ${visible ? "ON" : "OFF"}`;
btn.classList.toggle("active", visible);
});
}
function updateAtlasV8OperatingAssetToggleButtons() {
const labels = {
"solar_operational": "SOLAR OP",
"wind_onshore_operational": "ONSHORE WIND",
"wind_offshore_operational": "OFFSHORE WIND",
"bess_operational": "BESS OP"
};
Object.keys(labels).forEach(assetKey => {
const btn = $(`btn_asset_${assetKey}`);
if (!btn) return;
const visible = atlasV8OperatingAssetVisibility?.[assetKey] === true;
btn.textContent = `${labels[assetKey]} ${visible ? "ON" : "OFF"}`;
btn.classList.toggle("active", visible);
});
}
function wireAtlasV8OperatingAssetToggleButtons() {
document.querySelectorAll(".asset-layer-btn").forEach(btn => {
btn.addEventListener("click", () => {
toggleAtlasV8OperatingAssetLayer(btn.dataset.assetLayer);
updateAtlasV8OperatingAssetToggleButtons();
});
});
updateAtlasV8OperatingAssetToggleButtons();
}
function wireAtlasV8GridToggleButtons() {
document.querySelectorAll(".atlas-voltage-btn").forEach(btn => {
btn.addEventListener("click", () => {
toggleAtlasV8GridLayer(btn.dataset.atlasVoltage);
updateAtlasV8GridToggleButtons();
});
});
updateAtlasV8GridToggleButtons();
}
function toggleMapExpand() {
const panel = document.querySelector(".panel-right");
const btn = $("btn_map_expand");
if (!panel) return;
const active = !panel.classList.contains("map-expanded");
panel.classList.toggle("map-expanded", active);
document.body.classList.toggle("map-expanded", active);
if (btn) {
btn.textContent = active ? "MAP MIN" : "MAP MAX";
btn.classList.toggle("active", active);
}
setTimeout(() => { if (map && typeof map.resize === "function") map.resize(); }, 150);
}
function toggleKeyCollapse() {
const legend = $("map_legend");
const btn = $("btn_key_toggle");
if (!legend) return;
const hidden = !legend.classList.contains("key-collapsed");
legend.classList.toggle("key-collapsed", hidden);
if (btn) {
btn.textContent = hidden ? "KEY OFF" : "KEY ON";
btn.classList.toggle("active", !hidden);
}
}
function toggleMapToolsOverlay() {