# How GPS knows where you are

> A process map exported from forks.world (https://forks.world). Author: Brian. Source: https://forks.world/p/cmv0kps6i0048jn06bzsy2xom
> It describes who does what, in what order, and with which technology. Read the plain-language sections first; the JSON at the end is the exact, complete data.

## Summary

- 18 steps across 3 layers
- Persona: You
- Technology / systems: GPS satellites, Your phone, The map app

## How to read this file

- A process is made of **layers**. The main layer is the top level; any step of kind `subprocess` opens a detail layer with its own lanes and steps.
- **Lanes** are either persona (people/roles) or technology (systems). Each step belongs to one lane; `using` lists tools a person uses for that step.
- Step kinds: `start`, `task`, `decision` (its arrows carry the answer as a label), `subprocess`, `end`.

## How GPS knows where you are

Lanes:
- GPS satellites: technology / system (id `sat`)
- Your phone: technology / system (id `phone`)
- The map app: technology / system (id `map`)
- You: person / role (id `you`)

Steps, in the order they run:

1. **Each satellite broadcasts its position and the exact time** [start; GPS satellites; id `g1`]
   - then Pick up the signals
2. **Pick up the signals** [task; Your phone; id `g2`]
   - then Can it hear at least four satellites?
3. **Can it hear at least four satellites?** [decision; Your phone; id `g3`]
   - if "Yes" go to Measure how long each signal took to arrive; if "No" go to Move outdoors or wait for a clear sky
4. **Measure how long each signal took to arrive** [task; Your phone; id `g4`]
   - then Turn the delays into distances
5. **Turn the delays into distances** [task; Your phone; id `g5`]
   - then Find the one point that fits all of them (trilateration)
6. **Find the one point that fits all of them (trilateration)** [subprocess; Your phone; id `g6`], opens the detail layer "Trilateration"
   - then Correct for Einstein's relativity, or errors build up fast
7. **Correct for Einstein's relativity, or errors build up fast** [subprocess; GPS satellites; id `g7`], opens the detail layer "Why relativity matters"
   - then Snap the point to the nearest road
8. **Snap the point to the nearest road** [task; The map app; id `g8`]
   - then The blue dot appears
9. **The blue dot appears** [end; You; id `g9`]
10. **Move outdoors or wait for a clear sky** [task; You; id `g3a`]
   - then Can it hear at least four satellites?

```mermaid
flowchart LR
  subgraph l_sat["GPS satellites"]
    n_g1(["Each satellite broadcasts its position and the exact time"])
    n_g7[["Correct for Einstein's relativity, or errors build up fast"]]
  end
  subgraph l_phone["Your phone"]
    n_g2["Pick up the signals"]
    n_g3{"Can it hear at least four satellites?"}
    n_g4["Measure how long each signal took to arrive"]
    n_g5["Turn the delays into distances"]
    n_g6[["Find the one point that fits all of them (trilateration)"]]
  end
  subgraph l_map["The map app"]
    n_g8["Snap the point to the nearest road"]
  end
  subgraph l_you["You"]
    n_g3a["Move outdoors or wait for a clear sky"]
    n_g9(["The blue dot appears"])
  end
  n_g1 --> n_g2
  n_g2 --> n_g3
  n_g3 -->|"Yes"| n_g4
  n_g3 -->|"No"| n_g3a
  n_g3a --> n_g3
  n_g4 --> n_g5
  n_g5 --> n_g6
  n_g6 --> n_g7
  n_g7 --> n_g8
  n_g8 --> n_g9
```

### Why relativity matters (detail of step "Correct for Einstein's relativity, or errors build up fast")

Lanes:
- GPS satellites: technology / system (id `sat`)

Steps, in the order they run:

1. **Satellite clocks run faster because gravity is weaker up there** [start; GPS satellites; id `r1`]
   - then And slower because they move fast
2. **And slower because they move fast** [task; GPS satellites; id `r2`]
   - then The net effect: they gain about 38 microseconds a day
3. **The net effect: they gain about 38 microseconds a day** [task; GPS satellites; id `r3`]
   - then Uncorrected, position errors would grow by kilometers per day
4. **Uncorrected, position errors would grow by kilometers per day** [end; GPS satellites; id `r4`]

```mermaid
flowchart LR
  subgraph l_sat["GPS satellites"]
    n_r1(["Satellite clocks run faster because gravity is weaker up there"])
    n_r2["And slower because they move fast"]
    n_r3["The net effect: they gain about 38 microseconds a day"]
    n_r4(["Uncorrected, position errors would grow by kilometers per day"])
  end
  n_r1 --> n_r2
  n_r2 --> n_r3
  n_r3 --> n_r4
```

### Trilateration (detail of step "Find the one point that fits all of them (trilateration)")

Lanes:
- Your phone: technology / system (id `phone`)

Steps, in the order they run:

1. **One satellite: you are somewhere on a sphere** [start; Your phone; id `t1`]
   - then Two: on a circle
2. **Two: on a circle** [task; Your phone; id `t2`]
   - then Three: on two possible points
3. **Three: on two possible points** [task; Your phone; id `t3`]
   - then A fourth fixes the exact point and your clock error
4. **A fourth fixes the exact point and your clock error** [end; Your phone; id `t4`]

```mermaid
flowchart LR
  subgraph l_phone["Your phone"]
    n_t1(["One satellite: you are somewhere on a sphere"])
    n_t2["Two: on a circle"]
    n_t3["Three: on two possible points"]
    n_t4(["A fourth fixes the exact point and your clock error"])
  end
  n_t1 --> n_t2
  n_t2 --> n_t3
  n_t3 --> n_t4
```

## Full data (JSON)

```json
{
  "title": "How GPS knows where you are",
  "maps": {
    "m_rel": {
      "id": "m_rel",
      "lanes": [
        {
          "id": "sat",
          "name": "GPS satellites",
          "type": "system"
        }
      ],
      "steps": [
        {
          "id": "r1",
          "kind": "start",
          "lane": "sat",
          "next": [
            {
              "to": "r2"
            }
          ],
          "uses": [],
          "label": "Satellite clocks run faster because gravity is weaker up there"
        },
        {
          "id": "r2",
          "kind": "task",
          "lane": "sat",
          "next": [
            {
              "to": "r3"
            }
          ],
          "uses": [],
          "label": "And slower because they move fast"
        },
        {
          "id": "r3",
          "kind": "task",
          "lane": "sat",
          "next": [
            {
              "to": "r4"
            }
          ],
          "uses": [],
          "label": "The net effect: they gain about 38 microseconds a day"
        },
        {
          "id": "r4",
          "kind": "end",
          "lane": "sat",
          "next": [],
          "uses": [],
          "label": "Uncorrected, position errors would grow by kilometers per day"
        }
      ],
      "title": "Why relativity matters",
      "parent": {
        "map": "m_root",
        "step": "g7"
      }
    },
    "m_tri": {
      "id": "m_tri",
      "lanes": [
        {
          "id": "phone",
          "name": "Your phone",
          "type": "system"
        }
      ],
      "steps": [
        {
          "id": "t1",
          "kind": "start",
          "lane": "phone",
          "next": [
            {
              "to": "t2"
            }
          ],
          "uses": [],
          "label": "One satellite: you are somewhere on a sphere"
        },
        {
          "id": "t2",
          "kind": "task",
          "lane": "phone",
          "next": [
            {
              "to": "t3"
            }
          ],
          "uses": [],
          "label": "Two: on a circle"
        },
        {
          "id": "t3",
          "kind": "task",
          "lane": "phone",
          "next": [
            {
              "to": "t4"
            }
          ],
          "uses": [],
          "label": "Three: on two possible points"
        },
        {
          "id": "t4",
          "kind": "end",
          "lane": "phone",
          "next": [],
          "uses": [],
          "label": "A fourth fixes the exact point and your clock error"
        }
      ],
      "title": "Trilateration",
      "parent": {
        "map": "m_root",
        "step": "g6"
      }
    },
    "m_root": {
      "id": "m_root",
      "lanes": [
        {
          "id": "sat",
          "name": "GPS satellites",
          "type": "system"
        },
        {
          "id": "phone",
          "name": "Your phone",
          "type": "system"
        },
        {
          "id": "map",
          "name": "The map app",
          "type": "system"
        },
        {
          "id": "you",
          "name": "You",
          "type": "person"
        }
      ],
      "steps": [
        {
          "id": "g1",
          "kind": "start",
          "lane": "sat",
          "next": [
            {
              "to": "g2"
            }
          ],
          "uses": [],
          "label": "Each satellite broadcasts its position and the exact time"
        },
        {
          "id": "g2",
          "kind": "task",
          "lane": "phone",
          "next": [
            {
              "to": "g3"
            }
          ],
          "uses": [],
          "label": "Pick up the signals"
        },
        {
          "id": "g3",
          "kind": "decision",
          "lane": "phone",
          "next": [
            {
              "to": "g4",
              "label": "Yes"
            },
            {
              "to": "g3a",
              "label": "No"
            }
          ],
          "uses": [],
          "label": "Can it hear at least four satellites?"
        },
        {
          "id": "g3a",
          "kind": "task",
          "lane": "you",
          "next": [
            {
              "to": "g3"
            }
          ],
          "uses": [],
          "label": "Move outdoors or wait for a clear sky"
        },
        {
          "id": "g4",
          "kind": "task",
          "lane": "phone",
          "next": [
            {
              "to": "g5"
            }
          ],
          "uses": [],
          "label": "Measure how long each signal took to arrive"
        },
        {
          "id": "g5",
          "kind": "task",
          "lane": "phone",
          "next": [
            {
              "to": "g6"
            }
          ],
          "uses": [],
          "label": "Turn the delays into distances"
        },
        {
          "id": "g6",
          "kind": "subprocess",
          "lane": "phone",
          "next": [
            {
              "to": "g7"
            }
          ],
          "uses": [],
          "child": "m_tri",
          "label": "Find the one point that fits all of them (trilateration)"
        },
        {
          "id": "g7",
          "kind": "subprocess",
          "lane": "sat",
          "next": [
            {
              "to": "g8"
            }
          ],
          "uses": [],
          "child": "m_rel",
          "label": "Correct for Einstein's relativity, or errors build up fast"
        },
        {
          "id": "g8",
          "kind": "task",
          "lane": "map",
          "next": [
            {
              "to": "g9"
            }
          ],
          "uses": [],
          "label": "Snap the point to the nearest road"
        },
        {
          "id": "g9",
          "kind": "end",
          "lane": "you",
          "next": [],
          "uses": [],
          "label": "The blue dot appears"
        }
      ],
      "title": "How GPS knows where you are",
      "parent": null
    }
  }
}
```
