-
Notifications
You must be signed in to change notification settings - Fork 2
/
postgis2qfield.py
50 lines (39 loc) · 1.9 KB
/
postgis2qfield.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import argparse
from common.tasks import Tasks
from common.taskmanager import TaskManager
def createArgumentParser():
"""
Create the parameters for the script
"""
parser = argparse.ArgumentParser(
description="Create a QField datasets from PostGIS database.",
epilog="Example usage: python postgis2qfield.py -d yourdatabase -H localhost - p 5432 -u user -w securePassword -l list_of_distID(seperated by comma)"
)
parser.add_argument("-d", "--database", dest="database",
type=str, required=True,
help="The database to connect to")
# Python doesn't let you use -h as an option for some reason
parser.add_argument("-H", "--host", dest="host",
default="localhost", type=str,
help="Database host. Defaults to 'localhost'")
parser.add_argument("-p", "--port", dest="port",
default="5432", type=str,
help="Password for the database user")
parser.add_argument("-u", "--user", dest="user",
default="postgres", type=str,
help="Database user. Defaults to 'postgres'")
parser.add_argument("-w", "--password", dest="password",
type=str, required=True,
help="Password for the database user")
parser.add_argument("-l", "--dist_id", dest="dist_id",
default="", type=str,
help="List of district ID which you want to export. For example, '51,52,53'")
parser.add_argument("-o", "--output", default="./data/", type=str,
help="Output directory. Default is to export under data directory")
return parser.parse_args()
if __name__ == "__main__":
args = createArgumentParser()
t = Tasks(args)
tasks = t.get_tasks()
tm = TaskManager(tasks)
tm.start()