-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgis_mobile.py
45 lines (34 loc) · 1 KB
/
gis_mobile.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
"""
omsserver gis_mobile.py
:copyright: (c) 2019 by Pavel Konovalov
Created on 2019-08-13
"""
import time
from helper_database import cursor_to_json
def layer_get_list(db):
"""
Return the list of enabled layers
:param db:
:return:
"""
start = time.time()
r = {}
cursor = db.cursor()
sql = 'select id, ' \
'name, ' \
'subgroup_id as sbgrp_id ' \
'from gis_layer ' \
'where enabled_for_mobile = 1 ' \
'order by sortorder, name'
cursor.execute(sql)
r['layers'] = cursor_to_json(cursor)
sql = 'select gis_layer_subgroup.id as id, gis_layer_subgroup.name as name ' \
'from gis_layer_subgroup ' \
'where gis_layer_subgroup.id in ' \
'(select distinct subgroup_id from gis_layer ' \
'where enabled_for_mobile = 1 ) ' \
'order by gis_layer_subgroup.sortorder'
cursor.execute(sql)
r['sbrgp'] = cursor_to_json(cursor)
return r