feat: Mapbox custom WebGL layer for utility network with FDEB bundling - #86
Merged
elizabetheonoja-art merged 1 commit intoJun 25, 2026
Conversation
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
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mapbox GL JS Custom WebGL Layer for Utility Network Topology with FDEB (#51)
Closes #51
What's included
src/types/network.tsNetworkEdge/flow/load types, interleavedVertexData, 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.tslng/lat ↔ metersplus normalized Web-Mercator projection (the space Mapbox'su_matrixoperates in).src/utils/edgeSimplification.tssrc/utils/edgeBundling.tssrc/components/map/UtilityNetworkLayer.tsCustomLayerInterface(onAdd/render/prerender/onRemove): compiles shaders, builds interleaved position+color buffers, drawsgl.LINESwith the projection matrix; zoom-bucket rebuild andsetEdges()re-bind. PurebuildVertexData/edgeColorhelpers.src/components/map/shaders/utilityNetwork.{vert,frag}src/store/slices/networkSlice.tstoggleNetworkVisibilityaction andfilterEdgesselector (drives the layer re-bind).src/hooks/useNetworkTopology.tsNetworkEdge[].tests/unit/*