# leradurova/map-matching architecture

> Architecture diagram of the GitHub repository leradurova/map-matching, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leradurova/map-matching
- Repository: https://github.com/leradurova/map-matching

## Overview

This is a small, self-contained Python road-matching script. Its workflow turns OSM road geometry and GPS samples into candidate road positions, scores feasible routes between candidates, and visualizes the matched path. The excerpts show the matching and rendering calls; they do not show how the map file is opened or the full program entry point, so that data link is marked unverified.

Main entry points: [`map_matching_short.py`](https://github.com/leradurova/map-matching/blob/master/map_matching_short.py) (Road candidates), [`map.osm.txt`](https://github.com/leradurova/map-matching/blob/master/map.osm.txt) (OSM map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Inputs and map"]
  node_osm["OSM map<br/>[map.osm.txt]"]
  node_map_loader["Road extraction"]
  node_gps["GPS samples"]
end

subgraph group_matching["Map matching"]
  node_candidates["Road candidates"]
  node_road_graph["Road graph"]
  node_sequence_match["Sequence matching"]
end

subgraph group_output["Visualization"]
  node_plot["Path visualization"]
end

node_user(("User"))

node_osm -.->|"supplies map"| node_map_loader
node_gps -.->|"projects samples"| node_candidates
node_map_loader -.->|"provides segments"| node_candidates
node_candidates -->|"defines positions"| node_road_graph
node_gps -->|"provides samples"| node_sequence_match
node_road_graph -->|"routes candidates"| node_sequence_match
node_sequence_match -->|"renders matches"| node_plot
node_user -.->|"views output"| node_plot

click node_osm "https://github.com/leradurova/map-matching/blob/master/map.osm.txt"
click node_map_loader "https://github.com/leradurova/map-matching/blob/master/map_matching_short.py"
click node_gps "https://github.com/leradurova/map-matching/blob/master/map_matching_short.py"
click node_candidates "https://github.com/leradurova/map-matching/blob/master/map_matching_short.py"
click node_road_graph "https://github.com/leradurova/map-matching/blob/master/map_matching_short.py"
click node_sequence_match "https://github.com/leradurova/map-matching/blob/master/map_matching_short.py"
click node_plot "https://github.com/leradurova/map-matching/blob/master/map_matching_short.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_osm,node_map_loader,node_gps,node_user toneBlue
class node_candidates,node_road_graph,node_sequence_match toneAmber
class node_plot toneMint
```

## Components

### Inputs and map

- [OSM map](https://github.com/leradurova/map-matching/blob/master/map.osm.txt): `map.osm.txt`
- [Road extraction](https://github.com/leradurova/map-matching/blob/master/map_matching_short.py): `map_matching_short.py`
- [GPS samples](https://github.com/leradurova/map-matching/blob/master/map_matching_short.py): `map_matching_short.py`

### Map matching

- [Road candidates](https://github.com/leradurova/map-matching/blob/master/map_matching_short.py): `map_matching_short.py`
- [Road graph](https://github.com/leradurova/map-matching/blob/master/map_matching_short.py): `map_matching_short.py`
- [Sequence matching](https://github.com/leradurova/map-matching/blob/master/map_matching_short.py): `map_matching_short.py`

### Visualization

- [Path visualization](https://github.com/leradurova/map-matching/blob/master/map_matching_short.py): `map_matching_short.py`

### Other components

- **User**

## Connections

- OSM map → Road extraction: supplies map
- GPS samples → Road candidates: projects samples (evidence: `map_matching_short.py`)
- Road extraction → Road candidates: provides segments (evidence: `map_matching_short.py`)
- Road candidates → Road graph: defines positions (evidence: `map_matching_short.py`)
- GPS samples → Sequence matching: provides samples (evidence: `map_matching_short.py`)
- Road graph → Sequence matching: routes candidates (evidence: `map_matching_short.py`)
- Sequence matching → Path visualization: renders matches (evidence: `map_matching_short.py`)
- User → Path visualization: views output
