In this section
- GIS Single-Line Diagram (SLD) V3 Finance electrical · globalgrid2050 / solar-bess-topology-v3/gis-sld-v3-finance.js lines 1–192
- GIS Single-Line Diagram (SLD) V3 Helpers geodesy · globalgrid2050 / solar-bess-topology-v3/gis-sld-v3-helpers.js lines 1–75
- GIS Single-Line Diagram (SLD) V3 Map electrical · globalgrid2050 / solar-bess-topology-v3/gis-sld-v3-map.js lines 1–188
- GIS Single-Line Diagram (SLD) V3 State electrical · globalgrid2050 / solar-bess-topology-v3/gis-sld-v3-state.js lines 1–23
- GIS Single-Line Diagram (SLD) V3 Substations electrical · globalgrid2050 / solar-bess-topology-v3/gis-sld-v3-substations.js lines 1–83
- GIS Single-Line Diagram (SLD) V3 UI Core electrical · globalgrid2050 / solar-bess-topology-v3/gis-sld-v3-ui-core.js lines 1–95
GIS Single-Line Diagram (SLD) V3 Finance
A JavaScript file in GlobalGrid2050 that applies development stage defaults (`applyDevelopmentStageDefaults`) and renders finance warnings (`renderFinanceWarnings`) (units: MW, MWh), covering battery storage (BESS). Served with the page at https://globalgrid2050.com/solar-bess-topology-v3/.
electricalglobalgrid2050 / solar-bess-topology-v3/gis-sld-v3-finance.js · lines 1–192 of 192 · Entry point · pattern renderFinanceWarnings (shared by 4 files)
- What it does
- It draws battery storage (BESS). Defines applyDevelopmentStageDefaults, computeFinance, renderFinance, renderFinanceWarnings. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'bess'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: battery storage (BESS).
- Downstream impact
- Used directly by 1 file: Indexforgis Single-Line Diagram (SLD) V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html). Reached from 2 other entry points, including GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V3 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/); Module Layout V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/module-layout-v3.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v3/.
- What it achieves
- It applies development stage defaults (`applyDevelopmentStageDefaults`), computes finance (`computeFinance`) and renders finance (`renderFinance`). Defines `applyDevelopmentStageDefaults`, `computeFinance`, `renderFinance` and 1 more.
- Why it matters
- Loaded by the Indexforgis Single-Line Diagram (SLD) V3 page at https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html.
- Application
- globalgrid2050 · solar-bess-topology-v3 · script
- Uses
- none found
- Used by
- loaded by Indexforgis Single-Line Diagram (SLD) V3 (script src)
- Produces
- applyDevelopmentStageDefaults, computeFinance, renderFinance, renderFinanceWarnings
- Defines here
- applyDevelopmentStageDefaults, computeFinance, renderFinance, renderFinanceWarnings
- 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-v3/gis-sld-v3-finance.js:1-192 · blob 6182382e891909115892ca201173ce66a254d9c8 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";
// FINANCIALS
// ============================================================
function applyDevelopmentStageDefaults(prefix) {
const stage = $(prefix + "_dev_stage");
const cost = $(prefix + "_dev_cost_mw");
if (!stage || !cost) return;
cost.value = stage.value;
const success = $(prefix + "_dev_success");
const successByStage = {
"3000": 10,
"15000": 15,
"35000": 30,
"55000": 55,
"70000": 70,
"80000": 80,
"100000": 95
};
if (success && successByStage[stage.value] !== undefined) {
success.value = successByStage[stage.value];
}
}
function computeFinance(prefix, stats) {
const dc_mwp = stats.dc_mwp, ac_mw = stats.ac_mw;
const price = num(prefix + "_price");
const other = num(prefix + "_other");
const yieldVal = num(prefix + "_yield");
const bifacial = num(prefix + "_bifacial");
const baseLoss = num(prefix + "_losses");
const deg = num(prefix + "_deg");
const opexRate = num(prefix + "_opex");
const epcEx = num(prefix + "_epc_ex");
const floodAdder = checked(prefix + "_flood") ? num(prefix + "_flood_rate") : 0;
const modules = num(prefix + "_modules");
const otherCapex = num(prefix + "_other_capex");
const fixedCapex = num(prefix + "_fixed_capex");
const cont = num(prefix + "_cont");
const lossExtras = num(prefix + "_loss_dc_string") + num(prefix + "_loss_lv_dc") +
num(prefix + "_loss_lv_ac") + num(prefix + "_loss_tx") + num(prefix + "_loss_other");
const totalLoss = baseLoss + lossExtras;
const bessMw = num(prefix + "_bess_mw");
const bessMwh = num(prefix + "_bess_mwh");
const bessCapexRate = num(prefix + "_bess_capex");
const bessCycles = num(prefix + "_bess_cycles");
const bessSpread = num(prefix + "_bess_spread");
const bessEff = num(prefix + "_bess_eff") / 100;
const safeLoss = Math.min(Math.max(totalLoss, 0), 100);
const safeBessEff = Math.min(Math.max(bessEff, 0), 1);
const effectiveYield = yieldVal * (1 + bifacial / 100);
const year1Gen = dc_mwp * effectiveYield * (1 - safeLoss / 100);
// Cumulative generation
let gen25 = 0, gen35 = 0;
for (let y = 1; y <= 35; y++) {
const yr = year1Gen * Math.pow(1 - deg / 100, y - 1);
if (y <= 25) gen25 += yr;
gen35 += yr;
}
const annualSolarRevenue = year1Gen * (price + other);
const bessAnnualValue = bessMwh * bessCycles * bessSpread * safeBessEff;
const annualRevenue = annualSolarRevenue + bessAnnualValue;
const revenue25 = gen25 * (price + other) + bessAnnualValue * 25;
const revenue35 = gen35 * (price + other) + bessAnnualValue * 35;
const annualOpex = ac_mw * opexRate;
const baseCapexWp = epcEx + modules + otherCapex + floodAdder;
const baseCapex = dc_mwp * 1_000_000 * baseCapexWp;
const contingency = baseCapex * (cont / 100);
const bessCapex = bessMwh * bessCapexRate;
const totalCapex = baseCapex + contingency + fixedCapex + bessCapex;
const capexPerWp = dc_mwp > 0 ? totalCapex / (dc_mwp * 1_000_000) : 0;
const surplus25 = revenue25 - annualOpex * 25 - totalCapex;
const surplus35 = revenue35 - annualOpex * 35 - totalCapex;
const devCostPerMw = num(prefix + "_dev_cost_mw");
const devModulePerMwp = num(prefix + "_dev_module_mwp");
const devEpcPerMw = num(prefix + "_dev_epc_mw");
const devOwnerPerMw = num(prefix + "_dev_owner_mw");
const devGridPerMw = num(prefix + "_dev_grid_mw");
const devExitPerMwp = num(prefix + "_dev_exit_mwp");
const devNpvPerMwp = num(prefix + "_dev_npv_mwp");
const devSuccessPct = num(prefix + "_dev_success");
const devYears = num(prefix + "_dev_years");
const devStageEl = $(prefix + "_dev_stage");
const devStage = devStageEl ? devStageEl.options[devStageEl.selectedIndex]?.text || "Manual" : "Manual";
const devCapitalAtRisk = dc_mwp * devCostPerMw;
const devModuleCost = dc_mwp * devModulePerMwp;
const devEpcCost = dc_mwp * devEpcPerMw;
const devOwnerCost = dc_mwp * devOwnerPerMw;
const devGridCost = dc_mwp * devGridPerMw;
const devTotalBuildCost = devCapitalAtRisk + devModuleCost + devEpcCost + devOwnerCost + devGridCost;
const devExitValue = dc_mwp * devExitPerMwp;
const devOperatingNpv = dc_mwp * devNpvPerMwp;
const devGrossMargin = devExitValue - devTotalBuildCost;
const devRiskAdjustedValue = devGrossMargin * (devSuccessPct / 100);
const devReturnMultiple = devCapitalAtRisk > 0 ? devGrossMargin / devCapitalAtRisk : 0;
return {
annualRevenue, revenue25, revenue35, totalCapex, capexPerWp, surplus25, surplus35,
devStage, devCostPerMw, devModulePerMwp, devEpcPerMw, devOwnerPerMw, devGridPerMw, devExitPerMwp, devNpvPerMwp, devSuccessPct, devYears,
devCapitalAtRisk, devModuleCost, devEpcCost, devOwnerCost, devGridCost, devTotalBuildCost, devExitValue, devOperatingNpv,
devGrossMargin, devRiskAdjustedValue, devReturnMultiple,
// raw inputs for export
price, other, yieldVal, bifacial, baseLoss, deg, opexRate,
epcEx, floodActive: checked(prefix + "_flood"), floodRate: num(prefix + "_flood_rate"),
modules, otherCapex, fixedCapex, cont, totalLoss,
bessMw, bessMwh, bessCapexRate, bessCycles, bessSpread, bessEff: num(prefix + "_bess_eff"),
// for warnings
epcIncModules: epcEx + modules
};
}
function renderFinance(prefix, fin) {
setText(prefix + "_annual_rev", money(fin.annualRevenue));
setText(prefix + "_25_rev", money(fin.revenue25));
setText(prefix + "_35_rev", money(fin.revenue35));
setText(prefix + "_capex", money(fin.totalCapex));
setText(prefix + "_capex_wp", "£" + fin.capexPerWp.toFixed(2) + "/Wp");
setText(prefix + "_surplus_25", money(fin.surplus25));
setText(prefix + "_surplus_35", money(fin.surplus35));
setText(prefix + "_dev_capital", money(fin.devCapitalAtRisk));
setText(prefix + "_dev_module_cost", money(fin.devModuleCost));
setText(prefix + "_dev_epc_cost", money(fin.devEpcCost));
setText(prefix + "_dev_owner_cost", money(fin.devOwnerCost));
setText(prefix + "_dev_grid_cost", money(fin.devGridCost));
setText(prefix + "_dev_total_cost", money(fin.devTotalBuildCost));
setText(prefix + "_dev_exit_value", money(fin.devExitValue));
setText(prefix + "_dev_operating_npv", money(fin.devOperatingNpv));
setText(prefix + "_dev_margin", money(fin.devGrossMargin));
setText(prefix + "_dev_risk_value", money(fin.devRiskAdjustedValue));
setText(prefix + "_dev_multiple", fin.devReturnMultiple.toFixed(2) + "x");
}
function renderFinanceWarnings(prefix, fin, stats) {
const w = [];
if (fin.price < 0) w.push("Energy price cannot be negative.");
if (fin.opexRate < 0) w.push("OPEX cannot be negative.");
if (fin.totalLoss < 0) w.push("Losses cannot be negative.");
if (fin.epcIncModules < 0) w.push("EPC cannot be negative.");
if (fin.capexPerWp < 0) w.push("CAPEX cannot be negative.");
if (fin.bessMwh < 0 || fin.bessMw < 0) w.push("BESS size cannot be negative.");
if (fin.bessMwh > 0 && fin.bessEff / 100 <= 0) w.push("BESS efficiency missing.");
if (fin.bessEff / 100 > 1) w.push("BESS efficiency above 100 percent.");
if (fin.price < 50) w.push("Low energy price case.");
if (fin.price > 85) w.push("High energy price case.");
if (fin.epcIncModules < 0.42) w.push("Aggressive EPC pricing.");
if (fin.capexPerWp > 1.00) w.push("Full project cost territory.");
if (fin.capexPerWp > 1.25) w.push("Complex project or asset value territory.");
if (fin.devCostPerMw > 100000) w.push("Development cost is above typical EPC signature range.");
if (fin.devModulePerMwp < 100000 && fin.devModulePerMwp > 0) w.push("Module supply cost may be aggressive.");
if (fin.devEpcPerMw < 550000 && fin.devEpcPerMw > 0) w.push("EPC cost may be aggressive against UK benchmark range.");
if (fin.devEpcPerMw > 850000) w.push("EPC cost is above typical non BESS UK benchmark range.");
if (fin.devNpvPerMwp < 900000 && fin.devNpvPerMwp > 0) w.push("Operating asset Net Present Value (NPV) assumption is below current screening range.");
if (fin.devNpvPerMwp > 1400000) w.push("Operating asset Net Present Value (NPV) assumption is above current screening range and may require strong evidence.");
if (stats.dc_mwp > 100) w.push("Project capacity is above 100 megawatts peak. Nationally Significant Infrastructure Project (NSIP) and Development Consent Order (DCO) planning assumptions may apply and development cost, timescale and owner cost defaults may be too low.");
if (fin.devGridPerMw > 1000000) w.push("Grid connection cost assumption is very high and may indicate major reinforcement, transmission interface or abnormal connection risk.");
if (fin.devGridPerMw < 100000 && fin.devGridPerMw > 0) w.push("Grid connection cost assumption is low and should be checked against the project specific connection scope.");
if (fin.devSuccessPct < 8) w.push("Development success probability is below typical greenfield to EPC outcome range.");
if (fin.devSuccessPct > 25) w.push("Development success probability may be optimistic unless project is already materially de risked.");
if (fin.opexRate < 10000 && fin.opexRate >= 0) w.push("OPEX may be unrealistically low.");
if (fin.totalLoss > 6) w.push("High loss assumption.");
if (fin.bifacial > 12) w.push("Aggressive bifacial gain assumption.");
if (fin.bessMwh > 0 && fin.bessMw <= 0) w.push("BESS MW missing.");
if (fin.bessMw > 0 && fin.bessMwh / fin.bessMw > 8) w.push("Unusually long BESS duration.");
if (fin.bessCycles > 365) w.push("Aggressive storage cycling assumption.");
const elecZero = num(prefix + "_loss_dc_string") + num(prefix + "_loss_lv_dc") +
num(prefix + "_loss_lv_ac") + num(prefix + "_loss_tx") + num(prefix + "_loss_other");
if (elecZero === 0) w.push("Specialist electrical loss fields are blank or zero. Revenue may be overstated until verified.");
const gf = state.activeTab === "string" ? num("gross_factor") : num("gross_factor_c");
if (gf < 1.15) w.push("Gross site factor may be too low for roads, buffers, substations, drainage and ecology.");
if (stats.mods_pallet <= 0 || stats.mods_container <= 0) w.push("Module logistics assumptions are missing.");
const el = $(prefix + "_warnings");
if (el) el.innerHTML = w.join("<br>");
}
// ============================================================GIS Single-Line Diagram (SLD) V3 Helpers
A JavaScript file in GlobalGrid2050 that sets class (`setClass`), picks prop (`pickProp`) and sets fetch status (`setFetchStatus`). Served with the page at https://globalgrid2050.com/solar-bess-topology-v3/.
Set aside from the main view: 91% of its lines are the same as feature_requests/003_extract_v2_helpers/files/solar-bess-topology-v2/gis-sld-v2-helpers.js (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 91% of lines shared with GIS Single-Line Diagram (SLD) V5 Helpers; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.913 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 feature_requests/003_extract_v2_helpers/files/solar-bess-topology-v2/gis-sld-v2-helpers.js:1-75 3fe3702efbfab7b20e83e2e2f8113e55b3da2324
- sha256 9313aa89cb51b639beaffa49874ca10cd6385cfbd1a889ba8053781e1c73a86e
- target sha256 ecacdadc1dcdda92a551a0ec31344c4b9cb96958f8e35bf92a2896355fdd49b6
- 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 134 to file 256; similarity was measured to file 134
geodesyglobalgrid2050 / solar-bess-topology-v3/gis-sld-v3-helpers.js · lines 1–75 of 75 · Entry point · pattern setFetchStatus (shared by 7 files)
- What it does
- Defines 11 functions or classes, including $, num, intVal, checked, setText. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'bess'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Downstream impact
- Used directly by 2 files: Indexforgis Single-Line Diagram (SLD) V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html); Module Layout V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/module-layout-v3.html). Reached from 1 other entry point, including GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V3 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v3/.
- What it achieves
- It sets text (`setText`), sets class (`setClass`) and picks prop (`pickProp`). GIS SLD Financial Sandbox V3. Helpers extracted by GridBot feature 003.
- Why it matters
- Loaded by the Indexforgis Single-Line Diagram (SLD) V3 page at https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html and 1 other page.
- Application
- globalgrid2050 · solar-bess-topology-v3 · script
- Uses
- none found
- Used by
- loaded by Indexforgis Single-Line Diagram (SLD) V3 (script src), loaded by Module Layout V3 (script src)
- Produces
- $, num, intVal, checked, setText, setClass, money, debounce, isValidLngLat, pickProp, setFetchStatus
- Defines here
- $, num, intVal, checked, setText, setClass, money, debounce, isValidLngLat, pickProp, setFetchStatus
- 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-v3/gis-sld-v3-helpers.js:1-75 · blob 02d52262d7ab8f20c14f401492978112d1c692b6 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";
// GIS SLD Financial Sandbox V3
// Helpers extracted by GridBot feature 003.
// Must load after gis-sld-v3-config.js and before the inline app script.
const $ = (id) => document.getElementById(id);
const num = (id) => {
const el = $(id);
return el ? (parseFloat(el.value) || 0) : 0;
};
const intVal = (id, fallback = 0) => {
const el = $(id);
return el ? (parseInt(el.value, 10) || fallback) : fallback;
};
const checked = (id) => {
const el = $(id);
return el ? !!el.checked : false;
};
const setText = (id, val) => {
const el = $(id);
if (el) el.textContent = val;
};
const setClass = (id, cls) => {
const el = $(id);
if (el) el.className = cls;
};
function money(v) {
const rounded = Math.round(v);
if (rounded < 0) return "-£" + Math.abs(rounded).toLocaleString();
return "£" + rounded.toLocaleString();
}
function debounce(fn, ms) {
let t = null;
return function(...args) {
clearTimeout(t);
t = setTimeout(() => fn.apply(this, args), ms);
};
}
function isValidLngLat(c) {
return Array.isArray(c) && c.length >= 2
&& Number.isFinite(+c[0]) && Number.isFinite(+c[1])
&& +c[0] >= -180 && +c[0] <= 180 && +c[1] >= -90 && +c[1] <= 90;
}
function pickProp(obj, keys, fallback = null) {
for (const k of keys) {
if (obj && obj[k] !== undefined && obj[k] !== null && obj[k] !== "") return obj[k];
}
return fallback;
}
function setFetchStatus(msg, isError) {
const el = $("fetch_status");
if (!el) return;
if (!msg) {
el.style.display = "none";
el.textContent = "";
el.classList.remove("error");
return;
}
el.textContent = msg;
el.style.display = "block";
el.classList.toggle("error", !!isError);
}GIS Single-Line Diagram (SLD) V3 Map
A JavaScript file in GlobalGrid2050 that maps sat s, l sat, l subs and topology. Served with the page at https://globalgrid2050.com/solar-bess-topology-v3/.
electricalglobalgrid2050 / solar-bess-topology-v3/gis-sld-v3-map.js · lines 1–188 of 188 · Entry point · pattern onSubstationClick (shared by 6 files)
- What it does
- It maps sat s, l sat, l subs and topology. Defines 6 functions or classes, including initMap, onMapLoad, showPopup, onSubstationClick, onInverterClick. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'bess'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: 33kV.
- Inputs & outputs
- In: JSON file style.json. Out: interactive map. Voltage levels named: 33kV.
- Downstream impact
- Used directly by 1 file: Indexforgis Single-Line Diagram (SLD) V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html). Reached from 2 other entry points, including GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V3 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/); Module Layout V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/module-layout-v3.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v3/.
- What it achieves
- It shows popup (`showPopup`) and is built from the init map helper (`initMap`) and the on map load helper (`onMapLoad`). Defines `initMap`, `onMapLoad`, `showPopup` and 3 more.
- Why it matters
- Loaded by the Indexforgis Single-Line Diagram (SLD) V3 page at https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html.
- Application
- globalgrid2050 · solar-bess-topology-v3 · script
- Uses
- none found
- Used by
- loaded by Indexforgis Single-Line Diagram (SLD) V3 (script src)
- Produces
- initMap, onMapLoad, showPopup, onSubstationClick, onInverterClick, onPoiClick
- Defines here
- initMap, onMapLoad, showPopup, onSubstationClick, onInverterClick, 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-v3/gis-sld-v3-map.js:1-188 · blob 2124a34899389da943a862108c6ec1b05088a6fa · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";
// MAP
// ============================================================
let map = null;
function initMap() {
if (typeof maplibregl === "undefined") {
setFetchStatus("MapLibre failed to load. Check network.", true);
console.error("maplibregl is undefined");
return;
}
if (typeof turf === "undefined") {
setFetchStatus("Turf failed to load. Check network.", true);
console.error("turf is undefined");
return;
}
map = new maplibregl.Map({
container: "map",
style: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
center: CONSTANTS.DEFAULT_CENTER,
zoom: CONSTANTS.DEFAULT_ZOOM
});
map.on("error", (e) => console.error("MapLibre error:", e && e.error ? e.error : e));
map.on("load", onMapLoad);
}
function onMapLoad() {
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" } });
map.addSource("src-subs", { type: "geojson", data: { type: "FeatureCollection", features: [] } });
map.addLayer({
id: "l-subs", type: "circle", source: "src-subs",
paint: {
"circle-color": "#ffffff",
"circle-radius": ["interpolate", ["linear"], ["zoom"], 5, 3, 10, 5, 14, 10, 18, 22],
"circle-stroke-width": 1, "circle-stroke-color": "#ff3333", "circle-opacity": 0.8
}
});
map.addSource("topology", { type: "geojson", data: state.currentGeoJSON });
map.addLayer({
id: "overall_boundary_fill", type: "fill", source: "topology",
filter: ["==", "type", "array_boundary"],
paint: { "fill-color": "#0066ff", "fill-opacity": 0.25 }
});
map.addLayer({
id: "overall_boundary_line", type: "line", source: "topology",
filter: ["==", "type", "array_boundary"],
paint: { "line-color": "#0066ff", "line-width": 2, "line-dasharray": [4, 4] }
});
map.addLayer({
id: "footprints", type: "fill", source: "topology",
filter: ["in", ["get", "type"], ["literal", ["skid_footprint", "central_footprint", "bess_footprint"]]],
paint: {
"fill-color": ["match", ["get", "type"],
"skid_footprint", "#00ffff", "central_footprint", "#ff9900", "bess_footprint", "#ff00aa", "#000"],
"fill-opacity": 0.15
}
});
map.addLayer({
id: "footprints_outline", type: "line", source: "topology",
filter: ["in", ["get", "type"], ["literal", ["skid_footprint", "central_footprint", "bess_footprint"]]],
paint: {
"line-color": ["match", ["get", "type"],
"skid_footprint", "#00ffff", "central_footprint", "#ff9900", "bess_footprint", "#ff00aa", "#000"],
"line-width": 1
}
});
map.addLayer({
id: "export_cable", type: "line", source: "topology",
filter: ["==", "type", "export_cable"],
paint: { "line-color": "#ff3333", "line-width": 2, "line-dasharray": [4, 4] }
});
map.addLayer({
id: "radial_spine", type: "line", source: "topology",
filter: ["==", "type", "33kv_radial"],
paint: { "line-color": "#00ffff", "line-width": 2 }
});
map.addLayer({
id: "inverters", type: "circle", source: "topology",
filter: ["in", ["get", "type"], ["literal", ["string_substation", "central_inverter", "mv_station", "bess_compound"]]],
paint: {
"circle-color": ["match", ["get", "type"],
"string_substation", "#ffff00", "central_inverter", "#ff9900",
"mv_station", "#6633ff", "bess_compound", "#ff00aa", "#fff"],
"circle-radius": ["match", ["get", "type"],
"string_substation", 4, "central_inverter", 6, "mv_station", 4, "bess_compound", 6, 3],
"circle-stroke-color": "#000", "circle-stroke-width": 1
}
});
map.addLayer({
id: "substation", type: "circle", source: "topology",
filter: ["in", ["get", "type"], ["literal", ["poi", "private_sub"]]],
paint: {
"circle-color": ["match", ["get", "type"], "poi", "#ff3333", "private_sub", "#00ff88", "#fff"],
"circle-radius": 8, "circle-stroke-color": "#fff", "circle-stroke-width": 2
}
});
// Map clicks
map.on("click", "l-subs", onSubstationClick);
map.on("mouseenter", "l-subs", () => map.getCanvas().style.cursor = "pointer");
map.on("mouseleave", "l-subs", () => map.getCanvas().style.cursor = "");
map.on("click", "inverters", onInverterClick);
map.on("mouseenter", "inverters", () => map.getCanvas().style.cursor = "pointer");
map.on("mouseleave", "inverters", () => map.getCanvas().style.cursor = "");
map.on("click", "substation", onPoiClick);
map.on("mouseenter", "substation", () => map.getCanvas().style.cursor = "pointer");
map.on("mouseleave", "substation", () => map.getCanvas().style.cursor = "");
loadSubstations();
updateLegend();
recalcAll();
}
function showPopup(coords, html) {
if (state.activePopup) state.activePopup.remove();
state.activePopup = new maplibregl.Popup().setLngLat(coords).setHTML(html).addTo(map);
state.activePopup.on("close", () => { state.activePopup = null; });
}
// ============================================================
// MAP CLICK HANDLERS
// ============================================================
function onSubstationClick(e) {
const f = e.features && e.features[0];
if (!f || !f.geometry) return;
const coords = f.geometry.coordinates.slice();
const p = f.properties || {};
state.selectedSubstation = {
name: p.name_clean || pickProp(p, ["name","Name","SiteName","Site Name","substation","Substation"], "Selected Substation"),
voltage: p.voltage_clean || pickProp(p, ["voltage","Voltage","kv","kV","KV"], "Unknown"),
properties: p,
coordinates: coords
};
state.activeDrawCenter = coords;
updateSelectedSubstationDisplay();
computeAndDraw();
showPopup(coords, `
<div style="margin-bottom:5px;color:#ff3333;font-weight:bold;font-size:13px;text-transform:uppercase;">Grid Node</div>
<div class="popup-row"><span>Name:</span><span class="popup-val" style="color:#fff;">${state.selectedSubstation.name}</span></div>
<div class="popup-row"><span>Voltage:</span><span class="popup-val" style="color:#fff;">${state.selectedSubstation.voltage}</span></div>
<div class="popup-row"><span>Lon:</span><span class="popup-val" style="color:#fff;">${Number(coords[0]).toFixed(6)}</span></div>
<div class="popup-row"><span>Lat:</span><span class="popup-val" style="color:#fff;">${Number(coords[1]).toFixed(6)}</span></div>
`);
}
function onInverterClick(e) {
const prop = e.features[0].properties;
const coords = e.features[0].geometry.coordinates.slice();
const colourMap = {
central_inverter: "#ff9900", string_substation: "#ffff00",
bess_compound: "#ff00aa", mv_station: "#6633ff"
};
const colour = colourMap[prop.type] || "#00ffff";
let html = `<div style="margin-bottom:5px;color:${colour};font-weight:bold;font-size:13px;text-transform:uppercase;">Block Info</div>
<div class="popup-row"><span>Type:</span><span class="popup-val" style="color:#fff;">${prop.type}</span></div>`;
if (prop.type === "bess_compound" && prop.mwh !== undefined) {
html += `<div class="popup-row"><span>Capacity:</span><span class="popup-val" style="color:#fff;">${prop.mwh} MWh</span></div>`;
}
showPopup(coords, html);
}
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) V3 State
A JavaScript file in GlobalGrid2050. Served with the page at https://globalgrid2050.com/solar-bess-topology-v3/.
electricalglobalgrid2050 / solar-bess-topology-v3/gis-sld-v3-state.js · lines 1–23 of 23 · Entry point
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'bess'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary.
- Downstream impact
- Used directly by 1 file: Indexforgis Single-Line Diagram (SLD) V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html). Reached from 2 other entry points, including GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V3 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/); Module Layout V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/module-layout-v3.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v3/.
- What it achieves
- GIS SLD Financial Sandbox V3. State extracted by GridBot feature 004.
- Why it matters
- Loaded by the Indexforgis Single-Line Diagram (SLD) V3 page at https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html.
- Application
- globalgrid2050 · solar-bess-topology-v3 · script
- Uses
- none found
- Used by
- loaded by Indexforgis Single-Line Diagram (SLD) V3 (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-v3/gis-sld-v3-state.js:1-23 · blob 397da8687d936bbc5f7c0c22ee6fe8a9be55ea5e · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: unknown · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";
// GIS SLD Financial Sandbox V3
// 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: true,
satActive: false,
activePopup: null,
lastStats: null,
lastFinance: { fin_string: null, fin_central: null },
arrayMoveMode: false,
arrayOverrideCenter: null,
arrayRotationDeg: 0,
exportCableLengthKm: 0,
cableRouteMode: false,
cableRouteWaypoints: []
};GIS Single-Line Diagram (SLD) V3 Substations
A JavaScript file in GlobalGrid2050 that fetches substations. Served with the page at https://globalgrid2050.com/solar-bess-topology-v3/. 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 f059b9bc5a50795490a98ab6101e785d7196cfcddf321877404812a97cbc9215
- 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-v3/gis-sld-v3-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 sub33kv_design (path word 'bess'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: substations.
- Downstream impact
- Used directly by 1 file: Indexforgis Single-Line Diagram (SLD) V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html). Reached from 2 other entry points, including GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V3 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/); Module Layout V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/module-layout-v3.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v3/.
- What it achieves
- GIS SLD Financial Sandbox V3. Substation data loading extracted by GridBot feature 005.
- Why it matters
- Loaded by the Indexforgis Single-Line Diagram (SLD) V3 page at https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html.
- Application
- globalgrid2050 · solar-bess-topology-v3 · script
- Uses
- none found
- Used by
- loaded by Indexforgis Single-Line Diagram (SLD) V3 (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-v3/gis-sld-v3-substations.js:1-83 · blob 7ba86a7ba22d5ab48e45f1b4acbc3127369b7ffb · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: network · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";
// GIS SLD Financial Sandbox V3
// 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) V3 UI Core
A JavaScript file in GlobalGrid2050 that renders tech summary (`renderTechSummary`) and benchmark (`renderBenchmark`) and updates selected substation display (`updateSelectedSubstationDisplay`) (units: MW). Served with the page at https://globalgrid2050.com/solar-bess-topology-v3/.
electricalglobalgrid2050 / solar-bess-topology-v3/gis-sld-v3-ui-core.js · lines 1–95 of 95 · Entry point · pattern updateSelectedSubstationDisplay (shared by 5 files)
- What it does
- It draws substations, battery storage (BESS) and 33kV. Defines renderTechSummary, renderBenchmark, updateSelectedSubstationDisplay, recalcAll, updateLegend. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage sub33kv_design (path word 'bess'): inside-the-fence electrical and civil design below 33kV, which Ventus Ltd states is within its commercial execution boundary. Domain terms in the code: substations, battery storage (BESS), 33kV.
- Inputs & outputs
- Voltage levels named: 33kV.
- Downstream impact
- Used directly by 2 files: Indexforgis Single-Line Diagram (SLD) V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html); Indexforgis Single-Line Diagram (SLD) V4 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v4/indexforgis-sld-v4.html). Reached from 6 other entry points, including GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V3 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/); GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V4 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v4/); Module Layout V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/module-layout-v3.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v3/.
- What it achieves
- It renders tech summary (`renderTechSummary`), renders benchmark (`renderBenchmark`) and updates selected substation display (`updateSelectedSubstationDisplay`). Defines `renderTechSummary`, `renderBenchmark`, `updateSelectedSubstationDisplay` and 2 more. Its code works with 33 kV.
- Why it matters
- Loaded by the Indexforgis Single-Line Diagram (SLD) V3 page at https://globalgrid2050.com/solar-bess-topology-v3/indexforgis-sld-v3.html and 1 other page.
- Application
- globalgrid2050 · solar-bess-topology-v3 · script
- Uses
- none found
- Used by
- loaded by Indexforgis Single-Line Diagram (SLD) V3 (script src), loaded by Indexforgis Single-Line Diagram (SLD) V4 (script src)
- Produces
- renderTechSummary, renderBenchmark, updateSelectedSubstationDisplay, recalcAll, updateLegend
- Defines here
- renderTechSummary, renderBenchmark, updateSelectedSubstationDisplay, recalcAll, 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-v3/gis-sld-v3-ui-core.js:1-95 · blob e19147b9300b06159050811e00f9764886d16dc9 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · 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_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 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>
<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;
}
// ============================================================