正在显示
22 个修改的文件
包含
2335 行增加
和
24 行删除
... | ... | @@ -28,12 +28,10 @@ from app.util.component.StructuredPrint import StructurePrint |
28 | 28 | from app.util.component.PGUtil import PGUtil |
29 | 29 | import os |
30 | 30 | |
31 | -""" | |
32 | -因为decimal不能序列化,增加Flask对decimal类的解析 | |
33 | -""" | |
34 | - | |
35 | - | |
36 | 31 | class JSONEncoder(_JSONEncoder): |
32 | + """ | |
33 | + 因为decimal不能序列化,增加Flask对decimal类的解析 | |
34 | + """ | |
37 | 35 | def default(self, o): |
38 | 36 | if isinstance(o, decimal.Decimal): |
39 | 37 | return float(o) |
... | ... | @@ -44,10 +42,12 @@ class Flask(_Flask): |
44 | 42 | json_encoder = JSONEncoder |
45 | 43 | |
46 | 44 | |
47 | -# idx =None | |
48 | -# url_json_list=None | |
49 | -# sqlite3_connect= None | |
45 | +GLOBAL_DIC={} | |
50 | 46 | def create_app(): |
47 | + """ | |
48 | + flask应用创建函数 | |
49 | + :return:app,flask实例 | |
50 | + """ | |
51 | 51 | |
52 | 52 | # app基本设置 |
53 | 53 | app = Flask(__name__) |
... | ... | @@ -104,7 +104,9 @@ def create_app(): |
104 | 104 | |
105 | 105 | # 不检测https |
106 | 106 | os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' |
107 | - | |
107 | + | |
108 | + # 上下文全局变量字典 | |
109 | + global GLOBAL_DIC | |
108 | 110 | |
109 | 111 | return app |
110 | 112 | ... | ... |
... | ... | @@ -33,7 +33,9 @@ class Api(ApiTemplate): |
33 | 33 | # if Table.query.filter_by(catalog_guid=self.para.get("pguid")).all(): |
34 | 34 | # raise Exception("父目录挂载了数据,不能创建子目录") |
35 | 35 | |
36 | - if Catalog.query.filter_by(name=self.para.get("name"),pguid=self.para.get("pguid"),database_guid=self.para.get("database_guid")).one_or_none(): | |
36 | + if Catalog.query.filter_by(name=self.para.get("name"), | |
37 | + pguid=self.para.get("pguid"), | |
38 | + database_guid=self.para.get("database_guid")).one_or_none(): | |
37 | 39 | res["msg"]="目录已经存在!" |
38 | 40 | return res |
39 | 41 | |
... | ... | @@ -58,9 +60,12 @@ class Api(ApiTemplate): |
58 | 60 | |
59 | 61 | sort = Catalog.query.filter_by(pguid=self.para.get("pguid")).count() |
60 | 62 | |
61 | - catalog = Catalog(guid=guid,pguid=self.para.get("pguid"),name=self.para.get("name"), | |
62 | - sort=sort,description=self.para.get("description"), | |
63 | - database_guid=self.para.get("database_guid"),path=path) | |
63 | + catalog = Catalog(guid=guid, | |
64 | + pguid=self.para.get("pguid"),name=self.para.get("name"), | |
65 | + sort=sort, | |
66 | + description=self.para.get("description"), | |
67 | + database_guid=self.para.get("database_guid"), | |
68 | + path=path) | |
64 | 69 | db.session.add(catalog) |
65 | 70 | db.session.commit() |
66 | 71 | ... | ... |
1 | +#!/usr/bin/env python | |
2 | +# | |
3 | +# Autogenerated by Thrift Compiler (0.14.2) | |
4 | +# | |
5 | +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING | |
6 | +# | |
7 | +# options string: py | |
8 | +# | |
9 | + | |
10 | +import sys | |
11 | +import pprint | |
12 | +if sys.version_info[0] > 2: | |
13 | + from urllib.parse import urlparse | |
14 | +else: | |
15 | + from urlparse import urlparse | |
16 | +from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient | |
17 | +from thrift.protocol.TBinaryProtocol import TBinaryProtocol | |
18 | + | |
19 | +from . import ImageDataService | |
20 | +from .ttypes import * | |
21 | + | |
22 | +if len(sys.argv) <= 1 or sys.argv[1] == '--help': | |
23 | + print('') | |
24 | + print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] [-novalidate] [-ca_certs certs] [-keyfile keyfile] [-certfile certfile] function [arg1 [arg2...]]') | |
25 | + print('') | |
26 | + print('Functions:') | |
27 | + print(' string getData(string path, queryRange, originRange, bands)') | |
28 | + print(' string getInfo(string path)') | |
29 | + print(' bool buildOverview(string path)') | |
30 | + print(' string getImageList(string path)') | |
31 | + print('') | |
32 | + sys.exit(0) | |
33 | + | |
34 | +pp = pprint.PrettyPrinter(indent=2) | |
35 | +host = 'localhost' | |
36 | +port = 9090 | |
37 | +uri = '' | |
38 | +framed = False | |
39 | +ssl = False | |
40 | +validate = True | |
41 | +ca_certs = None | |
42 | +keyfile = None | |
43 | +certfile = None | |
44 | +http = False | |
45 | +argi = 1 | |
46 | + | |
47 | +if sys.argv[argi] == '-h': | |
48 | + parts = sys.argv[argi + 1].split(':') | |
49 | + host = parts[0] | |
50 | + if len(parts) > 1: | |
51 | + port = int(parts[1]) | |
52 | + argi += 2 | |
53 | + | |
54 | +if sys.argv[argi] == '-u': | |
55 | + url = urlparse(sys.argv[argi + 1]) | |
56 | + parts = url[1].split(':') | |
57 | + host = parts[0] | |
58 | + if len(parts) > 1: | |
59 | + port = int(parts[1]) | |
60 | + else: | |
61 | + port = 80 | |
62 | + uri = url[2] | |
63 | + if url[4]: | |
64 | + uri += '?%s' % url[4] | |
65 | + http = True | |
66 | + argi += 2 | |
67 | + | |
68 | +if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed': | |
69 | + framed = True | |
70 | + argi += 1 | |
71 | + | |
72 | +if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl': | |
73 | + ssl = True | |
74 | + argi += 1 | |
75 | + | |
76 | +if sys.argv[argi] == '-novalidate': | |
77 | + validate = False | |
78 | + argi += 1 | |
79 | + | |
80 | +if sys.argv[argi] == '-ca_certs': | |
81 | + ca_certs = sys.argv[argi+1] | |
82 | + argi += 2 | |
83 | + | |
84 | +if sys.argv[argi] == '-keyfile': | |
85 | + keyfile = sys.argv[argi+1] | |
86 | + argi += 2 | |
87 | + | |
88 | +if sys.argv[argi] == '-certfile': | |
89 | + certfile = sys.argv[argi+1] | |
90 | + argi += 2 | |
91 | + | |
92 | +cmd = sys.argv[argi] | |
93 | +args = sys.argv[argi + 1:] | |
94 | + | |
95 | +if http: | |
96 | + transport = THttpClient.THttpClient(host, port, uri) | |
97 | +else: | |
98 | + if ssl: | |
99 | + socket = TSSLSocket.TSSLSocket(host, port, validate=validate, ca_certs=ca_certs, keyfile=keyfile, certfile=certfile) | |
100 | + else: | |
101 | + socket = TSocket.TSocket(host, port) | |
102 | + if framed: | |
103 | + transport = TTransport.TFramedTransport(socket) | |
104 | + else: | |
105 | + transport = TTransport.TBufferedTransport(socket) | |
106 | +protocol = TBinaryProtocol(transport) | |
107 | +client = ImageDataService.Client(protocol) | |
108 | +transport.open() | |
109 | + | |
110 | +if cmd == 'getData': | |
111 | + if len(args) != 4: | |
112 | + print('getData requires 4 args') | |
113 | + sys.exit(1) | |
114 | + pp.pprint(client.getData(args[0], eval(args[1]), eval(args[2]), eval(args[3]),)) | |
115 | + | |
116 | +elif cmd == 'getInfo': | |
117 | + if len(args) != 1: | |
118 | + print('getInfo requires 1 args') | |
119 | + sys.exit(1) | |
120 | + pp.pprint(client.getInfo(args[0],)) | |
121 | + | |
122 | +elif cmd == 'buildOverview': | |
123 | + if len(args) != 1: | |
124 | + print('buildOverview requires 1 args') | |
125 | + sys.exit(1) | |
126 | + pp.pprint(client.buildOverview(args[0],)) | |
127 | + | |
128 | +elif cmd == 'getImageList': | |
129 | + if len(args) != 1: | |
130 | + print('getImageList requires 1 args') | |
131 | + sys.exit(1) | |
132 | + pp.pprint(client.getImageList(args[0],)) | |
133 | + | |
134 | +else: | |
135 | + print('Unrecognized method %s' % cmd) | |
136 | + sys.exit(1) | |
137 | + | |
138 | +transport.close() | ... | ... |
1 | +# | |
2 | +# Autogenerated by Thrift Compiler (0.14.2) | |
3 | +# | |
4 | +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING | |
5 | +# | |
6 | +# options string: py | |
7 | +# | |
8 | + | |
9 | +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException | |
10 | +from thrift.protocol.TProtocol import TProtocolException | |
11 | +from thrift.TRecursive import fix_spec | |
12 | + | |
13 | +import sys | |
14 | +import logging | |
15 | +from .ttypes import * | |
16 | +from thrift.Thrift import TProcessor | |
17 | +from thrift.transport import TTransport | |
18 | +all_structs = [] | |
19 | + | |
20 | + | |
21 | +class Iface(object): | |
22 | + def getData(self, path, queryRange, originRange, bands): | |
23 | + """ | |
24 | + Parameters: | |
25 | + - path | |
26 | + - queryRange | |
27 | + - originRange | |
28 | + - bands | |
29 | + | |
30 | + """ | |
31 | + pass | |
32 | + | |
33 | + def getInfo(self, path): | |
34 | + """ | |
35 | + Parameters: | |
36 | + - path | |
37 | + | |
38 | + """ | |
39 | + pass | |
40 | + | |
41 | + def buildOverview(self, path): | |
42 | + """ | |
43 | + Parameters: | |
44 | + - path | |
45 | + | |
46 | + """ | |
47 | + pass | |
48 | + | |
49 | + def getImageList(self, path): | |
50 | + """ | |
51 | + Parameters: | |
52 | + - path | |
53 | + | |
54 | + """ | |
55 | + pass | |
56 | + | |
57 | + | |
58 | +class Client(Iface): | |
59 | + def __init__(self, iprot, oprot=None): | |
60 | + self._iprot = self._oprot = iprot | |
61 | + if oprot is not None: | |
62 | + self._oprot = oprot | |
63 | + self._seqid = 0 | |
64 | + | |
65 | + def getData(self, path, queryRange, originRange, bands): | |
66 | + """ | |
67 | + Parameters: | |
68 | + - path | |
69 | + - queryRange | |
70 | + - originRange | |
71 | + - bands | |
72 | + | |
73 | + """ | |
74 | + self.send_getData(path, queryRange, originRange, bands) | |
75 | + return self.recv_getData() | |
76 | + | |
77 | + def send_getData(self, path, queryRange, originRange, bands): | |
78 | + self._oprot.writeMessageBegin('getData', TMessageType.CALL, self._seqid) | |
79 | + args = getData_args() | |
80 | + args.path = path | |
81 | + args.queryRange = queryRange | |
82 | + args.originRange = originRange | |
83 | + args.bands = bands | |
84 | + args.write(self._oprot) | |
85 | + self._oprot.writeMessageEnd() | |
86 | + self._oprot.trans.flush() | |
87 | + | |
88 | + def recv_getData(self): | |
89 | + iprot = self._iprot | |
90 | + (fname, mtype, rseqid) = iprot.readMessageBegin() | |
91 | + if mtype == TMessageType.EXCEPTION: | |
92 | + x = TApplicationException() | |
93 | + x.read(iprot) | |
94 | + iprot.readMessageEnd() | |
95 | + raise x | |
96 | + result = getData_result() | |
97 | + result.read(iprot) | |
98 | + iprot.readMessageEnd() | |
99 | + if result.success is not None: | |
100 | + return result.success | |
101 | + raise TApplicationException(TApplicationException.MISSING_RESULT, "getData failed: unknown result") | |
102 | + | |
103 | + def getInfo(self, path): | |
104 | + """ | |
105 | + Parameters: | |
106 | + - path | |
107 | + | |
108 | + """ | |
109 | + self.send_getInfo(path) | |
110 | + return self.recv_getInfo() | |
111 | + | |
112 | + def send_getInfo(self, path): | |
113 | + self._oprot.writeMessageBegin('getInfo', TMessageType.CALL, self._seqid) | |
114 | + args = getInfo_args() | |
115 | + args.path = path | |
116 | + args.write(self._oprot) | |
117 | + self._oprot.writeMessageEnd() | |
118 | + self._oprot.trans.flush() | |
119 | + | |
120 | + def recv_getInfo(self): | |
121 | + iprot = self._iprot | |
122 | + (fname, mtype, rseqid) = iprot.readMessageBegin() | |
123 | + if mtype == TMessageType.EXCEPTION: | |
124 | + x = TApplicationException() | |
125 | + x.read(iprot) | |
126 | + iprot.readMessageEnd() | |
127 | + raise x | |
128 | + result = getInfo_result() | |
129 | + result.read(iprot) | |
130 | + iprot.readMessageEnd() | |
131 | + if result.success is not None: | |
132 | + return result.success | |
133 | + raise TApplicationException(TApplicationException.MISSING_RESULT, "getInfo failed: unknown result") | |
134 | + | |
135 | + def buildOverview(self, path): | |
136 | + """ | |
137 | + Parameters: | |
138 | + - path | |
139 | + | |
140 | + """ | |
141 | + self.send_buildOverview(path) | |
142 | + return self.recv_buildOverview() | |
143 | + | |
144 | + def send_buildOverview(self, path): | |
145 | + self._oprot.writeMessageBegin('buildOverview', TMessageType.CALL, self._seqid) | |
146 | + args = buildOverview_args() | |
147 | + args.path = path | |
148 | + args.write(self._oprot) | |
149 | + self._oprot.writeMessageEnd() | |
150 | + self._oprot.trans.flush() | |
151 | + | |
152 | + def recv_buildOverview(self): | |
153 | + iprot = self._iprot | |
154 | + (fname, mtype, rseqid) = iprot.readMessageBegin() | |
155 | + if mtype == TMessageType.EXCEPTION: | |
156 | + x = TApplicationException() | |
157 | + x.read(iprot) | |
158 | + iprot.readMessageEnd() | |
159 | + raise x | |
160 | + result = buildOverview_result() | |
161 | + result.read(iprot) | |
162 | + iprot.readMessageEnd() | |
163 | + if result.success is not None: | |
164 | + return result.success | |
165 | + raise TApplicationException(TApplicationException.MISSING_RESULT, "buildOverview failed: unknown result") | |
166 | + | |
167 | + def getImageList(self, path): | |
168 | + """ | |
169 | + Parameters: | |
170 | + - path | |
171 | + | |
172 | + """ | |
173 | + self.send_getImageList(path) | |
174 | + return self.recv_getImageList() | |
175 | + | |
176 | + def send_getImageList(self, path): | |
177 | + self._oprot.writeMessageBegin('getImageList', TMessageType.CALL, self._seqid) | |
178 | + args = getImageList_args() | |
179 | + args.path = path | |
180 | + args.write(self._oprot) | |
181 | + self._oprot.writeMessageEnd() | |
182 | + self._oprot.trans.flush() | |
183 | + | |
184 | + def recv_getImageList(self): | |
185 | + iprot = self._iprot | |
186 | + (fname, mtype, rseqid) = iprot.readMessageBegin() | |
187 | + if mtype == TMessageType.EXCEPTION: | |
188 | + x = TApplicationException() | |
189 | + x.read(iprot) | |
190 | + iprot.readMessageEnd() | |
191 | + raise x | |
192 | + result = getImageList_result() | |
193 | + result.read(iprot) | |
194 | + iprot.readMessageEnd() | |
195 | + if result.success is not None: | |
196 | + return result.success | |
197 | + raise TApplicationException(TApplicationException.MISSING_RESULT, "getImageList failed: unknown result") | |
198 | + | |
199 | + | |
200 | +class Processor(Iface, TProcessor): | |
201 | + def __init__(self, handler): | |
202 | + self._handler = handler | |
203 | + self._processMap = {} | |
204 | + self._processMap["getData"] = Processor.process_getData | |
205 | + self._processMap["getInfo"] = Processor.process_getInfo | |
206 | + self._processMap["buildOverview"] = Processor.process_buildOverview | |
207 | + self._processMap["getImageList"] = Processor.process_getImageList | |
208 | + self._on_message_begin = None | |
209 | + | |
210 | + def on_message_begin(self, func): | |
211 | + self._on_message_begin = func | |
212 | + | |
213 | + def process(self, iprot, oprot): | |
214 | + (name, type, seqid) = iprot.readMessageBegin() | |
215 | + if self._on_message_begin: | |
216 | + self._on_message_begin(name, type, seqid) | |
217 | + if name not in self._processMap: | |
218 | + iprot.skip(TType.STRUCT) | |
219 | + iprot.readMessageEnd() | |
220 | + x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) | |
221 | + oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) | |
222 | + x.write(oprot) | |
223 | + oprot.writeMessageEnd() | |
224 | + oprot.trans.flush() | |
225 | + return | |
226 | + else: | |
227 | + self._processMap[name](self, seqid, iprot, oprot) | |
228 | + return True | |
229 | + | |
230 | + def process_getData(self, seqid, iprot, oprot): | |
231 | + args = getData_args() | |
232 | + args.read(iprot) | |
233 | + iprot.readMessageEnd() | |
234 | + result = getData_result() | |
235 | + try: | |
236 | + result.success = self._handler.getData(args.path, args.queryRange, args.originRange, args.bands) | |
237 | + msg_type = TMessageType.REPLY | |
238 | + except TTransport.TTransportException: | |
239 | + raise | |
240 | + except TApplicationException as ex: | |
241 | + logging.exception('TApplication exception in handler') | |
242 | + msg_type = TMessageType.EXCEPTION | |
243 | + result = ex | |
244 | + except Exception: | |
245 | + logging.exception('Unexpected exception in handler') | |
246 | + msg_type = TMessageType.EXCEPTION | |
247 | + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') | |
248 | + oprot.writeMessageBegin("getData", msg_type, seqid) | |
249 | + result.write(oprot) | |
250 | + oprot.writeMessageEnd() | |
251 | + oprot.trans.flush() | |
252 | + | |
253 | + def process_getInfo(self, seqid, iprot, oprot): | |
254 | + args = getInfo_args() | |
255 | + args.read(iprot) | |
256 | + iprot.readMessageEnd() | |
257 | + result = getInfo_result() | |
258 | + try: | |
259 | + result.success = self._handler.getInfo(args.path) | |
260 | + msg_type = TMessageType.REPLY | |
261 | + except TTransport.TTransportException: | |
262 | + raise | |
263 | + except TApplicationException as ex: | |
264 | + logging.exception('TApplication exception in handler') | |
265 | + msg_type = TMessageType.EXCEPTION | |
266 | + result = ex | |
267 | + except Exception: | |
268 | + logging.exception('Unexpected exception in handler') | |
269 | + msg_type = TMessageType.EXCEPTION | |
270 | + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') | |
271 | + oprot.writeMessageBegin("getInfo", msg_type, seqid) | |
272 | + result.write(oprot) | |
273 | + oprot.writeMessageEnd() | |
274 | + oprot.trans.flush() | |
275 | + | |
276 | + def process_buildOverview(self, seqid, iprot, oprot): | |
277 | + args = buildOverview_args() | |
278 | + args.read(iprot) | |
279 | + iprot.readMessageEnd() | |
280 | + result = buildOverview_result() | |
281 | + try: | |
282 | + result.success = self._handler.buildOverview(args.path) | |
283 | + msg_type = TMessageType.REPLY | |
284 | + except TTransport.TTransportException: | |
285 | + raise | |
286 | + except TApplicationException as ex: | |
287 | + logging.exception('TApplication exception in handler') | |
288 | + msg_type = TMessageType.EXCEPTION | |
289 | + result = ex | |
290 | + except Exception: | |
291 | + logging.exception('Unexpected exception in handler') | |
292 | + msg_type = TMessageType.EXCEPTION | |
293 | + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') | |
294 | + oprot.writeMessageBegin("buildOverview", msg_type, seqid) | |
295 | + result.write(oprot) | |
296 | + oprot.writeMessageEnd() | |
297 | + oprot.trans.flush() | |
298 | + | |
299 | + def process_getImageList(self, seqid, iprot, oprot): | |
300 | + args = getImageList_args() | |
301 | + args.read(iprot) | |
302 | + iprot.readMessageEnd() | |
303 | + result = getImageList_result() | |
304 | + try: | |
305 | + result.success = self._handler.getImageList(args.path) | |
306 | + msg_type = TMessageType.REPLY | |
307 | + except TTransport.TTransportException: | |
308 | + raise | |
309 | + except TApplicationException as ex: | |
310 | + logging.exception('TApplication exception in handler') | |
311 | + msg_type = TMessageType.EXCEPTION | |
312 | + result = ex | |
313 | + except Exception: | |
314 | + logging.exception('Unexpected exception in handler') | |
315 | + msg_type = TMessageType.EXCEPTION | |
316 | + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') | |
317 | + oprot.writeMessageBegin("getImageList", msg_type, seqid) | |
318 | + result.write(oprot) | |
319 | + oprot.writeMessageEnd() | |
320 | + oprot.trans.flush() | |
321 | + | |
322 | +# HELPER FUNCTIONS AND STRUCTURES | |
323 | + | |
324 | + | |
325 | +class getData_args(object): | |
326 | + """ | |
327 | + Attributes: | |
328 | + - path | |
329 | + - queryRange | |
330 | + - originRange | |
331 | + - bands | |
332 | + | |
333 | + """ | |
334 | + | |
335 | + | |
336 | + def __init__(self, path=None, queryRange=None, originRange=None, bands=None,): | |
337 | + self.path = path | |
338 | + self.queryRange = queryRange | |
339 | + self.originRange = originRange | |
340 | + self.bands = bands | |
341 | + | |
342 | + def read(self, iprot): | |
343 | + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: | |
344 | + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) | |
345 | + return | |
346 | + iprot.readStructBegin() | |
347 | + while True: | |
348 | + (fname, ftype, fid) = iprot.readFieldBegin() | |
349 | + if ftype == TType.STOP: | |
350 | + break | |
351 | + if fid == 1: | |
352 | + if ftype == TType.STRING: | |
353 | + self.path = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() | |
354 | + else: | |
355 | + iprot.skip(ftype) | |
356 | + elif fid == 2: | |
357 | + if ftype == TType.LIST: | |
358 | + self.queryRange = [] | |
359 | + (_etype3, _size0) = iprot.readListBegin() | |
360 | + for _i4 in range(_size0): | |
361 | + _elem5 = iprot.readDouble() | |
362 | + self.queryRange.append(_elem5) | |
363 | + iprot.readListEnd() | |
364 | + else: | |
365 | + iprot.skip(ftype) | |
366 | + elif fid == 3: | |
367 | + if ftype == TType.LIST: | |
368 | + self.originRange = [] | |
369 | + (_etype9, _size6) = iprot.readListBegin() | |
370 | + for _i10 in range(_size6): | |
371 | + _elem11 = iprot.readDouble() | |
372 | + self.originRange.append(_elem11) | |
373 | + iprot.readListEnd() | |
374 | + else: | |
375 | + iprot.skip(ftype) | |
376 | + elif fid == 4: | |
377 | + if ftype == TType.LIST: | |
378 | + self.bands = [] | |
379 | + (_etype15, _size12) = iprot.readListBegin() | |
380 | + for _i16 in range(_size12): | |
381 | + _elem17 = iprot.readI32() | |
382 | + self.bands.append(_elem17) | |
383 | + iprot.readListEnd() | |
384 | + else: | |
385 | + iprot.skip(ftype) | |
386 | + else: | |
387 | + iprot.skip(ftype) | |
388 | + iprot.readFieldEnd() | |
389 | + iprot.readStructEnd() | |
390 | + | |
391 | + def write(self, oprot): | |
392 | + if oprot._fast_encode is not None and self.thrift_spec is not None: | |
393 | + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) | |
394 | + return | |
395 | + oprot.writeStructBegin('getData_args') | |
396 | + if self.path is not None: | |
397 | + oprot.writeFieldBegin('path', TType.STRING, 1) | |
398 | + oprot.writeString(self.path.encode('utf-8') if sys.version_info[0] == 2 else self.path) | |
399 | + oprot.writeFieldEnd() | |
400 | + if self.queryRange is not None: | |
401 | + oprot.writeFieldBegin('queryRange', TType.LIST, 2) | |
402 | + oprot.writeListBegin(TType.DOUBLE, len(self.queryRange)) | |
403 | + for iter18 in self.queryRange: | |
404 | + oprot.writeDouble(iter18) | |
405 | + oprot.writeListEnd() | |
406 | + oprot.writeFieldEnd() | |
407 | + if self.originRange is not None: | |
408 | + oprot.writeFieldBegin('originRange', TType.LIST, 3) | |
409 | + oprot.writeListBegin(TType.DOUBLE, len(self.originRange)) | |
410 | + for iter19 in self.originRange: | |
411 | + oprot.writeDouble(iter19) | |
412 | + oprot.writeListEnd() | |
413 | + oprot.writeFieldEnd() | |
414 | + if self.bands is not None: | |
415 | + oprot.writeFieldBegin('bands', TType.LIST, 4) | |
416 | + oprot.writeListBegin(TType.I32, len(self.bands)) | |
417 | + for iter20 in self.bands: | |
418 | + oprot.writeI32(iter20) | |
419 | + oprot.writeListEnd() | |
420 | + oprot.writeFieldEnd() | |
421 | + oprot.writeFieldStop() | |
422 | + oprot.writeStructEnd() | |
423 | + | |
424 | + def validate(self): | |
425 | + return | |
426 | + | |
427 | + def __repr__(self): | |
428 | + L = ['%s=%r' % (key, value) | |
429 | + for key, value in self.__dict__.items()] | |
430 | + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) | |
431 | + | |
432 | + def __eq__(self, other): | |
433 | + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ | |
434 | + | |
435 | + def __ne__(self, other): | |
436 | + return not (self == other) | |
437 | +all_structs.append(getData_args) | |
438 | +getData_args.thrift_spec = ( | |
439 | + None, # 0 | |
440 | + (1, TType.STRING, 'path', 'UTF8', None, ), # 1 | |
441 | + (2, TType.LIST, 'queryRange', (TType.DOUBLE, None, False), None, ), # 2 | |
442 | + (3, TType.LIST, 'originRange', (TType.DOUBLE, None, False), None, ), # 3 | |
443 | + (4, TType.LIST, 'bands', (TType.I32, None, False), None, ), # 4 | |
444 | +) | |
445 | + | |
446 | + | |
447 | +class getData_result(object): | |
448 | + """ | |
449 | + Attributes: | |
450 | + - success | |
451 | + | |
452 | + """ | |
453 | + | |
454 | + | |
455 | + def __init__(self, success=None,): | |
456 | + self.success = success | |
457 | + | |
458 | + def read(self, iprot): | |
459 | + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: | |
460 | + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) | |
461 | + return | |
462 | + iprot.readStructBegin() | |
463 | + while True: | |
464 | + (fname, ftype, fid) = iprot.readFieldBegin() | |
465 | + if ftype == TType.STOP: | |
466 | + break | |
467 | + if fid == 0: | |
468 | + if ftype == TType.STRING: | |
469 | + self.success = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() | |
470 | + else: | |
471 | + iprot.skip(ftype) | |
472 | + else: | |
473 | + iprot.skip(ftype) | |
474 | + iprot.readFieldEnd() | |
475 | + iprot.readStructEnd() | |
476 | + | |
477 | + def write(self, oprot): | |
478 | + if oprot._fast_encode is not None and self.thrift_spec is not None: | |
479 | + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) | |
480 | + return | |
481 | + oprot.writeStructBegin('getData_result') | |
482 | + if self.success is not None: | |
483 | + oprot.writeFieldBegin('success', TType.STRING, 0) | |
484 | + oprot.writeString(self.success.encode('utf-8') if sys.version_info[0] == 2 else self.success) | |
485 | + oprot.writeFieldEnd() | |
486 | + oprot.writeFieldStop() | |
487 | + oprot.writeStructEnd() | |
488 | + | |
489 | + def validate(self): | |
490 | + return | |
491 | + | |
492 | + def __repr__(self): | |
493 | + L = ['%s=%r' % (key, value) | |
494 | + for key, value in self.__dict__.items()] | |
495 | + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) | |
496 | + | |
497 | + def __eq__(self, other): | |
498 | + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ | |
499 | + | |
500 | + def __ne__(self, other): | |
501 | + return not (self == other) | |
502 | +all_structs.append(getData_result) | |
503 | +getData_result.thrift_spec = ( | |
504 | + (0, TType.STRING, 'success', 'UTF8', None, ), # 0 | |
505 | +) | |
506 | + | |
507 | + | |
508 | +class getInfo_args(object): | |
509 | + """ | |
510 | + Attributes: | |
511 | + - path | |
512 | + | |
513 | + """ | |
514 | + | |
515 | + | |
516 | + def __init__(self, path=None,): | |
517 | + self.path = path | |
518 | + | |
519 | + def read(self, iprot): | |
520 | + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: | |
521 | + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) | |
522 | + return | |
523 | + iprot.readStructBegin() | |
524 | + while True: | |
525 | + (fname, ftype, fid) = iprot.readFieldBegin() | |
526 | + if ftype == TType.STOP: | |
527 | + break | |
528 | + if fid == 1: | |
529 | + if ftype == TType.STRING: | |
530 | + self.path = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() | |
531 | + else: | |
532 | + iprot.skip(ftype) | |
533 | + else: | |
534 | + iprot.skip(ftype) | |
535 | + iprot.readFieldEnd() | |
536 | + iprot.readStructEnd() | |
537 | + | |
538 | + def write(self, oprot): | |
539 | + if oprot._fast_encode is not None and self.thrift_spec is not None: | |
540 | + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) | |
541 | + return | |
542 | + oprot.writeStructBegin('getInfo_args') | |
543 | + if self.path is not None: | |
544 | + oprot.writeFieldBegin('path', TType.STRING, 1) | |
545 | + oprot.writeString(self.path.encode('utf-8') if sys.version_info[0] == 2 else self.path) | |
546 | + oprot.writeFieldEnd() | |
547 | + oprot.writeFieldStop() | |
548 | + oprot.writeStructEnd() | |
549 | + | |
550 | + def validate(self): | |
551 | + return | |
552 | + | |
553 | + def __repr__(self): | |
554 | + L = ['%s=%r' % (key, value) | |
555 | + for key, value in self.__dict__.items()] | |
556 | + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) | |
557 | + | |
558 | + def __eq__(self, other): | |
559 | + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ | |
560 | + | |
561 | + def __ne__(self, other): | |
562 | + return not (self == other) | |
563 | +all_structs.append(getInfo_args) | |
564 | +getInfo_args.thrift_spec = ( | |
565 | + None, # 0 | |
566 | + (1, TType.STRING, 'path', 'UTF8', None, ), # 1 | |
567 | +) | |
568 | + | |
569 | + | |
570 | +class getInfo_result(object): | |
571 | + """ | |
572 | + Attributes: | |
573 | + - success | |
574 | + | |
575 | + """ | |
576 | + | |
577 | + | |
578 | + def __init__(self, success=None,): | |
579 | + self.success = success | |
580 | + | |
581 | + def read(self, iprot): | |
582 | + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: | |
583 | + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) | |
584 | + return | |
585 | + iprot.readStructBegin() | |
586 | + while True: | |
587 | + (fname, ftype, fid) = iprot.readFieldBegin() | |
588 | + if ftype == TType.STOP: | |
589 | + break | |
590 | + if fid == 0: | |
591 | + if ftype == TType.STRING: | |
592 | + self.success = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() | |
593 | + else: | |
594 | + iprot.skip(ftype) | |
595 | + else: | |
596 | + iprot.skip(ftype) | |
597 | + iprot.readFieldEnd() | |
598 | + iprot.readStructEnd() | |
599 | + | |
600 | + def write(self, oprot): | |
601 | + if oprot._fast_encode is not None and self.thrift_spec is not None: | |
602 | + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) | |
603 | + return | |
604 | + oprot.writeStructBegin('getInfo_result') | |
605 | + if self.success is not None: | |
606 | + oprot.writeFieldBegin('success', TType.STRING, 0) | |
607 | + oprot.writeString(self.success.encode('utf-8') if sys.version_info[0] == 2 else self.success) | |
608 | + oprot.writeFieldEnd() | |
609 | + oprot.writeFieldStop() | |
610 | + oprot.writeStructEnd() | |
611 | + | |
612 | + def validate(self): | |
613 | + return | |
614 | + | |
615 | + def __repr__(self): | |
616 | + L = ['%s=%r' % (key, value) | |
617 | + for key, value in self.__dict__.items()] | |
618 | + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) | |
619 | + | |
620 | + def __eq__(self, other): | |
621 | + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ | |
622 | + | |
623 | + def __ne__(self, other): | |
624 | + return not (self == other) | |
625 | +all_structs.append(getInfo_result) | |
626 | +getInfo_result.thrift_spec = ( | |
627 | + (0, TType.STRING, 'success', 'UTF8', None, ), # 0 | |
628 | +) | |
629 | + | |
630 | + | |
631 | +class buildOverview_args(object): | |
632 | + """ | |
633 | + Attributes: | |
634 | + - path | |
635 | + | |
636 | + """ | |
637 | + | |
638 | + | |
639 | + def __init__(self, path=None,): | |
640 | + self.path = path | |
641 | + | |
642 | + def read(self, iprot): | |
643 | + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: | |
644 | + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) | |
645 | + return | |
646 | + iprot.readStructBegin() | |
647 | + while True: | |
648 | + (fname, ftype, fid) = iprot.readFieldBegin() | |
649 | + if ftype == TType.STOP: | |
650 | + break | |
651 | + if fid == 1: | |
652 | + if ftype == TType.STRING: | |
653 | + self.path = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() | |
654 | + else: | |
655 | + iprot.skip(ftype) | |
656 | + else: | |
657 | + iprot.skip(ftype) | |
658 | + iprot.readFieldEnd() | |
659 | + iprot.readStructEnd() | |
660 | + | |
661 | + def write(self, oprot): | |
662 | + if oprot._fast_encode is not None and self.thrift_spec is not None: | |
663 | + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) | |
664 | + return | |
665 | + oprot.writeStructBegin('buildOverview_args') | |
666 | + if self.path is not None: | |
667 | + oprot.writeFieldBegin('path', TType.STRING, 1) | |
668 | + oprot.writeString(self.path.encode('utf-8') if sys.version_info[0] == 2 else self.path) | |
669 | + oprot.writeFieldEnd() | |
670 | + oprot.writeFieldStop() | |
671 | + oprot.writeStructEnd() | |
672 | + | |
673 | + def validate(self): | |
674 | + return | |
675 | + | |
676 | + def __repr__(self): | |
677 | + L = ['%s=%r' % (key, value) | |
678 | + for key, value in self.__dict__.items()] | |
679 | + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) | |
680 | + | |
681 | + def __eq__(self, other): | |
682 | + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ | |
683 | + | |
684 | + def __ne__(self, other): | |
685 | + return not (self == other) | |
686 | +all_structs.append(buildOverview_args) | |
687 | +buildOverview_args.thrift_spec = ( | |
688 | + None, # 0 | |
689 | + (1, TType.STRING, 'path', 'UTF8', None, ), # 1 | |
690 | +) | |
691 | + | |
692 | + | |
693 | +class buildOverview_result(object): | |
694 | + """ | |
695 | + Attributes: | |
696 | + - success | |
697 | + | |
698 | + """ | |
699 | + | |
700 | + | |
701 | + def __init__(self, success=None,): | |
702 | + self.success = success | |
703 | + | |
704 | + def read(self, iprot): | |
705 | + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: | |
706 | + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) | |
707 | + return | |
708 | + iprot.readStructBegin() | |
709 | + while True: | |
710 | + (fname, ftype, fid) = iprot.readFieldBegin() | |
711 | + if ftype == TType.STOP: | |
712 | + break | |
713 | + if fid == 0: | |
714 | + if ftype == TType.BOOL: | |
715 | + self.success = iprot.readBool() | |
716 | + else: | |
717 | + iprot.skip(ftype) | |
718 | + else: | |
719 | + iprot.skip(ftype) | |
720 | + iprot.readFieldEnd() | |
721 | + iprot.readStructEnd() | |
722 | + | |
723 | + def write(self, oprot): | |
724 | + if oprot._fast_encode is not None and self.thrift_spec is not None: | |
725 | + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) | |
726 | + return | |
727 | + oprot.writeStructBegin('buildOverview_result') | |
728 | + if self.success is not None: | |
729 | + oprot.writeFieldBegin('success', TType.BOOL, 0) | |
730 | + oprot.writeBool(self.success) | |
731 | + oprot.writeFieldEnd() | |
732 | + oprot.writeFieldStop() | |
733 | + oprot.writeStructEnd() | |
734 | + | |
735 | + def validate(self): | |
736 | + return | |
737 | + | |
738 | + def __repr__(self): | |
739 | + L = ['%s=%r' % (key, value) | |
740 | + for key, value in self.__dict__.items()] | |
741 | + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) | |
742 | + | |
743 | + def __eq__(self, other): | |
744 | + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ | |
745 | + | |
746 | + def __ne__(self, other): | |
747 | + return not (self == other) | |
748 | +all_structs.append(buildOverview_result) | |
749 | +buildOverview_result.thrift_spec = ( | |
750 | + (0, TType.BOOL, 'success', None, None, ), # 0 | |
751 | +) | |
752 | + | |
753 | + | |
754 | +class getImageList_args(object): | |
755 | + """ | |
756 | + Attributes: | |
757 | + - path | |
758 | + | |
759 | + """ | |
760 | + | |
761 | + | |
762 | + def __init__(self, path=None,): | |
763 | + self.path = path | |
764 | + | |
765 | + def read(self, iprot): | |
766 | + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: | |
767 | + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) | |
768 | + return | |
769 | + iprot.readStructBegin() | |
770 | + while True: | |
771 | + (fname, ftype, fid) = iprot.readFieldBegin() | |
772 | + if ftype == TType.STOP: | |
773 | + break | |
774 | + if fid == 1: | |
775 | + if ftype == TType.STRING: | |
776 | + self.path = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() | |
777 | + else: | |
778 | + iprot.skip(ftype) | |
779 | + else: | |
780 | + iprot.skip(ftype) | |
781 | + iprot.readFieldEnd() | |
782 | + iprot.readStructEnd() | |
783 | + | |
784 | + def write(self, oprot): | |
785 | + if oprot._fast_encode is not None and self.thrift_spec is not None: | |
786 | + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) | |
787 | + return | |
788 | + oprot.writeStructBegin('getImageList_args') | |
789 | + if self.path is not None: | |
790 | + oprot.writeFieldBegin('path', TType.STRING, 1) | |
791 | + oprot.writeString(self.path.encode('utf-8') if sys.version_info[0] == 2 else self.path) | |
792 | + oprot.writeFieldEnd() | |
793 | + oprot.writeFieldStop() | |
794 | + oprot.writeStructEnd() | |
795 | + | |
796 | + def validate(self): | |
797 | + return | |
798 | + | |
799 | + def __repr__(self): | |
800 | + L = ['%s=%r' % (key, value) | |
801 | + for key, value in self.__dict__.items()] | |
802 | + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) | |
803 | + | |
804 | + def __eq__(self, other): | |
805 | + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ | |
806 | + | |
807 | + def __ne__(self, other): | |
808 | + return not (self == other) | |
809 | +all_structs.append(getImageList_args) | |
810 | +getImageList_args.thrift_spec = ( | |
811 | + None, # 0 | |
812 | + (1, TType.STRING, 'path', 'UTF8', None, ), # 1 | |
813 | +) | |
814 | + | |
815 | + | |
816 | +class getImageList_result(object): | |
817 | + """ | |
818 | + Attributes: | |
819 | + - success | |
820 | + | |
821 | + """ | |
822 | + | |
823 | + | |
824 | + def __init__(self, success=None,): | |
825 | + self.success = success | |
826 | + | |
827 | + def read(self, iprot): | |
828 | + if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None: | |
829 | + iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec]) | |
830 | + return | |
831 | + iprot.readStructBegin() | |
832 | + while True: | |
833 | + (fname, ftype, fid) = iprot.readFieldBegin() | |
834 | + if ftype == TType.STOP: | |
835 | + break | |
836 | + if fid == 0: | |
837 | + if ftype == TType.STRING: | |
838 | + self.success = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() | |
839 | + else: | |
840 | + iprot.skip(ftype) | |
841 | + else: | |
842 | + iprot.skip(ftype) | |
843 | + iprot.readFieldEnd() | |
844 | + iprot.readStructEnd() | |
845 | + | |
846 | + def write(self, oprot): | |
847 | + if oprot._fast_encode is not None and self.thrift_spec is not None: | |
848 | + oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec])) | |
849 | + return | |
850 | + oprot.writeStructBegin('getImageList_result') | |
851 | + if self.success is not None: | |
852 | + oprot.writeFieldBegin('success', TType.STRING, 0) | |
853 | + oprot.writeString(self.success.encode('utf-8') if sys.version_info[0] == 2 else self.success) | |
854 | + oprot.writeFieldEnd() | |
855 | + oprot.writeFieldStop() | |
856 | + oprot.writeStructEnd() | |
857 | + | |
858 | + def validate(self): | |
859 | + return | |
860 | + | |
861 | + def __repr__(self): | |
862 | + L = ['%s=%r' % (key, value) | |
863 | + for key, value in self.__dict__.items()] | |
864 | + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) | |
865 | + | |
866 | + def __eq__(self, other): | |
867 | + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ | |
868 | + | |
869 | + def __ne__(self, other): | |
870 | + return not (self == other) | |
871 | +all_structs.append(getImageList_result) | |
872 | +getImageList_result.thrift_spec = ( | |
873 | + (0, TType.STRING, 'success', 'UTF8', None, ), # 0 | |
874 | +) | |
875 | +fix_spec(all_structs) | |
876 | +del all_structs | ... | ... |
1 | +__all__ = ['ttypes', 'constants', 'ImageDataService'] | ... | ... |
1 | +# | |
2 | +# Autogenerated by Thrift Compiler (0.14.2) | |
3 | +# | |
4 | +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING | |
5 | +# | |
6 | +# options string: py | |
7 | +# | |
8 | + | |
9 | +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException | |
10 | +from thrift.protocol.TProtocol import TProtocolException | |
11 | +from thrift.TRecursive import fix_spec | |
12 | + | |
13 | +import sys | |
14 | +from .ttypes import * | ... | ... |
app/modules/image/ImageDataService/ttypes.py
0 → 100644
1 | +# | |
2 | +# Autogenerated by Thrift Compiler (0.14.2) | |
3 | +# | |
4 | +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING | |
5 | +# | |
6 | +# options string: py | |
7 | +# | |
8 | + | |
9 | +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException | |
10 | +from thrift.protocol.TProtocol import TProtocolException | |
11 | +from thrift.TRecursive import fix_spec | |
12 | + | |
13 | +import sys | |
14 | + | |
15 | +from thrift.transport import TTransport | |
16 | +all_structs = [] | |
17 | +fix_spec(all_structs) | |
18 | +del all_structs | ... | ... |
app/modules/image/__init__.py
0 → 100644
1 | +# coding=utf-8 | |
2 | +#author: 4N | |
3 | +#createtime: 2021/5/18 | |
4 | +#email: nheweijun@sina.com | |
5 | + | |
6 | + | |
7 | +from flasgger import swag_from | |
8 | +from flask import Blueprint | |
9 | +from app.util import BlueprintApi | |
10 | +from . import image_register | |
11 | +from . import image_service_register | |
12 | +from . import image_server_list | |
13 | +from . import data_list | |
14 | +class DataManager(BlueprintApi): | |
15 | + | |
16 | + bp = Blueprint("Image", __name__, url_prefix="/API/Image") | |
17 | + | |
18 | + @staticmethod | |
19 | + @bp.route('/Register', methods=['POST']) | |
20 | + @swag_from(image_register.Api.api_doc) | |
21 | + def image_register(): | |
22 | + """ | |
23 | + 影像注册 | |
24 | + """ | |
25 | + return image_register.Api().result | |
26 | + | |
27 | + @staticmethod | |
28 | + @bp.route('/ServiceRegister', methods=['POST']) | |
29 | + @swag_from(image_service_register.Api.api_doc) | |
30 | + def image_service_register(): | |
31 | + """ | |
32 | + 服务注册 | |
33 | + """ | |
34 | + return image_service_register.Api().result | |
35 | + | |
36 | + @staticmethod | |
37 | + @bp.route('/ServerList', methods=['GET']) | |
38 | + @swag_from(image_server_list.Api.api_doc) | |
39 | + def image_server_list(): | |
40 | + """ | |
41 | + 服务器列表 | |
42 | + """ | |
43 | + return image_server_list.Api().result | |
44 | + | |
45 | + | |
46 | + @staticmethod | |
47 | + @bp.route('/DataList', methods=['POST']) | |
48 | + @swag_from(data_list.Api.api_doc) | |
49 | + def data_list(): | |
50 | + """ | |
51 | + 数据列表 | |
52 | + """ | |
53 | + return data_list.Api().result | |
\ No newline at end of file | ... | ... |
app/modules/image/capabilities.py
0 → 100644
1 | +# coding=utf-8 | |
2 | +#author: 4N | |
3 | +#createtime: 2021/4/6 | |
4 | +#email: nheweijun@sina.com | |
5 | + | |
6 | + | |
7 | +from app.models import Database | |
8 | +from app.util import get_parameter,objects_to_jsonarray | |
9 | +import traceback | |
10 | +from flask import Response | |
11 | +def api(): | |
12 | + | |
13 | + x = '''<Capabilities xmlns="http://www.opengis.net/wmts/1.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" version="1.0.0"> | |
14 | + <!-- Service Identification --> | |
15 | + <ows:ServiceIdentification> | |
16 | + <ows:Title>localimage</ows:Title> | |
17 | + <ows:ServiceType>OGC WMTS</ows:ServiceType> | |
18 | + <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion> | |
19 | + </ows:ServiceIdentification> | |
20 | + <!-- Operations Metadata --> | |
21 | + <ows:OperationsMetadata> | |
22 | + <ows:Operation name="GetCapabilities"> | |
23 | + <ows:DCP> | |
24 | + <ows:HTTP> | |
25 | + <ows:Get xlink:href="http://172.26.99.160:8840/API/Image/Capabilities"> | |
26 | + <ows:Constraint name="GetEncoding"> | |
27 | + <ows:AllowedValues> | |
28 | + <ows:Value>RESTful</ows:Value> | |
29 | + </ows:AllowedValues> | |
30 | + </ows:Constraint> | |
31 | + </ows:Get> | |
32 | + <!-- add KVP binding in 10.1 --> | |
33 | + <ows:Get xlink:href="http://172.26.99.160:8840/API/Image/TileMany?"> | |
34 | + <ows:Constraint name="GetEncoding"> | |
35 | + <ows:AllowedValues> | |
36 | + <ows:Value>KVP</ows:Value> | |
37 | + </ows:AllowedValues> | |
38 | + </ows:Constraint> | |
39 | + </ows:Get> | |
40 | + </ows:HTTP> | |
41 | + </ows:DCP> | |
42 | + </ows:Operation> | |
43 | + <ows:Operation name="GetTile"> | |
44 | + <ows:DCP> | |
45 | + <ows:HTTP> | |
46 | + <ows:Get xlink:href="http://172.26.99.160:8840/API/Image/TileMany"> | |
47 | + <ows:Constraint name="GetEncoding"> | |
48 | + <ows:AllowedValues> | |
49 | + <ows:Value>RESTful</ows:Value> | |
50 | + </ows:AllowedValues> | |
51 | + </ows:Constraint> | |
52 | + </ows:Get> | |
53 | + <ows:Get xlink:href="http://172.26.99.160:8840/API/Image/TileMany?"> | |
54 | + <ows:Constraint name="GetEncoding"> | |
55 | + <ows:AllowedValues> | |
56 | + <ows:Value>KVP</ows:Value> | |
57 | + </ows:AllowedValues> | |
58 | + </ows:Constraint> | |
59 | + </ows:Get> | |
60 | + </ows:HTTP> | |
61 | + </ows:DCP> | |
62 | + </ows:Operation> | |
63 | + </ows:OperationsMetadata> | |
64 | + <Contents> | |
65 | + <!-- Layer --> | |
66 | + <Layer> | |
67 | + <ows:Title>changde</ows:Title> | |
68 | + <ows:Identifier>changde</ows:Identifier> | |
69 | + <ows:BoundingBox crs="urn:ogc:def:crs:EPSG::4490"> | |
70 | + <ows:LowerCorner>111.604613312 28.9170588759</ows:LowerCorner> | |
71 | + <ows:UpperCorner>111.751508603 29.079435995</ows:UpperCorner> | |
72 | + </ows:BoundingBox> | |
73 | + <ows:WGS84BoundingBox crs="urn:ogc:def:crs:OGC:2:84"> | |
74 | + <ows:LowerCorner>111.604613312 28.9170588759</ows:LowerCorner> | |
75 | + <ows:UpperCorner>111.751508603 29.079435995</ows:UpperCorner> | |
76 | + </ows:WGS84BoundingBox> | |
77 | + <Style isDefault="true"> | |
78 | + <ows:Title>Default Style</ows:Title> | |
79 | + <ows:Identifier>default</ows:Identifier> | |
80 | + </Style> | |
81 | + <Format>image/png</Format> | |
82 | + <TileMatrixSetLink> | |
83 | + <TileMatrixSet>default028mm</TileMatrixSet> | |
84 | + </TileMatrixSetLink> | |
85 | + <TileMatrixSetLink> | |
86 | + <TileMatrixSet>nativeTileMatrixSet</TileMatrixSet> | |
87 | + </TileMatrixSetLink> | |
88 | + <ResourceURL format="image/png" resourceType="tile" template="http://172.26.99.160:8840/API/Image/TileMany/{TileMatrix}/{TileRow}/{TileCol}?format=image/png"/> | |
89 | + </Layer> | |
90 | + <!-- TileMatrixSet --> | |
91 | + <TileMatrixSet> | |
92 | + <ows:Title>Default TileMatrix using 0.28mm</ows:Title> | |
93 | + <ows:Abstract>The tile matrix set that has scale values calculated based on the dpi defined by OGC specification (dpi assumes 0.28mm as the physical distance of a pixel).</ows:Abstract> | |
94 | + <ows:Identifier>default028mm</ows:Identifier> | |
95 | + <ows:SupportedCRS>urn:ogc:def:crs:EPSG::4490</ows:SupportedCRS> | |
96 | + <TileMatrix> | |
97 | + <ows:Identifier>0</ows:Identifier> | |
98 | + <ScaleDenominator>5.584552725961496E8</ScaleDenominator> | |
99 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
100 | + <TileWidth>256</TileWidth> | |
101 | + <TileHeight>256</TileHeight> | |
102 | + <MatrixWidth>1</MatrixWidth> | |
103 | + <MatrixHeight>1</MatrixHeight> | |
104 | + </TileMatrix> | |
105 | + <TileMatrix> | |
106 | + <ows:Identifier>1</ows:Identifier> | |
107 | + <ScaleDenominator>2.792276362980748E8</ScaleDenominator> | |
108 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
109 | + <TileWidth>256</TileWidth> | |
110 | + <TileHeight>256</TileHeight> | |
111 | + <MatrixWidth>1</MatrixWidth> | |
112 | + <MatrixHeight>1</MatrixHeight> | |
113 | + </TileMatrix> | |
114 | + <TileMatrix> | |
115 | + <ows:Identifier>2</ows:Identifier> | |
116 | + <ScaleDenominator>1.396138181490374E8</ScaleDenominator> | |
117 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
118 | + <TileWidth>256</TileWidth> | |
119 | + <TileHeight>256</TileHeight> | |
120 | + <MatrixWidth>1</MatrixWidth> | |
121 | + <MatrixHeight>1</MatrixHeight> | |
122 | + </TileMatrix> | |
123 | + <TileMatrix> | |
124 | + <ows:Identifier>3</ows:Identifier> | |
125 | + <ScaleDenominator>6.98069090745187E7</ScaleDenominator> | |
126 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
127 | + <TileWidth>256</TileWidth> | |
128 | + <TileHeight>256</TileHeight> | |
129 | + <MatrixWidth>1</MatrixWidth> | |
130 | + <MatrixHeight>1</MatrixHeight> | |
131 | + </TileMatrix> | |
132 | + <TileMatrix> | |
133 | + <ows:Identifier>4</ows:Identifier> | |
134 | + <ScaleDenominator>3.490345453725935E7</ScaleDenominator> | |
135 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
136 | + <TileWidth>256</TileWidth> | |
137 | + <TileHeight>256</TileHeight> | |
138 | + <MatrixWidth>1</MatrixWidth> | |
139 | + <MatrixHeight>1</MatrixHeight> | |
140 | + </TileMatrix> | |
141 | + <TileMatrix> | |
142 | + <ows:Identifier>5</ows:Identifier> | |
143 | + <ScaleDenominator>1.7451727268629674E7</ScaleDenominator> | |
144 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
145 | + <TileWidth>256</TileWidth> | |
146 | + <TileHeight>256</TileHeight> | |
147 | + <MatrixWidth>1</MatrixWidth> | |
148 | + <MatrixHeight>1</MatrixHeight> | |
149 | + </TileMatrix> | |
150 | + <TileMatrix> | |
151 | + <ows:Identifier>6</ows:Identifier> | |
152 | + <ScaleDenominator>8725863.634314837</ScaleDenominator> | |
153 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
154 | + <TileWidth>256</TileWidth> | |
155 | + <TileHeight>256</TileHeight> | |
156 | + <MatrixWidth>1</MatrixWidth> | |
157 | + <MatrixHeight>1</MatrixHeight> | |
158 | + </TileMatrix> | |
159 | + <TileMatrix> | |
160 | + <ows:Identifier>7</ows:Identifier> | |
161 | + <ScaleDenominator>4362931.8171574185</ScaleDenominator> | |
162 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
163 | + <TileWidth>256</TileWidth> | |
164 | + <TileHeight>256</TileHeight> | |
165 | + <MatrixWidth>1</MatrixWidth> | |
166 | + <MatrixHeight>1</MatrixHeight> | |
167 | + </TileMatrix> | |
168 | + <TileMatrix> | |
169 | + <ows:Identifier>8</ows:Identifier> | |
170 | + <ScaleDenominator>2181465.9085787092</ScaleDenominator> | |
171 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
172 | + <TileWidth>256</TileWidth> | |
173 | + <TileHeight>256</TileHeight> | |
174 | + <MatrixWidth>2</MatrixWidth> | |
175 | + <MatrixHeight>2</MatrixHeight> | |
176 | + </TileMatrix> | |
177 | + <TileMatrix> | |
178 | + <ows:Identifier>9</ows:Identifier> | |
179 | + <ScaleDenominator>1090732.9542893546</ScaleDenominator> | |
180 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
181 | + <TileWidth>256</TileWidth> | |
182 | + <TileHeight>256</TileHeight> | |
183 | + <MatrixWidth>3</MatrixWidth> | |
184 | + <MatrixHeight>3</MatrixHeight> | |
185 | + </TileMatrix> | |
186 | + <TileMatrix> | |
187 | + <ows:Identifier>10</ows:Identifier> | |
188 | + <ScaleDenominator>545366.4771446773</ScaleDenominator> | |
189 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
190 | + <TileWidth>256</TileWidth> | |
191 | + <TileHeight>256</TileHeight> | |
192 | + <MatrixWidth>6</MatrixWidth> | |
193 | + <MatrixHeight>6</MatrixHeight> | |
194 | + </TileMatrix> | |
195 | + <TileMatrix> | |
196 | + <ows:Identifier>11</ows:Identifier> | |
197 | + <ScaleDenominator>272683.23857233865</ScaleDenominator> | |
198 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
199 | + <TileWidth>256</TileWidth> | |
200 | + <TileHeight>256</TileHeight> | |
201 | + <MatrixWidth>11</MatrixWidth> | |
202 | + <MatrixHeight>11</MatrixHeight> | |
203 | + </TileMatrix> | |
204 | + <TileMatrix> | |
205 | + <ows:Identifier>12</ows:Identifier> | |
206 | + <ScaleDenominator>136341.61928616933</ScaleDenominator> | |
207 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
208 | + <TileWidth>256</TileWidth> | |
209 | + <TileHeight>256</TileHeight> | |
210 | + <MatrixWidth>21</MatrixWidth> | |
211 | + <MatrixHeight>20</MatrixHeight> | |
212 | + </TileMatrix> | |
213 | + <TileMatrix> | |
214 | + <ows:Identifier>13</ows:Identifier> | |
215 | + <ScaleDenominator>68170.80964308466</ScaleDenominator> | |
216 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
217 | + <TileWidth>256</TileWidth> | |
218 | + <TileHeight>256</TileHeight> | |
219 | + <MatrixWidth>42</MatrixWidth> | |
220 | + <MatrixHeight>40</MatrixHeight> | |
221 | + </TileMatrix> | |
222 | + <TileMatrix> | |
223 | + <ows:Identifier>14</ows:Identifier> | |
224 | + <ScaleDenominator>34085.40482154233</ScaleDenominator> | |
225 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
226 | + <TileWidth>256</TileWidth> | |
227 | + <TileHeight>256</TileHeight> | |
228 | + <MatrixWidth>83</MatrixWidth> | |
229 | + <MatrixHeight>80</MatrixHeight> | |
230 | + </TileMatrix> | |
231 | + <TileMatrix> | |
232 | + <ows:Identifier>15</ows:Identifier> | |
233 | + <ScaleDenominator>17042.702410771166</ScaleDenominator> | |
234 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
235 | + <TileWidth>256</TileWidth> | |
236 | + <TileHeight>256</TileHeight> | |
237 | + <MatrixWidth>166</MatrixWidth> | |
238 | + <MatrixHeight>158</MatrixHeight> | |
239 | + </TileMatrix> | |
240 | + <TileMatrix> | |
241 | + <ows:Identifier>16</ows:Identifier> | |
242 | + <ScaleDenominator>8521.351205385583</ScaleDenominator> | |
243 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
244 | + <TileWidth>256</TileWidth> | |
245 | + <TileHeight>256</TileHeight> | |
246 | + <MatrixWidth>331</MatrixWidth> | |
247 | + <MatrixHeight>314</MatrixHeight> | |
248 | + </TileMatrix> | |
249 | + <TileMatrix> | |
250 | + <ows:Identifier>17</ows:Identifier> | |
251 | + <ScaleDenominator>4260.6756026927915</ScaleDenominator> | |
252 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
253 | + <TileWidth>256</TileWidth> | |
254 | + <TileHeight>256</TileHeight> | |
255 | + <MatrixWidth>661</MatrixWidth> | |
256 | + <MatrixHeight>627</MatrixHeight> | |
257 | + </TileMatrix> | |
258 | + <TileMatrix> | |
259 | + <ows:Identifier>18</ows:Identifier> | |
260 | + <ScaleDenominator>2130.3378013463957</ScaleDenominator> | |
261 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
262 | + <TileWidth>256</TileWidth> | |
263 | + <TileHeight>256</TileHeight> | |
264 | + <MatrixWidth>1321</MatrixWidth> | |
265 | + <MatrixHeight>1254</MatrixHeight> | |
266 | + </TileMatrix> | |
267 | + <TileMatrix> | |
268 | + <ows:Identifier>19</ows:Identifier> | |
269 | + <ScaleDenominator>1065.1689006731979</ScaleDenominator> | |
270 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
271 | + <TileWidth>256</TileWidth> | |
272 | + <TileHeight>256</TileHeight> | |
273 | + <MatrixWidth>2642</MatrixWidth> | |
274 | + <MatrixHeight>2508</MatrixHeight> | |
275 | + </TileMatrix> | |
276 | + <TileMatrix> | |
277 | + <ows:Identifier>20</ows:Identifier> | |
278 | + <ScaleDenominator>532.5844503365989</ScaleDenominator> | |
279 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
280 | + <TileWidth>256</TileWidth> | |
281 | + <TileHeight>256</TileHeight> | |
282 | + <MatrixWidth>5283</MatrixWidth> | |
283 | + <MatrixHeight>5014</MatrixHeight> | |
284 | + </TileMatrix> | |
285 | + </TileMatrixSet> | |
286 | + <TileMatrixSet> | |
287 | + <ows:Title>Native TiledMapService TileMatrixSet</ows:Title> | |
288 | + <ows:Abstract>the tile matrix set that has scale values calculated based on the dpi defined by ArcGIS Server tiled map service. The current tile dpi is 96</ows:Abstract> | |
289 | + <ows:Identifier>nativeTileMatrixSet</ows:Identifier> | |
290 | + <ows:SupportedCRS>urn:ogc:def:crs:EPSG::4490</ows:SupportedCRS> | |
291 | + <TileMatrix> | |
292 | + <ows:Identifier>0</ows:Identifier> | |
293 | + <ScaleDenominator>5.909951861175001E8</ScaleDenominator> | |
294 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
295 | + <TileWidth>256</TileWidth> | |
296 | + <TileHeight>256</TileHeight> | |
297 | + <MatrixWidth>1</MatrixWidth> | |
298 | + <MatrixHeight>1</MatrixHeight> | |
299 | + </TileMatrix> | |
300 | + <TileMatrix> | |
301 | + <ows:Identifier>1</ows:Identifier> | |
302 | + <ScaleDenominator>2.9549759305875003E8</ScaleDenominator> | |
303 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
304 | + <TileWidth>256</TileWidth> | |
305 | + <TileHeight>256</TileHeight> | |
306 | + <MatrixWidth>1</MatrixWidth> | |
307 | + <MatrixHeight>1</MatrixHeight> | |
308 | + </TileMatrix> | |
309 | + <TileMatrix> | |
310 | + <ows:Identifier>2</ows:Identifier> | |
311 | + <ScaleDenominator>1.4774879652937502E8</ScaleDenominator> | |
312 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
313 | + <TileWidth>256</TileWidth> | |
314 | + <TileHeight>256</TileHeight> | |
315 | + <MatrixWidth>1</MatrixWidth> | |
316 | + <MatrixHeight>1</MatrixHeight> | |
317 | + </TileMatrix> | |
318 | + <TileMatrix> | |
319 | + <ows:Identifier>3</ows:Identifier> | |
320 | + <ScaleDenominator>7.387439826468751E7</ScaleDenominator> | |
321 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
322 | + <TileWidth>256</TileWidth> | |
323 | + <TileHeight>256</TileHeight> | |
324 | + <MatrixWidth>1</MatrixWidth> | |
325 | + <MatrixHeight>1</MatrixHeight> | |
326 | + </TileMatrix> | |
327 | + <TileMatrix> | |
328 | + <ows:Identifier>4</ows:Identifier> | |
329 | + <ScaleDenominator>3.6937199132343754E7</ScaleDenominator> | |
330 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
331 | + <TileWidth>256</TileWidth> | |
332 | + <TileHeight>256</TileHeight> | |
333 | + <MatrixWidth>1</MatrixWidth> | |
334 | + <MatrixHeight>1</MatrixHeight> | |
335 | + </TileMatrix> | |
336 | + <TileMatrix> | |
337 | + <ows:Identifier>5</ows:Identifier> | |
338 | + <ScaleDenominator>1.8468599566171877E7</ScaleDenominator> | |
339 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
340 | + <TileWidth>256</TileWidth> | |
341 | + <TileHeight>256</TileHeight> | |
342 | + <MatrixWidth>1</MatrixWidth> | |
343 | + <MatrixHeight>1</MatrixHeight> | |
344 | + </TileMatrix> | |
345 | + <TileMatrix> | |
346 | + <ows:Identifier>6</ows:Identifier> | |
347 | + <ScaleDenominator>9234299.783085939</ScaleDenominator> | |
348 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
349 | + <TileWidth>256</TileWidth> | |
350 | + <TileHeight>256</TileHeight> | |
351 | + <MatrixWidth>1</MatrixWidth> | |
352 | + <MatrixHeight>1</MatrixHeight> | |
353 | + </TileMatrix> | |
354 | + <TileMatrix> | |
355 | + <ows:Identifier>7</ows:Identifier> | |
356 | + <ScaleDenominator>4617149.891542969</ScaleDenominator> | |
357 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
358 | + <TileWidth>256</TileWidth> | |
359 | + <TileHeight>256</TileHeight> | |
360 | + <MatrixWidth>1</MatrixWidth> | |
361 | + <MatrixHeight>1</MatrixHeight> | |
362 | + </TileMatrix> | |
363 | + <TileMatrix> | |
364 | + <ows:Identifier>8</ows:Identifier> | |
365 | + <ScaleDenominator>2308574.9457714846</ScaleDenominator> | |
366 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
367 | + <TileWidth>256</TileWidth> | |
368 | + <TileHeight>256</TileHeight> | |
369 | + <MatrixWidth>2</MatrixWidth> | |
370 | + <MatrixHeight>2</MatrixHeight> | |
371 | + </TileMatrix> | |
372 | + <TileMatrix> | |
373 | + <ows:Identifier>9</ows:Identifier> | |
374 | + <ScaleDenominator>1154287.4728857423</ScaleDenominator> | |
375 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
376 | + <TileWidth>256</TileWidth> | |
377 | + <TileHeight>256</TileHeight> | |
378 | + <MatrixWidth>3</MatrixWidth> | |
379 | + <MatrixHeight>3</MatrixHeight> | |
380 | + </TileMatrix> | |
381 | + <TileMatrix> | |
382 | + <ows:Identifier>10</ows:Identifier> | |
383 | + <ScaleDenominator>577143.7364428712</ScaleDenominator> | |
384 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
385 | + <TileWidth>256</TileWidth> | |
386 | + <TileHeight>256</TileHeight> | |
387 | + <MatrixWidth>6</MatrixWidth> | |
388 | + <MatrixHeight>6</MatrixHeight> | |
389 | + </TileMatrix> | |
390 | + <TileMatrix> | |
391 | + <ows:Identifier>11</ows:Identifier> | |
392 | + <ScaleDenominator>288571.8682214356</ScaleDenominator> | |
393 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
394 | + <TileWidth>256</TileWidth> | |
395 | + <TileHeight>256</TileHeight> | |
396 | + <MatrixWidth>11</MatrixWidth> | |
397 | + <MatrixHeight>11</MatrixHeight> | |
398 | + </TileMatrix> | |
399 | + <TileMatrix> | |
400 | + <ows:Identifier>12</ows:Identifier> | |
401 | + <ScaleDenominator>144285.9341107178</ScaleDenominator> | |
402 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
403 | + <TileWidth>256</TileWidth> | |
404 | + <TileHeight>256</TileHeight> | |
405 | + <MatrixWidth>21</MatrixWidth> | |
406 | + <MatrixHeight>20</MatrixHeight> | |
407 | + </TileMatrix> | |
408 | + <TileMatrix> | |
409 | + <ows:Identifier>13</ows:Identifier> | |
410 | + <ScaleDenominator>72142.9670553589</ScaleDenominator> | |
411 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
412 | + <TileWidth>256</TileWidth> | |
413 | + <TileHeight>256</TileHeight> | |
414 | + <MatrixWidth>42</MatrixWidth> | |
415 | + <MatrixHeight>40</MatrixHeight> | |
416 | + </TileMatrix> | |
417 | + <TileMatrix> | |
418 | + <ows:Identifier>14</ows:Identifier> | |
419 | + <ScaleDenominator>36071.48352767945</ScaleDenominator> | |
420 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
421 | + <TileWidth>256</TileWidth> | |
422 | + <TileHeight>256</TileHeight> | |
423 | + <MatrixWidth>83</MatrixWidth> | |
424 | + <MatrixHeight>80</MatrixHeight> | |
425 | + </TileMatrix> | |
426 | + <TileMatrix> | |
427 | + <ows:Identifier>15</ows:Identifier> | |
428 | + <ScaleDenominator>18035.741763839724</ScaleDenominator> | |
429 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
430 | + <TileWidth>256</TileWidth> | |
431 | + <TileHeight>256</TileHeight> | |
432 | + <MatrixWidth>166</MatrixWidth> | |
433 | + <MatrixHeight>158</MatrixHeight> | |
434 | + </TileMatrix> | |
435 | + <TileMatrix> | |
436 | + <ows:Identifier>16</ows:Identifier> | |
437 | + <ScaleDenominator>9017.870881919862</ScaleDenominator> | |
438 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
439 | + <TileWidth>256</TileWidth> | |
440 | + <TileHeight>256</TileHeight> | |
441 | + <MatrixWidth>331</MatrixWidth> | |
442 | + <MatrixHeight>314</MatrixHeight> | |
443 | + </TileMatrix> | |
444 | + <TileMatrix> | |
445 | + <ows:Identifier>17</ows:Identifier> | |
446 | + <ScaleDenominator>4508.935440959931</ScaleDenominator> | |
447 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
448 | + <TileWidth>256</TileWidth> | |
449 | + <TileHeight>256</TileHeight> | |
450 | + <MatrixWidth>661</MatrixWidth> | |
451 | + <MatrixHeight>627</MatrixHeight> | |
452 | + </TileMatrix> | |
453 | + <TileMatrix> | |
454 | + <ows:Identifier>18</ows:Identifier> | |
455 | + <ScaleDenominator>2254.4677204799655</ScaleDenominator> | |
456 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
457 | + <TileWidth>256</TileWidth> | |
458 | + <TileHeight>256</TileHeight> | |
459 | + <MatrixWidth>1321</MatrixWidth> | |
460 | + <MatrixHeight>1254</MatrixHeight> | |
461 | + </TileMatrix> | |
462 | + <TileMatrix> | |
463 | + <ows:Identifier>19</ows:Identifier> | |
464 | + <ScaleDenominator>1127.2338602399827</ScaleDenominator> | |
465 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
466 | + <TileWidth>256</TileWidth> | |
467 | + <TileHeight>256</TileHeight> | |
468 | + <MatrixWidth>2642</MatrixWidth> | |
469 | + <MatrixHeight>2508</MatrixHeight> | |
470 | + </TileMatrix> | |
471 | + <TileMatrix> | |
472 | + <ows:Identifier>20</ows:Identifier> | |
473 | + <ScaleDenominator>563.6169301199914</ScaleDenominator> | |
474 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | |
475 | + <TileWidth>256</TileWidth> | |
476 | + <TileHeight>256</TileHeight> | |
477 | + <MatrixWidth>5283</MatrixWidth> | |
478 | + <MatrixHeight>5014</MatrixHeight> | |
479 | + </TileMatrix> | |
480 | + </TileMatrixSet> | |
481 | + </Contents> | |
482 | + <ServiceMetadataURL xlink:href="http://172.26.99.160:8840/API/Image/Capabilities"/> | |
483 | + </Capabilities>''' | |
484 | + | |
485 | + r = Response(response=x, status=200, mimetype="application/xml") | |
486 | + r.headers["Content-Type"] = "text/xml; charset=utf-8" | |
487 | + return r | |
488 | + | |
489 | + | |
490 | + | |
491 | + | |
492 | +api_doc={ | |
493 | +"tags":["影像接口"], | |
494 | +"parameters":[ | |
495 | + | |
496 | +], | |
497 | +"responses":{ | |
498 | + 200:{ | |
499 | + "schema":{ | |
500 | + "properties":{ | |
501 | + } | |
502 | + } | |
503 | + } | |
504 | + } | |
505 | +} | ... | ... |
app/modules/image/data_list.py
0 → 100644
1 | +# coding=utf-8 | |
2 | +#author: 4N | |
3 | +#createtime: 2021/7/19 | |
4 | +#email: nheweijun@sina.com | |
5 | + | |
6 | +from osgeo.ogr import * | |
7 | +from osgeo import gdal,ogr,osr | |
8 | +from osgeo.gdal import Dataset,Band | |
9 | +from app.util.component.ApiTemplate import ApiTemplate | |
10 | + | |
11 | + | |
12 | +from thrift.transport import TSocket | |
13 | +from thrift.transport import TTransport | |
14 | +from thrift.protocol import TBinaryProtocol | |
15 | +import numpy | |
16 | +import cv2 | |
17 | +import json | |
18 | +from .models import Image | |
19 | +from app.modules.image.ImageDataService import ImageDataService | |
20 | +from app.models import db | |
21 | +import uuid | |
22 | +import os | |
23 | +import time | |
24 | +class Api(ApiTemplate): | |
25 | + | |
26 | + api_name = "影像数据列表" | |
27 | + | |
28 | + def process(self): | |
29 | + | |
30 | + | |
31 | + # 返回结果 | |
32 | + res = {} | |
33 | + | |
34 | + try: | |
35 | + data_server = self.para.get("data_server") | |
36 | + | |
37 | + path = self.para.get("path") | |
38 | + host = data_server.split(":")[0] | |
39 | + port = int(data_server.split(":")[1]) | |
40 | + | |
41 | + # if data_server.__eq__("localhost"): | |
42 | + # pass | |
43 | + # else: | |
44 | + t1 =time.time() | |
45 | + transport = TSocket.TSocket(host, port) | |
46 | + transport = TTransport.TBufferedTransport(transport) | |
47 | + protocol = TBinaryProtocol.TBinaryProtocol(transport) | |
48 | + | |
49 | + client = ImageDataService.Client(protocol) | |
50 | + transport.open() | |
51 | + print(time.time()-t1) | |
52 | + info= json.loads(client.getImageList(path)) | |
53 | + res["data"] = info | |
54 | + res["result"] = True | |
55 | + | |
56 | + except Exception as e: | |
57 | + raise e | |
58 | + | |
59 | + return res | |
60 | + | |
61 | + api_doc = { | |
62 | + "tags": ["影像接口"], | |
63 | + "parameters": [ | |
64 | + {"name": "data_server", | |
65 | + "in": "formData", | |
66 | + "type": "string", | |
67 | + "description": "data_server"}, | |
68 | + {"name": "path", | |
69 | + "in": "formData", | |
70 | + "type": "string", | |
71 | + "description": "path"} | |
72 | + ], | |
73 | + "responses": { | |
74 | + 200: { | |
75 | + "schema": { | |
76 | + "properties": { | |
77 | + } | |
78 | + } | |
79 | + } | |
80 | + } | |
81 | + } | |
82 | + | ... | ... |
app/modules/image/image_list.py
0 → 100644
1 | +# coding=utf-8 | |
2 | +#author: 4N | |
3 | +#createtime: 2021/7/19 | |
4 | +#email: nheweijun@sina.com | |
5 | + | |
6 | + | |
7 | +from app.util.component.ApiTemplate import ApiTemplate | |
8 | +from app.util.component.ModelVisitor import ModelVisitor | |
9 | + | |
10 | +from app.modules.image.models import Image | |
11 | +class Api(ApiTemplate): | |
12 | + | |
13 | + api_name = "影像数据List" | |
14 | + | |
15 | + def process(self): | |
16 | + | |
17 | + # 返回结果 | |
18 | + res = {} | |
19 | + try: | |
20 | + images = Image.query.all() | |
21 | + res["data"] = ModelVisitor.objects_to_jsonarray(images) | |
22 | + res["result"] = True | |
23 | + except Exception as e: | |
24 | + raise e | |
25 | + | |
26 | + return res | |
27 | + | |
28 | + | |
29 | + api_doc = { | |
30 | + "tags": ["影像接口"], | |
31 | + "parameters": [ | |
32 | + ], | |
33 | + "responses": { | |
34 | + 200: { | |
35 | + "schema": { | |
36 | + "properties": { | |
37 | + } | |
38 | + } | |
39 | + } | |
40 | + } | |
41 | + } | |
42 | + | |
43 | + | ... | ... |
app/modules/image/image_register.py
0 → 100644
1 | +# coding=utf-8 | |
2 | +#author: 4N | |
3 | +#createtime: 2021/7/19 | |
4 | +#email: nheweijun@sina.com | |
5 | + | |
6 | +from osgeo.ogr import * | |
7 | +from osgeo import gdal,ogr,osr | |
8 | +from osgeo.gdal import Dataset,Band | |
9 | +from app.util.component.ApiTemplate import ApiTemplate | |
10 | + | |
11 | + | |
12 | +from thrift.transport import TSocket | |
13 | +from thrift.transport import TTransport | |
14 | +from thrift.protocol import TBinaryProtocol | |
15 | +import numpy | |
16 | +import cv2 | |
17 | +import json | |
18 | +from .models import Image | |
19 | +from app.modules.image.ImageDataService import ImageDataService | |
20 | +from app.models import db | |
21 | +import uuid | |
22 | +import os | |
23 | +class Api(ApiTemplate): | |
24 | + | |
25 | + api_name = "注册影像数据" | |
26 | + | |
27 | + def process(self): | |
28 | + | |
29 | + | |
30 | + # 返回结果 | |
31 | + res = {} | |
32 | + | |
33 | + try: | |
34 | + data_server = self.para.get("data_server") | |
35 | + | |
36 | + path = self.para.get("path") | |
37 | + host = data_server.split(":")[0] | |
38 | + port = int(data_server.split(":")[1]) | |
39 | + | |
40 | + if host.__eq__("localhost"): | |
41 | + pass | |
42 | + else: | |
43 | + transport = TSocket.TSocket(host, port) | |
44 | + transport = TTransport.TBufferedTransport(transport) | |
45 | + protocol = TBinaryProtocol.TBinaryProtocol(transport) | |
46 | + | |
47 | + client = ImageDataService.Client(protocol) | |
48 | + | |
49 | + transport.open() | |
50 | + | |
51 | + info= json.loads(client.getInfo(path)) | |
52 | + | |
53 | + # 影像空间范围 | |
54 | + if not info["origin_extent"]: | |
55 | + if not self.para.get("extent"): | |
56 | + res["result"] = False | |
57 | + res["msg"] = "数据解析范围失败,请手动输入范围" | |
58 | + return res | |
59 | + else : | |
60 | + origin_extent=json.loads(self.para.get("extent")) | |
61 | + else: | |
62 | + origin_extent = info["origin_extent"] | |
63 | + | |
64 | + transport.close() | |
65 | + guid = uuid.uuid1().__str__() | |
66 | + image = Image(guid= guid, | |
67 | + overview=info["overview_count"], | |
68 | + raster_x_size=info["xy_size"][0], | |
69 | + raster_y_size=info["xy_size"][1], | |
70 | + name=os.path.basename(path), | |
71 | + alias=self.para.get("alias"), | |
72 | + extent=origin_extent, | |
73 | + null_value=info["null_value"] | |
74 | + | |
75 | + ) | |
76 | + db.session.add(image) | |
77 | + db.session.commit() | |
78 | + res["data"] = guid | |
79 | + res["result"] = True | |
80 | + except Exception as e: | |
81 | + raise e | |
82 | + | |
83 | + return res | |
84 | + | |
85 | + | |
86 | + api_doc = { | |
87 | + "tags": ["影像接口"], | |
88 | + "parameters": [ | |
89 | + {"name": "data_server", | |
90 | + "in": "formData", | |
91 | + "type": "string", | |
92 | + "description": "data_server"}, | |
93 | + {"name": "path", | |
94 | + "in": "formData", | |
95 | + "type": "string", | |
96 | + "description": "path"} | |
97 | + ], | |
98 | + "responses": { | |
99 | + 200: { | |
100 | + "schema": { | |
101 | + "properties": { | |
102 | + } | |
103 | + } | |
104 | + } | |
105 | + } | |
106 | + } | |
107 | + | |
108 | + | ... | ... |
app/modules/image/image_server_list.py
0 → 100644
1 | +# coding=utf-8 | |
2 | +#author: 4N | |
3 | +#createtime: 2021/7/19 | |
4 | +#email: nheweijun@sina.com | |
5 | + | |
6 | +from app.util.component.ApiTemplate import ApiTemplate | |
7 | +from app import GLOBAL_DIC | |
8 | +from kazoo.client import KazooClient | |
9 | +import configure | |
10 | +class Api(ApiTemplate): | |
11 | + | |
12 | + api_name = "获取数据服务器列表" | |
13 | + | |
14 | + def process(self): | |
15 | + | |
16 | + # 返回结果 | |
17 | + res = {} | |
18 | + try: | |
19 | + zoo = GLOBAL_DIC.get("zookeeper") | |
20 | + if zoo is None: | |
21 | + zoo :KazooClient = KazooClient(hosts=configure.zookeeper, timeout=100) | |
22 | + zoo.start() | |
23 | + GLOBAL_DIC["zookeeper"] = zoo | |
24 | + else : | |
25 | + if not zoo.connected: | |
26 | + zoo.start() | |
27 | + res["data"] = zoo.get_children("/rpc") | |
28 | + res["result"] = True | |
29 | + except Exception as e: | |
30 | + raise e | |
31 | + return res | |
32 | + | |
33 | + api_doc = { | |
34 | + "tags": ["影像接口"], | |
35 | + "parameters": [ | |
36 | + ], | |
37 | + "responses": { | |
38 | + 200: { | |
39 | + "schema": { | |
40 | + "properties": { | |
41 | + } | |
42 | + } | |
43 | + } | |
44 | + } | |
45 | + } | |
46 | + | |
47 | +if __name__ == '__main__': | |
48 | + zoo: KazooClient = KazooClient(hosts="172.26.99.168:2181", timeout=100) | |
49 | + zoo.start() | |
50 | + print(zoo.get_children("/rpc")) | |
51 | + zoo.stop() | |
52 | + zoo.close() | |
\ No newline at end of file | ... | ... |
app/modules/image/image_service_register.py
0 → 100644
1 | +# coding=utf-8 | |
2 | +#author: 4N | |
3 | +#createtime: 2021/7/19 | |
4 | +#email: nheweijun@sina.com | |
5 | + | |
6 | +from osgeo.ogr import * | |
7 | +from osgeo import gdal,ogr,osr | |
8 | +from osgeo.gdal import Dataset,Band | |
9 | +from app.util.component.ApiTemplate import ApiTemplate | |
10 | +import uuid | |
11 | + | |
12 | + | |
13 | +class Api(ApiTemplate): | |
14 | + | |
15 | + api_name = "注册影像服务" | |
16 | + | |
17 | + def process(self): | |
18 | + | |
19 | + | |
20 | + | |
21 | + # 返回结果 | |
22 | + res = {} | |
23 | + | |
24 | + try: | |
25 | + guids = self.para.get("guids").split(",") | |
26 | + name = self.para.get("name") | |
27 | + service_guid = uuid.uuid1().__str__() | |
28 | + | |
29 | + | |
30 | + except Exception as e: | |
31 | + raise e | |
32 | + | |
33 | + return res | |
34 | + | |
35 | + api_doc = { | |
36 | + "tags": ["影像接口"], | |
37 | + "parameters": [ | |
38 | + {"name": "guids", | |
39 | + "in": "formData", | |
40 | + "type": "string", | |
41 | + "description": "影像guids,以英文逗号相隔"} | |
42 | + ], | |
43 | + "responses": { | |
44 | + 200: { | |
45 | + "schema": { | |
46 | + "properties": { | |
47 | + } | |
48 | + } | |
49 | + } | |
50 | + } | |
51 | + } | |
\ No newline at end of file | ... | ... |
app/modules/image/image_tile.py
0 → 100644
1 | +# coding=utf-8 | |
2 | +#author: 4N | |
3 | +#createtime: 2021/3/24 | |
4 | +#email: nheweijun@sina.com | |
5 | + | |
6 | +from app.util import * | |
7 | +import traceback | |
8 | +from osgeo import gdal | |
9 | +from osgeo.gdal import * | |
10 | +from numpy import ndarray | |
11 | +import numpy | |
12 | +from flask import Response | |
13 | +import io | |
14 | +import os | |
15 | +from PIL import Image | |
16 | +from app.util.slice_scheme import slice_scheme | |
17 | +import time | |
18 | +import cv2 | |
19 | +from .image_tile_center import create_by_opencv | |
20 | +def api(level,row,col): | |
21 | + result = {} | |
22 | + parameter: dict = get_parameter() | |
23 | + | |
24 | + | |
25 | + try: | |
26 | + | |
27 | + bands = [1, 2, 3] | |
28 | + | |
29 | + image_list=[ | |
30 | + {"origin_extent":[111.604613312, 29.0171545762, 111.653989358, 29.0531633509], | |
31 | + "path" : os.path.join(os.path.dirname(__file__), "data", "江南_03.tif"), | |
32 | + "xysize":[47646,28201], | |
33 | + "max_level":7}, | |
34 | + | |
35 | + {"origin_extent": [111.705644552, 28.9864085959, 111.737115887, 29.079435995], | |
36 | + "path": os.path.join(os.path.dirname(__file__), "data", "江南_01.tif"), | |
37 | + "xysize":[30116, 73219], | |
38 | + "max_level":8}, | |
39 | + | |
40 | + {"origin_extent": [111.639350712, 28.9170588759, 111.751508603, 29.032941696], | |
41 | + "path": os.path.join(os.path.dirname(__file__), "data", "江南_02.tif"), | |
42 | + "xysize": [108488, 90777], | |
43 | + "max_level": 9} | |
44 | + ] | |
45 | + | |
46 | + | |
47 | + | |
48 | + slice_para = {'rows': 256.0, 'cols': 256.0, 'x': -180.0, 'y': 90.0, 'dpi': 96.0, | |
49 | + '0': {'scale': 590995186.11750006, 'resolution': 1.4062500000000004}, | |
50 | + '1': {'scale': 295497593.05875003, 'resolution': 0.7031250000000002}, | |
51 | + '2': {'scale': 147748796.52937502, 'resolution': 0.3515625000000001}, | |
52 | + '3': {'scale': 73874398.26468751, 'resolution': 0.17578125000000006}, | |
53 | + '4': {'scale': 36937199.132343754, 'resolution': 0.08789062500000003}, | |
54 | + '5': {'scale': 18468599.566171877, 'resolution': 0.043945312500000014}, | |
55 | + '6': {'scale': 9234299.783085939, 'resolution': 0.021972656250000007}, | |
56 | + '7': {'scale': 4617149.891542969, 'resolution': 0.010986328125000003}, | |
57 | + '8': {'scale': 2308574.9457714846, 'resolution': 0.005493164062500002}, | |
58 | + '9': {'scale': 1154287.4728857423, 'resolution': 0.002746582031250001}, | |
59 | + '10': {'scale': 577143.7364428712, 'resolution': 0.0013732910156250004}, | |
60 | + '11': {'scale': 288571.8682214356, 'resolution': 0.0006866455078125002}, | |
61 | + '12': {'scale': 144285.9341107178, 'resolution': 0.0003433227539062501}, | |
62 | + '13': {'scale': 72142.9670553589, 'resolution': 0.00017166137695312505}, | |
63 | + '14': {'scale': 36071.48352767945, 'resolution': 8.583068847656253e-05}, | |
64 | + '15': {'scale': 18035.741763839724, 'resolution': 4.2915344238281264e-05}, | |
65 | + '16': {'scale': 9017.870881919862, 'resolution': 2.1457672119140632e-05}, | |
66 | + '17': {'scale': 4508.935440959931, 'resolution': 1.0728836059570316e-05}, | |
67 | + '18': {'scale': 2254.4677204799655, 'resolution': 5.364418029785158e-06}, | |
68 | + '19': {'scale': 1127.2338602399827, 'resolution': 2.682209014892579e-06}, | |
69 | + '20': {'scale': 563.6169301199914, 'resolution': 1.3411045074462895e-06}} | |
70 | + | |
71 | + if parameter.get("leaflet"): | |
72 | + slice_para = {'rows': 256.0, 'cols': 256.0, 'x': -180.0, 'y': 90.0, 'dpi': 96.0, | |
73 | + '0': {'scale': 295497593.05875003, 'resolution': 0.7031250000000002}, | |
74 | + '1': {'scale': 147748796.52937502, 'resolution': 0.3515625000000001}, | |
75 | + '2': {'scale': 73874398.26468751, 'resolution': 0.17578125000000006}, | |
76 | + '3': {'scale': 36937199.132343754, 'resolution': 0.08789062500000003}, | |
77 | + '4': {'scale': 18468599.566171877, 'resolution': 0.043945312500000014}, | |
78 | + '5': {'scale': 9234299.783085939, 'resolution': 0.021972656250000007}, | |
79 | + '6': {'scale': 4617149.891542969, 'resolution': 0.010986328125000003}, | |
80 | + '7': {'scale': 2308574.9457714846, 'resolution': 0.005493164062500002}, | |
81 | + '8': {'scale': 1154287.4728857423, 'resolution': 0.002746582031250001}, | |
82 | + '9': {'scale': 577143.7364428712, 'resolution': 0.0013732910156250004}, | |
83 | + '10': {'scale': 288571.8682214356, 'resolution': 0.0006866455078125002}, | |
84 | + '11': {'scale': 144285.9341107178, 'resolution': 0.0003433227539062501}, | |
85 | + '12': {'scale': 72142.9670553589, 'resolution': 0.00017166137695312505}, | |
86 | + '13': {'scale': 36071.48352767945, 'resolution': 8.583068847656253e-05}, | |
87 | + '14': {'scale': 18035.741763839724, 'resolution': 4.2915344238281264e-05}, | |
88 | + '15': {'scale': 9017.870881919862, 'resolution': 2.1457672119140632e-05}, | |
89 | + '16': {'scale': 4508.935440959931, 'resolution': 1.0728836059570316e-05}, | |
90 | + '17': {'scale': 2254.4677204799655, 'resolution': 5.364418029785158e-06}, | |
91 | + '18': {'scale': 1127.2338602399827, 'resolution': 2.682209014892579e-06}, | |
92 | + '19': {'scale': 563.6169301199914, 'resolution': 1.3411045074462895e-06}} | |
93 | + | |
94 | + # 转换参数 | |
95 | + new_para ={} | |
96 | + for key in parameter.keys(): | |
97 | + new_para[key.lower()] = parameter[key] | |
98 | + parameter=new_para | |
99 | + if parameter.get("tilematrix"): | |
100 | + if parameter.get("tilematrix").__contains__(":"): | |
101 | + level = int(parameter.get("tilematrix").split(":")[-1]) | |
102 | + else: | |
103 | + level = int(parameter.get("tilematrix")) | |
104 | + if parameter.get("tilerow"): | |
105 | + row = int(parameter.get("tilerow")) | |
106 | + if parameter.get("tilecol"): | |
107 | + col = int(parameter.get("tilecol")) | |
108 | + | |
109 | + image_type = parameter.get("format") if parameter.get("format") else "image/png" | |
110 | + | |
111 | + quality = int(parameter.get("quality")) if parameter.get("quality") else 30 | |
112 | + | |
113 | + extent = slice_scheme.get_polygon(slice_para, level, row, col) | |
114 | + | |
115 | + | |
116 | + pixel_array = numpy.zeros((256, 256,3), dtype=int) | |
117 | + ceng = 2 | |
118 | + for band in bands: | |
119 | + | |
120 | + empty = numpy.zeros((256, 256), dtype=int)+65536 | |
121 | + | |
122 | + for im in image_list: | |
123 | + | |
124 | + # 自决定金字塔等级 | |
125 | + xysize = im.get("xysize") | |
126 | + origin_extent = im.get("origin_extent") | |
127 | + max_level = im.get("max_level") | |
128 | + | |
129 | + # 超出空间范围 | |
130 | + if extent[2]<origin_extent[0] or extent[0]>origin_extent[2] or extent[1]>origin_extent[3] or extent[3]<origin_extent[1]: | |
131 | + pass | |
132 | + # 空间范围相交 | |
133 | + else: | |
134 | + image_level = determine_level(xysize, origin_extent, extent, max_level) | |
135 | + path = im.get("path") | |
136 | + | |
137 | + # print(image_level) | |
138 | + | |
139 | + image: Dataset = gdal.Open(path, 0) | |
140 | + | |
141 | + band_data: Band = image.GetRasterBand(band) | |
142 | + | |
143 | + if image_level == -1: | |
144 | + overview = band_data | |
145 | + else: | |
146 | + try: | |
147 | + overview: Band = band_data.GetOverview(image_level) | |
148 | + except: | |
149 | + raise Exception("该影像不存在该级别的金字塔数据!") | |
150 | + ox = overview.XSize | |
151 | + oy = overview.YSize | |
152 | + | |
153 | + # 网格大小 | |
154 | + grid_x = (origin_extent[2] - origin_extent[0]) / (ox * 1.0) | |
155 | + grid_y = (origin_extent[3] - origin_extent[1]) / (oy * 1.0) | |
156 | + | |
157 | + # 完全在影像范围内 | |
158 | + if extent[0]>origin_extent[0] and extent[1]>origin_extent[1] and extent[2]<origin_extent[2] and extent[3]<origin_extent[3]: | |
159 | + | |
160 | + t1 = time.time() | |
161 | + # 网格偏移量 | |
162 | + | |
163 | + off_x = math.floor((extent[0]-origin_extent[0])/grid_x) | |
164 | + off_y = math.floor((origin_extent[3] -extent[3]) / grid_y) | |
165 | + | |
166 | + # 截取后网格个数 | |
167 | + x_g = math.ceil((extent[2]-extent[0])/grid_x) | |
168 | + | |
169 | + y_g= math.ceil((extent[3]-extent[1])/grid_y) | |
170 | + t2 = time.time() | |
171 | + # print(t2-t1) | |
172 | + overview_raster:ndarray = overview.ReadAsArray(off_x,off_y,x_g,y_g,256,256) | |
173 | + t3 = time.time() | |
174 | + # print(t3-t2) | |
175 | + | |
176 | + mask1 = numpy.zeros((256, 256), dtype=int) | |
177 | + mask2 = numpy.zeros((256, 256), dtype=int) | |
178 | + mask1[overview_raster == 65536] = 1 | |
179 | + mask2[overview_raster != 65536] = 1 | |
180 | + | |
181 | + empty = empty*mask1+overview_raster*mask2 | |
182 | + t4 = time.time() | |
183 | + # print(t4-t3) | |
184 | + # 部分相交 | |
185 | + else: | |
186 | + | |
187 | + inter_extent = [0,0,0,0] | |
188 | + inter_extent[0] = origin_extent[0] if origin_extent[0]>extent[0] else extent[0] | |
189 | + inter_extent[1] = origin_extent[1] if origin_extent[1] > extent[1] else extent[1] | |
190 | + inter_extent[2] = origin_extent[2] if origin_extent[2] < extent[2] else extent[2] | |
191 | + inter_extent[3] = origin_extent[3] if origin_extent[3] < extent[3] else extent[3] | |
192 | + | |
193 | + # 网格偏移量 | |
194 | + off_x = math.floor((inter_extent[0]-origin_extent[0])/grid_x) | |
195 | + off_y = math.floor((origin_extent[3] -inter_extent[3]) / grid_y) | |
196 | + | |
197 | + # 截取后网格个数 | |
198 | + x_g = math.floor((inter_extent[2]-inter_extent[0])/grid_x) | |
199 | + y_g= math.floor((inter_extent[3]-inter_extent[1])/grid_y) | |
200 | + | |
201 | + # 相对于出图的偏移量 | |
202 | + | |
203 | + #出图的网格大小 | |
204 | + out_grid_x = (extent[2] - extent[0]) / (256 * 1.0) | |
205 | + out_grid_y = (extent[3] - extent[1]) / (256 * 1.0) | |
206 | + | |
207 | + out_off_x = int(math.ceil((inter_extent[0]-extent[0])/out_grid_x)) | |
208 | + out_off_y = int(math.ceil((extent[3] -inter_extent[3]) / out_grid_y)) | |
209 | + | |
210 | + out_x_g = int(math.floor((inter_extent[2]-inter_extent[0])/out_grid_x)) | |
211 | + out_y_g= int(math.floor((inter_extent[3]-inter_extent[1])/out_grid_y)) | |
212 | + | |
213 | + # 相交部分在出图的哪个位置 | |
214 | + | |
215 | + overview_raster:ndarray = overview.ReadAsArray(off_x,off_y,x_g,y_g,out_x_g,out_y_g) | |
216 | + | |
217 | + mask1 = numpy.zeros((out_y_g,out_x_g), dtype=int) | |
218 | + | |
219 | + mask2 = numpy.zeros((out_y_g,out_x_g), dtype=int) | |
220 | + | |
221 | + mask1[overview_raster == 65536] = 1 | |
222 | + mask2[overview_raster != 65536] = 1 | |
223 | + | |
224 | + empty[out_off_y:out_off_y + out_y_g, out_off_x:out_off_x + out_x_g] = empty[out_off_y:out_off_y + out_y_g,out_off_x:out_off_x + out_x_g]*mask1 + overview_raster*mask2 | |
225 | + | |
226 | + # 关闭句柄 | |
227 | + del image | |
228 | + | |
229 | + | |
230 | + | |
231 | + # opencv 的颜色排列为GBR | |
232 | + pixel_array[:,:,ceng]=empty | |
233 | + ceng-=1 | |
234 | + | |
235 | + t5 = time.time() | |
236 | + # print(t4-t3) | |
237 | + | |
238 | + #将图片生成在内存中,然后直接返回response | |
239 | + im_data = create_by_opencv(image_type, pixel_array, quality) | |
240 | + | |
241 | + return Response(im_data, mimetype=image_type.lower()) | |
242 | + | |
243 | + except Exception as e: | |
244 | + print(traceback.format_exc()) | |
245 | + result["state"] = -1 | |
246 | + result["message"] = e.__str__() | |
247 | + return result | |
248 | + | |
249 | + | |
250 | + | |
251 | + | |
252 | + | |
253 | +def determine_level(xysize,origin_extent,extent,max_level): | |
254 | + x = xysize[0] | |
255 | + y = xysize[1] | |
256 | + | |
257 | + level = -1 | |
258 | + pixel = x*y * (((extent[2]-extent[0])*(extent[3]-extent[1]))/((origin_extent[2]-origin_extent[0])*(origin_extent[3]-origin_extent[1]))) | |
259 | + | |
260 | + while pixel>100000 and level<max_level-1: | |
261 | + level+=1 | |
262 | + x=x/2 | |
263 | + y=y/2 | |
264 | + pixel = x * y * (((extent[2] - extent[0]) * (extent[3] - extent[1])) / ( | |
265 | + (origin_extent[2] - origin_extent[0]) * (origin_extent[3] - origin_extent[1]))) | |
266 | + return level | |
267 | + | |
268 | + | |
269 | + | |
270 | +def create_by_pil(image_type,pixel_list,quality): | |
271 | + buffer = io.BytesIO() | |
272 | + if image_type.__eq__("image/jpeg") or image_type.__eq__("image/jpg"): | |
273 | + im_type = "jpeg" | |
274 | + data = list(zip(pixel_list[0][0], pixel_list[1][0], pixel_list[2][0])) | |
275 | + image_out = Image.new("RGB", (256, 256)) | |
276 | + | |
277 | + else: | |
278 | + im_type = "png" | |
279 | + four = [0 if x.__eq__(65536) else 255 for x in pixel_list[0][0]] | |
280 | + data = list(zip(pixel_list[0][0], pixel_list[1][0], pixel_list[2][0], four)) | |
281 | + image_out = Image.new("RGBA", (256, 256)) | |
282 | + t6 = time.time() | |
283 | + | |
284 | + image_out.putdata(data) | |
285 | + image_out.save(buffer, im_type, quality=quality, optimize=True) | |
286 | + im_data = buffer.getvalue() | |
287 | + buffer.close() | |
288 | + t7 = time.time() | |
289 | + return im_data | |
290 | + | |
291 | + | |
292 | +api_doc={ | |
293 | +"tags":["影像接口"], | |
294 | +"parameters":[ | |
295 | + | |
296 | +], | |
297 | +"responses":{ | |
298 | + 200:{ | |
299 | + "schema":{ | |
300 | + "properties":{ | |
301 | + } | |
302 | + } | |
303 | + } | |
304 | + } | |
305 | +} | |
306 | + | ... | ... |
app/modules/image/models/__init__.py
0 → 100644
1 | +# coding=utf-8 | |
2 | +#author: 4N | |
3 | +#createtime: 2021/6/11 | |
4 | +#email: nheweijun@sina.com | |
5 | + | |
6 | + | |
7 | +from sqlalchemy import Column, Integer, String, ForeignKey, Text, DateTime, Time | |
8 | +from app.models import db | |
9 | + | |
10 | +class Image(db.Model): | |
11 | + ''' | |
12 | + 影像元数据 | |
13 | + ''' | |
14 | + __tablename__ = 'dmdms_image' | |
15 | + guid = Column(String(256), primary_key=True) | |
16 | + name = Column(String) | |
17 | + alias=Column(String) | |
18 | + raster_y_size=Column(Integer) | |
19 | + raster_x_size = Column(Integer) | |
20 | + overview = Column(Integer) | |
21 | + extent = Column(String) | |
22 | + null_value = Column(Integer) | |
23 | + available = Column(Integer)#影像是否可用,不可用可能在创建金字塔中 | |
24 | + bands = Column(Integer) | |
25 | + path=Column(String) | |
26 | + host=Column(String) | |
27 | + port=Column(Integer) | |
28 | + | |
29 | + | |
30 | + | |
31 | +dmdms_image_rel = db.Table('dmdms_image_rel', | |
32 | + Column('guid', String, primary_key=True), | |
33 | + Column('image_guid',String, ForeignKey('dmdms_image.guid')), | |
34 | + Column('priority',Integer), | |
35 | + Column('service_guid', String, ForeignKey('dmdms_image_service.guid')) | |
36 | + ) | |
37 | + | |
38 | +class ImageService(db.Model): | |
39 | + ''' | |
40 | + 影像服务 | |
41 | + ''' | |
42 | + __tablename__ = 'dmdms_image_service' | |
43 | + guid = Column(String(256), primary_key=True) | |
44 | + name=Column(String(256)) | |
45 | + alias = Column(String(256)) | |
46 | + state= Column(Integer) | |
47 | + create_time = Column(DateTime) | |
48 | + update_time = Column(DateTime) | |
49 | + description = Column(Text) | |
50 | + images = db.relationship('Image', | |
51 | + secondary=dmdms_image_rel, | |
52 | + backref='image_services', | |
53 | + lazy='dynamic' | |
54 | + ) | ... | ... |
... | ... | @@ -8,7 +8,7 @@ from app.util import BlueprintApi |
8 | 8 | from flasgger import swag_from |
9 | 9 | from . import index |
10 | 10 | from . import release |
11 | -from . import get_app_name | |
11 | +from . import app_name | |
12 | 12 | class Template(BlueprintApi): |
13 | 13 | |
14 | 14 | bp = Blueprint("Index", __name__, url_prefix="/") |
... | ... | @@ -33,9 +33,9 @@ class Template(BlueprintApi): |
33 | 33 | |
34 | 34 | @staticmethod |
35 | 35 | @bp.route('/GetAppName', methods=['GET']) |
36 | - @swag_from(get_app_name.Api.api_doc) | |
36 | + @swag_from(app_name.Api.api_doc) | |
37 | 37 | def get_app_name(): |
38 | 38 | """ |
39 | 39 | GetAppName接口 |
40 | 40 | """ |
41 | - return get_app_name.Api().result | |
\ No newline at end of file | ||
41 | + return app_name.Api().result | |
\ No newline at end of file | ... | ... |
... | ... | @@ -120,6 +120,8 @@ class Api(ApiTemplate): |
120 | 120 | except Exception as e: |
121 | 121 | try: |
122 | 122 | sys_session.query(Task).filter_by(guid=task_guid).update({"state": -1,"update_time":datetime.datetime.now()}) |
123 | + sys_session.query(Table).filter_by(guid=table.guid).update( | |
124 | + {"is_vacuate": 0, "update_time": datetime.datetime.now()}) | |
123 | 125 | |
124 | 126 | message = "{} {}".format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), e.__str__()) |
125 | 127 | task_process_guid = uuid.uuid1().__str__() |
... | ... | @@ -133,7 +135,8 @@ class Api(ApiTemplate): |
133 | 135 | except Exception as ee: |
134 | 136 | print(traceback.format_exc()) |
135 | 137 | finally: |
136 | - vacuate_process.end() | |
138 | + if vacuate_process: | |
139 | + vacuate_process.end() | |
137 | 140 | if sys_session: |
138 | 141 | sys_session.close() |
139 | 142 | if pg_session: | ... | ... |
... | ... | @@ -3,7 +3,9 @@ |
3 | 3 | # 程序部署ip:host |
4 | 4 | deploy_ip_host = "172.26.99.160:8840" |
5 | 5 | # 系统数据库 |
6 | -SQLALCHEMY_DATABASE_URI = "postgresql://postgres:postgres@localhost:5433/dmap_dms_test" | |
6 | + | |
7 | +# SQLALCHEMY_DATABASE_URI = "postgresql://postgres:postgres@172.26.40.254:5433/dmap_dms_test" | |
8 | +SQLALCHEMY_DATABASE_URI = "postgresql://postgres:chinadci@172.26.99.160:5432/dmap_dms_test" | |
7 | 9 | |
8 | 10 | |
9 | 11 | # 部署模式cluster,standalone |
... | ... | @@ -11,6 +13,8 @@ deployment_mode = "cluster" |
11 | 13 | # 部署模式味cluster时有用,master,slave |
12 | 14 | application_name = "master" |
13 | 15 | |
16 | +zookeeper = "172.26.99.168:2181" | |
17 | + | |
14 | 18 | # 固定配置不需要修改 |
15 | 19 | swagger_configure = {"title": "DMapManager"} |
16 | 20 | entry_data_thread = 3 | ... | ... |
请
注册
或
登录
后发表评论