wmts_register.py
3.0 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# coding=utf-8
#author: 4N
#createtime: 2021/7/19
#email: nheweijun@sina.com
from app.util.component.ApiTemplate import ApiTemplate
import uuid
from .models import WMTS
from app.models import Service,db
import datetime
import configure
class Api(ApiTemplate):
api_name = "注册WMTS服务"
def process(self):
# 返回结果
res = {}
try:
this_time = datetime.datetime.now()
service_guid = uuid.uuid1().__str__()
wmts_service_guid = uuid.uuid1().__str__()
service = Service(
guid = service_guid,
name = self.para.get("name"),
alias = self.para.get("alias"),
state = int(self.para.get("state")) if self.para.get("state") else None,
create_time = this_time,
update_time = this_time,
description = self.para.get("description"),
#node = Column(Integer),
overview = "http://{}/API/Service/Overview/{}".format(
configure.deploy_ip_host,
self.para.get("overview") if self.para.get("overview") else "wmts_tb.png"),
type = self.para.get("service_type"),
service_guid = wmts_service_guid,
catalog_guid = self.para.get("catalog_guid")
)
wmts = WMTS(
guid = wmts_service_guid,
name = self.para.get("name"),
wmts_type = self.para.get("wmts_type"),
vendor = self.para.get("vendor"),
create_time = this_time,
crs = self.para.get("crs"),
datasource = self.para.get("datasource"),
description = self.para.get("description"),
layer_name = self.para.get("layer_name"),
layer_alias = self.para.get("layer_alias"),
layer_tile = self.para.get("layer_title"),
layer_style = self.para.get("layer_style"),
layer_format = self.para.get("layer_format"),
layer_extent = self.para.get("layer_extent"),
layer_description = self.para.get("layer_description"),
scheme_guid = self.para.get("scheme_guid"),
service_guid = service_guid
)
#调用WMTS的注册服务接口
db.session.add(service)
db.session.add(wmts)
db.session.commit()
res["data"] = service_guid
res["result"] = True
except Exception as e:
db.session.rollback()
raise e
return res
api_doc = {
"tags": ["WMTS接口"],
"parameters": [
],
"responses": {
200: {
"schema": {
"properties": {
}
}
}
}
}