Skip to content

feat(api): add turn by turn directions types - #130

Open
ychae517 wants to merge 2 commits into
devfrom
turn_by_turn
Open

ychae517 wants to merge 2 commits into
devfrom
turn_by_turn

Conversation

@ychae517

Copy link
Copy Markdown

Description

Adds a new turn by turn directions format to replace the raw turn angle. Each step has an enum type that maps directly to an instruction the frontend shows, so the FE doesn't have to interpret angles without knowing what other branches exist. Types only; mock data comes in a follow-up PR.

Format

Directions is an ordered array of DirectionStep, a discriminated union on type:

type extra fields meaning
depart start walking (always first)
turn direction: slight_left | left | sharp_left | slight_right | right | sharp_right turn at an intersection or a sharp enough bend
continue go straight where another branch could be mistaken for the route
cross street: string | null cross a street
arrive end of the walking path (always last)

Every step also has path_index (index into path_coords), distance (meters until the next step), onto (street/path name after the step, or null), and landmark (nearby landmark, or null).

The enums can be extended as the algorithm improves; the FE should fall back to a generic instruction for values it doesn't recognize.

Type of Change

  • New feature (feat)

Changed Files

  • src/walking/directions.ts (new)
    • Zod schemas + inferred types: TurnDirection, DirectionStep, DirectionStepType, Directions
  • test/directions.test.ts (new)
    • Unit tests: valid directions parse, invalid steps are rejected, JSON schema generates

Related Issues

Part of #97 (step 1: types)

Does your code rely on another PR

No

Testing Done

Vitest:

  • new tests added: test/directions.test.ts (13 tests, all passing)
  • tsc --noEmit and typedoc --treatWarningsAsErrors pass locally

Checklist

  • Commit messages follow Conventional Commits
  • PR title follows <type>(scope): short description
  • PR target branch is not main and is our current working update branch (e.g. maizebus2.1, dev)
  • No print() / debugPrint() / console.log() left in production code
  • Secrets / keys not committed

Replaces the raw turn angle format with enum-typed steps that map
directly to the instructions the frontend shows. Types only; mock
data comes in a follow-up PR.

Part of #97.
@ychae517
ychae517 requested a review from jumpy-cat October 29, 2026 20:32

This branch has not been deployed

No deployments
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.

1 participant