If you are on Windows, you will need to run this whole project in WSL
- Install Poetry and Redis
poetry install
to install all Python dependencies
If you are on Windows, you will need to run this whole project in WSL
- Start Redis Server (if not already running):
redis-server
- Start GCOM:
poetry run python server.py
(in/src
) - Start Celery Worker:
poetry run python -m celery -A gcom worker
(in/src
)
- Uvicorn: ASGI Server
- Django + DRF: For ORM and API
- SocketIO: For WebSocket support
- Celery: for multithreading
- Redis: Message Broker (you will need to install this seperately)
This project uses poetry
. To install poetry, follow the guide on the
website. Then run: poetry install
to install required dependencies.
Some relavent commands you may want to know:
poetry shell
- Spawns and activates the poetry venv. Runexit
to exit the venvpoetry add <module>
- Add a dependencypoetry remove <module>
- Remove a dependencypoetry run <command>
- Run a command in the poetry venv without activating it
Documentation is automatically generated by drf-spectacular
to the
OpenAPIv3 standard. Sometimes, you may wish your endpoints be displayed
a bit differently and you can use the @extend_schema
decorator to
further control how your endpoint is displayed.
This is responsible for serving OpenStreetMap(OSM) tiles for the frontend. This mainly involves 3 components:
- Style file (osmbright.json)
- Initially accessed by the frontend - points it to the metadata json file, and glyphs(fonts) endpoint
- Contains layered information about how the map should be styled
- Metadata file
- Provides the url pattern for tile files
- Contains some layered information about when certain map features should be displayed (probably don't mess with this too much)
- Glyphs
- These are just fonts stored as vector pbf files
- Tiles
- These are the actual map tiles that are displayed in the frontend
- The view for these fetches a single tile at a time based on zoom level, x coord, and y coord
Tiles only need to be created once, and from there can be saved and downloaded
The process for creating them is as follows:
- Download the province osm data from geofabric
- Crop the data down to the specific region that the comp is in using osmconvert - to find the coordinates of the region, use latlong
- Convert the single .osm.pbf into individual tile files with tilemaker - use the docker image and make sure to specify the output location as a dir not a .pbf
- Paste the contents of the outputted tile dir into the
src/map_tiles/tile_data
dir
When you pull down the repo, there is a resources/map_tiles_archive.zip
file in the maptiles app. This contains the zipped pbf tile data that is housed in the tile_data
folder.
When the django app starts, the file is unzipped by the apply
script in map_tiles/apps.py
If you update the tile data and create a new zip file _you must delete your old tile_data
folder for changes to apply!