In this section
- Module Layout V3 render · globalgrid2050 / solar-bess-topology-v3/module-layout-v3.html lines 1–90
- Module Layout V3 interaction · globalgrid2050 / solar-bess-topology-v3/module-layout-v3.js lines 1–296
- GIS Single-Line Diagram (SLD) V4 Config electrical · globalgrid2050 / solar-bess-topology-v4/gis-sld-v4-config.js lines 1–24
- GIS Single-Line Diagram (SLD) V4 Drawing geodesy · globalgrid2050 / solar-bess-topology-v4/gis-sld-v4-drawing.js lines 1–234
Module Layout V3
A web page in GlobalGrid2050 that reads inputs for ml total modules, ml module width and ml module height. Published at https://globalgrid2050.com/solar-bess-topology-v3/module-layout-v3.html.
renderglobalgrid2050 / solar-bess-topology-v3/module-layout-v3.html · lines 1–90 of 90 · Entry point
- What it does
- It draws its content. 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.
- Inputs & outputs
- In: form fields (user input). Out: web page.
- Downstream impact
- It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v3/module-layout-v3.html.
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- globalgrid2050 · solar-bess-topology-v3 · page
- Uses
- GIS Single-Line Diagram (SLD) V2 (stylesheet), Module Layout V3 (stylesheet), Indexforgis Single-Line Diagram (SLD) V3 (link), GIS Single-Line Diagram (SLD) V3 Config (script src), GIS Single-Line Diagram (SLD) V3 Helpers (script src), Module Layout V3 (script src), https://unpkg.com/maplibre-gl@3.3.1/dist/maplibre-gl.js, https://unpkg.com/maplibre-gl@3.3.1/dist/maplibre-gl.css, https://cdn.jsdelivr.net/npm/@turf/turf@6/turf.min.js
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v3/module-layout-v3.html:1-90 · blob 783ccce7645426d873f744dae29fff853cd6ef9f · 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Module Layout V3 | GlobalGrid2050</title>
<script src="https://unpkg.com/maplibre-gl@3.3.1/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/maplibre-gl@3.3.1/dist/maplibre-gl.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/@turf/turf@6/turf.min.js"></script>
<link rel="stylesheet" href="./gis-sld-v3.css" />
<link rel="stylesheet" href="./module-layout-v3.css" />
</head>
<body>
<div class="module-app-shell">
<header class="module-header">
<div>
<div class="module-kicker">GlobalGrid2050 V3</div>
<h1>Physical Solar Module Layout</h1>
<p>Separate non breaking app for testing physical module footprint, portrait or landscape orientation and exact module count visualisation.</p>
</div>
<a class="module-link" href="./indexforgis-sld-v3.html">Back to GIS SLD V3</a>
</header>
<main class="module-main">
<section class="module-panel">
<h2>Module Inputs</h2>
<label>Total Modules</label>
<input id="ml_total_modules" type="number" value="1200" min="1" step="1" />
<label>Module Width m</label>
<input id="ml_module_width_m" type="number" value="1.134" min="0.1" step="0.001" />
<label>Module Height m</label>
<input id="ml_module_height_m" type="number" value="2.278" min="0.1" step="0.001" />
<label>Orientation</label>
<select id="ml_orientation">
<option value="portrait">Portrait</option>
<option value="landscape">Landscape</option>
</select>
<label>Modules Per Row</label>
<input id="ml_modules_per_row" type="number" value="60" min="1" step="1" />
<label>Row Pitch m</label>
<input id="ml_row_pitch_m" type="number" value="6.0" min="0.1" step="0.1" />
<label>Module Gap m</label>
<input id="ml_module_gap_m" type="number" value="0.03" min="0" step="0.01" />
<label>Array Rotation degrees</label>
<input id="ml_rotation_deg" type="number" value="0" step="5" />
<div class="module-button-row">
<button id="ml_draw_center" class="btn">Draw at Map Centre</button>
<button id="ml_pick_site" class="btn secondary">Pick Site on Map</button>
<button id="ml_clear" class="btn danger">Clear</button>
</div>
<h2>Results</h2>
<div class="module-stat"><span>Rows</span><strong id="ml_out_rows">0</strong></div>
<div class="module-stat"><span>Layout Width</span><strong id="ml_out_width">0 m</strong></div>
<div class="module-stat"><span>Layout Length</span><strong id="ml_out_length">0 m</strong></div>
<div class="module-stat"><span>Footprint Area</span><strong id="ml_out_area">0 ha</strong></div>
<div class="module-stat"><span>Rendered Modules</span><strong id="ml_out_rendered">0</strong></div>
<div id="ml_status" class="module-status">Ready.</div>
<div class="module-note">
This app is for physical GIS visualisation only. It does not replace paid EPC design, cable schedules, structural layout, shading study or IFC drawings.
</div>
</section>
<section class="module-map-card">
<div id="module_map"></div>
<div class="module-map-toolbar">
<button id="ml_satellite" class="btn small">Satellite View</button>
<button id="ml_zoom_layout" class="btn small secondary">Zoom to Layout</button>
</div>
</section>
</main>
</div>
<script src="./gis-sld-v3-config.js"></script>
<script src="./gis-sld-v3-helpers.js"></script>
<script src="./module-layout-v3.js"></script>
</body>
</html>Module Layout V3
A JavaScript file in GlobalGrid2050 that maps ml sat, ml boundary fill and ml boundary line. Served with the page at https://globalgrid2050.com/solar-bess-topology-v3/.
interactionglobalgrid2050 / solar-bess-topology-v3/module-layout-v3.js · lines 1–296 of 296 · Entry point
- What it does
- It maps ml sat, ml boundary fill and ml boundary line. Defines 18 functions or classes, including ml, mlNum, mlInt, mlSetStatus, mlSetText. 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.
- Inputs & outputs
- In: JSON file style.json. Out: interactive map.
- Downstream impact
- Used directly by 6 files: Module Layout V3 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v3/module-layout-v3.html); Module Layout V4 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v4/module-layout-v4.html); Module Layout V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/module-layout-v5.html); Solar Battery Energy Storage System (BESS) Topology V6 — Module Layout Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v6/module-layout/); and 2 more. Reached from 157 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 is built from the ml num helper (`mlNum`), the ml int helper (`mlInt`) and the ml set status helper (`mlSetStatus`). Defines `mlNum`, `mlInt`, `mlSetStatus` and 14 more. It responds to input, change and click events.
- Why it matters
- Loaded by the page of the same name at https://globalgrid2050.com/solar-bess-topology-v3/module-layout-v3.html and 5 other pages.
- Application
- globalgrid2050 · solar-bess-topology-v3 · script
- Uses
- none found
- Used by
- loaded by Module Layout V3 (script src), loaded by Module Layout V4 (script src), loaded by Module Layout V5 (script src), loaded by Solar Battery Energy Storage System (BESS) Topology V6 — Module Layout Page (script src), loaded by Solar Battery Energy Storage System (BESS) Topology V7 — Module Layout Page (script src), loaded by Solar Battery Energy Storage System (BESS) Topology V7 — Module Layout Page (script src)
- Produces
- ml, mlNum, mlInt, mlSetStatus, mlSetText, mlGetInputs, mlPointFromOffset, mlRect, mlUpdateResults, mlBuildLayout, mlDrawAtMapCentre, mlClear
- Defines here
- ml, mlNum, mlInt, mlSetStatus, mlSetText, mlGetInputs, mlPointFromOffset, mlRect, mlUpdateResults, mlBuildLayout, mlDrawAtMapCentre, mlClear, mlZoomToLayout, mlToggleSatellite, mlTogglePickMode, mlWireInputs, mlInitMap, mlBoot
- 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/module-layout-v3.js:1-296 · blob e1cc939eee3c100d1f7692fabc223840ca56e58d · 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";
const mlState = {
map: null,
satActive: false,
pickMode: false,
centre: null,
currentGeoJSON: { type: "FeatureCollection", features: [] }
};
function ml(id) {
return document.getElementById(id);
}
function mlNum(id, fallback = 0) {
const el = ml(id);
if (!el) return fallback;
const value = parseFloat(el.value);
return Number.isFinite(value) ? value : fallback;
}
function mlInt(id, fallback = 0) {
const value = Math.round(mlNum(id, fallback));
return Number.isFinite(value) ? value : fallback;
}
function mlSetStatus(text) {
const el = ml("ml_status");
if (el) el.textContent = text;
}
function mlSetText(id, text) {
const el = ml(id);
if (el) el.textContent = text;
}
function mlGetInputs() {
const totalModules = Math.max(1, mlInt("ml_total_modules", 1200));
const moduleWidthM = Math.max(0.1, mlNum("ml_module_width_m", 1.134));
const moduleHeightM = Math.max(0.1, mlNum("ml_module_height_m", 2.278));
const orientation = ml("ml_orientation")?.value || "portrait";
const modulesPerRow = Math.max(1, mlInt("ml_modules_per_row", 60));
const rowPitchM = Math.max(0.1, mlNum("ml_row_pitch_m", 6.0));
const moduleGapM = Math.max(0, mlNum("ml_module_gap_m", 0.03));
const rotationDeg = mlNum("ml_rotation_deg", 0);
const moduleAcrossM = orientation === "landscape" ? moduleHeightM : moduleWidthM;
const moduleAlongM = orientation === "landscape" ? moduleWidthM : moduleHeightM;
const rows = Math.ceil(totalModules / modulesPerRow);
const widthM = modulesPerRow * moduleAcrossM + Math.max(0, modulesPerRow - 1) * moduleGapM;
const lengthM = rows * rowPitchM;
const moduleAreaM2 = totalModules * moduleWidthM * moduleHeightM;
const footprintAreaM2 = widthM * lengthM;
return {
totalModules,
moduleWidthM,
moduleHeightM,
orientation,
modulesPerRow,
rowPitchM,
moduleGapM,
rotationDeg,
moduleAcrossM,
moduleAlongM,
rows,
widthM,
lengthM,
moduleAreaM2,
footprintAreaM2
};
}
function mlPointFromOffset(centerCoord, acrossM, alongM, axisDeg) {
const acrossKm = acrossM / 1000;
const alongKm = alongM / 1000;
const p1 = turf.destination(turf.point(centerCoord), acrossKm, axisDeg + 90, { units: "kilometers" }).geometry.coordinates;
return turf.destination(turf.point(p1), alongKm, axisDeg, { units: "kilometers" }).geometry.coordinates;
}
function mlRect(centerCoord, widthM, lengthM, type, axisDeg, props = {}) {
const halfW = widthM / 2;
const halfL = lengthM / 2;
const nw = mlPointFromOffset(centerCoord, -halfW, halfL, axisDeg);
const ne = mlPointFromOffset(centerCoord, halfW, halfL, axisDeg);
const se = mlPointFromOffset(centerCoord, halfW, -halfL, axisDeg);
const sw = mlPointFromOffset(centerCoord, -halfW, -halfL, axisDeg);
return turf.polygon([[nw, ne, se, sw, nw]], { type, ...props });
}
function mlUpdateResults(inputs, renderedCount) {
mlSetText("ml_out_rows", String(inputs.rows));
mlSetText("ml_out_width", inputs.widthM.toFixed(1) + " m");
mlSetText("ml_out_length", inputs.lengthM.toFixed(1) + " m");
mlSetText("ml_out_area", (inputs.footprintAreaM2 / 10000).toFixed(2) + " ha");
mlSetText("ml_out_rendered", String(renderedCount));
}
function mlBuildLayout(centerCoord) {
const inputs = mlGetInputs();
const features = [];
const axis = inputs.rotationDeg;
features.push(mlRect(centerCoord, inputs.widthM, inputs.lengthM, "module_layout_boundary", axis, {
total_modules: inputs.totalModules,
orientation: inputs.orientation,
modules_per_row: inputs.modulesPerRow,
row_count: inputs.rows,
width_m: inputs.widthM,
length_m: inputs.lengthM,
footprint_area_m2: inputs.footprintAreaM2,
physical_module_area_m2: inputs.moduleAreaM2
}));
const maxRenderModules = 6000;
const renderCount = Math.min(inputs.totalModules, maxRenderModules);
const startAcross = -inputs.widthM / 2 + inputs.moduleAcrossM / 2;
const startAlong = inputs.lengthM / 2 - inputs.rowPitchM / 2;
for (let i = 0; i < renderCount; i++) {
const row = Math.floor(i / inputs.modulesPerRow);
const col = i % inputs.modulesPerRow;
const acrossM = startAcross + col * (inputs.moduleAcrossM + inputs.moduleGapM);
const alongM = startAlong - row * inputs.rowPitchM;
const moduleCenter = mlPointFromOffset(centerCoord, acrossM, alongM, axis);
features.push(mlRect(moduleCenter, inputs.moduleAcrossM, inputs.moduleAlongM, "solar_module", axis, {
module_index: i + 1,
row: row + 1,
column: col + 1,
orientation: inputs.orientation
}));
}
if (inputs.totalModules > maxRenderModules) {
mlSetStatus("Rendered first " + maxRenderModules + " modules. Reduce count or use a block level view for very large layouts.");
} else {
mlSetStatus("Rendered " + renderCount + " physical modules. Zoom in to inspect module footprint.");
}
mlUpdateResults(inputs, renderCount);
mlState.currentGeoJSON = turf.featureCollection(features);
const src = mlState.map?.getSource("module-layout");
if (src) src.setData(mlState.currentGeoJSON);
}
function mlDrawAtMapCentre() {
if (!mlState.map) return;
const c = mlState.map.getCenter();
mlState.centre = [c.lng, c.lat];
mlBuildLayout(mlState.centre);
mlZoomToLayout();
}
function mlClear() {
mlState.centre = null;
mlState.currentGeoJSON = { type: "FeatureCollection", features: [] };
const src = mlState.map?.getSource("module-layout");
if (src) src.setData(mlState.currentGeoJSON);
mlUpdateResults(mlGetInputs(), 0);
mlSetStatus("Cleared.");
}
function mlZoomToLayout() {
if (!mlState.map || !mlState.currentGeoJSON.features.length) return;
const bbox = turf.bbox(mlState.currentGeoJSON);
mlState.map.fitBounds(bbox, { padding: 80, duration: 700 });
}
function mlToggleSatellite() {
if (!mlState.map || !mlState.map.getLayer("ml-sat-layer")) return;
mlState.satActive = !mlState.satActive;
mlState.map.setLayoutProperty("ml-sat-layer", "visibility", mlState.satActive ? "visible" : "none");
const btn = ml("ml_satellite");
if (btn) btn.textContent = mlState.satActive ? "Dark View" : "Satellite View";
}
function mlTogglePickMode() {
mlState.pickMode = !mlState.pickMode;
mlSetStatus(mlState.pickMode ? "Pick mode active. Click the map to place module layout centre." : "Pick mode cancelled.");
}
function mlWireInputs() {
[
"ml_total_modules",
"ml_module_width_m",
"ml_module_height_m",
"ml_orientation",
"ml_modules_per_row",
"ml_row_pitch_m",
"ml_module_gap_m",
"ml_rotation_deg"
].forEach(id => {
const el = ml(id);
if (!el) return;
el.addEventListener("input", () => {
if (mlState.centre) mlBuildLayout(mlState.centre);
else mlUpdateResults(mlGetInputs(), 0);
});
el.addEventListener("change", () => {
if (mlState.centre) mlBuildLayout(mlState.centre);
else mlUpdateResults(mlGetInputs(), 0);
});
});
ml("ml_draw_center")?.addEventListener("click", mlDrawAtMapCentre);
ml("ml_pick_site")?.addEventListener("click", mlTogglePickMode);
ml("ml_clear")?.addEventListener("click", mlClear);
ml("ml_satellite")?.addEventListener("click", mlToggleSatellite);
ml("ml_zoom_layout")?.addEventListener("click", mlZoomToLayout);
}
function mlInitMap() {
if (typeof maplibregl === "undefined" || typeof turf === "undefined") {
mlSetStatus("MapLibre or Turf failed to load.");
return;
}
mlState.map = new maplibregl.Map({
container: "module_map",
style: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
center: CONSTANTS.DEFAULT_CENTER || [-0.1276, 51.5072],
zoom: 15
});
mlState.map.on("load", () => {
mlState.map.addSource("ml-sat-source", {
type: "raster",
tiles: ["https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"],
tileSize: 256
});
mlState.map.addLayer({
id: "ml-sat-layer",
type: "raster",
source: "ml-sat-source",
layout: { visibility: "none" }
});
mlState.map.addSource("module-layout", {
type: "geojson",
data: mlState.currentGeoJSON
});
mlState.map.addLayer({
id: "ml-boundary-fill",
type: "fill",
source: "module-layout",
filter: ["==", "type", "module_layout_boundary"],
paint: { "fill-color": "#0066ff", "fill-opacity": 0.18 }
});
mlState.map.addLayer({
id: "ml-boundary-line",
type: "line",
source: "module-layout",
filter: ["==", "type", "module_layout_boundary"],
paint: { "line-color": "#00ffff", "line-width": 2 }
});
mlState.map.addLayer({
id: "ml-modules-fill",
type: "fill",
source: "module-layout",
filter: ["==", "type", "solar_module"],
minzoom: 15,
paint: { "fill-color": "#00ffff", "fill-opacity": ["interpolate", ["linear"], ["zoom"], 15, 0.2, 18, 0.55, 21, 0.85] }
});
mlState.map.addLayer({
id: "ml-modules-line",
type: "line",
source: "module-layout",
filter: ["==", "type", "solar_module"],
minzoom: 16,
paint: { "line-color": "#00ffff", "line-width": ["interpolate", ["linear"], ["zoom"], 16, 0.3, 20, 1.2] }
});
mlSetStatus("Ready. Draw at map centre or pick a site.");
mlUpdateResults(mlGetInputs(), 0);
});
mlState.map.on("click", (e) => {
if (!mlState.pickMode) return;
mlState.pickMode = false;
mlState.centre = [e.lngLat.lng, e.lngLat.lat];
mlBuildLayout(mlState.centre);
mlZoomToLayout();
});
}
function mlBoot() {
mlWireInputs();
mlInitMap();
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", mlBoot);
} else {
mlBoot();
}GIS Single-Line Diagram (SLD) V4 Config
A JavaScript file in GlobalGrid2050 covering grid substations. Served with the page at https://globalgrid2050.com/solar-bess-topology-v4/.
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 682104163682c1cc769a5cefb4d034f6d4ccb5995726d665e52b226de1a122fb
- 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-v4/gis-sld-v4-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) V4 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v4/indexforgis-sld-v4.html); Module Layout V4 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v4/module-layout-v4.html). Reached from 3 other entry points, including GlobalGrid2050 — Solar Battery Energy Storage System (BESS) Topology V4 Page (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v4/); GlobalGrid2050 Clone V3 to V4 Once Workflow (globalgrid2050); GlobalGrid2050 Clone V3 to V4 (globalgrid2050). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v4/.
- What it achieves
- GIS SLD Financial Sandbox V4. Config extracted by GridBot feature 002.
- Why it matters
- Loaded by the Indexforgis Single-Line Diagram (SLD) V4 page at https://globalgrid2050.com/solar-bess-topology-v4/indexforgis-sld-v4.html and 1 other page.
- Application
- globalgrid2050 · solar-bess-topology-v4 · script
- Uses
- none found
- Used by
- loaded by Indexforgis Single-Line Diagram (SLD) V4 (script src), loaded by Module Layout V4 (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-v4/gis-sld-v4-config.js:1-24 · blob 756f021a0b4740dcf69d6d7a7ab23a099959ca23 · 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 V4
// 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) V4 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-v4/.
Set aside from the main view: 99% of its lines are the same as solar-bess-topology-v7/gis-sld-financial-sandbox/gis-sld-v5-drawing.js (globalgrid2050), which stays. (near-copy-of, proposed by families.py). 98% of lines shared with GIS Single-Line Diagram (SLD) V5 Drawing; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.9886 to globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 solar-bess-topology-v7/gis-sld-financial-sandbox/gis-sld-v5-drawing.js:1-236 fd8e16fafe1e151fc86d425c0b2df0b5871cb98b
- sha256 3642719b4c06faa7c74f6eb85563edb81d026caa52bdcda19565942c8b32edfc
- target sha256 a18140d0099a9e711164494111cc81211424d4a6d546045aab15f923932b9bc1
- group of 2 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
geodesyglobalgrid2050 / solar-bess-topology-v4/gis-sld-v4-drawing.js · lines 1–234 of 234 · Entry point · pattern addCableRoutePinMarkers (shared by 2 files)
- What it does
- It calculates battery storage (BESS) and substations. Defines 12 functions or classes, including normBearing, getArrayAxisDeg, getRectPolygon, atlasHaversineKm, routeLengthKm.
- 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 3 files: 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/). Reached from 111 other entry points, including Cable Geometry Visualiser V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/cable-geometry-visualiser-v5.html); DC AC LV Topology Review V5 (globalgrid2050, https://globalgrid2050.com/solar-bess-topology-v5/dc-ac-lv-topology-review-v5.html); GlobalGrid2050 Historical Builds (globalgrid2050, https://globalgrid2050.com/historical_builds.html). It is itself an entry point, published at https://globalgrid2050.com/solar-bess-topology-v4/.
- What it achieves
- It gets array axis deg (`getArrayAxisDeg`), gets rect polygon (`getRectPolygon`) and routes length km (`routeLengthKm`). Defines `normBearing`, `getArrayAxisDeg`, `getRectPolygon` and 9 more. Its code works with 33 kV.
- Why it matters
- Loaded by the Indexforgis Single-Line Diagram (SLD) V4 page at https://globalgrid2050.com/solar-bess-topology-v4/indexforgis-sld-v4.html and 2 other pages.
- Application
- globalgrid2050 · solar-bess-topology-v4 · script
- Uses
- none found
- Used by
- 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)
- Produces
- normBearing, getArrayAxisDeg, getRectPolygon, atlasHaversineKm, routeLengthKm, getBlockAspect, getExportCableExtraKm, getCommittedCablePins, shouldShowExportCable, buildExportCableLine, addCableRoutePinMarkers, computeAndDraw
- Defines here
- normBearing, getArrayAxisDeg, getRectPolygon, atlasHaversineKm, routeLengthKm, getBlockAspect, getExportCableExtraKm, getCommittedCablePins, shouldShowExportCable, buildExportCableLine, addCableRoutePinMarkers, 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-v4/gis-sld-v4-drawing.js:1-234 · blob ab627edd96af6fb87e7ae843fb2967a10d0758c3 · 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 atlasHaversineKm(a, b) {
const R = 6378.137;
const r = Math.PI / 180;
const lon1 = a[0], lat1 = a[1], lon2 = b[0], lat2 = b[1];
const dLat = (lat2 - lat1) * r;
const dLon = (lon2 - lon1) * r;
const x = Math.sin(dLat / 2) ** 2 + Math.cos(lat1 * r) * Math.cos(lat2 * r) * Math.sin(dLon / 2) ** 2;
return R * 2 * Math.atan2(Math.sqrt(x), Math.sqrt(1 - x));
}
function routeLengthKm(coords) {
if (!Array.isArray(coords) || coords.length < 2) return 0;
let total = 0;
for (let i = 1; i < coords.length; i++) total += atlasHaversineKm(coords[i - 1], coords[i]);
return total;
}
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 getCommittedCablePins() {
return state.cableRouteCommitted && Array.isArray(state.cableRoutePins) ? state.cableRoutePins : [];
}
function shouldShowExportCable() {
if (state.cableRoutePinMode) return false;
if (Array.isArray(state.cableRoutePins) && state.cableRoutePins.length > 0 && !state.cableRouteCommitted) return false;
return true;
}
function buildExportCableLine(privateSubCoord, publicSubCoord, safeExtraOffsetKm) {
const routePoints = getCommittedCablePins();
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_pins: routePoints.length > 0,
route_pin_count: routePoints.length,
measurement_method: "atlas_haversine_6378_137_km"
});
}
function addCableRoutePinMarkers(features) {
if (!Array.isArray(state.cableRoutePins)) return;
state.cableRoutePins.forEach((coord, idx) => {
features.push(turf.point(coord, {
type: "export_cable_pin",
pin_index: idx + 1,
committed_to_route: Boolean(state.cableRouteCommitted)
}));
});
}
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 = routeLengthKm(exportCableLine.geometry.coordinates);
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_pin_count: state.cableRoutePins.length,
export_cable_route_committed: Boolean(state.cableRouteCommitted)
}));
if (shouldShowExportCable()) features.push(exportCableLine);
addCableRoutePinMarkers(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 = routeLengthKm([privateSubCoord, projected]);
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 && !state.suppressNextMapFit) {
const bbox = turf.bbox(state.currentGeoJSON);
map.fitBounds(bbox, { padding: 60, duration: 800 });
}
state.suppressNextMapFit = false;
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);
}
// ============================================================