claude/vigorous-stonebraker-41cc2d
needs attentionviewing older commitec4eea3 · incrementalpre-PRreviewed 2026-07-13 18:42 UTC1H · 3M · 7L · 5I- Purpose
- Atlas visualization of the Mexican national electricity system (SEN) — a public-facing reference map for CFE infrastructure
- Goal
- Add a planned-transmission layer showing CFE's Plan de Fortalecimiento y Expansión del SEN 2025-2030 (transmission lines and substations at various construction stages)
- Sub-goals
- SG-1: New transmission.json data file with 2 planned lines + 8 substations from Plan SEN
- SG-2: MapLibre sources and layers (glow/core/label for lines, circle for subs) with status-based coloring
- SG-3: Click popups for tx-subs and tx-lines with bilingual status labels
- SG-4: Legend toggle integration (off by default, distinct group key 'tx')
- SG-5: rehab flag propagation for project layer popups
- What
- New data file apps/web/public/atlas/data/transmission.json (17 lines) + 40 net additions to index.html adding fetch, FeatureCollection builders, 5 map layers, 2 click handlers, cursor events, GROUPS/TOGS entries for the new 'tx' layer group.
- Why
- The atlas lacked planned/in-progress transmission infrastructure — only operational generation plants and existing lines were shown. Plan SEN 2025-2030 is publicly available CFE data that adds analytical value for energy professionals reviewing grid development.
- Areas
- apps/web/public/atlas/data/transmission.json+17−0apps/web/public/atlas/index.html+195−53
- Blast
- 2 files changed in the incremental window (+12/−0 net for transmission.json, +40/−10 net for index.html changes in this commit); static public assets with no build step — change is self-contained.
Findings · 17
correctness3
HVDC line's 1,500 MW capacity not rendered in popup
apps/web/public/atlas/index.html
The HVDC entry has mw:1500 in GeoJSON properties but the tx-lines popup template omits it. The 1,500 MW capacity is the defining characteristic of this interconnection. Add `${+p.mw?' · '+p.mw.toLocaleString()+' MW':''}` after the km display.
Coordinate swap logic verified correct
apps/web/public/atlas/index.html
JSON stores from/to as [lat,lng]; GeoJSON builder correctly swaps to [lng,lat]. All 10 coordinates cross-check against known Mexican geography (Mexicali 32.63/-115.45, Hermosillo 29.07/-110.96, Laguna Verde 19.72/-96.41).
rehab integer coercion is safe
apps/web/public/atlas/index.html
rehab:pr.rehab?1:0 stores 0/1; read back as +p.rehab (unary plus, no-op on integer). Correct both ways.
security2
New popup handlers extend existing innerHTML XSS surface
apps/web/public/atlas/index.html
The tx-subs and tx-lines click handlers interpolate GeoJSON properties (p.n, p.a, p.b, p.kv, p.note, p.cod, p.edo) into innerHTML via pop() without escaping. Current data is static same-origin JSON so risk is low, but any future supply-chain compromise or CDN replacement would allow stored XSS. Add a minimal escapeHtml() helper used consistently across all popup handlers.
No CSP restricting connect-src for transmission.json fetch
apps/web/public/atlas/index.html
Without a connect-src 'self' CSP, a MITM or CDN misconfiguration could serve a tampered JSON file that reaches the innerHTML sink. Defense-in-depth gap — add a CSP header or SRI hash if the file moves to a CDN.
conventions5
Toggle color collision: `tx` reuses #2bd4ee already assigned to `lines`
apps/web/public/atlas/index.html
TOGS entry ['tx','Transmisión planeada (Plan SEN)','#2bd4ee',0] uses the same hex as the existing `lines` toggle. Both swatches in the legend are indistinguishable. Use a distinct hue (e.g. #f5a623 amber or #c084fc violet) to visually separate planned transmission from the existing operational lines layer.
Redundant `planeacion` arm in txColor match expression
apps/web/public/atlas/index.html
The MapLibre ['match',...] expression lists 'planeacion','#8aa4c8' explicitly, but #8aa4c8 is also the fallback — the explicit branch is dead code. Either drop it (rely on fallback) or change the fallback to a sentinel color so unrecognised statuses are visually flagged.
txst() maps concluido → 'concluido' (no expansion unlike other statuses)
apps/web/public/atlas/index.html
All other statuses get expanded Spanish phrases (en construcción, en planeación, en licitación) but concluido stays as-is. For consistency use 'concluido' or 'concluída' with accent, matching CFE terminology and the expansion style.
TOGS label rename 'Proyectos → Generación' may be inaccurate if projects include non-generation
apps/web/public/atlas/index.html
The projects layer was renamed to 'Generación · construcción/planeación'. If projects.json contains storage or T&D entries this label is inaccurate. Verify the data scope; 'Proyectos de generación' is safer if uncertain.
transmission.json src attribution uses en-dash (U+2013)
apps/web/public/atlas/data/transmission.json
Minor: the en-dash in the src field (–) is U+2013, not U+2014 EM DASH. Verify consistency with other data file src fields. Not blocking.
tests3
No bounds check on l.from/l.to arrays before coordinate indexing
apps/web/public/atlas/index.html
l.from[0], l.from[1], l.to[0], l.to[1] are accessed without verifying from/to are 2-element numeric arrays. A malformed entry silently renders NaN coordinates. Consistent with existing layer pattern but a single Array.isArray + length guard would catch authoring errors.
No numeric validation on substation lat/lng scalars
apps/web/public/atlas/index.html
s.lat and s.lng are used directly. Missing or string values produce silent NaN markers. A typeof-number guard or optional chaining with a fallback skip would surface authoring errors faster.
Graceful fallbacks correctly implemented
apps/web/public/atlas/index.html
.catch(()=>({lines:[],subs:[]})) and (tx&&tx.lines)||[] guards ensure a missing transmission.json never breaks the map. Positive finding.
improvement4
licitacion and planeacion share the same color — likely unintentional
apps/web/public/atlas/index.html
Both status values resolve to #8aa4c8 in txColor. If these represent distinct lifecycle phases they should be visually distinguishable. If grouping is intentional (both = not-yet-built), document that decision to prevent future confusion.
txst() duplicates status→label mapping; could be a shared statusLabel() helper
apps/web/public/atlas/index.html
The projects layer likely uses the same status vocabulary. Extracting a single statusLabel(st) helper shared by both popup handlers keeps the mapping in one place and makes future label changes atomic.
Straight-line 2-point geometry may misrepresent 1,500 km HVDC corridors
apps/web/public/atlas/data/transmission.json
Long HVDC lines modeled as straight point-to-point segments cross mountain ranges or the Gulf in unrealistic paths. Consider an optional waypoints[] array in the data schema for future multi-segment routing without breaking existing entries.
No waypoints data available for HVDC route — schematic is acceptable for now
apps/web/public/atlas/data/transmission.json
CFE has not published the exact HVDC corridor route. The straight-line schematic is appropriate given data availability; adding a disclaimer in the popup note (already present: 'trazo esquemático') covers this.
History · 10 commits
- a081002safeincremental0H · 0M · 0L2026-07-14 01:23
- 64dc83dneeds attentionincremental0H · 1M · 7L2026-07-13 20:03
- ec4eea3needs attentionincremental1H · 3M · 7L2026-07-13 18:42current
- f4b4129safeincremental0H · 0M · 3L2026-07-13 04:34
- 8ea0c8asafeincremental0H · 0M · 3L2026-07-13 04:21
- 37ce28asafeincremental0H · 2M · 3L2026-07-10 17:22
- d28c6daneeds attentionincremental0H · 3M · 10L2026-07-10 16:59
- 754a65dneeds attentionincremental0H · 3M · 4L2026-07-10 16:39
- a9190b2safeincremental0H · 0M · 5L2026-07-10 16:14
- 0bf12a0blockedfull1H · 2M · 4L2026-07-10 16:06