Skip to content

feat: Mapbox custom WebGL layer for utility network with FDEB bundling - #86

Merged
elizabetheonoja-art merged 1 commit into
Utility-Protocol:mainfrom
real-venus:feat/utility-network-layer
Jun 25, 2026
Merged

feat: Mapbox custom WebGL layer for utility network with FDEB bundling#86
elizabetheonoja-art merged 1 commit into
Utility-Protocol:mainfrom
real-venus:feat/utility-network-layer

Conversation

@real-venus

Copy link
Copy Markdown
Contributor

Mapbox GL JS Custom WebGL Layer for Utility Network Topology with FDEB (#51)

Closes #51

What's included

File Responsibility
src/types/network.ts NetworkEdge/flow/load types, interleaved VertexData, and invariants (50k viewport cap → 15k target, FDEB 40 iters / ε 0.001 / 0.7 compatibility / 8 subdivisions, DP 5 m @z≤14 → 20 m @z≥16, flow→hue / load→alpha).
src/utils/geo.ts Equirectangular lng/lat ↔ meters plus normalized Web-Mercator projection (the space Mapbox's u_matrix operates in).
src/utils/edgeSimplification.ts Douglas-Peucker with a zoom-aware epsilon in meters; runs in metric space, reprojects to lng/lat.
src/utils/edgeBundling.ts FDEB — subdivide, angle/scale/position compatibility, spring + compatibility-attraction iterations in normalized space, pinned endpoints, convergence early-exit.
src/components/map/UtilityNetworkLayer.ts CustomLayerInterface (onAdd/render/prerender/onRemove): compiles shaders, builds interleaved position+color buffers, draws gl.LINES with the projection matrix; zoom-bucket rebuild and setEdges() re-bind. Pure buildVertexData/edgeColor helpers.
src/components/map/shaders/utilityNetwork.{vert,frag} Per-vertex color with an optional dash-pattern uniform (mirrors the inline shaders).
src/store/slices/networkSlice.ts Visibility + load-status-filter store with a toggleNetworkVisibility action and filterEdges selector (drives the layer re-bind).
src/hooks/useNetworkTopology.ts Fetches GeoJSON and parses LineString features into NetworkEdge[].
tests/unit/* Simplification (zoom epsilon, DP), FDEB (subdivide, compatibility, endpoints pinned, parallel edges converge), vertex/color builder, the slice, and GeoJSON parsing.

Utility-Protocol#51)

Renders a dense planar utility graph (pipes/cables/conduits) past the ~10k-edge
limit of Mapbox's native line layer by uploading the whole network into one
interleaved vertex buffer and drawing it with a single gl.LINES call.

- types/network.ts: NetworkEdge/flow/load types, interleaved VertexData, and
  invariants (50k viewport cap → 15k target, FDEB 40 iters/eps 0.001/0.7
  compatibility, DP 5m@z14 / 20m@z16, flow→hue / load→alpha)
- utils/geo.ts: equirectangular lng/lat↔meters + normalized mercator projection
  (Mapbox u_matrix space)
- utils/edgeSimplification.ts: Douglas-Peucker with zoom-aware epsilon in meters
- utils/edgeBundling.ts: FDEB — subdivide, angle/scale/position compatibility,
  spring + compatibility-attraction iterations in normalized space, pinned
  endpoints, convergence early-exit
- components/map/UtilityNetworkLayer.ts: CustomLayerInterface (onAdd/render/
  prerender/onRemove) — compiles shaders, builds interleaved position+color
  buffers, draws gl.LINES with the projection matrix; zoom-aware rebuild and
  setEdges() re-bind; pure buildVertexData/edgeColor helpers
- shaders/utilityNetwork.vert/.frag: per-vertex color with optional dash pattern
- store/slices/networkSlice.ts: visibility + status-filter store with
  toggleNetworkVisibility action and filterEdges selector
- hooks/useNetworkTopology.ts: fetch GeoJSON LineStrings → NetworkEdge[]
- tests for simplification, FDEB, vertex/color builder, the slice, and parsing
@elizabetheonoja-art
elizabetheonoja-art merged commit 789c2a8 into Utility-Protocol:main Jun 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mapbox GL JS Custom Style Layer for Utility Network Topology with Dynamic Edge Bundling

2 participants