5.7 KiB
5.7 KiB
QGIS Traffic Signal Overrides
Goal
Make every automatically generated vehicle traffic signal independently identifiable and editable in QGIS. A user must be able to assign a display number, move a pole, rotate its assembly, adjust supported placement attributes, run reimport, and have Blender and Cesium consume that edited result without OSM regeneration overwriting it.
Background
- Current traffic signals are derived from OSM
highway=traffic_signalscontrols, road topology,vehicle_stop_lines.geojson, andintersection_surface.geojsonbyscripts/lib/traffic-signals.js. - Current sequential ids such as
signal-1depend on generation order and are not suitable as persistent edit identities. - Current
<geojsonDir>/traffic_signals.jsoncontains fully derivedpose.*data but is deliberately excluded from the GeoPackage and QGIS project. - Existing road editing establishes the desired lifecycle:
intermediatesinitializes a GeoPackage, the user edits it in QGIS, andreimportexports the edited data back to GeoJSON. Runningintermediatesagain may discard manual edits; that behavior remains explicit and unchanged.
Requirements
R1. Editable auxiliary layer
intermediatesmust create a point FeatureCollection containing one feature per physical signal assembly and import it into the area GeoPackage.- The generated QGIS project must expose the layer with a visible directional symbol and a label suitable for identifying individual signals.
- The auxiliary layer must not join
SCENE_LAYERSor the merged road scene because it is an editing/control artifact, not a road render layer.
R2. Stable identity and numbering
- Every generated feature must contain an immutable technical
signal_uidderived deterministically from its OSM control and physical approach identity, rather than array order. - Every feature must contain an editable
display_idintended for user-facing numbering. - Build/reimport validation must reject duplicate or missing
signal_uidvalues and duplicate non-emptydisplay_idvalues with an actionable error.
R3. Editable placement contract
- Point geometry represents the pole ground position.
- Editable attributes must include at least
display_id,heading_deg,phase_group,mast_reach_m,enabled, andz_offset_m. - Source/control attributes required for matching and diagnostics must be preserved, including
control_idand approach identity. - Vehicle stop coordinates remain independent attributes; moving the pole must not silently move the vehicle stop point.
- After reimport, the pipeline must deterministically rebuild
pose.pole,pose.arm,pose.head,pose.lenses, andpose.countdownfrom the edited point and attributes.
R4. Stage ownership
intermediatesinitializes the editable signal layer from current OSM/topology and derives the runtimetraffic_signals.jsonfrom it.reimportmust stage, validate, and export the editable signal layer along with the existing road layers, then rebuild the runtime JSON.blendermust rebuild runtimetraffic_signals.jsonfrom the current editable signal GeoJSON. It must not recompute signal placement directly from OSM and erase QGIS edits.cesiumandpreviewcontinue consuming artifacts derived from the same runtime JSON and retain matching signal node ids.
R5. Diagnostics and compatibility
- Invalid geometry, invalid numeric fields, duplicate identities, unsupported phase groups, and unmatched source references must fail before replacing valid output artifacts.
enabled=falsesuppresses a signal without requiring feature deletion, so automatic regeneration cannot accidentally resurrect an intentionally disabled assembly within the same edit lifecycle.- Existing areas without an editable signal layer must receive one on their next
intermediatesrun. No migration of previously hand-edited traffic signal JSON is required.
Acceptance Criteria
- A clean
intermediatesrun creates the editable traffic-signal GeoJSON, a GeoPackage layer with the same feature count, and a QGIS project layer with labels and directional symbols. - T junctions produce three editable features and cross junctions produce four, each with a unique deterministic
signal_uid. - Moving one point in QGIS and changing its
display_idandheading_deg, followed byreimport,blender,cesium,preview, changes only that signal assembly's placement/identity-facing metadata while preserving its vehicle stop point. - Re-running
blenderafter reimport does not overwrite the QGIS-edited pole position or heading from OSM. - Setting one feature to disabled removes its static and dynamic signal assets while leaving the other signals intact.
- Duplicate
signal_uidor non-emptydisplay_id, invalid geometry, and invalid placement fields abort reimport without partially replacing GeoJSON outputs. - Blender/Cesium node counts and ids match the enabled features in the final runtime JSON; lights and countdowns continue switching correctly.
- Existing road GeoPackage import/reimport behavior and merged scene layer order remain unchanged.
- Unit/integration tests cover stable ids, editable-feature validation, override-to-pose reconstruction, auxiliary GeoPackage round-trip, and stage ownership.
Out Of Scope
- Preserving QGIS edits across a subsequent full
intermediatesrebuild; as with road edits, users must preserve or reapply edits before regenerating the GeoPackage. - A complete traffic-controller timing editor or arbitrary multi-phase signal program.
- Independent editing of each lens or countdown glyph position; those remain derived from the assembly point, heading, and shared layout.
- Automatically assigning a stable identity to a brand-new signal feature drawn manually in QGIS.