A web application that visualizes radiation data from Safecast devices on an interactive map. This project fetches real-time radiation measurements and displays them using a heatmap overlay.
- Real-time radiation data visualization
- Interactive map with zoom and pan capabilities
- Historical data tracking
- Multiple device support
- Responsive design for desktop and mobile
- Python 3.8+ (Interpreted scripting language)
- PostgreSQL 16.9+ (Object-relational database engine)
- Supervisor (Python package to manage tasks)
- Git (for version control)
-
Clone the repository:
git clone https://github.com/Safecast/rt-ca-map.git cd radiation-map -
Initialize the database (as a PostgreSQL user e.g. role 'admin'):
misc/postgresql-initialize-mapsdb.sh
-
Create and activate a virtual environment (recommended):
python -m venv venv . venv/bin/activate # On Linux with bash: source venv/bin/activate
-
Install the required packages:
python3 -m pip install pip --upgrade # Get latest installation utility pip install -r requirements.txt
Edit the file constants.py to add the PostgreSQL mapsdb connection parameters:
# PostgreSQL on Grendel
DB_HOST = 'localhost'
DB_PORT = '5432'
DB_NAME = 'mapsdb'
DB_USER = 'mapsuser'
DB_PASS = '' # Add your secret password (may be blank if you ssh tunnel)-
Start the ASGI server:
./uvicorn_start.sh
-
Open your web browser and navigate to:
http://127.0.0.1:8000
Launch the start script with Supervisor. The daemon takes care of restarting the application if it quits unexpectedly.
maps_application/
├── maps/ # Main ASGI application module
│ ├── app.py # Main ASGI application
│ ├── asgi.py # Main ASGI wrapper
│ ├── templates/ # Jinja2 HTML templates
│ ├── admin.html # Form for /admin end points
│ └── index.html # Map starting point
├── admin.py # Manage /admin end points
├── database.py # Interface to PostgreSQL database
├── devices.py # Manage the devices and /devices end point
├── fetcher.py # Utilities to fetch from Safecast database
├── requirements.txt # Python dependencies (install in venv)
├── misc/ # Installation support
│ ├── postgresql-initialize-mapsdb.sh # Inintialize mapsdb database
│ └── postgresql-schema.sql # PostgreSQL database schema
├── static/ # Static files (CSS, JS, images)
│ ├── css/
│ └── js/
-
/mapGET the map and markers -
/devicesGET the list of devices with latitude, longitude, when_captured and uSv/h -
/measurements/{device_urn}GET latest measurements since (time span TBD) -
GET /map- Map and markers, main application interface -
GET /devices- list of devices with latitude, longitude, when_captured and uSv/h -
GET /measurements/{device_urn}- latest measurements since (time span TBD) -
POST /api/fetch-data- Trigger data fetch from Safecast API -
GET /admin- Admin interface form -
POST /admin- With command=..., administer devices
This application uses data from the Safecast API.
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin feature/your-feature) - Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.