Skip to content

LocalStorage Schema

Marco Supino edited this page Jun 5, 2026 · 11 revisions

🇮🇱 עברית

LocalStorage Schema

NavAid persists everything under the navaid.* key prefix. There is no other storage (no IndexedDB, no cookies).

Keys

Key Type Default Notes
navaid.route JSON string null Full route state: { waypoints, legs, notes }.
navaid.lang "he" / "en" "he" Last chosen language.
navaid.layer string "CVFR" Base layer.
navaid.bearing number string "0" Map rotation in degrees.
navaid.toolbarPos JSON { x, y } n/a Toolbar screen position.
navaid.toolbarCollapsed "0" / "1" "1" on phones, "0" desktop Toolbar collapse state.
navaid.yellowAlpha number string "1" Label background opacity 0..1.
navaid.mapOpacity number string "1" Base-map brightness 0.1..1 on screen and in PNG export.
navaid.wpSize number string "1" Waypoint circle / name multiplier 0.6..2.0.
navaid.legArrowSize number string "1" Leg info marker size multiplier 0.3..2.0.
navaid.showNavWP "0" / "1" "1" "Show Navigation Waypoints" toggle.
navaid.showAirfields "0" / "1" "1" "Show Airfields" toggle.
navaid.showVor "0" / "1" "0" "Show VOR stations" marker overlay toggle. Radial/DME readouts can still work when markers are hidden.
navaid.vorRef string null Global reference VOR ident for map, inspector and Flight Plan radial/DME readouts. Removed when no VOR is selected.
navaid.showFreqChanges "0" / "1" "1" "Show/Add Freq Changes" overlay and linked lightning callouts. Replaces legacy navaid.showCommChange; old stored-off values are ignored.
navaid.showWpNames "0" / "1" "1" "Show Waypoint names" toggle.
navaid.wpNameAngle "0" / "90" / "180" / "270" "0" Rotation of waypoint name labels in degrees (cycled by the ⟳ button).
navaid.showReturn "0" / "1" "0" "Show return path" toggle.
navaid.showMidLeg "0" / "1" "0" "Show leg dist" toggle.
navaid.highlightDiff "0" / "1" "0" "Highlight alt/speed diff" toggle.
navaid.sec.<id> "0" / "1" "0" Per-section expand/collapse state. <id> is one of build, view, display, charts, export, print. Accordion: opening one section sets the others to "0".
navaid.pageOrient "portrait" / "landscape" "portrait" Print page orientation, flipped via the ▭/▯ button next to A3 / A4. Saved on every flip; restored on boot.
navaid.aircraft JSON { gph, taxiGal } { gph: 8, taxiGal: 1.1 } Fuel calculator settings. Filled by the Flight Plan modal's Gallons per Hour + Taxi/T.O. (gal) inputs.
navaid.fpPos JSON { x, y } n/a Flight-Plan modal screen position (draggable via the title bar).
navaid.commFreqOverrides JSON { [callSignId]: freq } n/a Local frequency overrides per call sign, set via the inspector or the 📡 Freq table. Keys are upper-cased call-sign IDs; values are validated MHz strings. Removed entirely when the last override is cleared.

sessionStorage (per-tab, cleared on tab close):

Key Notes
navaid.fpOpen "1" while the Flight Plan modal is open — restored across a language switch.
navaid.selected JSON of the currently selected leg/waypoint/note — restored across a language switch.

This list is normative as of v1.2.

Reading / writing

All access goes through small helpers in core.js / ui.js that catch and ignore storage errors (private browsing, quota exceeded). Failure modes:

  • Quota exceeded — NavAid surfaces an alert (errStorageFull) so the user can export the route before continuing.
  • JSON parse or schema error on navaid.route - current versions warn and preserve the original saved blob instead of overwriting it with empty state.

Schema of navaid.route

{
  "waypoints": [
    {
      "lat": 32.084,
      "lng": 34.778,
      "name": "TLV"          // required string; use "" for unnamed waypoint
    }
  ],
  "legs": [
    {
      "inboundAltitude": 3000,
      "outboundAltitude": 3000,
      "flightSpeed": 90,                // kt
      "vorRef": "NAT",                  // optional per-leg VOR override
      "inLabel":  { "a": 0, "p": 44 },  // marker offset: along leg & perpendicular px
      "outLabel": { "a": 0, "p": -44 }
    }
  ],
  "notes": [
    {
      "lat": 32.55,
      "lng": 35.55,
      "text": "climb 4500ft",
      "color": "#ffd84a",
      "shape": "rect"   // or "oval"
    },
    {
      "lat": 32.30,
      "lng": 34.95,
      "text": "Freq change",
      "color": "#ffd84a",
      "shape": "rect",
      "cc": "TYONA",
      "freqName": "PLUTO_WEST",
      "freq": "118.40"
    }
  ]
}

legs.length === max(0, waypoints.length - 1).

inLabel / outLabel are marker offsets used by the renderer. vorRef on a leg is optional; when present, it overrides the global navaid.vorRef for that leg's Flight Plan Radial/DME cells. Frequency-change callouts are stored as notes so export/import and localStorage preserve the user's chosen call sign, frequency, and callout tail position. Current route JSON validation is strict for known fields while allowing extras for forward compatibility.

Reset / migration

To wipe everything NavAid owns:

Object.keys(localStorage)
  .filter(k => k.startsWith('navaid.'))
  .forEach(k => localStorage.removeItem(k));
location.reload();

Old single-language keys ("Nav", "Heli") are migrated to the new layer names on first load by a small migration shim in core.js.

Naming rules for new keys

  • Always prefix navaid..
  • Store strings; serialize objects via JSON.stringify.
  • Read with try { … } catch (e) { /* storage unavailable */ }.
  • Document the key here when you add it.

Clone this wiki locally