提交 9aab7cbe06dc0e6caed24d25e1ed6236f7a89407

作者 nheweijun
1 个父辈 a83e26c9

修改抽稀前

... ... @@ -150,7 +150,7 @@ class Api(ApiTemplate):
150 150 if count%10000==0:
151 151 StructurePrint().print("{}图层已抽稀{}个对象".format(table.name, count))
152 152
153   - vacuate_process.set_vacuate_count()
  153 + #vacuate_process.set_vacuate_count()
154 154
155 155 #新增
156 156 if configure.VACUATE_DB_URI:
... ... @@ -386,6 +386,7 @@ class VacuateProcess:
386 386 field_dict = feature.items()
387 387 for field_name in field_dict:
388 388 feat.SetField(field_name, field_dict[field_name])
  389 +
389 390 feat.SetField("_dcigrid_name_",".".join(key.split(".")[1:]))
390 391
391 392 vacuate_layer.CreateFeature(feat)
... ... @@ -393,6 +394,8 @@ class VacuateProcess:
393 394 #超大的还有机会
394 395 elif long_extent > 10 * this_grid_len or lat_extent > 10 * this_grid_len:
395 396 vacuate_layer: Layer = self.vacuate_layers.get(level)
  397 +
  398 +
396 399 feat = ogr.Feature(vacuate_layer.GetLayerDefn())
397 400 feat.SetGeometry(g)
398 401
... ...
... ... @@ -27,7 +27,7 @@ class Api(ApiTemplate):
27 27 url = "{}/API/Service/Delete".format(self.para.get("url"))
28 28 response:requests.Response = requests.post(url,data=self.para)
29 29 if not response.json().get("result"):
30   - raise Exception("由于{},影像服务删除失败!".format(response.json().get("msg")))
  30 + raise Exception("由于{},影像地图删除失败!".format(response.json().get("msg")))
31 31 res["result"] = True
32 32 except Exception as e:
33 33 raise e
... ...
... ... @@ -7,6 +7,7 @@
7 7 from app.util.component.ApiTemplate import ApiTemplate
8 8 import requests
9 9 from app.util.component.UserCheck import UserCheck
  10 +from ..util.ServiceType import ServiceType
10 11
11 12 class Api(ApiTemplate):
12 13
... ... @@ -27,7 +28,7 @@ class Api(ApiTemplate):
27 28 url = "{}/API/Service/Edit".format(self.para.get("url"))
28 29 response:requests.Response = requests.post(url,data=self.para)
29 30 if not response.json().get("result"):
30   - raise Exception("由于{},影像服务修改失败!".format(response.json().get("msg")))
  31 + raise Exception("由于{},影像地图修改失败!".format(response.json().get("msg")))
31 32 res["result"] = True
32 33 except Exception as e:
33 34 raise e
... ... @@ -45,8 +46,8 @@ class Api(ApiTemplate):
45 46 {"name": "type",
46 47 "in": "formData",
47 48 "type": "string",
48   - "enum": ["地图服务","切片服务","影像服务"],
49   - "description": "[地图服务,切片服务,影像服务]"},
  49 + "enum": [ServiceType.image_service.value],
  50 + },
50 51
51 52 {"name": "url",
52 53 "in": "formData",
... ... @@ -56,31 +57,31 @@ class Api(ApiTemplate):
56 57 {"name": "name",
57 58 "in": "formData",
58 59 "type": "string",
59   - "description": "[地图服务,切片服务,影像服务]"},
  60 + "description": "[矢量地图,电子地图,影像地图]"},
60 61 {"name": "title",
61 62 "in": "formData",
62 63 "type": "string",
63   - "description": "[地图服务,切片服务,影像服务]"},
  64 + "description": "[矢量地图,电子地图,影像地图]"},
64 65 {"name": "description",
65 66 "in": "formData",
66 67 "type": "string",
67   - "description": "[地图服务,切片服务,影像服务]"},
  68 + "description": "[矢量地图,电子地图,影像地图]"},
68 69
69 70 {"name": "catalog_guid",
70 71 "in": "formData",
71 72 "type": "string",
72   - "description": "[地图服务,切片服务,影像服务]"},
  73 + "description": "[矢量地图,电子地图,影像地图]"},
73 74
74 75 {"name": "functions",
75 76 "in": "formData",
76 77 "type": "string",
77   - "description": "[地图服务,影像服务]以逗号相隔,可选WMTS,WMS"},
  78 + "description": "[矢量地图,影像地图]以逗号相隔,可选WMTS,WMS"},
78 79
79 80 # 影像参数
80 81 {"name": "image_guids",
81 82 "in": "formData",
82 83 "type": "string",
83   - "description": "[影像服务]影像guids,以英文逗号相隔"},
  84 + "description": "[影像地图]影像guids,以英文逗号相隔"},
84 85 {"name": "scheme",
85 86 "in": "formData",
86 87 "type": "string",
... ...
... ... @@ -18,7 +18,7 @@ class Api(ApiTemplate):
18 18 url = "{}/API/Service/Register".format(self.para.get("url"))
19 19 response:requests.Response = requests.post(url,data=self.para)
20 20 if not response.json().get("result"):
21   - raise Exception("由于{}影像服务注册失败!".format(response.json().get("msg")))
  21 + raise Exception("由于{}影像地图注册失败!".format(response.json().get("msg")))
22 22 res["result"] = True
23 23 except Exception as e:
24 24 raise e
... ... @@ -34,12 +34,12 @@ class Api(ApiTemplate):
34 34 "in": "formData",
35 35 "type": "string",
36 36 "required": "true",
37   - "description": "[地图服务,切片服务,影像服务]"},
  37 + "description": "[矢量地图,电子地图,影像地图]"},
38 38
39 39 {"name": "title",
40 40 "in": "formData",
41 41 "type": "string",
42   - "description": "[地图服务,切片服务,影像服务]"},
  42 + "description": "[矢量地图,电子地图,影像地图]"},
43 43
44 44 {"name": "url",
45 45 "in": "formData",
... ... @@ -48,33 +48,33 @@ class Api(ApiTemplate):
48 48 {"name": "description",
49 49 "in": "formData",
50 50 "type": "string",
51   - "description": "[地图服务,切片服务,影像服务]"},
  51 + "description": "[矢量地图,电子地图,影像地图]"},
52 52 {"name": "type",
53 53 "in": "formData",
54 54 "type": "string",
55   - "enum":["影像服务"],
  55 + "enum":["影像地图"],
56 56 "required": "true",
57   - "description": "[地图服务,切片服务,影像服务]"},
  57 + "description": "[矢量地图,电子地图,影像地图]"},
58 58 {"name": "catalog_guid",
59 59 "in": "formData",
60 60 "type": "string",
61   - "description": "[地图服务,切片服务,影像服务]"},
  61 + "description": "[矢量地图,电子地图,影像地图]"},
62 62
63 63 #影像参数
64 64 {"name": "image_guids",
65 65 "in": "formData",
66 66 "type": "string",
67   - "description": "[影像服务]影像guids,以英文逗号相隔"},
  67 + "description": "[影像地图]影像guids,以英文逗号相隔"},
68 68
69 69 {"name": "scheme",
70 70 "in": "formData",
71 71 "type": "string",
72   - "description": "影像服务切片方案,json形式"},
  72 + "description": "影像地图切片方案,json形式"},
73 73
74 74 {"name": "functions",
75 75 "in": "formData",
76 76 "type": "string",
77   - "description": "[影像服务]functions",
  77 + "description": "[影像地图]functions",
78 78 "enum": ["WMS","WMTS"]},
79 79
80 80 ],
... ...
... ... @@ -8,13 +8,13 @@ from flask import Blueprint
8 8 from app.util import BlueprintApi
9 9 from . import map_service_register, map_service_edit
10 10 from app.decorators.token_decorator import token_decorator
11   -
  11 +from ..util.ServiceType import ServiceType
12 12
13 13 class DataManager(BlueprintApi):
14 14
15 15 bp = Blueprint("MapService", __name__,
16 16 url_prefix="/API/Service/MapService")
17   - service_type = ["地图服务"]
  17 + service_type = [ServiceType.map_service.value]
18 18
19 19 @staticmethod
20 20 @bp.route('/Register', methods=['POST'])
... ...
... ... @@ -89,47 +89,47 @@ class Api(ApiTemplate):
89 89 return res
90 90
91 91 api_doc = {
92   - "tags": ["地图服务接口"],
  92 + "tags": ["矢量地图接口"],
93 93 "parameters": [
94 94
95 95 {"name": "name",
96 96 "in": "formData",
97 97 "type": "string",
98 98 "required": "true",
99   - "description": "[地图服务,切片服务,影像服务]"},
  99 + "description": "[矢量地图,电子地图,影像地图]"},
100 100 {"name": "title",
101 101 "in": "formData",
102 102 "type": "string",
103   - "description": "[地图服务,切片服务,影像服务]"},
  103 + "description": "[矢量地图,电子地图,影像地图]"},
104 104 {"name": "description",
105 105 "in": "formData",
106 106 "type": "string",
107   - "description": "[地图服务,切片服务,影像服务]"},
  107 + "description": "[矢量地图,电子地图,影像地图]"},
108 108 {"name": "catalog_guid",
109 109 "in": "formData",
110 110 "type": "string",
111   - "description": "[地图服务,切片服务,影像服务]"},
  111 + "description": "[矢量地图,电子地图,影像地图]"},
112 112
113 113
114 114 {"name": "layer_style",
115 115 "in": "formData",
116 116 "type": "string",
117   - "description": "[地图服务,切片服务]图层样式"},
  117 + "description": "[矢量地图,电子地图]图层样式"},
118 118
119 119 {"name": "functions",
120 120 "in": "formData",
121 121 "type": "string",
122   - "description": "[地图服务]服务能力,用逗号相隔"},
  122 + "description": "[矢量地图]服务能力,用逗号相隔"},
123 123
124   - #地图服务参数
  124 + #矢量地图参数
125 125 {"name": "capabilities",
126 126 "in": "formData",
127 127 "type": "int",
128   - "description": "[地图服务]"},
  128 + "description": "[矢量地图]"},
129 129 {"name": "project",
130 130 "in": "formData",
131 131 "type": "string",
132   - "description": "[地图服务]project"},
  132 + "description": "[矢量地图]project"},
133 133
134 134 ],
135 135 "responses": {
... ...
... ... @@ -88,43 +88,43 @@ class Api(ApiTemplate):
88 88 return res
89 89
90 90 api_doc = {
91   - "tags": ["地图服务接口"],
  91 + "tags": ["矢量地图接口"],
92 92 "parameters": [
93 93
94 94 {"name": "name",
95 95 "in": "formData",
96 96 "type": "string",
97 97 "required": "true",
98   - "description": "[地图服务,切片服务,影像服务]"},
  98 + "description": "[矢量地图,电子地图,影像地图]"},
99 99 {"name": "title",
100 100 "in": "formData",
101 101 "type": "string",
102   - "description": "[地图服务,切片服务,影像服务]"},
  102 + "description": "[矢量地图,电子地图,影像地图]"},
103 103 {"name": "description",
104 104 "in": "formData",
105 105 "type": "string",
106   - "description": "[地图服务,切片服务,影像服务]"},
  106 + "description": "[矢量地图,电子地图,影像地图]"},
107 107 {"name": "type",
108 108 "in": "formData",
109 109 "type": "string",
110   - "enum": ["地图服务"],
  110 + "enum": ["矢量地图"],
111 111 "required": "true",
112   - "description": "[地图服务,切片服务,影像服务]"},
  112 + "description": "[矢量地图,电子地图,影像地图]"},
113 113 {"name": "catalog_guid",
114 114 "in": "formData",
115 115 "type": "string",
116   - "description": "[地图服务,切片服务,影像服务]"},
  116 + "description": "[矢量地图,电子地图,影像地图]"},
117 117
118 118
119   - #地图服务参数
  119 + #矢量地图参数
120 120 {"name": "capabilities",
121 121 "in": "formData",
122 122 "type": "int",
123   - "description": "[地图服务]"},
  123 + "description": "[矢量地图]"},
124 124 {"name": "project",
125 125 "in": "formData",
126 126 "type": "string",
127   - "description": "[地图服务]project"},
  127 + "description": "[矢量地图]project"},
128 128
129 129
130 130 ],
... ...
... ... @@ -9,7 +9,7 @@ from app.modules.service.models import Service
9 9 from app.modules.service.models import TileService
10 10 from app.modules.service.models import MapService
11 11 from app.util.component.UserCheck import UserCheck
12   -
  12 +from .util.ServiceType import ServiceType
13 13 class Api(ApiTemplate):
14 14
15 15 api_name = "服务删除"
... ... @@ -24,7 +24,7 @@ class Api(ApiTemplate):
24 24 s_type = self.para.get("type")
25 25
26 26 #删除本地服务
27   - if s_type in ["切片服务","地图服务"]:
  27 + if s_type in [ServiceType.map_service.value,ServiceType.tile_service.value]:
28 28 service:Service = Service.query.filter_by(guid=guid).one_or_none()
29 29 if service:
30 30
... ... @@ -32,12 +32,12 @@ class Api(ApiTemplate):
32 32 UserCheck.verify(service.creator)
33 33
34 34 try:
35   - if service.type.__eq__("切片服务"):
  35 + if service.type == ServiceType.tile_service.value:
36 36 #调用接口
37 37 tile_service = TileService.query.filter_by(service_guid=guid).one_or_none()
38 38 db.session.delete(tile_service)
39 39
40   - if service.type.__eq__("地图服务"):
  40 + if service.type == ServiceType.map_service.value:
41 41 map_service = MapService.query.filter_by(service_guid=guid).one_or_none()
42 42 db.session.delete(map_service)
43 43
... ...
... ... @@ -5,7 +5,7 @@
5 5
6 6 from app.util.component.ApiTemplate import ApiTemplate
7 7 from app.modules.service.models import Service
8   -
  8 +from .util.ServiceType import ServiceType
9 9
10 10
11 11 class Api(ApiTemplate):
... ... @@ -19,19 +19,19 @@ class Api(ApiTemplate):
19 19 s_type = self.para.get("type")
20 20
21 21 # 修改本地服务
22   - if s_type in ["切片服务", "地图服务"]:
  22 + if s_type in [ServiceType.tile_service.value, ServiceType.map_service.value]:
23 23
24 24 service = Service.query.filter_by(guid=guid).one_or_none()
25 25 if not service:
26 26 raise Exception("服务不存在!")
27 27
28   - if service.type.__eq__("地图服务"):
  28 + if service.type == ServiceType.map_service.value:
29 29 from app.modules.service.map_service.map_service_edit import Api as RealApi
30   - elif service.type.__eq__("切片服务"):
  30 + elif service.type == ServiceType.tile_service.value:
31 31 from app.modules.service.tile_service.tile_service_edit import Api as RealApi
32 32 else:
33 33 return res
34   - elif s_type.__eq__("影像服务"):
  34 + elif s_type == ServiceType.image_service.value:
35 35 from app.modules.service.image_service.image_service_edit import Api as RealApi
36 36 else:
37 37 return res
... ... @@ -55,8 +55,8 @@ class Api(ApiTemplate):
55 55 {"name": "type",
56 56 "in": "formData",
57 57 "type": "string",
58   - "enum": ["地图服务","切片服务","影像服务"],
59   - "description": "[地图服务,切片服务,影像服务]"},
  58 + "enum": [st.value for st in ServiceType],
  59 + "description": "[矢量地图,电子地图,影像地图]"},
60 60
61 61 {"name": "url",
62 62 "in": "formData",
... ... @@ -66,31 +66,31 @@ class Api(ApiTemplate):
66 66 {"name": "name",
67 67 "in": "formData",
68 68 "type": "string",
69   - "description": "[地图服务,切片服务,影像服务]"},
  69 + "description": "[矢量地图,电子地图,影像地图]"},
70 70 {"name": "title",
71 71 "in": "formData",
72 72 "type": "string",
73   - "description": "[地图服务,切片服务,影像服务]"},
  73 + "description": "[矢量地图,电子地图,影像地图]"},
74 74 {"name": "description",
75 75 "in": "formData",
76 76 "type": "string",
77   - "description": "[地图服务,切片服务,影像服务]"},
  77 + "description": "[矢量地图,电子地图,影像地图]"},
78 78
79 79 {"name": "catalog_guid",
80 80 "in": "formData",
81 81 "type": "string",
82   - "description": "[地图服务,切片服务,影像服务]"},
  82 + "description": "[矢量地图,电子地图,影像地图]"},
83 83
84 84 {"name": "functions",
85 85 "in": "formData",
86 86 "type": "string",
87   - "description": "[地图服务,影像服务]以逗号相隔,可选WMTS,WMS"},
  87 + "description": "[矢量地图,影像地图]以逗号相隔,可选WMTS,WMS"},
88 88
89 89 # 影像参数
90 90 {"name": "image_guids",
91 91 "in": "formData",
92 92 "type": "string",
93   - "description": "[影像服务]影像guids,以英文逗号相隔"},
  93 + "description": "[影像地图]影像guids,以英文逗号相隔"},
94 94 {"name": "scheme",
95 95 "in": "formData",
96 96 "type": "string",
... ... @@ -100,65 +100,65 @@ class Api(ApiTemplate):
100 100 {"name": "overview",
101 101 "in": "formData",
102 102 "type": "string",
103   - "description": "[切片服务]缩略图"},
  103 + "description": "[电子地图]缩略图"},
104 104 {"name": "scheme_guid",
105 105 "in": "formData",
106 106 "type": "string",
107   - "description": "切片服务切片方案"},
  107 + "description": "电子地图切片方案"},
108 108 {"name": "tile_type",
109 109 "in": "formData",
110 110 "type": "string",
111   - "description": "[切片服务]tile_type"},
  111 + "description": "[电子地图]tile_type"},
112 112 {"name": "vendor",
113 113 "in": "formData",
114 114 "type": "string",
115   - "description": "[切片服务]厂商"},
  115 + "description": "[电子地图]厂商"},
116 116 {"name": "crs",
117 117 "in": "formData",
118 118 "type": "string",
119   - "description": "[切片服务]坐标系"},
  119 + "description": "[电子地图]坐标系"},
120 120 {"name": "datasource",
121 121 "in": "formData",
122 122 "type": "string",
123   - "description": "[切片服务]数据路径"},
  123 + "description": "[电子地图]数据路径"},
124 124 {"name": "layer_name",
125 125 "in": "formData",
126 126 "type": "string",
127   - "description": "[切片服务]图层名"},
  127 + "description": "[电子地图]图层名"},
128 128 {"name": "layer_alias",
129 129 "in": "formData",
130 130 "type": "string",
131   - "description": "[切片服务]图层别名"},
  131 + "description": "[电子地图]图层别名"},
132 132 {"name": "layer_title",
133 133 "in": "formData",
134 134 "type": "string",
135   - "description": "[切片服务]图层标题"},
  135 + "description": "[电子地图]图层标题"},
136 136 {"name": "layer_style",
137 137 "in": "formData",
138 138 "type": "string",
139   - "description": "[地图服务,切片服务]图层样式"},
  139 + "description": "[矢量地图,电子地图]图层样式"},
140 140 {"name": "layer_format",
141 141 "in": "formData",
142 142 "type": "string",
143   - "description": "[切片服务]图层format"},
  143 + "description": "[电子地图]图层format"},
144 144 {"name": "layer_extent",
145 145 "in": "formData",
146 146 "type": "string",
147   - "description": "[切片服务]图层范围"},
  147 + "description": "[电子地图]图层范围"},
148 148 {"name": "layer_description",
149 149 "in": "formData",
150 150 "type": "string",
151   - "description": "[切片服务]图层描述"},
  151 + "description": "[电子地图]图层描述"},
152 152
153   - #地图服务参数
  153 + #矢量地图参数
154 154 {"name": "capabilities",
155 155 "in": "formData",
156 156 "type": "int",
157   - "description": "[地图服务]"},
  157 + "description": "[矢量地图]"},
158 158 {"name": "project",
159 159 "in": "formData",
160 160 "type": "string",
161   - "description": "[地图服务]project"},
  161 + "description": "[矢量地图]project"},
162 162 ],
163 163 "responses": {
164 164 200: {
... ...
... ... @@ -8,7 +8,7 @@
8 8 from app.util.component.ApiTemplate import ApiTemplate
9 9 from .models import ServiceEngine
10 10 from app.util import find_class,BlueprintApi
11   -
  11 +from .util.ServiceType import ServiceType
12 12
13 13 class Api(ApiTemplate):
14 14 api_name = "服务类型"
... ... @@ -24,7 +24,7 @@ class Api(ApiTemplate):
24 24 if hasattr(api,"service_type"):
25 25 service_types.extend(api.service_type)
26 26 if ServiceEngine.query.filter_by(type="ImageServer").first():
27   - service_types.append("影像服务")
  27 + service_types.append(ServiceType.image_service.value)
28 28 res["data"] = service_types
29 29 res["result"] = True
30 30
... ...
... ... @@ -8,6 +8,8 @@ from app.util.component.ApiTemplate import ApiTemplate
8 8 from app.util.component.ModelVisitor import ModelVisitor
9 9 from .models import Service
10 10 import requests
  11 +from .util.ServiceType import ServiceType
  12 +
11 13 class Api(ApiTemplate):
12 14 api_name = "服务Info"
13 15 def process(self):
... ... @@ -17,24 +19,17 @@ class Api(ApiTemplate):
17 19 guid = self.para.get("guid")
18 20 s_type = self.para.get("type")
19 21
20   - if s_type in ["地图服务","切片服务"]:
  22 + if s_type in [ServiceType.map_service.value,ServiceType.tile_service.value]:
21 23
22 24 service = Service.query.filter_by(guid=guid).one_or_none()
23 25 if not service:
24 26 raise Exception("服务不存在!")
25 27 res["data"] = {}
26 28
27   - if service.type.__eq__("影像服务"):
28   - speci_service = service.relate_image_service.one_or_none()
29   - relate_images = speci_service.images.all()
30   - res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service)
31   - res["data"]["speci_service"]["images"] = [{"name":im["name"],"guid":im["guid"]} for im in ModelVisitor.objects_to_jsonarray(relate_images)]
32   - res["data"]["speci_service"]["images"] = sorted(res["data"]["speci_service"]["images"], key=lambda x: x["name"])
33   -
34   - elif service.type.__eq__("切片服务"):
  29 + if service.type == ServiceType.tile_service.value:
35 30 speci_service = service.relate_tile_service.one_or_none()
36 31 res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service)
37   - elif service.type.__eq__("地图服务"):
  32 + elif service.type == ServiceType.map_service.value:
38 33 speci_service = service.relate_map_service.one_or_none()
39 34 res["data"]["speci_service"] = ModelVisitor.object_to_json(speci_service)
40 35 else:
... ... @@ -44,11 +39,12 @@ class Api(ApiTemplate):
44 39 res["data"]["service"] = ModelVisitor.object_to_json(service)
45 40 res["data"]["service"]["functions"] = functions
46 41
47   - elif s_type in ["影像服务"]:
  42 + elif s_type in [ServiceType.image_service.value]:
  43 +
48 44 edit_url = "{}/API/Service/Info".format(self.para.get("url"))
49 45 response:requests.Response = requests.post(edit_url,self.para)
50 46 if not response.json().get("result"):
51   - raise Exception("查询影像服务失败!")
  47 + raise Exception("查询影像地图失败!")
52 48 res = response.json()
53 49 else:
54 50 pass
... ... @@ -69,7 +65,7 @@ class Api(ApiTemplate):
69 65 "in": "formData",
70 66 "type": "string",
71 67 "description": "type",
72   - "enum":["地图服务","切片服务","影像服务"]},
  68 + "enum":[st.value for st in ServiceType]},
73 69 {"name": "url",
74 70 "in": "formData",
75 71 "type": "string",
... ...
... ... @@ -10,7 +10,7 @@ from .models import Service,ServiceFunction,ServiceEngine
10 10 from sqlalchemy import or_
11 11 import requests
12 12 import re
13   -from datetime import datetime
  13 +from .util.ServiceType import ServiceType
14 14
15 15 class Api(ApiTemplate):
16 16 api_name = "服务列表"
... ... @@ -59,14 +59,14 @@ class Api(ApiTemplate):
59 59 service_json["functions"] = sorted(ModelVisitor.objects_to_jsonarray(ServiceFunction.query.filter_by(service_guid=service_json["guid"]).all()),
60 60 key=lambda x:x["type"])
61 61
62   - # 影像服务
  62 + # 影像地图
63 63 image_engines = ServiceEngine.query.filter_by(type="ImageServer").all()
64 64
65 65 for ie in image_engines:
66 66 url = "{}/API/Service/List".format(ie.url)
67 67 response:requests.Response = requests.post(url,{"page_size":"9999","page_index":"0"})
68 68 if not response.json().get("result"):
69   - raise Exception("修改影像服务失败!")
  69 + raise Exception("获取影像地图失败!")
70 70 else:
71 71 raw_json = response.json()["data"]["list"]
72 72 if state:
... ... @@ -141,7 +141,7 @@ class Api(ApiTemplate):
141 141 "in": "formData",
142 142 "type": "string",
143 143 "description": "服务类型",
144   - "enum":["影像服务","切片服务","地图服务"]},
  144 + "enum":[st.value for st in ServiceType]},
145 145 {"name": "catalog_guid",
146 146 "in": "formData",
147 147 "type": "string",
... ...
... ... @@ -9,7 +9,7 @@ from app.util.component.ModelVisitor import ModelVisitor
9 9 from .models import Service,ServiceFunction,ServiceEngine
10 10 from app.util.component.GeometryAdapter import GeometryAdapter
11 11 import requests
12   -import json
  12 +from .util.ServiceType import ServiceType
13 13
14 14 class Api(ApiTemplate):
15 15
... ... @@ -38,7 +38,7 @@ class Api(ApiTemplate):
38 38 if bbox:
39 39 g1 = GeometryAdapter.bbox_2_polygon([float(x) for x in bbox.split(",")])
40 40 for ser in services:
41   - if ser.type.__eq__("切片服务"):
  41 + if ser.type == ServiceType.tile_service.value:
42 42 layer_exetent = ser.relate_tile_service.one_or_none().layer_extent
43 43
44 44 g2 = GeometryAdapter.envelop_2_polygon([float(x) for x in layer_exetent.split(",")])
... ... @@ -54,7 +54,7 @@ class Api(ApiTemplate):
54 54 service_json["functions"] = sorted(ModelVisitor.objects_to_jsonarray(ServiceFunction.query.filter_by(service_guid=service_json["guid"]).all()),
55 55 key=lambda x:x["type"])
56 56
57   - # 影像服务
  57 + # 影像地图
58 58 image_engines = ServiceEngine.query.filter_by(type="ImageServer").all()
59 59
60 60 for ie in image_engines:
... ... @@ -62,7 +62,7 @@ class Api(ApiTemplate):
62 62 response:requests.Response = requests.post(url,{"page_size":"9999","page_index":"0",
63 63 "bbox":bbox,"state":state})
64 64 if not response.json().get("result"):
65   - raise Exception("修改影像服务失败!")
  65 + raise Exception("获取影像地图失败!")
66 66 else:
67 67 raw_json = response.json()["data"]["list"]
68 68 fit_services_json.extend(raw_json)
... ...
... ... @@ -5,7 +5,7 @@
5 5
6 6 from app.util.component.ApiTemplate import ApiTemplate
7 7 from .models import Service
8   -import requests
  8 +from .util.ServiceType import ServiceType
9 9 class Api(ApiTemplate):
10 10 api_name = "注册服务"
11 11 def process(self):
... ... @@ -16,13 +16,13 @@ class Api(ApiTemplate):
16 16 if service:
17 17 raise Exception("服务已存在!")
18 18
19   - if self.para.get("type").__eq__("地图服务"):
  19 + if self.para.get("type") == ServiceType.map_service.value:
20 20 from app.modules.service.map_service.map_service_register import Api as RealApi
21 21
22   - elif self.para.get("type").__eq__("切片服务"):
  22 + elif self.para.get("type") == ServiceType.tile_service.value:
23 23 from app.modules.service.tile_service.tile_service_register import Api as RealApi
24 24
25   - elif self.para.get("type").__eq__("影像服务"):
  25 + elif self.para.get("type") == ServiceType.image_service.value:
26 26 from app.modules.service.image_service.image_service_register import Api as RealApi
27 27
28 28 else:
... ... @@ -45,12 +45,12 @@ class Api(ApiTemplate):
45 45 "in": "formData",
46 46 "type": "string",
47 47 "required": "true",
48   - "description": "[地图服务,切片服务,影像服务]"},
  48 + "description": "[矢量地图,电子地图,影像地图]"},
49 49
50 50 {"name": "title",
51 51 "in": "formData",
52 52 "type": "string",
53   - "description": "[地图服务,切片服务,影像服务]"},
  53 + "description": "[矢量地图,电子地图,影像地图]"},
54 54
55 55 {"name": "creator",
56 56 "in": "formData",
... ... @@ -63,97 +63,97 @@ class Api(ApiTemplate):
63 63 {"name": "description",
64 64 "in": "formData",
65 65 "type": "string",
66   - "description": "[地图服务,切片服务,影像服务]"},
  66 + "description": "[矢量地图,电子地图,影像地图]"},
67 67 {"name": "type",
68 68 "in": "formData",
69 69 "type": "string",
70   - "enum":["地图服务","切片服务","影像服务"],
  70 + "enum":[st.value for st in ServiceType],
71 71 "required": "true",
72   - "description": "[地图服务,切片服务,影像服务]"},
  72 + "description": "[矢量地图,电子地图,影像地图]"},
73 73 {"name": "catalog_guid",
74 74 "in": "formData",
75 75 "type": "string",
76   - "description": "[地图服务,切片服务,影像服务]"},
  76 + "description": "[矢量地图,电子地图,影像地图]"},
77 77
78 78 #影像参数
79 79 {"name": "image_guids",
80 80 "in": "formData",
81 81 "type": "string",
82   - "description": "[影像服务]影像guids,以英文逗号相隔"},
  82 + "description": "[影像地图]影像guids,以英文逗号相隔"},
83 83
84 84 {"name": "scheme",
85 85 "in": "formData",
86 86 "type": "string",
87   - "description": "[影像服务,切片服务]切片方案json"},
  87 + "description": "[影像地图,电子地图]切片方案json"},
88 88
89 89
90 90 {"name": "functions",
91 91 "in": "formData",
92 92 "type": "string",
93   - "description": "[影像服务]functions",
  93 + "description": "[影像地图]functions",
94 94 "enum": ["WMS","WMTS"]},
95 95
96 96 # 切片参数
97 97 {"name": "overview",
98 98 "in": "formData",
99 99 "type": "string",
100   - "description": "[切片服务]缩略图"},
  100 + "description": "[电子地图]缩略图"},
101 101 {"name": "tile_type",
102 102 "in": "formData",
103 103 "type": "string",
104   - "description": "[切片服务]tile_type",
  104 + "description": "[电子地图]tile_type",
105 105 "enum":["WMTS","TMS"]},
106 106
107 107 {"name": "vendor",
108 108 "in": "formData",
109 109 "type": "string",
110   - "description": "[切片服务]厂商"},
  110 + "description": "[电子地图]厂商"},
111 111 {"name": "crs",
112 112 "in": "formData",
113 113 "type": "string",
114   - "description": "[切片服务]坐标系"},
  114 + "description": "[电子地图]坐标系"},
115 115 {"name": "datasource",
116 116 "in": "formData",
117 117 "type": "string",
118   - "description": "[切片服务]数据路径"},
  118 + "description": "[电子地图]数据路径"},
119 119 {"name": "layer_name",
120 120 "in": "formData",
121 121 "type": "string",
122   - "description": "[切片服务]图层名"},
  122 + "description": "[电子地图]图层名"},
123 123 {"name": "layer_alias",
124 124 "in": "formData",
125 125 "type": "string",
126   - "description": "[切片服务]图层别名"},
  126 + "description": "[电子地图]图层别名"},
127 127 {"name": "layer_title",
128 128 "in": "formData",
129 129 "type": "string",
130   - "description": "[切片服务]图层标题"},
  130 + "description": "[电子地图]图层标题"},
131 131 {"name": "layer_style",
132 132 "in": "formData",
133 133 "type": "string",
134   - "description": "[切片服务,地图服务]图层样式"},
  134 + "description": "[电子地图,矢量地图]图层样式"},
135 135 {"name": "layer_format",
136 136 "in": "formData",
137 137 "type": "string",
138   - "description": "[切片服务]图层format"},
  138 + "description": "[电子地图]图层format"},
139 139 {"name": "layer_extent",
140 140 "in": "formData",
141 141 "type": "string",
142   - "description": "[切片服务]图层范围"},
  142 + "description": "[电子地图]图层范围"},
143 143 {"name": "layer_description",
144 144 "in": "formData",
145 145 "type": "string",
146   - "description": "[切片服务]图层描述"},
  146 + "description": "[电子地图]图层描述"},
147 147
148   - #地图服务参数
  148 + #矢量地图参数
149 149 {"name": "capabilities",
150 150 "in": "formData",
151 151 "type": "int",
152   - "description": "[地图服务]"},
  152 + "description": "[矢量地图]"},
153 153 {"name": "project",
154 154 "in": "formData",
155 155 "type": "string",
156   - "description": "[地图服务]project"},
  156 + "description": "[矢量地图]project"},
157 157
158 158 ],
159 159 "responses": {
... ...
... ... @@ -9,7 +9,7 @@ from .models import TileService,db,Service,MapService
9 9 from app.util.component.ModelVisitor import ModelVisitor
10 10 from .tile_service.util.ProjectFile import ProjectFile
11 11
12   -
  12 +from .util.ServiceType import ServiceType
13 13 class Api(ApiTemplate):
14 14
15 15 api_name = "服务reload"
... ... @@ -22,8 +22,8 @@ class Api(ApiTemplate):
22 22
23 23 res["data"]["list"] = []
24 24
25   - #切片服务
26   - tile_services = TileService.query.join(Service).filter(Service.type == "切片服务").all()
  25 + #电子地图
  26 + tile_services = TileService.query.join(Service).filter(Service.type == ServiceType.tile_service.value).all()
27 27 for ts in tile_services:
28 28 project_file = ProjectFile.create(ModelVisitor.object_to_json(ts))
29 29 service:Service = Service.query.filter_by(guid=ts.service_guid).one_or_none()
... ...
... ... @@ -7,6 +7,8 @@ from app.util.component.UserCheck import UserCheck
7 7 from app.util.component.ApiTemplate import ApiTemplate
8 8 from .models import Service,db
9 9 import requests
  10 +from .util.ServiceType import ServiceType
  11 +
10 12
11 13 class Api(ApiTemplate):
12 14 api_name = "修改服务状态"
... ... @@ -17,7 +19,7 @@ class Api(ApiTemplate):
17 19 state = int(self.para.get("state"))
18 20 s_type = self.para.get("type")
19 21
20   - if s_type in ["切片服务","地图服务","地址匹配"]:
  22 + if s_type in [ServiceType.tile_service.value,ServiceType.map_service.value]:
21 23 service = Service.query.filter_by(guid=guid).one_or_none()
22 24 # 验证权限
23 25 UserCheck.verify(service.creator)
... ... @@ -28,8 +30,8 @@ class Api(ApiTemplate):
28 30 res["result"] = True
29 31 else:
30 32 raise Exception("服务不存在!")
31   - # 删除影像服务
32   - else:
  33 +
  34 + elif s_type == ServiceType.image_service.value:
33 35 user_req: requests.Response = requests.post("{}/API/Service/Info".format(self.para.get("url")),
34 36 data={"guid": self.para.get("guid")})
35 37 if not user_req.json().get("result"):
... ... @@ -40,7 +42,7 @@ class Api(ApiTemplate):
40 42 url = "{}/API/Service/State".format(self.para.get("url"))
41 43 response: requests.Response = requests.post(url, data=self.para)
42 44 if not response.json().get("result"):
43   - raise Exception("由于{},影像服务修改失败!".format(response.json().get("msg")))
  45 + raise Exception("由于{},影像地图修改失败!".format(response.json().get("msg")))
44 46 res["result"] = True
45 47
46 48 except Exception as e:
... ... @@ -58,6 +60,7 @@ class Api(ApiTemplate):
58 60 {"name": "type",
59 61 "in": "formData",
60 62 "type": "string",
  63 + "enum":[st.value for st in ServiceType],
61 64 "description": "type"},
62 65 {"name": "url",
63 66 "in": "formData",
... ...
... ... @@ -9,22 +9,13 @@ from flask import Blueprint
9 9 from app.util import BlueprintApi
10 10 from . import upload_oview,tile_service_register,tile_service_edit,tile_service_reload
11 11 from app.decorators.token_decorator import token_decorator
12   -
  12 +from ..util.ServiceType import ServiceType
13 13
14 14 class DataManager(BlueprintApi):
15 15
16 16 bp = Blueprint("TileService", __name__, url_prefix="/API/Service/TileService")
17 17
18   - service_type = ["切片服务"]
19   -
20   - # @staticmethod
21   - # @bp.route('/UploadOverview', methods=['POST'])
22   - # @swag_from(upload_oview.Api.api_doc)
23   - # def api_upload_oview():
24   - # """
25   - # 上传缩略图
26   - # """
27   - # return upload_oview.Api().result
  18 + service_type = [ServiceType.tile_service.value]
28 19
29 20
30 21 @staticmethod
... ...
... ... @@ -18,7 +18,7 @@ from app.util.component.UserCheck import UserCheck
18 18
19 19 class Api(ApiTemplate):
20 20
21   - api_name = "修改切片服务"
  21 + api_name = "修改电子地图"
22 22
23 23 def process(self):
24 24 res = {}
... ... @@ -66,7 +66,7 @@ class Api(ApiTemplate):
66 66 resp.encoding="utf-8"
67 67 resp_json = resp.json()
68 68 if not resp_json["status"].__eq__("1"):
69   - raise Exception("调用切片服务的注册服务接口失败!")
  69 + raise Exception("调用电子地图的注册服务接口失败!")
70 70
71 71 service_update["overview"] = resp_json["url"]
72 72 #修改数据库
... ... @@ -96,7 +96,7 @@ class Api(ApiTemplate):
96 96 return res
97 97
98 98 api_doc = {
99   - "tags": ["切片服务接口"],
  99 + "tags": ["电子地图接口"],
100 100 "parameters": [
101 101 {"name": "guid",
102 102 "in": "formData",
... ... @@ -106,76 +106,76 @@ class Api(ApiTemplate):
106 106 {"name": "name",
107 107 "in": "formData",
108 108 "type": "string",
109   - "description": "[地图服务,切片服务,影像服务]"},
  109 + "description": "[矢量地图,电子地图,影像地图]"},
110 110 {"name": "title",
111 111 "in": "formData",
112 112 "type": "string",
113   - "description": "[地图服务,切片服务,影像服务]"},
  113 + "description": "[矢量地图,电子地图,影像地图]"},
114 114 {"name": "description",
115 115 "in": "formData",
116 116 "type": "string",
117   - "description": "[地图服务,切片服务,影像服务]"},
  117 + "description": "[矢量地图,电子地图,影像地图]"},
118 118
119 119 {"name": "catalog_guid",
120 120 "in": "formData",
121 121 "type": "string",
122   - "description": "[地图服务,切片服务,影像服务]"},
  122 + "description": "[矢量地图,电子地图,影像地图]"},
123 123
124 124 {"name": "scheme_guid",
125 125 "in": "formData",
126 126 "type": "string",
127   - "description": "[切片服务,影像服务]切片方案"},
  127 + "description": "[电子地图,影像地图]切片方案"},
128 128
129   - # 切片服务参数
  129 + # 电子地图参数
130 130 {"name": "overview",
131 131 "in": "formData",
132 132 "type": "string",
133   - "description": "[切片服务]缩略图"},
  133 + "description": "[电子地图]缩略图"},
134 134 {"name": "tile_type",
135 135 "in": "formData",
136 136 "type": "string",
137   - "description": "[切片服务]tile_type",
  137 + "description": "[电子地图]tile_type",
138 138 "enum":["WMTS","TMS"]},
139 139 {"name": "vendor",
140 140 "in": "formData",
141 141 "type": "string",
142   - "description": "[切片服务]厂商"},
  142 + "description": "[电子地图]厂商"},
143 143 {"name": "crs",
144 144 "in": "formData",
145 145 "type": "string",
146   - "description": "[切片服务]坐标系"},
  146 + "description": "[电子地图]坐标系"},
147 147 {"name": "datasource",
148 148 "in": "formData",
149 149 "type": "string",
150   - "description": "[切片服务]数据路径"},
  150 + "description": "[电子地图]数据路径"},
151 151 {"name": "layer_name",
152 152 "in": "formData",
153 153 "type": "string",
154   - "description": "[切片服务]图层名"},
  154 + "description": "[电子地图]图层名"},
155 155 {"name": "layer_alias",
156 156 "in": "formData",
157 157 "type": "string",
158   - "description": "[切片服务]图层别名"},
  158 + "description": "[电子地图]图层别名"},
159 159 {"name": "layer_title",
160 160 "in": "formData",
161 161 "type": "string",
162   - "description": "[切片服务]图层标题"},
  162 + "description": "[电子地图]图层标题"},
163 163 {"name": "layer_style",
164 164 "in": "formData",
165 165 "type": "string",
166   - "description": "[切片服务,地图服务]图层样式"},
  166 + "description": "[电子地图,矢量地图]图层样式"},
167 167 {"name": "layer_format",
168 168 "in": "formData",
169 169 "type": "string",
170   - "description": "[切片服务]图层format"},
  170 + "description": "[电子地图]图层format"},
171 171 {"name": "layer_extent",
172 172 "in": "formData",
173 173 "type": "string",
174   - "description": "[切片服务]图层范围"},
  174 + "description": "[电子地图]图层范围"},
175 175 {"name": "layer_description",
176 176 "in": "formData",
177 177 "type": "string",
178   - "description": "[切片服务]图层描述"},
  178 + "description": "[电子地图]图层描述"},
179 179
180 180
181 181 ],
... ...
... ... @@ -18,7 +18,7 @@ from .util.ProjectFile import ProjectFile
18 18
19 19 class Api(ApiTemplate):
20 20
21   - api_name = "注册切片服务"
  21 + api_name = "注册电子地图"
22 22
23 23 def process(self):
24 24 # 返回结果
... ... @@ -28,7 +28,7 @@ class Api(ApiTemplate):
28 28 service_guid = uuid.uuid1().__str__()
29 29 tile_service_guid = uuid.uuid1().__str__()
30 30 service_function_guid = uuid.uuid1().__str__()
31   - # 调用切片服务的注册服务接口
  31 + # 调用电子地图的注册服务接口
32 32
33 33 project_file = ProjectFile.create(self.para)
34 34 para = {"name":self.para.get("name"),
... ... @@ -48,7 +48,7 @@ class Api(ApiTemplate):
48 48 StructurePrint().print(resp_json)
49 49
50 50 if not resp_json["status"]=="1":
51   - raise Exception("调用切片服务的注册服务接口失败!")
  51 + raise Exception("调用电子地图的注册服务接口失败!")
52 52
53 53 service = Service(
54 54 guid = service_guid,
... ... @@ -114,82 +114,82 @@ class Api(ApiTemplate):
114 114
115 115
116 116 api_doc = {
117   - "tags": ["切片服务接口"],
  117 + "tags": ["电子地图接口"],
118 118 "parameters": [
119 119 {"name": "name",
120 120 "in": "formData",
121 121 "type": "string",
122   - "description": "[地图服务,切片服务,影像服务]"},
  122 + "description": "[矢量地图,电子地图,影像地图]"},
123 123 {"name": "title",
124 124 "in": "formData",
125 125 "type": "string",
126   - "description": "[地图服务,切片服务,影像服务]"},
  126 + "description": "[矢量地图,电子地图,影像地图]"},
127 127 {"name": "description",
128 128 "in": "formData",
129 129 "type": "string",
130   - "description": "[地图服务,切片服务,影像服务]"},
  130 + "description": "[矢量地图,电子地图,影像地图]"},
131 131 {"name": "type",
132 132 "in": "formData",
133 133 "type": "string",
134   - "description": "[地图服务,切片服务,影像服务",
135   - "enum":["地图服务","切片服务","影像服务"]},
  134 + "description": "[矢量地图,电子地图,影像地图",
  135 + "enum":["矢量地图","电子地图","影像地图"]},
136 136 {"name": "catalog_guid",
137 137 "in": "formData",
138 138 "type": "string",
139   - "description": "[地图服务,切片服务,影像服务]"},
  139 + "description": "[矢量地图,电子地图,影像地图]"},
140 140 {"name": "scheme_guid",
141 141 "in": "formData",
142 142 "type": "string",
143   - "description": "[切片服务,影像服务]切片方案"},
  143 + "description": "[电子地图,影像地图]切片方案"},
144 144 {"name": "overview",
145 145 "in": "formData",
146 146 "type": "string",
147   - "description": "[切片服务]缩略图"},
  147 + "description": "[电子地图]缩略图"},
148 148 {"name": "tile_type",
149 149 "in": "formData",
150 150 "type": "string",
151   - "description": "[切片服务]tile_type",
  151 + "description": "[电子地图]tile_type",
152 152 "enum":["WMTS","TMS"]},
153 153 {"name": "vendor",
154 154 "in": "formData",
155 155 "type": "string",
156   - "description": "[切片服务]厂商"},
  156 + "description": "[电子地图]厂商"},
157 157 {"name": "crs",
158 158 "in": "formData",
159 159 "type": "string",
160   - "description": "[切片服务]坐标系"},
  160 + "description": "[电子地图]坐标系"},
161 161 {"name": "datasource",
162 162 "in": "formData",
163 163 "type": "string",
164   - "description": "[切片服务]数据路径"},
  164 + "description": "[电子地图]数据路径"},
165 165 {"name": "layer_name",
166 166 "in": "formData",
167 167 "type": "string",
168   - "description": "[切片服务]图层名"},
  168 + "description": "[电子地图]图层名"},
169 169 {"name": "layer_alias",
170 170 "in": "formData",
171 171 "type": "string",
172   - "description": "[切片服务]图层别名"},
  172 + "description": "[电子地图]图层别名"},
173 173 {"name": "layer_title",
174 174 "in": "formData",
175 175 "type": "string",
176   - "description": "[切片服务]图层标题"},
  176 + "description": "[电子地图]图层标题"},
177 177 {"name": "layer_style",
178 178 "in": "formData",
179 179 "type": "string",
180   - "description": "[切片服务]图层样式"},
  180 + "description": "[电子地图]图层样式"},
181 181 {"name": "layer_format",
182 182 "in": "formData",
183 183 "type": "string",
184   - "description": "[切片服务]图层format"},
  184 + "description": "[电子地图]图层format"},
185 185 {"name": "layer_extent",
186 186 "in": "formData",
187 187 "type": "string",
188   - "description": "[切片服务]图层范围"},
  188 + "description": "[电子地图]图层范围"},
189 189 {"name": "layer_description",
190 190 "in": "formData",
191 191 "type": "string",
192   - "description": "[切片服务]图层描述"},
  192 + "description": "[电子地图]图层描述"},
193 193 ],
194 194 "responses": {
195 195 200: {
... ...
  1 +# coding=utf-8
  2 +#author: 4N
  3 +#createtime: 2022/1/24
  4 +#email: nheweijun@sina.com
  5 +
  6 +from enum import Enum
  7 +
  8 +#服务枚举类
  9 +class ServiceType(Enum):
  10 +
  11 + map_service = "矢量地图"
  12 + tile_service = "电子地图"
  13 + image_service = "影像地图"
  14 +
  15 + # add_service = "地址匹配"
\ No newline at end of file
... ...
注册登录 后发表评论