A Flask web application that analyzes GPX cycling routes and identifies roadworks along the path across multiple European countries. The application provides interactive maps with route visualization, roadwork zone polygons, and suggested detours.
- Multi-Country Support: Checks roadworks in Belgium (GIPOD), Netherlands (NDW), France (Bison Futé), and UK (StreetManager)
- Interactive Map: Full-screen map with route visualization and work zone polygons
- Automatic Detection: Detects which countries your route passes through
- Street-Following Detours: Generates realistic detour routes using OSRM and OpenRouteService APIs
- Work Zone Polygons: Displays actual roadwork boundaries instead of just point markers
- Redis Caching: Optional Redis support for improved performance
- GPX Export: Download your route with detours as a standard GPX file
- Python 3.8+
- Flask
- Redis (optional, for caching)
- Clone the repository:
git clone <repository-url>
cd gpx-detours- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create upload directory:
mkdir uploads- Set up environment variables (optional):
cp .env.example .env
# Edit .env with your settingsCreate a .env file in the project root:
# Cache Configuration
CACHE_TYPE=redis # or 'memory'
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0
REDIS_PASSWORD= # Leave empty if no password
CACHE_DEFAULT_TTL=1800
# Flask Configuration
SECRET_KEY=your-secret-key-here
UPLOAD_FOLDER=uploads
MAX_CONTENT_LENGTH=16777216 # 16MB
# Logging Level
LOG_LEVEL=INFOFor improved caching performance, install and start Redis:
macOS (Homebrew):
brew install redis
brew services start redisUbuntu/Debian:
sudo apt update
sudo apt install redis-server
sudo systemctl start redis
sudo systemctl enable redisWindows: Download and install from Redis for Windows
- Start the application:
python app.py-
Open your browser and navigate to
http://localhost:5000 -
Upload a GPX file using the drag-and-drop interface
-
Select your planned ride date
-
Click "Analyze Route" to check for roadworks
-
View results on the interactive map:
- Blue line: Your original route
- Red polygons: Roadwork zones
- Green dashed lines: Suggested detours
- Orange clusters: Multiple nearby roadworks
-
Download the enhanced GPX file with detours included
- GIPOD (Geografisch Informatie Platform Openbare Domeinen)
- API:
https://geo.api.vlaanderen.be/GIPOD/ogc/features/v1 - Coverage: Flanders region roadworks and utility works
- NDW (Nationale Databank Wegverkeersgegevens)
- Coverage: National road network incidents and roadworks
- Bison Futé: National road network events
- Paris OpenData: Construction sites in Paris
- Coverage: Major roads and urban areas
- StreetManager: Street works and traffic management
- Coverage: England, Wales, Scotland
gpx-detours/
├── app.py # Main Flask application
├── config.py # Configuration management
├── requirements.txt # Python dependencies
├── adapters/ # Country-specific data adapters
│ ├── __init__.py
│ ├── base_adapter.py
│ ├── belgium_gipod.py
│ ├── france_bison_fute.py
│ ├── netherlands_ndw.py
│ └── uk_streetmanager.py
├── cache/ # Caching system
│ └── __init__.py
├── core/ # Core processing modules
│ ├── country_detector.py
│ ├── map_generator.py
│ └── route_processor.py
├── templates/ # HTML templates
│ └── index.html
├── utils/ # Utility functions
│ └── date_utils.py
└── uploads/ # Temporary GPX file storage
- Create a new adapter in
adapters/inheriting fromCountryAdapter - Implement required methods:
get_country_code()get_country_name()get_supported_bbox()_fetch_roadworks_uncached()parse_work_location()get_work_info()
- Register the adapter in
adapters/__init__.py
# Test individual country adapters
python -c "from adapters.belgium_gipod import BelgiumGIPODAdapter; adapter = BelgiumGIPODAdapter(); print(len(adapter.fetch_roadworks('2025-01-01', '2025-12-31')))"
# Test cache performance
curl http://localhost:5000/debug/cache
# Test specific country
curl http://localhost:5000/test-franceGET /- Main application interfacePOST /upload- Upload and analyze GPX fileGET /cache/stats- Cache performance statisticsPOST /cache/clear- Clear all cached dataGET /debug/cache- Debug cache contentsGET /test-france- Test France adapter directly
- Caching: Use Redis for production deployments
- File Cleanup: Uploaded GPX files are automatically deleted after processing
- Rate Limiting: Consider implementing rate limiting for production use
- Timeout Handling: All external API calls have 30-second timeouts
No roadworks found:
- Check if your route passes through supported countries
- Verify date range (some APIs only show current/future works)
- Check logs for API connection errors
Slow performance:
- Enable Redis caching
- Check network connectivity to external APIs
- Reduce GPX file complexity (fewer track points)
Cache issues:
- Clear cache via
/cache/clearendpoint - Restart Redis if using Redis caching
- Check Redis connection settings
The application logs to console by default. Key information includes:
- Country detection results
- API response times and cache hit rates
- Number of roadworks found per country
- Performance metrics for route analysis
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License. See LICENSE file for details.
- OpenStreetMap for map tiles
- Folium for interactive mapping
- OSRM and OpenRouteService for routing
- Government Open Data initiatives for roadworks APIs