2.4. Configuration du poste de travail

2.4.1. Configuration de la base de données

To tell a workstation, where the database is (on the local system or on a network server) you will have to create some files initially on every device on which you will have QGIS/TWW running (client). It is not required to do that on the server itself.

Ces étapes dépendent de votre système d’exploitation.

2.4.1.1. Windows pg_service

Créer un nouveau dossier où vous souhaitez enregister la configuration. Par exemple pgconfig dans vos documents. Ce dossier sera connu sous le nom de PGSYSCONFDIR dans ce guide.

Configurer la variable d’environnement PGSYSCONFDIR pour pointer sur le chemin de PGSYSCONFDIR

Note

Search for environment variable in your windows system settings, then click one of the following options, for either a user or a system variable:

Click New to add a new variable name and value. Click an existing variable, and then click Edit to change its name or value. Click an existing variable, and then click Delete to remove it.

../_images/umgebungsvariablen_pgconfdir.jpg

You can check your environment variables also within QGIS: Menu Settings –> Options... –> System Tab –> Environment

Dans ce dossier, vous trouverez deux fichiers

  • pg_service.conf

  • pgpass (si vous ne souhaitez pas entrer le mot de passe à chaque connexion)

Attention

On Windows, you need to save pg_service.conf in Unix format in order to work. One way to do it is to open it with Notepad++ and Edit –> EOL Conversion –> UNIX Format –> File save .

2.4.1.2. Linux/macOS pg_service

On Unix systems (linux/macOS etc.) you may put the files .pg_service.conf and .pgpass into your home folder (normally /home/[username]). Pay attention to the starting . (<> Windows)!

If your QGIS doesn’t find the .pg_service.conf file, set the environment variable PGSYSCONFDIR:

In QGIS go to Settings > Options > System tab. Near the bottom you’ll find Environment. Tick Use custom variables and click on the plus on the right. Add the PGSYSCONFDIR variable using Append (to make sure you don’t delete anything - doesn’t matter probably) and its value (probably /home/[username] see above). Then click OK at the bottom right.

../_images/macEnvVarSet.png

After closing and reopening QGIS, you should be able to see the added PGSYSCONFDIR at the bottom of the same window under Current environment variables. .. figure:: images/macEnvVarCheck.png

2.4.1.3. Tous les systèmes

Placer les lignes suivantes dans le fichier pg_service.conf ou .pg_service.conf. Vous devrez peut-être apporter des modifications selon votre configuration.

[pg_tww]
host=localhost
port=5432
dbname=tww
user=twwuser

Pour enregistrer le mot de passe sur votre système, vous pouvez utiliser le fichier pgpass.

localhost:5432:*:twwuser:password

Note

Si la base de données n’est pas sur votre poste local, remplacer toutes les occurences de localhost par l’adresse réseau du serveur de base de données.

Alternative: put your password directly into the pg_service.conf (on Windows) / .pg_service.conf (on *nix) file:

[pg_tww]
host=localhost
port=5432
dbname=tww
user=twwuser
password=***

2.4.2. Installer QGIS

  • Minimum requirement 3.34.8

  • We recommend using the latest master build (called qgis-dev on Windows) which often offers a better experience in combination with TWW. For Windows installation, download the OSGeo4W Installer choose advanced installation and install qgis-dev.

2.4.3. Install TWW plugin

Exigences du plugin;

You can install them on Debian based systems with:

sudo pip install networkx
sudo apt-get install libqt4-sql-psql

Or for Windows users, directly in QGIS via the Python Console with:

import pip; pip.main(["install", "networkx"])
  • Ouvrir QGIS

  • Aller à « plugins »

    • « installer/gérer les extensions »

    • « Paramètres « 

      • Activer l’onglet Afficher les extensions expérimentales

    • Activer le plugin (voir l’image ci-dessous):

    • Tous

      • Search TWW

      • Cocher la case à côté

../_images/001_searchplugin.jpeg

Add the TWW plugin

TWW uses a data historization process. The pg history viewer plugin allows you to view the changes made and replay some of them.

2.4.4. Install the demo data

as described here

2.4.5. Installation du projet de démo

project-translations.zip

  • Extraire le ficher

  • If you leave the teksi_wastewater_[language].qm files in the same directory as the teksi_wastewater.qgs file and start QGIS with one of these languages, your project will be translated to that langue when you start the project. E.g. you start teksi_wastewater.qgs with a QGIS Installation that is set to German, then the teksi_wastewater.qgs project will appear in German.

Note

You need to explicitly set the language in QGIS in settings. If QGIS is configured to take the system language, the TWW translation is not loaded.

../_images/tww_project_qm_language_files.jpg
  • Open project-translations/teksi_wastewater.qgs with QGIS

  • When you save that project it will keep it’s language and it cannot be changed in the same way.

2.4.6. If you are a data owner: Add your own OID to the project

  • If you are a data owner (Datenherr), you should add your OID data in the table tww_sys.oid_prefixes:

../_images/oid_prefix.jpg
  • Edit 02_oid_generation.sql with your OID if you want it permanently in the TWW project and hand in a pull request

https://github.com/TWW/datamodel/blob/master/02_oid_generation.sql

-- sample entry for the City of Uster - you need to add an entry for your own organization
INSERT INTO tww_sys.oid_prefixes (prefix,organization,active) VALUES ('ch11h8mw','Stadt Uster',TRUE);
INSERT INTO tww_sys.oid_prefixes (prefix,organization,active) VALUES ('ch15z36d','SIGE',FALSE);
INSERT INTO tww_sys.oid_prefixes (prefix,organization,active) VALUES ('ch13p7mz','Arbon',FALSE);

et définir la valeur de l’IDO que vous voulez utiliser dans votre projet à VRAI.

Note

If you work with different databases for different communities, you should use different OID prefixes for each database.

2.4.7. Travailler avec plusieurs base de données

  • Create a new database in pgAdmin with a new name, e.g. communityA

  • Create a new schema tww in this database (do not choose another name, because all scripts works with the schema-name tww)

  • Continuer comme indiqué dans 1.2 Initialisation de la base de données

  • Modifier le fichier pg_service.conf

[pg_tww]
host=localhost
port=5432
dbname=tww
user=twwuser
[pg_communityA]
host=localhost
port=5432
dbname=communityA
user=twwuser
  • Search and replace in the copy of tww_en.qgs all “pg_tww” with “pg_communityA”