Skip to content

ARCHITECTURE

github-actions[bot] edited this page Nov 25, 2026 · 10 revisions

Lane Studio architecture

Lane Studio is a layer on iD. iD provides the editor (data graph, history, modes, OSM API, imagery, validator, sidebar, saving); Lane Studio adds a map layer drawing roads lane by lane, sidebar sections and fields that edit lane tags, tools, panes, a walkthrough and help pages. iD changes only through small hooks that keep its behaviour by default (Code map).

Two rules:

  • The tags are the truth. Everything drawn is worked out from the data on every redraw. Lining lanes up, tapers, junction boxes and guide lines are drawing only; tags change only through edits, each one iD action and undo step.
  • Geometry is in metres, in a local frame (metricFrame), converted to map coordinates only to draw.

Modules (modules/lanes/)

Folder Holds
model/ Pure functions: parseLanes reads lane tags into lanes per direction, serialiseLanes writes back only the keys that changed; lane types, markings, signs, connectivity, street features, street parking, speed limits, active traffic management
actions/ iD actions for lane edits, markings, signs, copying and connecting lanes
geometry/ Everything drawn, in metres: laneLayout, roadGeometry, streetGeometry, laneSymbols, parkingGeometry, parkingSpaceGeometry, railGeometry, railFeatures, waterGeometry, worksGeometry, signGeometry, routing.ts
svg/ The lanes layer (svgLanes) that runs the geometry and draws it, with click targets; vertices.ts
core/ State with d3 dispatch: selected lanes, tools, settings, the tools' modes (Routing, Speed Limit, Connectivity), brand logos, what's new, boot (laneStudioInit)
osm/ Looking along roads: the corridor ahead, roundabouts
ui/ Sidebar sections and fields, panes, panels, welcome screen, what's new, walkthrough, help pages
validations/ The Lane tags rule

Files by feature: Code map.

Drawing a frame

svgLanes redraws when the map moves or the graph changes:

  1. Collect the lane roads, carriageway areas, islands and street features in view.
  2. roadGeometry works out the roads: fitted into their carriageway areas; parted round painted areas between lanes (partsFromAreas, road_marking=restriction ways and multipolygons; rings, areas beyond another road and junction ends stay put); shifted and tapered at each join so lanes that carry on line up (alignAt, alignBranches, alignMerges, from connectivity relations or turn:lanes; alignFork where a road divides into one-way roads, forkPairs saying which lane leads into which branch; joinRun where two roads with lanes of different widths meet end to end; both give the way a ForkRun); junctions (junctionAt: through road, side roads, the box, flares, splits); road pieces (buildPieces: lanes, lines, arrows, labels, roadside strips); guide lines (junctionConnections); lanes channelled between islands.
  3. streetGeometry, signGeometry, laneSymbols, the railway and parking geometry use the same shifts; waterGeometry draws water under it all and worksGeometry building work (roadworks cones along the road pieces).
  4. Draw it all with click targets, then mark iD's own features for what was drawn (markIdFeatures).

Work is skipped when nothing changed: at most one redraw a frame (drawWhenChanged), geometry kept while the graph and view are the same, layouts cached per way version (cachedLayout), and attributes written only when they change (attrChanged).

Editing and the sidebar

  • Clicking a lane selects it in laneState; the Lanes section edits the road's model and actionChangeLanes writes it as one action. Tools (laneTools) change what a click does; Esc returns to Select.
  • One menu with iD's: road fields are iD field types (uiFields.lanes_*) and fields (lanes/*) placed in road presets by arrangeFields (common ones in fields, the rest in moreFields). field_filter.ts leaves out iD's field for a tag Lane Studio edits. Lane Studio's own sections build fields with fieldShell and laneField, which make iD's markup. Every field's i button (fieldReference) shows _lanes.info.<topic> and a wiki link (fieldInfoPages); a test checks each has both.

Tools

  • Speed Limit (lanes-speed mode): laneSpeed holds the measure and pick; the layer colours lanes by speedClassOf; clicks write maxspeed or maxspeed:lanes.
  • Routing (lanes-routing mode): vehicleRoutes explores junction by junction with the drawing's junction rules, per vehicle profile, blocked by restrictions and limits; the lanes layer colours each lane by laneAccess (core/route_access.ts) for the vehicle picked, from model/access.ts.
  • Connectivity (lanes-connectivity mode): laneLinksAt (geometry/connectivity.ts) lists every connection from the lanes arriving at a node: those a type=connectivity relation declares (resolveConnectivity reads its members, via node or via ways), and between roads no relation covers, those routing works out (junctionLaneMoves), less banned turns. svg/connectivity.ts draws them lane centre to lane centre; laneConnectivity holds the lane picked; actionConnectLanes splits a road running through the junction, starts a new relation from the connections worked out, and deletes it when empty. The Lane tags rule checks relations with connectivityProblems.

Walkthrough and help

uiIntroSetChapters gives iD's walkthrough Lane Studio's chapters (ui/intro.ts), and uiPaneHelpAddDocs puts Lane Studio's pages first in the Help pane (ui/help.ts); their text is _lanes.intro and _lanes.help.

Tests

test/spec/lanes/: model, actions, geometry, routing, UI and the version rules. Geometry and routing tests build small graphs in code or load fixtures from real data (test/spec/lanes/fixtures/).

Developer pages

Running locally · Code map · iD core · Customising · iD accessibility · Website statistics

Lane Studio

Clone this wiki locally