In this section
- Indexforgis Single-Line Diagram (SLD) V2 electrical · globalgrid2050 / solar-bess-topology-v2/indexforgis-sld-v2.html lines 1378–1406
- GIS Single-Line Diagram (SLD) V3 Calculations electrical · globalgrid2050 / solar-bess-topology-v3/gis-sld-v3-calculations.js lines 1–105
- GIS Single-Line Diagram (SLD) V3 Config electrical · globalgrid2050 / solar-bess-topology-v3/gis-sld-v3-config.js lines 1–24
- GIS Single-Line Diagram (SLD) V3 Drawing geodesy · globalgrid2050 / solar-bess-topology-v3/gis-sld-v3-drawing.js lines 1–203
- GIS Single-Line Diagram (SLD) V3 Export electrical · globalgrid2050 / solar-bess-topology-v3/gis-sld-v3-export.js lines 1–148
Indexforgis Single-Line Diagram (SLD) V2
A map page in GlobalGrid2050 that maps sat s, l sat, l subs and topology, and uses data from OpenStreetMap Nominatim. Published at https://globalgrid2050.com/solar-bess-topology-v2/indexforgis-sld-v2.html.
electricalglobalgrid2050 / solar-bess-topology-v2/indexforgis-sld-v2.html · lines 1378–1406 of 1406 (continued from section 74) · Entry point · pattern triggerDownload (shared by 3 files)
- What it does
- It maps sat s, l sat, l subs and topology. Defines 35 functions or classes, including initMap, onMapLoad, showPopup, onSubstationClick, onInverterClick. Side effects: changes the web page (DOM); 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: 33kV.
- Inputs & outputs
- In: data source: OpenStreetMap Nominatim; JSON file style.json; form fields (user input). Out: web page; interactive map. Voltage levels named: 33kV.
- Downstream impact
- It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v2/indexforgis-sld-v2.html.
- What it achieves
- It shows popup (`showPopup`), reads physical inputs (`readPhysicalInputs`) and builds stats (`buildStats`). GIS SLD Financial Sandbox V2. Its code works with 33 kV. It responds to click, keydown and change events.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- globalgrid2050 · solar-bess-topology-v2 · page
- Uses
- GIS Single-Line Diagram (SLD) V2 Config (script src), GIS Single-Line Diagram (SLD) V2 Helpers (script src), GIS Single-Line Diagram (SLD) V2 State (script src), GIS Single-Line Diagram (SLD) V2 Substations (script src), GIS Single-Line Diagram (SLD) V2 (stylesheet), https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css, https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.js, https://cdn.jsdelivr.net/npm/@turf/turf@6/turf.min.js
- Used by
- mentioned in Standalone (comment link)
- Produces
- initMap, onMapLoad, showPopup, onSubstationClick, onInverterClick, onPoiClick, readPhysicalInputs, zeroStats, buildStats, computeStringStats, computeCentralStats, computeStats
- Defines here
- boot
- 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-v2/indexforgis-sld-v2.html:1378-1406 · blob b5c7689b86d9bf022a6b0e8f9a1984c0d8ae3b7d · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, network · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
$("mounting_type_c")?.addEventListener("change", (e) => autoFillBifacial(e.target.value, "fin_central_bifacial"));
// Global recalc on input changes (debounced)
document.querySelectorAll("input, select").forEach(el => {
el.addEventListener("input", recalcDebounced);
el.addEventListener("change", recalcDebounced);
});
}
// ============================================================
// BOOT
// ============================================================
function boot() {
wireEvents();
initMap();
updateSelectedSubstationDisplay();
renderBenchmark();
}
// Libraries loaded via defer, so DOMContentLoaded is the right signal.
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", boot);
} else {
boot();
}
</script>
</body>
</html>GIS Single-Line Diagram (SLD) V3 Calculations
A JavaScript file in GlobalGrid2050 that reads physical inputs (`readPhysicalInputs`), builds stats (`buildStats`) and computes stats (`computeStringStats`) (units: MW). Served with the page at https://globalgrid2050.com/solar-bess-topology-v3/.
electricalglobalgrid2050 / solar-bess-topology-v3/gis-sld-v3-calculations.js · lines 1–105 of 105 · Entry point · pattern computeCentralStats (shared by 4 files)
- What it does
- It calculates its inputs. Defines 6 functions or classes, including readPhysicalInputs, zeroStats, buildStats, computeStringStats, computeCentralStats.
- 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); 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 reads physical inputs (`readPhysicalInputs`), builds stats (`buildStats`) and computes string stats (`computeStringStats`). AGGREGATE STATS (single unified function).
- 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
- readPhysicalInputs, zeroStats, buildStats, computeStringStats, computeCentralStats, computeStats
- Defines here
- readPhysicalInputs, zeroStats, buildStats, computeStringStats, computeCentralStats, computeStats
- 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-calculations.js:1-105 · blob 70704f2c461361cb1155de64c55c0c2a46ace9b2 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";
// AGGREGATE STATS (single unified function)
// ============================================================
function readPhysicalInputs(suffix) {
return {
mod_wp: num("mod_wp" + suffix),
mod_l: num("mod_l" + suffix),
mod_w: num("mod_w" + suffix),
gcr: parseFloat($("mounting_type" + suffix)?.value) || (suffix === "_c" ? 0.45 : 0.75),
gross_factor: num("gross_factor" + suffix) || 1.35,
mods_pallet: intVal("mods_pallet" + suffix, 1),
mods_container: intVal("mods_container" + suffix, 1),
spare_pct: num("spare_pct" + suffix)
};
}
function zeroStats(dc_ac_ratio, mods_pallet, mods_container) {
return {
total_blocks: 0, block_ground_area_m2: 0, dc_mwp: 0, ac_mw: 0, module_count: 0,
net_mod_area_m2: 0, net_array_area_m2: 0, gross_site_area_m2: 0,
dc_ac_ratio, pallets: 0, containers: 0, spares_pct: 0,
modules_inc_spares: 0, pallets_inc_spares: 0, containers_inc_spares: 0,
mods_pallet, mods_container,
combiner_boxes_per_inverter: 0, total_combiner_boxes: 0
};
}
function buildStats(opts) {
const { total_blocks, module_count, ac_mw_direct, dc_ac_ratio, physical, combiner_boxes_per_inverter, total_combiner_boxes } = opts;
const { mod_wp, mod_l, mod_w, gcr, gross_factor, mods_pallet, mods_container, spare_pct } = physical;
const dc_mwp = (module_count * mod_wp) / 1_000_000;
const ac_mw = ac_mw_direct != null ? ac_mw_direct : (dc_ac_ratio > 0 ? dc_mwp / dc_ac_ratio : 0);
const net_mod_area_m2 = module_count * mod_l * mod_w;
const net_array_area_m2 = gcr > 0 ? net_mod_area_m2 / gcr : 0;
const gross_site_area_m2 = net_array_area_m2 * gross_factor;
const block_ground_area_m2 = total_blocks > 0 ? net_array_area_m2 / total_blocks : 0;
const pallets = Math.ceil(module_count / mods_pallet);
const containers = Math.ceil(module_count / mods_container);
const modules_inc_spares = Math.ceil(module_count * (1 + spare_pct / 100));
const pallets_inc_spares = Math.ceil(modules_inc_spares / mods_pallet);
const containers_inc_spares = Math.ceil(modules_inc_spares / mods_container);
return {
total_blocks, block_ground_area_m2, dc_mwp, ac_mw, module_count,
net_mod_area_m2, net_array_area_m2, gross_site_area_m2, dc_ac_ratio,
pallets, containers, spares_pct: spare_pct,
modules_inc_spares, pallets_inc_spares, containers_inc_spares,
mods_pallet, mods_container,
combiner_boxes_per_inverter: combiner_boxes_per_inverter || 0,
total_combiner_boxes: total_combiner_boxes || 0
};
}
function computeStringStats() {
const physical = readPhysicalInputs("");
const x = intVal("x_mods"), z = intVal("z_strings"), y = intVal("y_invs"), s = intVal("s_subs"), rings = intVal("b_cols");
const dc_ac_ratio = num("dc_ac_ratio") || 1.2;
if (physical.mod_wp <= 0 || physical.mod_l <= 0 || physical.mod_w <= 0 || x <= 0) {
return zeroStats(dc_ac_ratio, physical.mods_pallet, physical.mods_container);
}
const total_blocks = rings * s;
const module_count = total_blocks * y * z * x;
return buildStats({ total_blocks, module_count, dc_ac_ratio, physical });
}
function computeCentralStats() {
const physical = readPhysicalInputs("_c");
const x_mods = intVal("x_mods_c");
const inv_ac_mw = num("inv_ac_mw_c");
const dc_ac_ratio = num("dc_ac_ratio_c") || 1.2;
const str_per_cb = intVal("str_per_cb_c", 1);
const inv_per_mv = intVal("inv_per_mv_c");
const mv_per_ring = intVal("mv_per_ring_c");
const rings = intVal("rings_c");
if (physical.mod_wp <= 0 || physical.mod_l <= 0 || physical.mod_w <= 0 || x_mods <= 0) {
return zeroStats(dc_ac_ratio, physical.mods_pallet, physical.mods_container);
}
const str_dc_kwp = (x_mods * physical.mod_wp) / 1000;
const inv_dc_mwp = inv_ac_mw * dc_ac_ratio;
const req_strings = str_dc_kwp > 0 ? Math.ceil((inv_dc_mwp * 1000) / str_dc_kwp) : 0;
const combiner_boxes_per_inverter = Math.ceil(req_strings / str_per_cb);
const total_blocks = inv_per_mv * mv_per_ring * rings;
const total_combiner_boxes = combiner_boxes_per_inverter * total_blocks;
const module_count = req_strings * x_mods * total_blocks;
const ac_mw_direct = total_blocks * inv_ac_mw;
return buildStats({
total_blocks, module_count, ac_mw_direct, dc_ac_ratio, physical,
combiner_boxes_per_inverter, total_combiner_boxes
});
}
function computeStats() {
return state.activeTab === "string" ? computeStringStats() : computeCentralStats();
}
// ============================================================GIS Single-Line Diagram (SLD) V3 Config
A JavaScript file in GlobalGrid2050 covering grid substations. Served with the page at https://globalgrid2050.com/solar-bess-topology-v3/.
Set aside from the main view: 90% of its lines are the same as feature_requests/002_extract_v2_config/files/solar-bess-topology-v2/gis-sld-v2-config.js (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 90% of lines shared with GIS Single-Line Diagram (SLD) V5 Config; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 feature_requests/002_extract_v2_config/files/solar-bess-topology-v2/gis-sld-v2-config.js:1-24 16f6bd9326da4b37595e2387875688de764ea254
- sha256 3f39085ac42faf2ad1d48e67b7bb2eccd7ec87bd17255f2a808c32cb92550422
- target sha256 65b623d4bf62135a3f36e5c0ead7648018db95602b369dfb519cc19542ab22c6
- group of 8 (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 133 to file 254; similarity was measured to file 133
electricalglobalgrid2050 / solar-bess-topology-v3/gis-sld-v3-config.js · lines 1–24 of 24 · 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 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
- GIS SLD Financial Sandbox V3. Config extracted by GridBot feature 002.
- 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
- 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-config.js:1-24 · blob b259ebb910fe62011ed44bfa5520011c127330ec · 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
// Config extracted by GridBot feature 002.
// TODO: migrate config into the shared GISSLD namespace at feature 007.
const SUBSTATIONS_URL = "/grid_substations.geojson";
const CONSTANTS = {
M2_PER_ACRE: 4046.86,
BESS_M2_PER_MWH: 85,
BESS_ASPECT: 2.5,
BLOCK_SPACING_KM: 0.01,
BOUNDARY_BUFFER_KM: 0.02,
ARRAY_OFFSET_KM: 0.2,
DEFAULT_CENTER: [-0.1276, 51.5072],
DEFAULT_ZOOM: 13,
RECALC_DEBOUNCE_MS: 80,
BIFACIAL_BY_GCR: { "0.35": 8, "0.45": 5, "0.75": 2 },
LOGISTICS_PRESETS: {
high_density: { pallet: 33, container: 594 },
legacy: { pallet: 31, container: 620 }
}
};GIS Single-Line Diagram (SLD) V3 Drawing
A JavaScript file in GlobalGrid2050 that works with battery storage (BESS) and substations. Served with the page at https://globalgrid2050.com/solar-bess-topology-v3/.
geodesyglobalgrid2050 / solar-bess-topology-v3/gis-sld-v3-drawing.js · lines 1–203 of 203 · Entry point · pattern getExportCableExtraKm (shared by 3 files)
- What it does
- It calculates battery storage (BESS) and substations. Defines 8 functions or classes, including normBearing, getArrayAxisDeg, getRectPolygon, getBlockAspect, getExportCableExtraKm.
- 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), substations, 33kV.
- Inputs & outputs
- 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 gets array axis deg (`getArrayAxisDeg`), gets rect polygon (`getRectPolygon`) and gets block aspect (`getBlockAspect`). Defines `normBearing`, `getArrayAxisDeg`, `getRectPolygon` and 5 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.
- Application
- globalgrid2050 · solar-bess-topology-v3 · script
- Uses
- none found
- Used by
- loaded by Indexforgis Single-Line Diagram (SLD) V3 (script src)
- Produces
- normBearing, getArrayAxisDeg, getRectPolygon, getBlockAspect, getExportCableExtraKm, buildExportCableLine, addCableRouteWaypointMarkers, computeAndDraw
- Defines here
- normBearing, getArrayAxisDeg, getRectPolygon, getBlockAspect, getExportCableExtraKm, buildExportCableLine, addCableRouteWaypointMarkers, computeAndDraw
- 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-drawing.js:1-203 · blob 4bcb82101604440ff24f4a1b1f78155569341dae · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: sub33kv_design · users: EPC_contractor, ICP_grid_engineer · canonical: production_core
"use strict";
// DRAWING
// ============================================================
function normBearing(deg) {
return ((deg % 360) + 360) % 360;
}
function getArrayAxisDeg() {
return normBearing(Number.isFinite(state.arrayRotationDeg) ? state.arrayRotationDeg : 0);
}
function getRectPolygon(centerCoord, width_km, length_km, propType, rotationDeg = 0) {
const axis = normBearing(rotationDeg);
const pt = turf.point(centerCoord);
const ptN = turf.destination(pt, length_km / 2, axis, { units: "kilometers" }).geometry.coordinates;
const ptS = turf.destination(pt, length_km / 2, axis + 180, { units: "kilometers" }).geometry.coordinates;
const nw = turf.destination(turf.point(ptN), width_km / 2, axis - 90, { units: "kilometers" }).geometry.coordinates;
const ne = turf.destination(turf.point(ptN), width_km / 2, axis + 90, { units: "kilometers" }).geometry.coordinates;
const se = turf.destination(turf.point(ptS), width_km / 2, axis + 90, { units: "kilometers" }).geometry.coordinates;
const sw = turf.destination(turf.point(ptS), width_km / 2, axis - 90, { units: "kilometers" }).geometry.coordinates;
return turf.polygon([[nw, ne, se, sw, nw]], { type: propType });
}
function getBlockAspect() {
const mountingVal = state.activeTab === "string" ? $("mounting_type").value : $("mounting_type_c").value;
if (mountingVal === "0.45") return 1 / 1.4;
if (mountingVal === "0.75") return 1.0;
return 1.4;
}
function getExportCableExtraKm() {
const el = $("layout_export_extra_km");
if (!el) return 0;
const value = parseFloat(el.value);
return Number.isFinite(value) ? value : 0;
}
function buildExportCableLine(privateSubCoord, publicSubCoord, safeExtraOffsetKm) {
const routePoints = Array.isArray(state.cableRouteWaypoints) ? state.cableRouteWaypoints : [];
const coords = [privateSubCoord, ...routePoints, publicSubCoord];
return turf.lineString(coords, {
type: "export_cable",
export_cable_extra_km: safeExtraOffsetKm,
export_cable_length_km: 0,
array_moved_manually: Boolean(state.arrayOverrideCenter),
array_rotation_deg: getArrayAxisDeg(),
routed_by_waypoints: routePoints.length > 0,
waypoint_count: routePoints.length
});
}
function addCableRouteWaypointMarkers(features) {
if (!Array.isArray(state.cableRouteWaypoints)) return;
state.cableRouteWaypoints.forEach((coord, idx) => {
features.push(turf.point(coord, {
type: "export_cable_waypoint",
waypoint_index: idx + 1
}));
});
}
function computeAndDraw() {
if (!state.activeDrawCenter || !map) return;
const stats = computeStats();
state.lastStats = stats;
if (stats.total_blocks === 0) {
recalcAll();
return;
}
const axis = getArrayAxisDeg();
const N = stats.total_blocks;
const cols = Math.ceil(Math.sqrt(N));
const rows = Math.ceil(N / cols);
const block_area_km2 = stats.block_ground_area_m2 / 1_000_000;
const aspect = getBlockAspect();
const block_w = Math.sqrt(block_area_km2 / aspect);
const block_l = block_w * aspect;
const spacing = CONSTANTS.BLOCK_SPACING_KM;
const grid_w = cols * block_w + (cols - 1) * spacing;
const grid_l = rows * block_l + (rows - 1) * spacing;
const features = [];
const publicSubCoord = state.activeDrawCenter;
const safeExtraOffsetKm = Math.max(-CONSTANTS.ARRAY_OFFSET_KM, getExportCableExtraKm());
const arrayOffsetKm = grid_l / 2 + CONSTANTS.ARRAY_OFFSET_KM + safeExtraOffsetKm;
const defaultGridCenter = turf.destination(turf.point(publicSubCoord), arrayOffsetKm, axis, { units: "kilometers" }).geometry.coordinates;
const gridCenter = state.arrayOverrideCenter || defaultGridCenter;
const privateSubCoord = turf.destination(turf.point(gridCenter), grid_l / 2, axis + 180, { units: "kilometers" }).geometry.coordinates;
const exportCableLine = buildExportCableLine(privateSubCoord, publicSubCoord, safeExtraOffsetKm);
state.exportCableLengthKm = turf.length(exportCableLine, { units: "kilometers" });
exportCableLine.properties.export_cable_length_km = state.exportCableLengthKm;
features.push(turf.point(publicSubCoord, {
type: "poi",
selected_substation_name: state.selectedSubstation?.name || "Local Grid Node",
selected_substation_voltage: state.selectedSubstation?.voltage || "Unknown"
}));
features.push(turf.point(privateSubCoord, {
type: "private_sub",
selected_substation_name: "Customer Substation",
selected_substation_voltage: "Local Voltage",
export_cable_extra_km: safeExtraOffsetKm,
export_cable_length_km: state.exportCableLengthKm,
array_moved_manually: Boolean(state.arrayOverrideCenter),
array_rotation_deg: axis,
export_cable_waypoint_count: state.cableRouteWaypoints.length
}));
features.push(exportCableLine);
addCableRouteWaypointMarkers(features);
features.push(getRectPolygon(gridCenter, grid_w + CONSTANTS.BOUNDARY_BUFFER_KM, grid_l + CONSTANTS.BOUNDARY_BUFFER_KM, "array_boundary", axis));
const ptN = turf.destination(turf.point(gridCenter), grid_l / 2, axis, { units: "kilometers" }).geometry.coordinates;
const ptNW = turf.destination(turf.point(ptN), grid_w / 2, axis - 90, { units: "kilometers" }).geometry.coordinates;
const inverters = [];
let count = 0;
for (let r = 0; r < rows; r++) {
for (let c = 0; c < cols; c++) {
if (count >= N) break;
const posAcross = turf.destination(turf.point(ptNW), c * block_w + c * spacing + block_w / 2, axis + 90, { units: "kilometers" }).geometry.coordinates;
const finalPos = turf.destination(turf.point(posAcross), r * block_l + r * spacing + block_l / 2, axis + 180, { units: "kilometers" }).geometry.coordinates;
const nodeType = state.activeTab === "string" ? "string_substation" : "central_inverter";
const footType = state.activeTab === "string" ? "skid_footprint" : "central_footprint";
features.push(getRectPolygon(finalPos, block_w, block_l, footType, axis));
inverters.push({ coords: finalPos, type: nodeType });
features.push(turf.point(finalPos, { type: nodeType }));
count++;
}
}
// BESS
const prefix = state.activeTab === "string" ? "fin_string" : "fin_central";
const bess_mwh = num(prefix + "_bess_mwh");
if (bess_mwh > 0) {
const bess_area_km2 = (bess_mwh * CONSTANTS.BESS_M2_PER_MWH) / 1_000_000;
const bess_w = Math.sqrt(bess_area_km2 * CONSTANTS.BESS_ASPECT);
const bess_l = bess_area_km2 / bess_w;
const bessCenter = turf.destination(turf.point(privateSubCoord), bess_w / 2 + 0.05, axis - 90, { units: "kilometers" }).geometry.coordinates;
features.push(getRectPolygon(bessCenter, bess_w, bess_l, "bess_footprint", axis));
features.push(turf.point(bessCenter, { type: "bess_compound", mwh: bess_mwh }));
features.push(turf.lineString([bessCenter, privateSubCoord], { type: "33kv_radial" }));
}
// Internal 33kV radial links with a clipped visible trunk back to the customer substation.
if (inverters.length > 0) {
const projectionLine = turf.lineString([
privateSubCoord,
turf.destination(turf.point(privateSubCoord), grid_l, axis, { units: "kilometers" }).geometry.coordinates
], { type: "33kv_projection_only" });
let maxTrunkDistanceKm = 0;
const projectedBranches = [];
inverters.forEach(inv => {
const projected = turf.nearestPointOnLine(projectionLine, turf.point(inv.coords), { units: "kilometers" }).geometry.coordinates;
const distanceFromCustomerSub = turf.length(turf.lineString([privateSubCoord, projected]), { units: "kilometers" });
if (distanceFromCustomerSub > maxTrunkDistanceKm) maxTrunkDistanceKm = distanceFromCustomerSub;
projectedBranches.push({ inverter: inv.coords, projected });
});
if (maxTrunkDistanceKm > 0) {
const clippedTrunkEnd = turf.destination(turf.point(privateSubCoord), maxTrunkDistanceKm, axis, { units: "kilometers" }).geometry.coordinates;
features.push(turf.lineString([privateSubCoord, clippedTrunkEnd], {
type: "33kv_radial",
role: "collector_trunk",
clipped_to_inverter_extent: true
}));
}
projectedBranches.forEach(branch => {
features.push(turf.lineString([branch.inverter, branch.projected], {
type: "33kv_radial",
role: "block_branch"
}));
});
}
state.currentGeoJSON = turf.featureCollection(features);
const src = map.getSource("topology");
if (src) src.setData(state.currentGeoJSON);
if (features.length > 0) {
const bbox = turf.bbox(state.currentGeoJSON);
map.fitBounds(bbox, { padding: 60, duration: 800 });
}
updateExportCableLengthDisplay();
updateCableRouteStatus();
updateArrayRotationDisplay();
// Refresh side-panel values
renderTechSummary(stats);
const fin = computeFinance(prefix, stats);
state.lastFinance[prefix] = fin;
renderFinance(prefix, fin);
renderFinanceWarnings(prefix, fin, stats);
}
// ============================================================GIS Single-Line Diagram (SLD) V3 Export
A JavaScript file in GlobalGrid2050 that exports geo (`exportGeoJSON`) (units: MW, MWh, kV). Served with the page at https://globalgrid2050.com/solar-bess-topology-v3/.
electricalglobalgrid2050 / solar-bess-topology-v3/gis-sld-v3-export.js · lines 1–148 of 148 · Entry point · pattern triggerDownload (shared by 3 files)
- What it does
- It draws its content. Defines exportGeoJSON, triggerDownload. 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 7 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); Indexforgis Single-Line Diagram (SLD) V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/indexforgis-sld-v5.html); 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/); and 3 more. Reached from 170 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/); Cable Geometry Visualiser V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v3/.
- What it achieves
- It exports geo JSON (`exportGeoJSON`) and is built from the trigger download helper (`triggerDownload`). Defines `exportGeoJSON` and `triggerDownload`.
- 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 6 other pages.
- 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), loaded by Indexforgis Single-Line Diagram (SLD) V5 (script src), 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
- exportGeoJSON, triggerDownload
- Defines here
- exportGeoJSON, triggerDownload
- 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-export.js:1-148 · blob 619f4f9789078c5b96360c7e1c69a99014dc0dad · 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";
// EXPORT
// ============================================================
function exportGeoJSON() {
if (state.currentGeoJSON.features.length === 0) return;
const exportData = JSON.parse(JSON.stringify(state.currentGeoJSON));
const boundary = exportData.features.find(f => f.properties.type === "array_boundary");
if (!boundary) return triggerDownload(exportData);
const stats = state.lastStats || computeStats();
const prefix = state.activeTab === "string" ? "fin_string" : "fin_central";
const fin = state.lastFinance[prefix] || computeFinance(prefix, stats);
const suffix = state.activeTab === "string" ? "" : "_c";
const logisticsPreset = $("logistics_preset" + suffix)?.value || "manual";
const grossFactor = num("gross_factor" + suffix);
const gcr = parseFloat($("mounting_type" + suffix)?.value) || 0;
const moduleRatingWp = num("mod_wp" + suffix);
const topologyProps = state.activeTab === "string" ? {
tech_modules_per_string: intVal("x_mods"),
tech_strings_per_inverter: intVal("z_strings"),
tech_inverters_per_substation: intVal("y_invs"),
tech_substations_per_33kv_ring: intVal("s_subs"),
tech_33kv_rings: intVal("b_cols")
} : {
tech_central_ac_rating_mwac: num("inv_ac_mw_c"),
tech_modules_per_string: intVal("x_mods_c"),
tech_strings_per_combiner_box: intVal("str_per_cb_c"),
tech_central_inverters_per_mv_station: intVal("inv_per_mv_c"),
tech_mv_stations_per_33kv_ring: intVal("mv_per_ring_c"),
tech_33kv_rings: intVal("rings_c"),
tech_combiner_boxes_per_inverter: stats.combiner_boxes_per_inverter,
tech_total_combiner_boxes: stats.total_combiner_boxes
};
boundary.properties = {
...boundary.properties,
fin_active_tab: state.activeTab,
fin_export_note: "Engineering screening output only. Not construction design, financial advice, EPC pricing, grid compliance, logistics planning or transport instruction. Electrical loss fields are assumption fields and require competent project specific verification. Selected substation is a public dataset reference point and does not confirm available capacity, connection rights, voltage … [line shortened here: 434 characters; full line on GitHub]
grid_selected_substation_name: state.selectedSubstation?.name || null,
grid_selected_substation_voltage: state.selectedSubstation?.voltage || null,
grid_selected_substation_lon: state.selectedSubstation?.coordinates?.[0] ?? null,
grid_selected_substation_lat: state.selectedSubstation?.coordinates?.[1] ?? null,
grid_selected_substation_properties: state.selectedSubstation?.properties || null,
tech_module_rating_wp: moduleRatingWp,
tech_module_length_m: num("mod_l" + suffix),
tech_module_width_m: num("mod_w" + suffix),
tech_ground_coverage_ratio: gcr,
tech_gross_site_factor: grossFactor,
tech_logistics_preset: logisticsPreset,
tech_modules_per_packing_unit: stats.mods_pallet,
tech_modules_per_40ft_container: stats.mods_container,
tech_spare_allowance_percent: stats.spares_pct,
tech_total_base_packing_units: stats.pallets,
tech_total_base_containers: stats.containers,
tech_total_modules_inc_spares: stats.modules_inc_spares,
tech_total_packing_units_inc_spares: stats.pallets_inc_spares,
tech_total_containers_inc_spares: stats.containers_inc_spares,
tech_containers_per_mwp: stats.dc_mwp > 0 ? Number((stats.containers_inc_spares / stats.dc_mwp).toFixed(2)) : 0,
...topologyProps,
tech_module_count: stats.module_count,
tech_dc_capacity_mwp: stats.dc_mwp,
tech_ac_capacity_mwac: stats.ac_mw,
tech_net_mod_area_m2: stats.net_mod_area_m2,
tech_net_array_area_m2: stats.net_array_area_m2,
tech_gross_site_area_m2: stats.gross_site_area_m2,
// Finance — numbers, not formatted strings
fin_total_capex_gbp: Math.round(fin.totalCapex),
fin_capex_per_wp_gbp: Number(fin.capexPerWp.toFixed(4)),
fin_annual_rev_gbp: Math.round(fin.annualRevenue),
fin_25yr_revenue_gbp: Math.round(fin.revenue25),
fin_35yr_revenue_gbp: Math.round(fin.revenue35),
fin_25yr_surplus_gbp: Math.round(fin.surplus25),
fin_35yr_surplus_gbp: Math.round(fin.surplus35),
fin_development_stage: fin.devStage,
fin_development_cost_gbp_mw: fin.devCostPerMw,
fin_development_module_supply_cost_gbp_mwp: fin.devModulePerMwp,
fin_development_epc_cost_gbp_mw: fin.devEpcPerMw,
fin_development_owner_cost_gbp_mw: fin.devOwnerPerMw,
fin_development_grid_connection_cost_gbp_mw: fin.devGridPerMw,
fin_development_exit_value_gbp_mwp: fin.devExitPerMwp,
fin_development_operating_npv_gbp_mwp: fin.devNpvPerMwp,
fin_development_success_probability_percent: fin.devSuccessPct,
fin_development_years: fin.devYears,
fin_development_capital_at_risk_gbp: Math.round(fin.devCapitalAtRisk),
fin_development_module_supply_cost_gbp: Math.round(fin.devModuleCost),
fin_development_epc_cost_gbp: Math.round(fin.devEpcCost),
fin_development_owner_cost_gbp: Math.round(fin.devOwnerCost),
fin_development_grid_connection_cost_gbp: Math.round(fin.devGridCost),
fin_development_total_build_cost_gbp: Math.round(fin.devTotalBuildCost),
fin_development_target_exit_value_gbp: Math.round(fin.devExitValue),
fin_development_operating_npv_gbp: Math.round(fin.devOperatingNpv),
fin_development_gross_margin_gbp: Math.round(fin.devGrossMargin),
fin_development_risk_adjusted_value_gbp: Math.round(fin.devRiskAdjustedValue),
fin_development_return_multiple: Number(fin.devReturnMultiple.toFixed(4)),
fin_energy_price_gbp_mwh: fin.price,
fin_other_income_gbp_mwh: fin.other,
fin_yield_kwh_kwp: fin.yieldVal,
fin_bifacial_gain: fin.bifacial,
fin_flood_resilience: fin.floodActive,
fin_flood_adder_gbp_wp: fin.floodRate,
fin_base_losses_percent: fin.baseLoss,
fin_loss_dc_string_percent: num(prefix + "_loss_dc_string"),
fin_loss_lv_main_dc_percent: num(prefix + "_loss_lv_dc"),
fin_loss_lv_ac_percent: num(prefix + "_loss_lv_ac"),
fin_loss_transformer_percent: num(prefix + "_loss_tx"),
fin_loss_other_electrical_percent: num(prefix + "_loss_other"),
fin_opex_gbp_mwac_year: fin.opexRate,
fin_epc_ex_modules_gbp_wp: fin.epcEx,
fin_modules_gbp_wp: fin.modules,
fin_other_capex_gbp_wp: fin.otherCapex,
fin_fixed_capex_gbp: fin.fixedCapex,
fin_contingency_percent: fin.cont,
fin_bess_mw: fin.bessMw,
fin_bess_mwh: fin.bessMwh,
fin_bess_capex_gbp_mwh: fin.bessCapexRate,
fin_bess_cycles_year: fin.bessCycles,
fin_bess_spread_gbp_mwh: fin.bessSpread,
fin_bess_efficiency_percent: fin.bessEff
};
triggerDownload(exportData);
}
function triggerDownload(data) {
const blob = new Blob([JSON.stringify(data, null, 2)], { type: "application/json" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `gis_sld_${state.activeTab}_neat_grid.geojson`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
setTimeout(() => URL.revokeObjectURL(url), 1000);
}
// ============================================================