2.5 KiB
2.5 KiB
Technical Design
Boundaries
bin/road-workbench.jsowns process startup and creates an import session/workspace.workbench/server.jsowns HTTP routes and session-local files; it continues to callcompileInput()for compilation.workbench/client/index.htmlandworkbench/client/app.jsadd the upload/bootstrap state only; existing editing panels remain unchanged.src/compile/compiler.jsandsrc/osm.jsremain the source of truth for input validation and OSM processing.
Data Flow
- CLI starts a workbench with an optional existing
--inputfor compatibility, or with no input for the new import-first flow. - The browser submits multipart OSM content (bounded by a server upload limit) to a new session/import endpoint.
- The server validates the filename/content, creates a unique workspace directory under a configured workbench data root, and writes:
source.osmnative-road-overrides.jsonwith the existing empty schemanative-traffic-signals.jsonwith the existing empty schemaRoadCompilerInput.jsonusing conservative defaults and workspace-relative output paths
- The server calls
compileInput()and swaps the active session from the import screen to the existing state/map view. - Existing routes operate against the active session's
areaobject. A failed import/compile removes only the new staging directory and leaves any prior active session untouched.
Defaults and Compatibility
- Area id is derived from a sanitized user-provided name or uploaded basename, with a unique suffix when necessary.
options.edgeLinesandoptions.junctionTemplatesuse the same shape required byvalidateInput(); no new compiler options are introduced.- Existing
--input RoadCompilerInput.jsonstartup remains supported by adapting it into the same active-session context. - The server binds to localhost as it does today and does not add authentication or remote persistence.
Error and Recovery
- Reject empty/non-XML uploads, oversized bodies, malformed OSM, and compile failures with JSON errors suitable for the browser.
- Stage all files before switching the active session; cleanup on failure.
- Keep workspace directories recoverable on disk; do not delete an existing user workspace during a new import.
Testing Strategy
- Unit/integration tests for workspace initialization, default input generation, upload size/content validation, and failed-import cleanup.
- HTTP smoke test for import -> state -> compile/export using the existing fixture OSM.
- Existing compiler and fixture tests remain the regression gate.