Skip to content

How to change template of QGIS project file

mirankunda edited this page Sep 11, 2020 · 6 revisions

1. Structure of Project folder

Template of QGIS project is managed under template folder. Python script will copy QGIS project from template folder and create completed package each district.

If you want to change any styling and layer configuration, you need to change QGIS project file under template.

.
├── LICENSE
├── README.md
├── common -> python source code
├── layers -> python source code
├── postgis2qfield.py -> main python source code
├── requirements.txt -> manages python package used.
├── run_postgis2qfield.bat -> bat file for windows
├── run_postgis2qfield.sh -> script file for unix
├── template -> QGIS project template is under here.
    ├── images -> manages all icons used in QGIS project
    │   ├── handpump_abandoned.svg
    │   ├── (skip)
    │   └── watersource_partialyfunctional.svg
    ├── template_gis_database.gpkg -> template of geopackage
    ├── water_network_for_qfield.qgs -> template of QGIS project
    └── water_network_for_qfield.qgs.cfg -> template of Lizmap (you can ignore this currently)

2. Download the latest source code in your computer

cd postgis2qfield
git checkout master
git pull origin master

3. Generate QField package by using the latest source code

Before generating it, please make sure your database settings are correct on run_postgis2qfield.bat or run_postgis2qfield.sh.

python postgis2qfield.py -d your_database -H localhost -p 5432 -u postgres -w your_password

Then, double-click run_postgis2qfield.bat file as usual to generate QField packages.

4. Edit QGIS project for one of district

In this case, we are going to use 51_Rwamagana_20200812_090957.zip. Please extract zip file, then open QGIS project file.

image

If the above dialog appeared, please click Keep Unavailable Layers.

Change styling of layers for your needs.

5. Copy and replace QGIS project template

After editing QGIS project, follow below steps.

  • copy water_network_for_qfield_Rwamagana.qgs file to template folder.
  • delete water_network_for_qfield.qgs
  • rename water_network_for_qfield_Rwamagana.qgs to be water_network_for_qfield.qgs again.

When you added or modified icons under images, please do not forget to overwrite the same images folder under template.

6. Generate QField package now

Now you can generate QField package by using new template, then confirm all of your changes are reflected well. If it is not expected, you can repeat the process of editing QGIS project file.

If all of stying is okay, go to next step.

7. Make sub branch and commit you changes

It is not good to push your changes directly to master branch in order to avoid any mistakes. We can create new branch and commit changes.

git checkout -b {new branch name}
git add .
git commit -m "{your comment}"
  • {new branch name}: please decide a simple branch name. eg, add-industrial-layer if we add new layer of industrial
  • {your comment}: please describe briefly what you changed. eg, added new industrial layer in QGIS project template

the below is example.

$ git checkout -b add-industrial
Switched to a new branch 'add-industrial'
$ git add .
$ git commit -m "added industiral, enable show counts for institution, added solar pump into waterfacilities. fixed bug for geopandas."
 30 files changed, 53272 insertions(+), 51248 deletions(-)

8. Push you changes to Github repository

Once you committed your changed in new branch, you can push it to Github repository now.

git push origin {new branch name}

the below is example.

$ git push origin add-industrial
Enumerating objects: 37, done.
Counting objects: 100% (37/37), done.
Delta compression using up to 4 threads
Compressing objects: 100% (31/31), done.
Writing objects: 100% (31/31), 145.75 KiB | 561.00 KiB/s, done.
Total 31 (delta 20), reused 0 (delta 0)
remote: Resolving deltas: 100% (20/20), completed with 5 local objects.
remote: 
remote: Create a pull request for 'add-industrial' on GitHub by visiting:
remote:      https://github.com/WASAC/postgis2qfield/pull/new/add-industrial
remote: 
To github.com:WASAC/postgis2qfield.git
 * [new branch]      add-industrial -> add-industrial

9. Make pull request to master branch

  • open pull request of postgis2qfield.
  • click New pull request
  • select master as base and {new branch} as compare.
  • you can see the difference between master and {new branch}, if it is okay to merge, click Create pull request. image
  • write details what you changed in the source code, so reviewers can know details. Pull request should includes:
    • describe shortly your changes in title
    • describe details what you changed.
    • put Reviewers and Assignees if necessary.
    • put labels as much as possible. for instance, like bug or enhancement image
  • Now, click Create pull request.
  • After opening pull request, please also link related issues to your pull request. image
  • Then, please text me (Jin IGARASHI) for reviewing your pull request. I will check it and correct it if your changes have problems.

10. Merge pull request after reviewing

After reviewing your pull request, I will merge it into master branch. image

Related issues will be automatically closed after merging. image

11. Download the merged source code to you computer

Now, you can download the latest source code and generate QField geopackages!

cd postgis2qfield
git checkout master
git pull origin master

launch run_postgis2qfield.bat to generate! Please make sure your database settings inside bat file!

DONE!!