6  Anhang

6.1 Anhang 1

Tabelle 6.1: Geopackage Data Types. Quelle: geopackage.org
Data Type Size and Description
INTEGER 32 bit 32-bit signed two’s complement integer. Stored as SQLite INTEGER with values in the range [-2147483648, 2147483647].
INTEGER 64 bit 64-bit signed two’s complement integer. Stored as SQLite INTEGER with values in the range [-9223372036854775808, 9223372036854775807].
REAL 64-bit IEEE floating point number. Stored as SQLite REAL.
TEXT{(maxchar_count)} Variable length string encoded in either UTF-8 or UTF-16. The optional maxchar_count defines the maximum number of characters in the string. If not specified, the length is unbounded. Stored as SQLite TEXT.
BLOB{(max_size)} Variable length binary data. The optional max_size defines the maximum number of bytes in the blob. If not specified, the length is unbounded.
DATE ISO 8601 date string in the form YYYY-MM-DD encoded in either UTF-8 or UTF-16. Stored as SQLite TEXT (see TEXT above).
DATETIME ISO-8601 date/time string in the form YYYY-MM-DDTHH:MM:SS.SSSZ with T separator character and Z suffix for coordinated universal time (UTC) encoded in either UTF-8 or UTF-16. Stored as SQLite TEXT (see TEXT above).

6.2 Anhang 2

Einzelne Nutzer können können sehr gut via dem Webinterface von QField Cloud hinzugefügt werden. Um mehrere Nutzer zu importieren, können wir die QFieldCloud API verwenden. Diese API kann man auf verschiedene Arten benutzen:

  1. QFieldCloud SDK via Python (Dokumentation)
  2. QFieldCloud SDK via Kommandozeile (Dokumentation)
  3. (RestAPI von der Kommandozeile (Dokumentation))

In den Beispielen verwenden wir die SDK via Python. Installation: pip install qfieldcloud-sdk

Hinweis

Aktuell können nur bereits existierende QField Cloud Nutzer via der API unserer Organisation hinzugefügt werden. Das Hinzufügen funktioniert nur via Benutzername, nicht via Emailadresse. rata hat am 26.06.2025 einen Feature request gemacht, welches das Hinzufügen via Emailadresse ermöglichen soll. Bis dieses Feature implementiert ist, müssen die Studenten zuerst QField Cloud Accounts erstellen und uns im Anschluss die Benutzernamen mitteilen.

Ein einzelner Nutzer der Organisation hinzufügen

import getpass
from qfieldcloud_sdk import sdk

user = getpass.getpass("Username:")
passwd = getpass.getpass("Password:")

client = sdk.Client(url="https://app.qfield.cloud/api/v1/")
client.login(user, passwd)

# Der Nutzer "BENUTZERNAME" muss bereits existieren!
# "BENUTZERNAME" darf keine Emailadresse sein :-(
client.add_organization_member("ZHAW", "BENUTZERNAME", "member", False) 

Mehrere Nutzer der Organisation hinzufügen

Um mehrere Mitglieder unserer Organisation hinzuzufügen, braucht es eine CSV Datei mit folgender Struktur:

username,org_role,proj_role
ninja_1,member,reader
ninja_2,member,editor
ninja_3,admin,manager
ninja_4,member,reporter

Hier der Python code für das Importieren via CSV:

import requests, csv
from qfieldcloud_sdk import sdk

client = sdk.Client(
    url="https://app.qfield.cloud/api/v1/"
)
client.login(username='myuser', password='mypassword')

def read_csv(csv_path: str, organization: str, project_id: str, is_public: bool):
    with open(csv_path, mode="r", newline="", encoding="utf-8") as csvfile:
        reader = csv.DictReader(csvfile)
        for user in reader:
            try:
                client.add_organization_member(
                    organization, user["username"], user["org_role"], is_public
                )
                print(
                    f"Added member {user['username']} with role {user['org_role']} in {organization}"
                )
            except requests.exceptions.RequestException:
                print("Oops!")


if __name__ == "__main__":
    organization = "ZHAW"
    is_public = False
    csv_path = 'path/to/files/surveyors.csv'
    read_csv(csv_path, organization, project_id, is_public)