Interactive web-based map of the Hungarian road network using official DATEX II data from Magyar KΓΆzΓΊt (Hungarian Public Roads).
- Interactive Map with toggleable point layers (motorway junctions, intersections, services)
- Dynamic Data Loading - only fetches data for current viewport (high performance)
- Search Functionality - search for locations by name
- Layer Controls - toggle visibility of 5 different point categories (top-right corner)
- 30 Point Types - complete icon system for all junction and infrastructure types
- REST API - full-featured API for accessing road network data
- Modern Stack - DuckDB, FastAPI, Leaflet.js, Docker Compose
What You See on the Map:
- Gray/Colored Roads (Background): These come from OpenStreetMap (the base layer), providing geographic context
- Icons (π· β β π): These are your DATEX II reference points from Magyar KΓΆzΓΊt - junctions, bridges, service areas, etc.
What You DON'T See:
- Road lines drawn from your data: The DATEX II database contains reference points only, not road geometry (the actual paths/lines of roads)
Why?
Your data is a location reference system designed for traffic management ("accident at M1 Junction 15"), not a complete road map. The OpenStreetMap base layer provides the road visualization, while your Magyar KΓΆzΓΊt points mark the official reference locations.
- 63,488 Location codes
- 14,476 Geographic points with coordinates (junctions, intersections, bridges, tunnels)
- 11,197 Intersections
- 4,199 Road metadata entries
- 3,201 Administrative areas
- Motorways: M0-M86 (ring roads and major highways)
- Road Classifications: 1st, 2nd, and 3rd class roads
Data Type: This DATEX II dataset contains location reference points (junctions, intersections, service areas, bridges) but NOT road geometry (the actual lines/paths of roads).
Map Display:
- Base Layer (OpenStreetMap): Shows actual roads for geographic context
- Your Data Points: 14,476 official Magyar KΓΆzΓΊt reference locations overlaid on top
- Why No Lines from Your Data: The database only has point coordinates, not the path geometry between them
Think of it like a catalog of important landmarks on the road network rather than a complete street map.
- Database: DuckDB with spatial extension
- Backend: FastAPI (Python 3.12)
- Frontend: Leaflet.js
- Package Manager: uv (ultra-fast Python package manager)
- Deployment: Docker Compose
- Coordinate System: EOV (EPSG:23700) β WGS84 (EPSG:4326)
- Docker and Docker Compose
- OR Python 3.12+ with uv
# 1. Start the application
docker compose up
# 2. Wait for the data parsing (first run only, ~30 seconds)
# You'll see: "π Database not found. Parsing DAT files..."
# Then: "β
Database created successfully!"
# Finally: "π Starting FastAPI server..."
# 3. Open your browser
http://localhost:8000
# Done! The application will automatically parse data on first run.
# Subsequent starts will be instant since the database is already created.Note: On first startup, the container will automatically:
- Parse all 27 DAT files
- Create the DuckDB spatial database
- Convert coordinates to WGS84
- Build spatial indexes
- Then start the web server
This takes ~30-60 seconds on first run. After that, startup is instant!
# 1. Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# 2. Create virtual environment and install dependencies
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e .
# 3. Parse the DAT files and create DuckDB database
python backend/parser.py data/ road_network.duckdb
# 4. Run the FastAPI server
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000
# 5. Open your browser
http://localhost:8000hungarian-road-map/
βββ docker-compose.yml # Docker Compose configuration
βββ Dockerfile # Container definition
βββ pyproject.toml # Python dependencies (uv)
βββ README.md # This file
βββ data/ # Source DAT files
β βββ ROADS.DAT
β βββ POINTS.DAT
β βββ INTERSECTIONS.DAT
β βββ ...
βββ backend/
β βββ __init__.py
β βββ main.py # FastAPI application
β βββ database.py # DuckDB queries
β βββ parser.py # DAT file parser
β βββ models.py # Pydantic models
βββ frontend/
β βββ templates/
β βββ map.html # Interactive map UI
βββ road_network.duckdb # Generated database (after parsing)
Once running, visit:
- Interactive Map: http://localhost:8000
- API Docs (Swagger): http://localhost:8000/docs
- API Docs (ReDoc): http://localhost:8000/redoc
Get overall database statistics
curl http://localhost:8000/api/statsGet roads within bounding box
curl "http://localhost:8000/api/roads?west=19.0&south=47.0&east=19.5&north=47.5&types=1,2"Parameters:
west,south,east,north- Bounding box (WGS84 coordinates)types- Optional comma-separated road types (1=motorway, 2=1st class, 3=2nd class, 4=3rd class)
Get points of interest within bounding box
curl "http://localhost:8000/api/points?west=19.0&south=47.0&east=19.5&north=47.5"Search for locations by name
curl "http://localhost:8000/api/search?q=budapest&limit=10"Get list of all motorways
curl http://localhost:8000/api/motorwaysHealth check endpoint
curl http://localhost:8000/health- Zoom: Mouse wheel or +/- buttons
- Pan: Click and drag
- Layer Toggle: β° Checkbox panel in top-right corner - turn categories on/off
- Search: Type location name in the search box (top-left, below info panel)
- Info: Click on any icon to see details (name, type, junction number)
Use the layer control in the top-right corner to show/hide:
- β π· Motorway Points (581) - Junctions, exits, entrances on M-roads
- β β Junctions & Intersections (11,370) - T-junctions, crossroads, roundabouts, link roads
- β π Infrastructure - Bridges, tunnels, railroad crossings
- β β½ Services & Facilities - Rest areas, ferry terminals, border crossings
- β π Other Points - Tourist attractions, airports, churches, traffic cameras
Motorway Features:
- π· Motorway Junction
- β‘ Motorway Intersection
- πΊ Motorway Triangle
- β‘οΈ Motorway Entrance
- π» Exit
Junctions (11,370 total):
- β€ T-Junction (7,381)
- β Crossroads (2,684)
βοΈ Link Road Point (1,877)- β Roundabout (499)
- π Gyratory (793)
Infrastructure:
- π Bridge (8)
- π Tunnel (1)
- π Railroad Crossing (5)
Services:
- β½ Rest Area (110)
- π΄ Service Area (2)
- β΄οΈ Ferry Terminal (99)
- π§ Border Crossing (71)
Note: The gray/colored roads you see are from OpenStreetMap (base layer). Your Magyar KΓΆzΓΊt data points appear as icons on top.
The application automatically:
- Parses DAT files (CSV format with
;delimiter) - Converts EOV coordinates to WGS84 using DuckDB's ST_Transform
- Creates spatial indexes for fast bounding box queries
- Stores data in optimized DuckDB database
# Delete existing database
rm road_network.duckdb
# Reparse data
python backend/parser.py data/ road_network.duckdb- Spatial Indexing: R-tree indexes on geometry columns
- Viewport-based Loading: Only fetches visible data
- Result Limits: Maximum 5,000 roads and 10,000 points per query
- Debounced Loading: 500ms delay after map movement
- Read-only Database: Concurrent queries without locking
-
Traffic Management Systems
- Reference exact locations for traffic events ("Accident at M1 Junction 15")
- Map real-time incidents to specific junctions
- Integration with DATEX II traffic feeds
-
Logistics & Transportation
- Identify motorway access points for route planning
- Locate rest areas for driver breaks (110 locations)
- Find border crossings for international routes (71 crossings)
- Ferry terminal locations (99 terminals)
-
Emergency Services
- Reference exact junction locations for dispatch
- Identify bridge and tunnel locations
- Border crossing coordination
-
Data Integration
- Combine with OpenStreetMap for complete visualization
- Link traffic sensor data to specific junctions
- Connect weather data to road segments
- GIS analysis in QGIS/ArcGIS (export to GeoJSON)
- β Turn-by-turn navigation (use OpenStreetMap/Google Maps instead)
- β Complete street maps (only major reference points)
- β Drawing road geometry (points only, no path data)
- β Address geocoding (no address database)
- Backend: Add endpoints in
backend/main.py - Database: Add queries in
backend/database.py - Frontend: Modify
frontend/templates/map.html
uv pip install pytest
pytest tests/uv pip install black ruff
black backend/
ruff check backend/Make sure to run the parser first:
python backend/parser.py data/ road_network.duckdbZoom in to level 9 or higher. Data loading is disabled at low zoom levels for performance. You should see icons (π· β β) appear on the map.
Make sure:
- You've zoomed in enough (level 9+)
- The layer control (top-right) has categories checked β
- The gray roads are from OpenStreetMap (base layer) - your data points appear as icons on top
Your DATEX II data contains points only (junctions, bridges, etc.), not road geometry. The roads you see on the map are from the OpenStreetMap base layer, which provides geographic context. See the DATA_NOTES.md file for a detailed explanation.
Change the port in docker-compose.yml or use a different port:
uvicorn backend.main:app --port 8080- Provider: Magyar KΓΆzΓΊt Nonprofit Zrt. (Hungarian Public Roads)
- Format: DATEX II
- Valid: September 15, 2024 - September 15, 2025
- Coordinate System: EOV (EPSG:23700) converted to WGS84 (EPSG:4326)
This project is licensed under the GNU General Public License v3.0 (GPL-3.0).
You are free to use, modify, and distribute this software under the terms of the GPL-3.0 license. Any derivative work must also be open source under GPL-3.0 or a compatible license.
See the LICENSE file for the full license text.
Data License: Road network data is provided by Magyar KΓΆzΓΊt Nonprofit Zrt. and is subject to their terms of use. The data is included for educational and research purposes.
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
For issues or questions:
- Check the API documentation at
/docs - Review the troubleshooting section above
- Open an issue on GitHub
Built with β€οΈ using DuckDB, FastAPI, and Leaflet.js