Mapogram is a platform powered by containerized QGIS server, which supported by any container infrastructure, to provide map generation service for the map they needed to deal with natural disaster like Forest fire, Flood event etc...
This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to mapogram@slash.co.
If you want to contribute about using Mapogram, please do the following:
- Raise the issue in Github issue tab
- If you would like to make changes, please fork and make the pull request. See the pull request template
In this project, we use:
frontendandbackend apifor serving web applicationQGIS serveris used to open QGIS project and generate flood information on specify areanginx: to serve http request which required for QGIS ServerGeocoding: to get latitude and longitude from google api
Limitation: The current open source version of Mapogram is limited to 1) running single project, 2) the cron job updating the data is specific to the current data structure
- To improve on the data cron job and downloader at this file
src\server\utils\downloader.ts - Current docker and Mapogram can only run with single project and cannot switch in real time
- Make sure you have
docker - Install the dep:
yarn install
After pull the project, find out the .env.example file in the root directory.
If you found the file, do this command:
cp .env.example .env
After copy the file, there are some configuration that you need to concern, but it's up to you, I mean the .env file has default value for configuration.
Example
# Docker Settings
PROJECT_DIRECTORY=./
PORT=3000
POSTGRES_PORT=5432
POSTGRES_PASSWORD=mapogram123
POSTGRES_USER=postgres
POSTGRES_DB=mapogram
NODE_ENV=development
POSTGRES_SCHEMA=public
POSTGRES_HOST=localhost
DATABASE_URL="postgresql://postgres:mapogram123@${POSTGRES_HOST}:5432/mapogram?schema=public"
API_URL=http://localhost:3000/
Run command: docker-compose up db to run the database at localhost and port 5432
please change POSTGRES_HOST from localhost to db
POSTGRES_HOST=db
If the .env file seems right to you, do this command:
yarn localstack Let's waiting for the process, and voila! Everything was created for you (web-app, nginx, gis-server and db)
Take this example from this example link.
Extract the zip and you will see for this example:
-
Example-QGISfolder and inside with:\Mapogram-FIRMS.qgz: The Mapogram Project\Datasources\MODIS_C6_1_Global_24h: The data folder for MODIS\Datasources\SUOMI_VIIRS_C2_Global_24h: The data folder for VIIRS
-
Copy the content of
Example-QGISto the folder./dataof the project
Setup your env with those data folder and path:
QGIS_MAPOGRAM_FIRE_DIR=./data
QGIS_MAPOGRAM_FIRE_FILE=Mapogram-FIRMS.qgz
QGIS_MAPOGRAM_FIRE_SERVER_PORT=8380
QGIS_MAPOGRAM_FIRE_SERVER_URL=http://localhost:8380/qgis-server
QGIS_MAPOGRAM_FIRE_LAYERS=Google Satellite Hybrid,MODIS 24h Confidence (<80),MODIS 24h Confidence (80-95),MODIS 24h Confidence (>= 95)
MAPOGRAM_DOWNLOAD_DIR=./src/server/public
- **If you are using docker, please enter container:
docker exec -it [mapogram-web-container-id] sh #replace [mapogram-web-container-id] by the actual id of the container - Generate the prisma client:
yarn prisma:generate - Run Migration:
yarn migrate - Run Migration deploy (to make sure):
yarn migrate:deploy - Seed some data:
yarn seed
Then you are ready to have the DB running, please also check if the DB is actually running with docker as well.
Run yarn dev to start the application.
If container does not reflect your change, you can rebuild image to reflect latest changes Run following command
yarn localstack:buildCommand for prisma
# Init Prisma schema
./node_modules/.bin/prisma init
./node_modules/.bin/prisma format
# Generate Schema
./node_modules/.bin/prisma generate
# Run migration
./node_modules/.bin/prisma migrate dev
Please refer to this Official Link
To run docker command without sudo:
sudo usermod -a -G docker [user] #Where [user] is your login user
newgrp docker
mkdir -p /home/ubuntu/project-data/gis-data
mkdir -p /home/ubuntu/project-data/nginx
mkdir -p /home/ubuntu/project-data/public
scp -i ~/mapogram-key.pem data ubuntu@@13.250.17.55:home/ubuntu/project-data/gis-dataGo to deployment variable and update 2 variables below
HOST_IP=[VPS ip]
DOCKER_HOST=[username]@[VPS ip]- Go to
SSH keytab in repository setting - Add private key from mapogram-key.pem
- Add public key from generate from:
ssh-keygen -f ~/mapogram-key.pem -y - Below the SSH key, fetch fingerprint by input VPS IP, and add to Known Hosts
- SSH to VPS
- Run database migration inside web-app container
docker exec -it [mapogram-web-container-id] sh
npm run migrate:deploy
npm run seed
exit- SSH to VPS
- Run database migration inside web-app container
docker exec -it [mapogram-web-container-id] sh
npm run migrate:deploy
exit