正在显示
20 个修改的文件
包含
1083 行增加
和
800 行删除
@@ -16,8 +16,8 @@ else: | @@ -16,8 +16,8 @@ else: | ||
16 | from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient | 16 | from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient |
17 | from thrift.protocol.TBinaryProtocol import TBinaryProtocol | 17 | from thrift.protocol.TBinaryProtocol import TBinaryProtocol |
18 | 18 | ||
19 | -from . import ImageDataService | ||
20 | -from .ttypes import * | 19 | +from app.modules.image.ImageDataService import ImageDataService |
20 | +from app.modules.image.ImageDataService.ttypes import * | ||
21 | 21 | ||
22 | if len(sys.argv) <= 1 or sys.argv[1] == '--help': | 22 | if len(sys.argv) <= 1 or sys.argv[1] == '--help': |
23 | print('') | 23 | print('') |
@@ -466,7 +466,7 @@ class getData_result(object): | @@ -466,7 +466,7 @@ class getData_result(object): | ||
466 | break | 466 | break |
467 | if fid == 0: | 467 | if fid == 0: |
468 | if ftype == TType.STRING: | 468 | if ftype == TType.STRING: |
469 | - self.success = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() | 469 | + self.success = iprot.readBinary() |
470 | else: | 470 | else: |
471 | iprot.skip(ftype) | 471 | iprot.skip(ftype) |
472 | else: | 472 | else: |
@@ -481,7 +481,7 @@ class getData_result(object): | @@ -481,7 +481,7 @@ class getData_result(object): | ||
481 | oprot.writeStructBegin('getData_result') | 481 | oprot.writeStructBegin('getData_result') |
482 | if self.success is not None: | 482 | if self.success is not None: |
483 | oprot.writeFieldBegin('success', TType.STRING, 0) | 483 | oprot.writeFieldBegin('success', TType.STRING, 0) |
484 | - oprot.writeString(self.success.encode('utf-8') if sys.version_info[0] == 2 else self.success) | 484 | + oprot.writeBinary(self.success) |
485 | oprot.writeFieldEnd() | 485 | oprot.writeFieldEnd() |
486 | oprot.writeFieldStop() | 486 | oprot.writeFieldStop() |
487 | oprot.writeStructEnd() | 487 | oprot.writeStructEnd() |
@@ -501,7 +501,7 @@ class getData_result(object): | @@ -501,7 +501,7 @@ class getData_result(object): | ||
501 | return not (self == other) | 501 | return not (self == other) |
502 | all_structs.append(getData_result) | 502 | all_structs.append(getData_result) |
503 | getData_result.thrift_spec = ( | 503 | getData_result.thrift_spec = ( |
504 | - (0, TType.STRING, 'success', 'UTF8', None, ), # 0 | 504 | + (0, TType.STRING, 'success', 'BINARY', None, ), # 0 |
505 | ) | 505 | ) |
506 | 506 | ||
507 | 507 |
@@ -9,8 +9,14 @@ from flask import Blueprint | @@ -9,8 +9,14 @@ from flask import Blueprint | ||
9 | from app.util import BlueprintApi | 9 | from app.util import BlueprintApi |
10 | from . import image_register | 10 | from . import image_register |
11 | from . import image_service_register | 11 | from . import image_service_register |
12 | +from . import image_service_list | ||
12 | from . import image_server_list | 13 | from . import image_server_list |
13 | from . import data_list | 14 | from . import data_list |
15 | +from . import capabilities | ||
16 | +from . import image_list | ||
17 | +from . import image_tile | ||
18 | + | ||
19 | + | ||
14 | class DataManager(BlueprintApi): | 20 | class DataManager(BlueprintApi): |
15 | 21 | ||
16 | bp = Blueprint("Image", __name__, url_prefix="/API/Image") | 22 | bp = Blueprint("Image", __name__, url_prefix="/API/Image") |
@@ -50,4 +56,49 @@ class DataManager(BlueprintApi): | @@ -50,4 +56,49 @@ class DataManager(BlueprintApi): | ||
50 | """ | 56 | """ |
51 | 数据列表 | 57 | 数据列表 |
52 | """ | 58 | """ |
53 | - return data_list.Api().result | ||
59 | + return data_list.Api().result | ||
60 | + | ||
61 | + @staticmethod | ||
62 | + @bp.route('/Capabilities', methods=['POST']) | ||
63 | + @swag_from(capabilities.Api.api_doc) | ||
64 | + def capabilities(): | ||
65 | + """ | ||
66 | + 能力文档 | ||
67 | + """ | ||
68 | + return capabilities.Api().result | ||
69 | + | ||
70 | + @staticmethod | ||
71 | + @bp.route('/ImageList', methods=['POST']) | ||
72 | + @swag_from(image_list.Api.api_doc) | ||
73 | + def image_list(): | ||
74 | + """ | ||
75 | + 影像列表 | ||
76 | + """ | ||
77 | + return image_list.Api().result | ||
78 | + | ||
79 | + @staticmethod | ||
80 | + @bp.route('/ImageServiceList', methods=['POST']) | ||
81 | + @swag_from(image_service_list.Api.api_doc) | ||
82 | + def image_service_list(): | ||
83 | + """ | ||
84 | + 影像服务列表 | ||
85 | + """ | ||
86 | + return image_service_list.Api().result | ||
87 | + | ||
88 | + @staticmethod | ||
89 | + @bp.route('/Tile/<guid>/<l>/<y>/<z>', methods=['GET']) | ||
90 | + @swag_from(image_tile.Api.api_doc) | ||
91 | + def api_image_tile(guid,l,y,z): | ||
92 | + """ | ||
93 | + 切片服务 | ||
94 | + """ | ||
95 | + return image_tile.Api(guid,l,y,z).result | ||
96 | + | ||
97 | + @staticmethod | ||
98 | + @bp.route('/Tile', methods=['GET','POST']) | ||
99 | + @swag_from(image_tile.Api.api_doc) | ||
100 | + def api_image_tile_kv(): | ||
101 | + """ | ||
102 | + 切片服务 | ||
103 | + """ | ||
104 | + return image_tile.Api("1",1,1,1).result |
@@ -4,502 +4,507 @@ | @@ -4,502 +4,507 @@ | ||
4 | #email: nheweijun@sina.com | 4 | #email: nheweijun@sina.com |
5 | 5 | ||
6 | 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 | 7 | from flask import Response |
11 | -def api(): | 8 | +from app.util.component.ApiTemplate import ApiTemplate |
9 | +class Api(ApiTemplate): | ||
12 | 10 | ||
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>''' | 11 | + api_name = "影像数据列表" |
484 | 12 | ||
485 | - r = Response(response=x, status=200, mimetype="application/xml") | ||
486 | - r.headers["Content-Type"] = "text/xml; charset=utf-8" | ||
487 | - return r | 13 | + def process(self): |
488 | 14 | ||
15 | + 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"> | ||
16 | + <!-- Service Identification --> | ||
17 | + <ows:ServiceIdentification> | ||
18 | + <ows:Title>localimage</ows:Title> | ||
19 | + <ows:ServiceType>OGC WMTS</ows:ServiceType> | ||
20 | + <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion> | ||
21 | + </ows:ServiceIdentification> | ||
22 | + <!-- Operations Metadata --> | ||
23 | + <ows:OperationsMetadata> | ||
24 | + <ows:Operation name="GetCapabilities"> | ||
25 | + <ows:DCP> | ||
26 | + <ows:HTTP> | ||
27 | + <ows:Get xlink:href="http://172.26.99.160:8840/API/Image/Capabilities"> | ||
28 | + <ows:Constraint name="GetEncoding"> | ||
29 | + <ows:AllowedValues> | ||
30 | + <ows:Value>RESTful</ows:Value> | ||
31 | + </ows:AllowedValues> | ||
32 | + </ows:Constraint> | ||
33 | + </ows:Get> | ||
34 | + <!-- add KVP binding in 10.1 --> | ||
35 | + <ows:Get xlink:href="http://172.26.99.160:8840/API/Image/TileMany?"> | ||
36 | + <ows:Constraint name="GetEncoding"> | ||
37 | + <ows:AllowedValues> | ||
38 | + <ows:Value>KVP</ows:Value> | ||
39 | + </ows:AllowedValues> | ||
40 | + </ows:Constraint> | ||
41 | + </ows:Get> | ||
42 | + </ows:HTTP> | ||
43 | + </ows:DCP> | ||
44 | + </ows:Operation> | ||
45 | + <ows:Operation name="GetTile"> | ||
46 | + <ows:DCP> | ||
47 | + <ows:HTTP> | ||
48 | + <ows:Get xlink:href="http://172.26.99.160:8840/API/Image/TileMany"> | ||
49 | + <ows:Constraint name="GetEncoding"> | ||
50 | + <ows:AllowedValues> | ||
51 | + <ows:Value>RESTful</ows:Value> | ||
52 | + </ows:AllowedValues> | ||
53 | + </ows:Constraint> | ||
54 | + </ows:Get> | ||
55 | + <ows:Get xlink:href="http://172.26.99.160:8840/API/Image/TileMany?"> | ||
56 | + <ows:Constraint name="GetEncoding"> | ||
57 | + <ows:AllowedValues> | ||
58 | + <ows:Value>KVP</ows:Value> | ||
59 | + </ows:AllowedValues> | ||
60 | + </ows:Constraint> | ||
61 | + </ows:Get> | ||
62 | + </ows:HTTP> | ||
63 | + </ows:DCP> | ||
64 | + </ows:Operation> | ||
65 | + </ows:OperationsMetadata> | ||
66 | + <Contents> | ||
67 | + <!-- Layer --> | ||
68 | + <Layer> | ||
69 | + <ows:Title>changde</ows:Title> | ||
70 | + <ows:Identifier>changde</ows:Identifier> | ||
71 | + <ows:BoundingBox crs="urn:ogc:def:crs:EPSG::4490"> | ||
72 | + <ows:LowerCorner>111.604613312 28.9170588759</ows:LowerCorner> | ||
73 | + <ows:UpperCorner>111.751508603 29.079435995</ows:UpperCorner> | ||
74 | + </ows:BoundingBox> | ||
75 | + <ows:WGS84BoundingBox crs="urn:ogc:def:crs:OGC:2:84"> | ||
76 | + <ows:LowerCorner>111.604613312 28.9170588759</ows:LowerCorner> | ||
77 | + <ows:UpperCorner>111.751508603 29.079435995</ows:UpperCorner> | ||
78 | + </ows:WGS84BoundingBox> | ||
79 | + <Style isDefault="true"> | ||
80 | + <ows:Title>Default Style</ows:Title> | ||
81 | + <ows:Identifier>default</ows:Identifier> | ||
82 | + </Style> | ||
83 | + <Format>image/png</Format> | ||
84 | + <TileMatrixSetLink> | ||
85 | + <TileMatrixSet>default028mm</TileMatrixSet> | ||
86 | + </TileMatrixSetLink> | ||
87 | + <TileMatrixSetLink> | ||
88 | + <TileMatrixSet>nativeTileMatrixSet</TileMatrixSet> | ||
89 | + </TileMatrixSetLink> | ||
90 | + <ResourceURL format="image/png" resourceType="tile" template="http://172.26.99.160:8840/API/Image/TileMany/{TileMatrix}/{TileRow}/{TileCol}?format=image/png"/> | ||
91 | + </Layer> | ||
92 | + <!-- TileMatrixSet --> | ||
93 | + <TileMatrixSet> | ||
94 | + <ows:Title>Default TileMatrix using 0.28mm</ows:Title> | ||
95 | + <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> | ||
96 | + <ows:Identifier>default028mm</ows:Identifier> | ||
97 | + <ows:SupportedCRS>urn:ogc:def:crs:EPSG::4490</ows:SupportedCRS> | ||
98 | + <TileMatrix> | ||
99 | + <ows:Identifier>0</ows:Identifier> | ||
100 | + <ScaleDenominator>5.584552725961496E8</ScaleDenominator> | ||
101 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
102 | + <TileWidth>256</TileWidth> | ||
103 | + <TileHeight>256</TileHeight> | ||
104 | + <MatrixWidth>1</MatrixWidth> | ||
105 | + <MatrixHeight>1</MatrixHeight> | ||
106 | + </TileMatrix> | ||
107 | + <TileMatrix> | ||
108 | + <ows:Identifier>1</ows:Identifier> | ||
109 | + <ScaleDenominator>2.792276362980748E8</ScaleDenominator> | ||
110 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
111 | + <TileWidth>256</TileWidth> | ||
112 | + <TileHeight>256</TileHeight> | ||
113 | + <MatrixWidth>1</MatrixWidth> | ||
114 | + <MatrixHeight>1</MatrixHeight> | ||
115 | + </TileMatrix> | ||
116 | + <TileMatrix> | ||
117 | + <ows:Identifier>2</ows:Identifier> | ||
118 | + <ScaleDenominator>1.396138181490374E8</ScaleDenominator> | ||
119 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
120 | + <TileWidth>256</TileWidth> | ||
121 | + <TileHeight>256</TileHeight> | ||
122 | + <MatrixWidth>1</MatrixWidth> | ||
123 | + <MatrixHeight>1</MatrixHeight> | ||
124 | + </TileMatrix> | ||
125 | + <TileMatrix> | ||
126 | + <ows:Identifier>3</ows:Identifier> | ||
127 | + <ScaleDenominator>6.98069090745187E7</ScaleDenominator> | ||
128 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
129 | + <TileWidth>256</TileWidth> | ||
130 | + <TileHeight>256</TileHeight> | ||
131 | + <MatrixWidth>1</MatrixWidth> | ||
132 | + <MatrixHeight>1</MatrixHeight> | ||
133 | + </TileMatrix> | ||
134 | + <TileMatrix> | ||
135 | + <ows:Identifier>4</ows:Identifier> | ||
136 | + <ScaleDenominator>3.490345453725935E7</ScaleDenominator> | ||
137 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
138 | + <TileWidth>256</TileWidth> | ||
139 | + <TileHeight>256</TileHeight> | ||
140 | + <MatrixWidth>1</MatrixWidth> | ||
141 | + <MatrixHeight>1</MatrixHeight> | ||
142 | + </TileMatrix> | ||
143 | + <TileMatrix> | ||
144 | + <ows:Identifier>5</ows:Identifier> | ||
145 | + <ScaleDenominator>1.7451727268629674E7</ScaleDenominator> | ||
146 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
147 | + <TileWidth>256</TileWidth> | ||
148 | + <TileHeight>256</TileHeight> | ||
149 | + <MatrixWidth>1</MatrixWidth> | ||
150 | + <MatrixHeight>1</MatrixHeight> | ||
151 | + </TileMatrix> | ||
152 | + <TileMatrix> | ||
153 | + <ows:Identifier>6</ows:Identifier> | ||
154 | + <ScaleDenominator>8725863.634314837</ScaleDenominator> | ||
155 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
156 | + <TileWidth>256</TileWidth> | ||
157 | + <TileHeight>256</TileHeight> | ||
158 | + <MatrixWidth>1</MatrixWidth> | ||
159 | + <MatrixHeight>1</MatrixHeight> | ||
160 | + </TileMatrix> | ||
161 | + <TileMatrix> | ||
162 | + <ows:Identifier>7</ows:Identifier> | ||
163 | + <ScaleDenominator>4362931.8171574185</ScaleDenominator> | ||
164 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
165 | + <TileWidth>256</TileWidth> | ||
166 | + <TileHeight>256</TileHeight> | ||
167 | + <MatrixWidth>1</MatrixWidth> | ||
168 | + <MatrixHeight>1</MatrixHeight> | ||
169 | + </TileMatrix> | ||
170 | + <TileMatrix> | ||
171 | + <ows:Identifier>8</ows:Identifier> | ||
172 | + <ScaleDenominator>2181465.9085787092</ScaleDenominator> | ||
173 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
174 | + <TileWidth>256</TileWidth> | ||
175 | + <TileHeight>256</TileHeight> | ||
176 | + <MatrixWidth>2</MatrixWidth> | ||
177 | + <MatrixHeight>2</MatrixHeight> | ||
178 | + </TileMatrix> | ||
179 | + <TileMatrix> | ||
180 | + <ows:Identifier>9</ows:Identifier> | ||
181 | + <ScaleDenominator>1090732.9542893546</ScaleDenominator> | ||
182 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
183 | + <TileWidth>256</TileWidth> | ||
184 | + <TileHeight>256</TileHeight> | ||
185 | + <MatrixWidth>3</MatrixWidth> | ||
186 | + <MatrixHeight>3</MatrixHeight> | ||
187 | + </TileMatrix> | ||
188 | + <TileMatrix> | ||
189 | + <ows:Identifier>10</ows:Identifier> | ||
190 | + <ScaleDenominator>545366.4771446773</ScaleDenominator> | ||
191 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
192 | + <TileWidth>256</TileWidth> | ||
193 | + <TileHeight>256</TileHeight> | ||
194 | + <MatrixWidth>6</MatrixWidth> | ||
195 | + <MatrixHeight>6</MatrixHeight> | ||
196 | + </TileMatrix> | ||
197 | + <TileMatrix> | ||
198 | + <ows:Identifier>11</ows:Identifier> | ||
199 | + <ScaleDenominator>272683.23857233865</ScaleDenominator> | ||
200 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
201 | + <TileWidth>256</TileWidth> | ||
202 | + <TileHeight>256</TileHeight> | ||
203 | + <MatrixWidth>11</MatrixWidth> | ||
204 | + <MatrixHeight>11</MatrixHeight> | ||
205 | + </TileMatrix> | ||
206 | + <TileMatrix> | ||
207 | + <ows:Identifier>12</ows:Identifier> | ||
208 | + <ScaleDenominator>136341.61928616933</ScaleDenominator> | ||
209 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
210 | + <TileWidth>256</TileWidth> | ||
211 | + <TileHeight>256</TileHeight> | ||
212 | + <MatrixWidth>21</MatrixWidth> | ||
213 | + <MatrixHeight>20</MatrixHeight> | ||
214 | + </TileMatrix> | ||
215 | + <TileMatrix> | ||
216 | + <ows:Identifier>13</ows:Identifier> | ||
217 | + <ScaleDenominator>68170.80964308466</ScaleDenominator> | ||
218 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
219 | + <TileWidth>256</TileWidth> | ||
220 | + <TileHeight>256</TileHeight> | ||
221 | + <MatrixWidth>42</MatrixWidth> | ||
222 | + <MatrixHeight>40</MatrixHeight> | ||
223 | + </TileMatrix> | ||
224 | + <TileMatrix> | ||
225 | + <ows:Identifier>14</ows:Identifier> | ||
226 | + <ScaleDenominator>34085.40482154233</ScaleDenominator> | ||
227 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
228 | + <TileWidth>256</TileWidth> | ||
229 | + <TileHeight>256</TileHeight> | ||
230 | + <MatrixWidth>83</MatrixWidth> | ||
231 | + <MatrixHeight>80</MatrixHeight> | ||
232 | + </TileMatrix> | ||
233 | + <TileMatrix> | ||
234 | + <ows:Identifier>15</ows:Identifier> | ||
235 | + <ScaleDenominator>17042.702410771166</ScaleDenominator> | ||
236 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
237 | + <TileWidth>256</TileWidth> | ||
238 | + <TileHeight>256</TileHeight> | ||
239 | + <MatrixWidth>166</MatrixWidth> | ||
240 | + <MatrixHeight>158</MatrixHeight> | ||
241 | + </TileMatrix> | ||
242 | + <TileMatrix> | ||
243 | + <ows:Identifier>16</ows:Identifier> | ||
244 | + <ScaleDenominator>8521.351205385583</ScaleDenominator> | ||
245 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
246 | + <TileWidth>256</TileWidth> | ||
247 | + <TileHeight>256</TileHeight> | ||
248 | + <MatrixWidth>331</MatrixWidth> | ||
249 | + <MatrixHeight>314</MatrixHeight> | ||
250 | + </TileMatrix> | ||
251 | + <TileMatrix> | ||
252 | + <ows:Identifier>17</ows:Identifier> | ||
253 | + <ScaleDenominator>4260.6756026927915</ScaleDenominator> | ||
254 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
255 | + <TileWidth>256</TileWidth> | ||
256 | + <TileHeight>256</TileHeight> | ||
257 | + <MatrixWidth>661</MatrixWidth> | ||
258 | + <MatrixHeight>627</MatrixHeight> | ||
259 | + </TileMatrix> | ||
260 | + <TileMatrix> | ||
261 | + <ows:Identifier>18</ows:Identifier> | ||
262 | + <ScaleDenominator>2130.3378013463957</ScaleDenominator> | ||
263 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
264 | + <TileWidth>256</TileWidth> | ||
265 | + <TileHeight>256</TileHeight> | ||
266 | + <MatrixWidth>1321</MatrixWidth> | ||
267 | + <MatrixHeight>1254</MatrixHeight> | ||
268 | + </TileMatrix> | ||
269 | + <TileMatrix> | ||
270 | + <ows:Identifier>19</ows:Identifier> | ||
271 | + <ScaleDenominator>1065.1689006731979</ScaleDenominator> | ||
272 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
273 | + <TileWidth>256</TileWidth> | ||
274 | + <TileHeight>256</TileHeight> | ||
275 | + <MatrixWidth>2642</MatrixWidth> | ||
276 | + <MatrixHeight>2508</MatrixHeight> | ||
277 | + </TileMatrix> | ||
278 | + <TileMatrix> | ||
279 | + <ows:Identifier>20</ows:Identifier> | ||
280 | + <ScaleDenominator>532.5844503365989</ScaleDenominator> | ||
281 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
282 | + <TileWidth>256</TileWidth> | ||
283 | + <TileHeight>256</TileHeight> | ||
284 | + <MatrixWidth>5283</MatrixWidth> | ||
285 | + <MatrixHeight>5014</MatrixHeight> | ||
286 | + </TileMatrix> | ||
287 | + </TileMatrixSet> | ||
288 | + <TileMatrixSet> | ||
289 | + <ows:Title>Native TiledMapService TileMatrixSet</ows:Title> | ||
290 | + <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> | ||
291 | + <ows:Identifier>nativeTileMatrixSet</ows:Identifier> | ||
292 | + <ows:SupportedCRS>urn:ogc:def:crs:EPSG::4490</ows:SupportedCRS> | ||
293 | + <TileMatrix> | ||
294 | + <ows:Identifier>0</ows:Identifier> | ||
295 | + <ScaleDenominator>5.909951861175001E8</ScaleDenominator> | ||
296 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
297 | + <TileWidth>256</TileWidth> | ||
298 | + <TileHeight>256</TileHeight> | ||
299 | + <MatrixWidth>1</MatrixWidth> | ||
300 | + <MatrixHeight>1</MatrixHeight> | ||
301 | + </TileMatrix> | ||
302 | + <TileMatrix> | ||
303 | + <ows:Identifier>1</ows:Identifier> | ||
304 | + <ScaleDenominator>2.9549759305875003E8</ScaleDenominator> | ||
305 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
306 | + <TileWidth>256</TileWidth> | ||
307 | + <TileHeight>256</TileHeight> | ||
308 | + <MatrixWidth>1</MatrixWidth> | ||
309 | + <MatrixHeight>1</MatrixHeight> | ||
310 | + </TileMatrix> | ||
311 | + <TileMatrix> | ||
312 | + <ows:Identifier>2</ows:Identifier> | ||
313 | + <ScaleDenominator>1.4774879652937502E8</ScaleDenominator> | ||
314 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
315 | + <TileWidth>256</TileWidth> | ||
316 | + <TileHeight>256</TileHeight> | ||
317 | + <MatrixWidth>1</MatrixWidth> | ||
318 | + <MatrixHeight>1</MatrixHeight> | ||
319 | + </TileMatrix> | ||
320 | + <TileMatrix> | ||
321 | + <ows:Identifier>3</ows:Identifier> | ||
322 | + <ScaleDenominator>7.387439826468751E7</ScaleDenominator> | ||
323 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
324 | + <TileWidth>256</TileWidth> | ||
325 | + <TileHeight>256</TileHeight> | ||
326 | + <MatrixWidth>1</MatrixWidth> | ||
327 | + <MatrixHeight>1</MatrixHeight> | ||
328 | + </TileMatrix> | ||
329 | + <TileMatrix> | ||
330 | + <ows:Identifier>4</ows:Identifier> | ||
331 | + <ScaleDenominator>3.6937199132343754E7</ScaleDenominator> | ||
332 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
333 | + <TileWidth>256</TileWidth> | ||
334 | + <TileHeight>256</TileHeight> | ||
335 | + <MatrixWidth>1</MatrixWidth> | ||
336 | + <MatrixHeight>1</MatrixHeight> | ||
337 | + </TileMatrix> | ||
338 | + <TileMatrix> | ||
339 | + <ows:Identifier>5</ows:Identifier> | ||
340 | + <ScaleDenominator>1.8468599566171877E7</ScaleDenominator> | ||
341 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
342 | + <TileWidth>256</TileWidth> | ||
343 | + <TileHeight>256</TileHeight> | ||
344 | + <MatrixWidth>1</MatrixWidth> | ||
345 | + <MatrixHeight>1</MatrixHeight> | ||
346 | + </TileMatrix> | ||
347 | + <TileMatrix> | ||
348 | + <ows:Identifier>6</ows:Identifier> | ||
349 | + <ScaleDenominator>9234299.783085939</ScaleDenominator> | ||
350 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
351 | + <TileWidth>256</TileWidth> | ||
352 | + <TileHeight>256</TileHeight> | ||
353 | + <MatrixWidth>1</MatrixWidth> | ||
354 | + <MatrixHeight>1</MatrixHeight> | ||
355 | + </TileMatrix> | ||
356 | + <TileMatrix> | ||
357 | + <ows:Identifier>7</ows:Identifier> | ||
358 | + <ScaleDenominator>4617149.891542969</ScaleDenominator> | ||
359 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
360 | + <TileWidth>256</TileWidth> | ||
361 | + <TileHeight>256</TileHeight> | ||
362 | + <MatrixWidth>1</MatrixWidth> | ||
363 | + <MatrixHeight>1</MatrixHeight> | ||
364 | + </TileMatrix> | ||
365 | + <TileMatrix> | ||
366 | + <ows:Identifier>8</ows:Identifier> | ||
367 | + <ScaleDenominator>2308574.9457714846</ScaleDenominator> | ||
368 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
369 | + <TileWidth>256</TileWidth> | ||
370 | + <TileHeight>256</TileHeight> | ||
371 | + <MatrixWidth>2</MatrixWidth> | ||
372 | + <MatrixHeight>2</MatrixHeight> | ||
373 | + </TileMatrix> | ||
374 | + <TileMatrix> | ||
375 | + <ows:Identifier>9</ows:Identifier> | ||
376 | + <ScaleDenominator>1154287.4728857423</ScaleDenominator> | ||
377 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
378 | + <TileWidth>256</TileWidth> | ||
379 | + <TileHeight>256</TileHeight> | ||
380 | + <MatrixWidth>3</MatrixWidth> | ||
381 | + <MatrixHeight>3</MatrixHeight> | ||
382 | + </TileMatrix> | ||
383 | + <TileMatrix> | ||
384 | + <ows:Identifier>10</ows:Identifier> | ||
385 | + <ScaleDenominator>577143.7364428712</ScaleDenominator> | ||
386 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
387 | + <TileWidth>256</TileWidth> | ||
388 | + <TileHeight>256</TileHeight> | ||
389 | + <MatrixWidth>6</MatrixWidth> | ||
390 | + <MatrixHeight>6</MatrixHeight> | ||
391 | + </TileMatrix> | ||
392 | + <TileMatrix> | ||
393 | + <ows:Identifier>11</ows:Identifier> | ||
394 | + <ScaleDenominator>288571.8682214356</ScaleDenominator> | ||
395 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
396 | + <TileWidth>256</TileWidth> | ||
397 | + <TileHeight>256</TileHeight> | ||
398 | + <MatrixWidth>11</MatrixWidth> | ||
399 | + <MatrixHeight>11</MatrixHeight> | ||
400 | + </TileMatrix> | ||
401 | + <TileMatrix> | ||
402 | + <ows:Identifier>12</ows:Identifier> | ||
403 | + <ScaleDenominator>144285.9341107178</ScaleDenominator> | ||
404 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
405 | + <TileWidth>256</TileWidth> | ||
406 | + <TileHeight>256</TileHeight> | ||
407 | + <MatrixWidth>21</MatrixWidth> | ||
408 | + <MatrixHeight>20</MatrixHeight> | ||
409 | + </TileMatrix> | ||
410 | + <TileMatrix> | ||
411 | + <ows:Identifier>13</ows:Identifier> | ||
412 | + <ScaleDenominator>72142.9670553589</ScaleDenominator> | ||
413 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
414 | + <TileWidth>256</TileWidth> | ||
415 | + <TileHeight>256</TileHeight> | ||
416 | + <MatrixWidth>42</MatrixWidth> | ||
417 | + <MatrixHeight>40</MatrixHeight> | ||
418 | + </TileMatrix> | ||
419 | + <TileMatrix> | ||
420 | + <ows:Identifier>14</ows:Identifier> | ||
421 | + <ScaleDenominator>36071.48352767945</ScaleDenominator> | ||
422 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
423 | + <TileWidth>256</TileWidth> | ||
424 | + <TileHeight>256</TileHeight> | ||
425 | + <MatrixWidth>83</MatrixWidth> | ||
426 | + <MatrixHeight>80</MatrixHeight> | ||
427 | + </TileMatrix> | ||
428 | + <TileMatrix> | ||
429 | + <ows:Identifier>15</ows:Identifier> | ||
430 | + <ScaleDenominator>18035.741763839724</ScaleDenominator> | ||
431 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
432 | + <TileWidth>256</TileWidth> | ||
433 | + <TileHeight>256</TileHeight> | ||
434 | + <MatrixWidth>166</MatrixWidth> | ||
435 | + <MatrixHeight>158</MatrixHeight> | ||
436 | + </TileMatrix> | ||
437 | + <TileMatrix> | ||
438 | + <ows:Identifier>16</ows:Identifier> | ||
439 | + <ScaleDenominator>9017.870881919862</ScaleDenominator> | ||
440 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
441 | + <TileWidth>256</TileWidth> | ||
442 | + <TileHeight>256</TileHeight> | ||
443 | + <MatrixWidth>331</MatrixWidth> | ||
444 | + <MatrixHeight>314</MatrixHeight> | ||
445 | + </TileMatrix> | ||
446 | + <TileMatrix> | ||
447 | + <ows:Identifier>17</ows:Identifier> | ||
448 | + <ScaleDenominator>4508.935440959931</ScaleDenominator> | ||
449 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
450 | + <TileWidth>256</TileWidth> | ||
451 | + <TileHeight>256</TileHeight> | ||
452 | + <MatrixWidth>661</MatrixWidth> | ||
453 | + <MatrixHeight>627</MatrixHeight> | ||
454 | + </TileMatrix> | ||
455 | + <TileMatrix> | ||
456 | + <ows:Identifier>18</ows:Identifier> | ||
457 | + <ScaleDenominator>2254.4677204799655</ScaleDenominator> | ||
458 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
459 | + <TileWidth>256</TileWidth> | ||
460 | + <TileHeight>256</TileHeight> | ||
461 | + <MatrixWidth>1321</MatrixWidth> | ||
462 | + <MatrixHeight>1254</MatrixHeight> | ||
463 | + </TileMatrix> | ||
464 | + <TileMatrix> | ||
465 | + <ows:Identifier>19</ows:Identifier> | ||
466 | + <ScaleDenominator>1127.2338602399827</ScaleDenominator> | ||
467 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
468 | + <TileWidth>256</TileWidth> | ||
469 | + <TileHeight>256</TileHeight> | ||
470 | + <MatrixWidth>2642</MatrixWidth> | ||
471 | + <MatrixHeight>2508</MatrixHeight> | ||
472 | + </TileMatrix> | ||
473 | + <TileMatrix> | ||
474 | + <ows:Identifier>20</ows:Identifier> | ||
475 | + <ScaleDenominator>563.6169301199914</ScaleDenominator> | ||
476 | + <TopLeftCorner>90.0 -180.0</TopLeftCorner> | ||
477 | + <TileWidth>256</TileWidth> | ||
478 | + <TileHeight>256</TileHeight> | ||
479 | + <MatrixWidth>5283</MatrixWidth> | ||
480 | + <MatrixHeight>5014</MatrixHeight> | ||
481 | + </TileMatrix> | ||
482 | + </TileMatrixSet> | ||
483 | + </Contents> | ||
484 | + <ServiceMetadataURL xlink:href="http://172.26.99.160:8840/API/Image/Capabilities"/> | ||
485 | + </Capabilities>''' | ||
489 | 486 | ||
487 | + r = Response(response=x, status=200, mimetype="application/xml") | ||
488 | + r.headers["Content-Type"] = "text/xml; charset=utf-8" | ||
489 | + return r | ||
490 | 490 | ||
491 | 491 | ||
492 | -api_doc={ | ||
493 | -"tags":["影像接口"], | ||
494 | -"parameters":[ | ||
495 | 492 | ||
496 | -], | ||
497 | -"responses":{ | ||
498 | - 200:{ | ||
499 | - "schema":{ | ||
500 | - "properties":{ | 493 | + |
494 | + api_doc = { | ||
495 | + "tags": ["影像接口"], | ||
496 | + "parameters": [ | ||
497 | + {"name": "guid", | ||
498 | + "in": "formData", | ||
499 | + "type": "string", | ||
500 | + "description": "服务guid"}, | ||
501 | + ], | ||
502 | + "responses": { | ||
503 | + 200: { | ||
504 | + "schema": { | ||
505 | + "properties": { | ||
506 | + } | ||
501 | } | 507 | } |
502 | } | 508 | } |
503 | - } | ||
504 | } | 509 | } |
505 | } | 510 | } |
@@ -3,24 +3,17 @@ | @@ -3,24 +3,17 @@ | ||
3 | #createtime: 2021/7/19 | 3 | #createtime: 2021/7/19 |
4 | #email: nheweijun@sina.com | 4 | #email: nheweijun@sina.com |
5 | 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 | 6 | ||
7 | +from app.util.component.ApiTemplate import ApiTemplate | ||
12 | from thrift.transport import TSocket | 8 | from thrift.transport import TSocket |
13 | from thrift.transport import TTransport | 9 | from thrift.transport import TTransport |
14 | from thrift.protocol import TBinaryProtocol | 10 | from thrift.protocol import TBinaryProtocol |
15 | -import numpy | ||
16 | -import cv2 | ||
17 | import json | 11 | import json |
18 | -from .models import Image | ||
19 | from app.modules.image.ImageDataService import ImageDataService | 12 | from app.modules.image.ImageDataService import ImageDataService |
20 | -from app.models import db | ||
21 | -import uuid | 13 | +from app.util.component.FileProcess import FileProcess |
14 | +import datetime | ||
15 | + | ||
22 | import os | 16 | import os |
23 | -import time | ||
24 | class Api(ApiTemplate): | 17 | class Api(ApiTemplate): |
25 | 18 | ||
26 | api_name = "影像数据列表" | 19 | api_name = "影像数据列表" |
@@ -35,22 +28,50 @@ class Api(ApiTemplate): | @@ -35,22 +28,50 @@ class Api(ApiTemplate): | ||
35 | data_server = self.para.get("data_server") | 28 | data_server = self.para.get("data_server") |
36 | 29 | ||
37 | path = self.para.get("path") | 30 | 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 | 31 | + |
32 | + | ||
33 | + if data_server.__eq__("本地服务器"): | ||
34 | + project_path = (os.path.dirname(os.path.abspath(__file__))) | ||
35 | + | ||
36 | + base_path = os.path.join(project_path, "data") | ||
37 | + if path: | ||
38 | + base_path = os.path.normpath(path) | ||
39 | + | ||
40 | + data_list: list = [] | ||
41 | + for f in os.listdir(base_path): | ||
42 | + | ||
43 | + file_path = os.path.normpath(os.path.join(base_path, f)) | ||
44 | + file_size = FileProcess.get_file_size(file_path) | ||
45 | + | ||
46 | + fctime = datetime.datetime.fromtimestamp(os.path.getctime(file_path)).strftime('%Y-%m-%d %H:%M:%S') | ||
47 | + | ||
48 | + file_info = {"name": f, "path": file_path, "size": file_size, "create_time": fctime} | ||
49 | + | ||
50 | + if file_path.lower().endswith("tiff") or file_path.lower().endswith("tif"): | ||
51 | + file_info["type"] = "tif" | ||
52 | + data_list.append(file_info) | ||
53 | + elif file_path.lower().endswith("img"): | ||
54 | + file_info["type"] = "img" | ||
55 | + data_list.append(file_info) | ||
56 | + elif os.path.isdir(file_path): | ||
57 | + file_info["type"] = "dir" | ||
58 | + data_list.append(file_info) | ||
59 | + data_list_sorted = sorted(data_list, key=lambda x: x["name"]) | ||
60 | + res["data"] = data_list_sorted | ||
61 | + | ||
62 | + else: | ||
63 | + host = data_server.split(":")[0] | ||
64 | + port = int(data_server.split(":")[1]) | ||
65 | + | ||
66 | + transport = TSocket.TSocket(host, port) | ||
67 | + transport = TTransport.TBufferedTransport(transport) | ||
68 | + protocol = TBinaryProtocol.TBinaryProtocol(transport) | ||
69 | + client = ImageDataService.Client(protocol) | ||
70 | + transport.open() | ||
71 | + info= json.loads(client.getImageList(path)) | ||
72 | + transport.close() | ||
73 | + res["data"] = info | ||
74 | + | ||
54 | res["result"] = True | 75 | res["result"] = True |
55 | 76 | ||
56 | except Exception as e: | 77 | except Exception as e: |
@@ -8,6 +8,7 @@ from app.util.component.ApiTemplate import ApiTemplate | @@ -8,6 +8,7 @@ from app.util.component.ApiTemplate import ApiTemplate | ||
8 | from app.util.component.ModelVisitor import ModelVisitor | 8 | from app.util.component.ModelVisitor import ModelVisitor |
9 | 9 | ||
10 | from app.modules.image.models import Image | 10 | from app.modules.image.models import Image |
11 | + | ||
11 | class Api(ApiTemplate): | 12 | class Api(ApiTemplate): |
12 | 13 | ||
13 | api_name = "影像数据List" | 14 | api_name = "影像数据List" |
@@ -17,6 +18,13 @@ class Api(ApiTemplate): | @@ -17,6 +18,13 @@ class Api(ApiTemplate): | ||
17 | # 返回结果 | 18 | # 返回结果 |
18 | res = {} | 19 | res = {} |
19 | try: | 20 | try: |
21 | + page_index = int(self.para.get("page_index", "0")) | ||
22 | + page_size = int(self.para.get("page_size", "10")) | ||
23 | + | ||
24 | + alias = self.para.get("alias") | ||
25 | + name = self.para.get("name") | ||
26 | + | ||
27 | + | ||
20 | images = Image.query.all() | 28 | images = Image.query.all() |
21 | res["data"] = ModelVisitor.objects_to_jsonarray(images) | 29 | res["data"] = ModelVisitor.objects_to_jsonarray(images) |
22 | res["result"] = True | 30 | res["result"] = True |
@@ -34,49 +34,77 @@ class Api(ApiTemplate): | @@ -34,49 +34,77 @@ class Api(ApiTemplate): | ||
34 | data_server = self.para.get("data_server") | 34 | data_server = self.para.get("data_server") |
35 | 35 | ||
36 | path = self.para.get("path") | 36 | path = self.para.get("path") |
37 | - host = data_server.split(":")[0] | ||
38 | - port = int(data_server.split(":")[1]) | ||
39 | 37 | ||
40 | - if host.__eq__("localhost"): | ||
41 | - pass | 38 | + |
39 | + if data_server.__eq__("本地服务器"): | ||
40 | + host = data_server | ||
41 | + port = 0 | ||
42 | + | ||
43 | + image: Dataset = gdal.Open(path, 0) | ||
44 | + geo = image.GetGeoTransform() | ||
45 | + | ||
46 | + origin = osr.SpatialReference() | ||
47 | + origin.ImportFromWkt(image.GetProjection()) | ||
48 | + band_count = image.RasterCount | ||
49 | + band: Band = image.GetRasterBand(1) | ||
50 | + count = band.GetOverviewCount() | ||
51 | + nodatavalue = band.GetNoDataValue() | ||
52 | + left_top = (geo[0], geo[3]) | ||
53 | + | ||
54 | + right_buttom = (geo[0] + geo[1] * image.RasterXSize, geo[3] + geo[5] * image.RasterYSize) | ||
55 | + origin_extent = [left_top[0], right_buttom[0], right_buttom[1], left_top[1]] | ||
56 | + | ||
57 | + info = {"band_count": band_count, "overview_count": count, | ||
58 | + "xy_size": [image.RasterXSize, image.RasterYSize] | ||
59 | + , "origin_extent": origin_extent, "null_value": nodatavalue} | ||
60 | + | ||
61 | + del image | ||
62 | + | ||
42 | else: | 63 | else: |
64 | + host = data_server.split(":")[0] | ||
65 | + port = int(data_server.split(":")[1]) | ||
66 | + | ||
43 | transport = TSocket.TSocket(host, port) | 67 | transport = TSocket.TSocket(host, port) |
44 | transport = TTransport.TBufferedTransport(transport) | 68 | transport = TTransport.TBufferedTransport(transport) |
45 | protocol = TBinaryProtocol.TBinaryProtocol(transport) | 69 | protocol = TBinaryProtocol.TBinaryProtocol(transport) |
46 | - | ||
47 | client = ImageDataService.Client(protocol) | 70 | client = ImageDataService.Client(protocol) |
48 | - | ||
49 | transport.open() | 71 | transport.open() |
50 | - | ||
51 | info= json.loads(client.getInfo(path)) | 72 | info= json.loads(client.getInfo(path)) |
73 | + transport.close() | ||
52 | 74 | ||
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"] | 75 | + # 影像空间范围 |
76 | + if not info["origin_extent"]: | ||
77 | + if not self.para.get("extent"): | ||
78 | + res["result"] = False | ||
79 | + res["msg"] = "数据解析范围失败,请手动输入范围" | ||
80 | + return res | ||
81 | + else : | ||
82 | + origin_extent=json.loads(self.para.get("extent")) | ||
83 | + else: | ||
84 | + origin_extent = info["origin_extent"] | ||
85 | + | ||
86 | + | ||
87 | + guid = uuid.uuid1().__str__() | ||
88 | + | ||
89 | + image = Image(guid= guid, | ||
90 | + overview=info["overview_count"], | ||
91 | + raster_x_size=info["xy_size"][0], | ||
92 | + raster_y_size=info["xy_size"][1], | ||
93 | + name=os.path.basename(path), | ||
94 | + alias=self.para.get("alias"), | ||
95 | + extent=json.dumps(origin_extent), | ||
96 | + null_value=info["null_value"], | ||
97 | + host=host, | ||
98 | + port=port, | ||
99 | + # path=os.path.normpath(path) | ||
100 | + path = path | ||
101 | + ) | ||
102 | + | ||
103 | + db.session.add(image) | ||
104 | + db.session.commit() | ||
105 | + res["data"] = guid | ||
106 | + res["result"] = True | ||
63 | 107 | ||
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: | 108 | except Exception as e: |
81 | raise e | 109 | raise e |
82 | 110 |
@@ -25,6 +25,7 @@ class Api(ApiTemplate): | @@ -25,6 +25,7 @@ class Api(ApiTemplate): | ||
25 | if not zoo.connected: | 25 | if not zoo.connected: |
26 | zoo.start() | 26 | zoo.start() |
27 | res["data"] = zoo.get_children("/rpc") | 27 | res["data"] = zoo.get_children("/rpc") |
28 | + res["data"].append("本地服务器") | ||
28 | res["result"] = True | 29 | res["result"] = True |
29 | except Exception as e: | 30 | except Exception as e: |
30 | raise e | 31 | raise e |
app/modules/image/image_service_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 | +from app.modules.image.models import ImageService | ||
10 | + | ||
11 | + | ||
12 | +class Api(ApiTemplate): | ||
13 | + | ||
14 | + | ||
15 | + | ||
16 | + api_name = "注册影像服务" | ||
17 | + | ||
18 | + | ||
19 | + | ||
20 | + | ||
21 | + def process(self): | ||
22 | + | ||
23 | + | ||
24 | + | ||
25 | + # 返回结果 | ||
26 | + res = {} | ||
27 | + | ||
28 | + try: | ||
29 | + page_index = int(self.para.get("page_index", "0")) | ||
30 | + page_size = int(self.para.get("page_size", "10")) | ||
31 | + | ||
32 | + alias = self.para.get("alias") | ||
33 | + name = self.para.get("name") | ||
34 | + | ||
35 | + | ||
36 | + image_services = ImageService.query.all() | ||
37 | + | ||
38 | + res["data"] = ModelVisitor.objects_to_jsonarray(image_services) | ||
39 | + res["result"] = True | ||
40 | + | ||
41 | + | ||
42 | + except Exception as e: | ||
43 | + raise e | ||
44 | + | ||
45 | + return res | ||
46 | + | ||
47 | + api_doc = { | ||
48 | + "tags": ["影像接口"], | ||
49 | + "parameters": [ | ||
50 | + ], | ||
51 | + "responses": { | ||
52 | + 200: { | ||
53 | + "schema": { | ||
54 | + "properties": { | ||
55 | + } | ||
56 | + } | ||
57 | + } | ||
58 | + } | ||
59 | + } |
@@ -3,13 +3,14 @@ | @@ -3,13 +3,14 @@ | ||
3 | #createtime: 2021/7/19 | 3 | #createtime: 2021/7/19 |
4 | #email: nheweijun@sina.com | 4 | #email: nheweijun@sina.com |
5 | 5 | ||
6 | -from osgeo.ogr import * | ||
7 | -from osgeo import gdal,ogr,osr | ||
8 | -from osgeo.gdal import Dataset,Band | 6 | +from app.modules.image.models import ImageService,Image |
7 | +from app.models import db | ||
9 | from app.util.component.ApiTemplate import ApiTemplate | 8 | from app.util.component.ApiTemplate import ApiTemplate |
10 | import uuid | 9 | import uuid |
11 | - | ||
12 | - | 10 | +from app.util.component.SliceScheme import SliceScheme |
11 | +from app.util.component.FileProcess import FileProcess | ||
12 | +import os | ||
13 | +import json | ||
13 | class Api(ApiTemplate): | 14 | class Api(ApiTemplate): |
14 | 15 | ||
15 | api_name = "注册影像服务" | 16 | api_name = "注册影像服务" |
@@ -27,6 +28,30 @@ class Api(ApiTemplate): | @@ -27,6 +28,30 @@ class Api(ApiTemplate): | ||
27 | service_guid = uuid.uuid1().__str__() | 28 | service_guid = uuid.uuid1().__str__() |
28 | 29 | ||
29 | 30 | ||
31 | + parent = os.path.dirname(os.path.realpath(__file__)) | ||
32 | + dir_path, store_file = FileProcess.save(parent) | ||
33 | + scheme = SliceScheme(store_file).parameter | ||
34 | + | ||
35 | + service = ImageService(guid=service_guid, name=name, slice_scheme=json.dumps(scheme)) | ||
36 | + service_exetent = [] | ||
37 | + | ||
38 | + for g in guids: | ||
39 | + image = Image.query.filter_by(guid=g).one_or_none() | ||
40 | + if image: | ||
41 | + image_extent = json.loads(image.extent) | ||
42 | + if not service_exetent: | ||
43 | + service_exetent = image_extent | ||
44 | + else: | ||
45 | + service_exetent[0] = min(image_extent[0],service_exetent[0]) | ||
46 | + service_exetent[1] = min(image_extent[1], service_exetent[1]) | ||
47 | + service_exetent[2] = max(image_extent[2], service_exetent[2]) | ||
48 | + service_exetent[3] = max(image_extent[3], service_exetent[3]) | ||
49 | + service.images.append(image) | ||
50 | + service.extent = json.dumps(service_exetent) | ||
51 | + db.session.add(service) | ||
52 | + db.session.commit() | ||
53 | + res["data"] = service_guid | ||
54 | + res["result"] = True | ||
30 | except Exception as e: | 55 | except Exception as e: |
31 | raise e | 56 | raise e |
32 | 57 | ||
@@ -38,7 +63,11 @@ class Api(ApiTemplate): | @@ -38,7 +63,11 @@ class Api(ApiTemplate): | ||
38 | {"name": "guids", | 63 | {"name": "guids", |
39 | "in": "formData", | 64 | "in": "formData", |
40 | "type": "string", | 65 | "type": "string", |
41 | - "description": "影像guids,以英文逗号相隔"} | 66 | + "description": "影像guids,以英文逗号相隔"}, |
67 | + {"name": "file", | ||
68 | + "in": "formData", | ||
69 | + "type": "file", | ||
70 | + "description": "切片方案"}, | ||
42 | ], | 71 | ], |
43 | "responses": { | 72 | "responses": { |
44 | 200: { | 73 | 200: { |
@@ -13,281 +13,320 @@ from flask import Response | @@ -13,281 +13,320 @@ from flask import Response | ||
13 | import io | 13 | import io |
14 | import os | 14 | import os |
15 | from PIL import Image | 15 | from PIL import Image |
16 | -from app.util.slice_scheme import slice_scheme | 16 | + |
17 | import time | 17 | import time |
18 | import cv2 | 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") | 19 | +from app.modules.image.models import ImageService,Image |
20 | +from app.models import db | ||
21 | +from app.util.component.ApiTemplate import ApiTemplate | ||
22 | +import uuid | ||
23 | +from app.util.component.SliceScheme import SliceScheme | ||
24 | +from app.util.component.FileProcess import FileProcess | ||
25 | +from app.util.component.ParameterUtil import ParameterUtil | ||
26 | +from app.util.component.GeometryAdapter import GeometryAdapter | ||
27 | +import os | ||
28 | +import json | ||
29 | +from kazoo.client import KazooClient | ||
30 | +from app import GLOBAL_DIC | ||
31 | +from threading import Thread | ||
32 | +from thrift.transport import TSocket | ||
33 | +from thrift.transport import TTransport | ||
34 | +from thrift.protocol import TBinaryProtocol | ||
35 | +from .ImageDataService import ImageDataService | ||
36 | +from flask import current_app | ||
37 | +import gzip | ||
136 | 38 | ||
137 | - # print(image_level) | 39 | +class Api(ApiTemplate): |
138 | 40 | ||
139 | - image: Dataset = gdal.Open(path, 0) | 41 | + api_name = "切片" |
140 | 42 | ||
141 | - band_data: Band = image.GetRasterBand(band) | 43 | + def __init__(self,guid,level, row, col): |
44 | + super().__init__() | ||
45 | + self.guid = guid | ||
46 | + self.level = level | ||
47 | + self.row = row | ||
48 | + self.col = col | ||
142 | 49 | ||
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 | 50 | + def process(self): |
152 | 51 | ||
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) | 52 | + result = {} |
53 | + parameter: dict = self.para | ||
156 | 54 | ||
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]: | 55 | + try: |
56 | + if parameter.get("guid"): | ||
57 | + self.guid = parameter.get("guid") | ||
58 | + | ||
59 | + image_service = ImageService.query.filter_by(guid = self.guid).one_or_none() | ||
60 | + images = image_service.images.all() | ||
61 | + | ||
62 | + zoo = GLOBAL_DIC.get("zookeeper") | ||
63 | + if zoo is None: | ||
64 | + zoo :KazooClient = KazooClient(hosts=configure.zookeeper, timeout=100) | ||
65 | + zoo.start() | ||
66 | + GLOBAL_DIC["zookeeper"] = zoo | ||
67 | + else : | ||
68 | + if not zoo.connected: | ||
69 | + zoo.start() | ||
70 | + | ||
71 | + bands = [1, 2, 3] | ||
72 | + | ||
73 | + | ||
74 | + # 转换参数 | ||
75 | + parameter = ParameterUtil.to_lower(parameter) | ||
159 | 76 | ||
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 | 77 | ||
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] | 78 | + if parameter.get("tilematrix"): |
79 | + if parameter.get("tilematrix").__contains__(":"): | ||
80 | + self.level = int(parameter.get("tilematrix").split(":")[-1]) | ||
81 | + else: | ||
82 | + self.level = int(parameter.get("tilematrix")) | ||
83 | + if parameter.get("tilerow"): | ||
84 | + self.row = int(parameter.get("tilerow")) | ||
85 | + if parameter.get("tilecol"): | ||
86 | + self.col = int(parameter.get("tilecol")) | ||
87 | + | ||
88 | + | ||
89 | + | ||
90 | + image_type = parameter.get("format") if parameter.get("format") else "image/png" | ||
91 | + | ||
92 | + quality = int(parameter.get("quality")) if parameter.get("quality") else 30 | ||
93 | + | ||
94 | + slice_para = json.loads(image_service.slice_scheme) | ||
192 | 95 | ||
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) | 96 | + extent = SliceScheme.get_polygon(slice_para, self.level, self.row, self.col) |
196 | 97 | ||
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) | 98 | + # 结果矩阵 |
200 | 99 | ||
201 | - # 相对于出图的偏移量 | 100 | + empty_list = [numpy.zeros((256, 256), dtype=int) + 65536, |
101 | + numpy.zeros((256, 256), dtype=int) + 65536, | ||
102 | + numpy.zeros((256, 256), dtype=int) + 65536] | ||
202 | 103 | ||
203 | - #出图的网格大小 | ||
204 | - out_grid_x = (extent[2] - extent[0]) / (256 * 1.0) | ||
205 | - out_grid_y = (extent[3] - extent[1]) / (256 * 1.0) | 104 | + # 多线程获取分布式数据 |
206 | 105 | ||
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)) | 106 | + intersect_image = [im for im in images if self.determin_intersect(json.loads(im.extent),extent)] |
209 | 107 | ||
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)) | 108 | + pixel_array = numpy.zeros((256, 256,3), dtype=int) |
212 | 109 | ||
213 | - # 相交部分在出图的哪个位置 | 110 | + for image in intersect_image: |
214 | 111 | ||
215 | - overview_raster:ndarray = overview.ReadAsArray(off_x,off_y,x_g,y_g,out_x_g,out_y_g) | 112 | + if image.host.__eq__("本地服务器"): |
216 | 113 | ||
217 | - mask1 = numpy.zeros((out_y_g,out_x_g), dtype=int) | 114 | + pixel_array = numpy.zeros((256, 256, 3), dtype=int) |
115 | + ceng = 0 | ||
116 | + img: Dataset = gdal.Open(image.path, 0) | ||
117 | + t1 = time.time() | ||
118 | + for band in bands: | ||
218 | 119 | ||
219 | - mask2 = numpy.zeros((out_y_g,out_x_g), dtype=int) | 120 | + # 自决定金字塔等级 |
121 | + xysize = [img.RasterXSize, img.RasterYSize] | ||
122 | + origin_extent = image.extent | ||
123 | + band_data: Band = img.GetRasterBand(band) | ||
124 | + max_level = band_data.GetOverviewCount() | ||
220 | 125 | ||
221 | - mask1[overview_raster == 65536] = 1 | ||
222 | - mask2[overview_raster != 65536] = 1 | 126 | + # 超出空间范围 |
127 | + if extent[2] < origin_extent[0] or extent[0] > origin_extent[2] or extent[1] > origin_extent[ | ||
128 | + 3] or extent[3] < origin_extent[1]: | ||
129 | + empty = numpy.zeros((256, 256), dtype=int) + 65536 | ||
130 | + # 空间范围相交 | ||
131 | + else: | ||
132 | + image_level = self.determine_level(xysize, origin_extent, extent, max_level) | ||
223 | 133 | ||
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 | 134 | + if image_level == -1: |
135 | + overview = band_data | ||
136 | + else: | ||
137 | + try: | ||
138 | + overview: Band = band_data.GetOverview(image_level) | ||
139 | + except: | ||
140 | + raise Exception("该影像不存在该级别的金字塔数据!") | ||
141 | + ox = overview.XSize | ||
142 | + oy = overview.YSize | ||
225 | 143 | ||
226 | - # 关闭句柄 | ||
227 | - del image | 144 | + # 网格大小 |
145 | + grid_x = (origin_extent[2] - origin_extent[0]) / (ox * 1.0) | ||
146 | + grid_y = (origin_extent[3] - origin_extent[1]) / (oy * 1.0) | ||
228 | 147 | ||
148 | + # 完全在影像范围内 | ||
149 | + if extent[0] > origin_extent[0] and extent[1] > origin_extent[1] and extent[2] < \ | ||
150 | + origin_extent[2] and extent[3] < origin_extent[3]: | ||
229 | 151 | ||
152 | + # 网格偏移量 | ||
153 | + off_x = math.floor((extent[0] - origin_extent[0]) / grid_x) | ||
154 | + off_y = math.floor((origin_extent[3] - extent[3]) / grid_y) | ||
230 | 155 | ||
231 | - # opencv 的颜色排列为GBR | ||
232 | - pixel_array[:,:,ceng]=empty | ||
233 | - ceng-=1 | 156 | + # 截取后网格个数 |
157 | + x_g = math.ceil((extent[2] - extent[0]) / grid_x) | ||
234 | 158 | ||
235 | - t5 = time.time() | ||
236 | - # print(t4-t3) | 159 | + y_g = math.ceil((extent[3] - extent[1]) / grid_y) |
237 | 160 | ||
238 | - #将图片生成在内存中,然后直接返回response | ||
239 | - im_data = create_by_opencv(image_type, pixel_array, quality) | 161 | + empty = overview.ReadAsArray(off_x, off_y, x_g, y_g, 256, 256) |
240 | 162 | ||
241 | - return Response(im_data, mimetype=image_type.lower()) | ||
242 | 163 | ||
243 | - except Exception as e: | ||
244 | - print(traceback.format_exc()) | ||
245 | - result["state"] = -1 | ||
246 | - result["message"] = e.__str__() | ||
247 | - return result | 164 | + # 部分相交 |
165 | + else: | ||
248 | 166 | ||
167 | + inter_extent = [0, 0, 0, 0] | ||
168 | + inter_extent[0] = origin_extent[0] if origin_extent[0] > extent[0] else extent[0] | ||
169 | + inter_extent[1] = origin_extent[1] if origin_extent[1] > extent[1] else extent[1] | ||
170 | + inter_extent[2] = origin_extent[2] if origin_extent[2] < extent[2] else extent[2] | ||
171 | + inter_extent[3] = origin_extent[3] if origin_extent[3] < extent[3] else extent[3] | ||
249 | 172 | ||
173 | + # 网格偏移量 | ||
174 | + off_x = math.floor((inter_extent[0] - origin_extent[0]) / grid_x) | ||
175 | + off_y = math.floor((origin_extent[3] - inter_extent[3]) / grid_y) | ||
250 | 176 | ||
177 | + # 截取后网格个数 | ||
178 | + x_g = math.floor((inter_extent[2] - inter_extent[0]) / grid_x) | ||
179 | + y_g = math.floor((inter_extent[3] - inter_extent[1]) / grid_y) | ||
251 | 180 | ||
181 | + # 相对于出图的偏移量 | ||
252 | 182 | ||
253 | -def determine_level(xysize,origin_extent,extent,max_level): | ||
254 | - x = xysize[0] | ||
255 | - y = xysize[1] | 183 | + # 出图的网格大小 |
184 | + out_grid_x = (extent[2] - extent[0]) / (256 * 1.0) | ||
185 | + out_grid_y = (extent[3] - extent[1]) / (256 * 1.0) | ||
256 | 186 | ||
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]))) | 187 | + out_off_x = int(math.ceil((inter_extent[0] - extent[0]) / out_grid_x)) |
188 | + out_off_y = int(math.ceil((extent[3] - inter_extent[3]) / out_grid_y)) | ||
259 | 189 | ||
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 | 190 | + out_x_g = int(math.floor((inter_extent[2] - inter_extent[0]) / out_grid_x)) |
191 | + out_y_g = int(math.floor((inter_extent[3] - inter_extent[1]) / out_grid_y)) | ||
267 | 192 | ||
193 | + # 相交部分在出图的哪个位置 | ||
268 | 194 | ||
195 | + overview_raster: ndarray = overview.ReadAsArray(off_x, off_y, x_g, y_g, out_x_g, | ||
196 | + out_y_g) | ||
269 | 197 | ||
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)) | 198 | + dat = numpy.zeros((256, 256), dtype=int) + 65536 |
199 | + dat[out_off_y:out_off_y + out_y_g, out_off_x:out_off_x + out_x_g] = overview_raster | ||
276 | 200 | ||
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() | 201 | + empty = dat |
283 | 202 | ||
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 | 203 | + pixel_array[:, :, ceng] = empty |
204 | + ceng += 1 | ||
290 | 205 | ||
206 | + data = pixel_array | ||
207 | + | ||
208 | + else: | ||
209 | + ser = "{}:{}".format(image.host,image.port) | ||
210 | + if zoo.exists("/rpc/{}".format(ser)): | ||
211 | + | ||
212 | + transport = TSocket.TSocket(image.host, image.port) | ||
213 | + transport = TTransport.TBufferedTransport(transport) | ||
214 | + protocol = TBinaryProtocol.TBinaryProtocol(transport) | ||
215 | + client = ImageDataService.Client(protocol) | ||
216 | + transport.open() | ||
217 | + t1 = time.time() | ||
218 | + data = client.getData(image.path, extent, json.loads(image.extent), bands) | ||
219 | + transport.close() | ||
220 | + current_app.logger.info("time {}".format(time.time()-t1)) | ||
221 | + | ||
222 | + data = gzip.decompress(data) | ||
223 | + data = numpy.frombuffer(data, dtype=int) | ||
224 | + data= data.reshape((256, 256, 3)) | ||
225 | + else: | ||
226 | + data = numpy.zeros((256, 256, 3), dtype=int) + 65536 | ||
227 | + | ||
228 | + | ||
229 | + # 掩膜在中央接口生成 | ||
230 | + mask = numpy.zeros((256, 256), dtype=int) | ||
231 | + mask2 = numpy.zeros((256, 256), dtype=int) | ||
232 | + jizhun = data[:, :, 0] | ||
233 | + | ||
234 | + mask[jizhun == 65536] = 1 | ||
235 | + mask[jizhun != 65536] = 0 | ||
236 | + mask2[jizhun == 65536] = 0 | ||
237 | + mask2[jizhun != 65536] = 1 | ||
238 | + | ||
239 | + # 掩膜计算 | ||
240 | + for i, d in enumerate(empty_list): | ||
241 | + empty_list[i] = empty_list[i] * mask + data[:, :, i] * mask2 | ||
242 | + | ||
243 | + | ||
244 | + for ii in [0, 1, 2]: | ||
245 | + # opencv 颜色排序为GBR | ||
246 | + pixel_array[:, :, 2 - ii] = empty_list[ii] | ||
247 | + | ||
248 | + #将图片生成在内存中,然后直接返回response | ||
249 | + im_data = self.create_by_opencv(image_type, pixel_array, quality) | ||
250 | + | ||
251 | + return Response(im_data, mimetype=image_type.lower()) | ||
252 | + | ||
253 | + except Exception as e: | ||
254 | + print(traceback.format_exc()) | ||
255 | + result["state"] = -1 | ||
256 | + result["message"] = e.__str__() | ||
257 | + return result | ||
258 | + | ||
259 | + | ||
260 | + def determine_level(self,xysize,origin_extent,extent,max_level): | ||
261 | + ''' | ||
262 | + 根据范围判断调用金字塔的哪一层 | ||
263 | + :param xysize: | ||
264 | + :param origin_extent: | ||
265 | + :param extent: | ||
266 | + :param max_level: | ||
267 | + :return: | ||
268 | + ''' | ||
269 | + x = xysize[0] | ||
270 | + y = xysize[1] | ||
271 | + level = -1 | ||
272 | + pixel = x*y * (((extent[2]-extent[0])*(extent[3]-extent[1]))/((origin_extent[2]-origin_extent[0])*(origin_extent[3]-origin_extent[1]))) | ||
273 | + while pixel>100000 and level<max_level-1: | ||
274 | + level+=1 | ||
275 | + x=x/2 | ||
276 | + y=y/2 | ||
277 | + pixel = x * y * (((extent[2] - extent[0]) * (extent[3] - extent[1])) / ( | ||
278 | + (origin_extent[2] - origin_extent[0]) * (origin_extent[3] - origin_extent[1]))) | ||
279 | + return level | ||
280 | + | ||
281 | + def create_by_opencv(self,image_type, pixel_array, quality): | ||
282 | + | ||
283 | + if image_type.__eq__("image/jpeg") or image_type.__eq__("image/jpg"): | ||
284 | + r, buf = cv2.imencode(".jpg", pixel_array, [cv2.IMWRITE_JPEG_QUALITY, quality]) | ||
285 | + image_out = buf.tobytes() | ||
286 | + else: | ||
287 | + four = numpy.zeros((256, 256), dtype=int) + 255 | ||
288 | + four[pixel_array[:, :, 0] == 65536] = 0 | ||
289 | + r, buf = cv2.imencode(".png", numpy.dstack((pixel_array, four))) | ||
290 | + image_out = buf.tobytes() | ||
291 | + return image_out | ||
292 | + | ||
293 | + def get_data(self,image,extent,bands): | ||
294 | + ''' | ||
295 | + 通过RPC获取远程数据 | ||
296 | + :param image: | ||
297 | + :param extent: | ||
298 | + :param bands: | ||
299 | + :return: | ||
300 | + ''' | ||
301 | + transport = TSocket.TSocket(image.host, image.port) | ||
302 | + transport = TTransport.TBufferedTransport(transport) | ||
303 | + protocol = TBinaryProtocol.TBinaryProtocol(transport) | ||
304 | + client = ImageDataService.Client(protocol) | ||
305 | + | ||
306 | + transport.open() | ||
307 | + data = client.getData(image.path,extent,json.loads(image.extent), bands) | ||
308 | + transport.close() | ||
309 | + | ||
310 | + return numpy.array(json.loads(data)) | ||
311 | + | ||
312 | + def determin_intersect(self,extent1,extent2): | ||
313 | + g1 = GeometryAdapter.envelop_2_polygon(extent1) | ||
314 | + g2 = GeometryAdapter.envelop_2_polygon(extent2) | ||
315 | + return g1.Intersect(g2) | ||
316 | + | ||
317 | + | ||
318 | +class MyThread(Thread): | ||
319 | + def __init__(self,func,args=()): | ||
320 | + super(MyThread,self).__init__() | ||
321 | + self.func = func | ||
322 | + self.args = args | ||
323 | + def run(self): | ||
324 | + self.result = self.func(*self.args) | ||
325 | + def get_result(self): | ||
326 | + try: | ||
327 | + return self.result | ||
328 | + except Exception: | ||
329 | + return None | ||
291 | 330 | ||
292 | api_doc={ | 331 | api_doc={ |
293 | "tags":["影像接口"], | 332 | "tags":["影像接口"], |
@@ -6,7 +6,9 @@ | @@ -6,7 +6,9 @@ | ||
6 | 6 | ||
7 | from sqlalchemy import Column, Integer, String, ForeignKey, Text, DateTime, Time | 7 | from sqlalchemy import Column, Integer, String, ForeignKey, Text, DateTime, Time |
8 | from app.models import db | 8 | from app.models import db |
9 | +from sqlalchemy.ext.declarative import declarative_base | ||
9 | 10 | ||
11 | +Base = declarative_base() | ||
10 | class Image(db.Model): | 12 | class Image(db.Model): |
11 | ''' | 13 | ''' |
12 | 影像元数据 | 14 | 影像元数据 |
@@ -27,14 +29,13 @@ class Image(db.Model): | @@ -27,14 +29,13 @@ class Image(db.Model): | ||
27 | port=Column(Integer) | 29 | port=Column(Integer) |
28 | 30 | ||
29 | 31 | ||
30 | - | ||
31 | dmdms_image_rel = db.Table('dmdms_image_rel', | 32 | dmdms_image_rel = db.Table('dmdms_image_rel', |
32 | - Column('guid', String, primary_key=True), | ||
33 | Column('image_guid',String, ForeignKey('dmdms_image.guid')), | 33 | Column('image_guid',String, ForeignKey('dmdms_image.guid')), |
34 | - Column('priority',Integer), | ||
35 | Column('service_guid', String, ForeignKey('dmdms_image_service.guid')) | 34 | Column('service_guid', String, ForeignKey('dmdms_image_service.guid')) |
36 | ) | 35 | ) |
37 | 36 | ||
37 | + | ||
38 | + | ||
38 | class ImageService(db.Model): | 39 | class ImageService(db.Model): |
39 | ''' | 40 | ''' |
40 | 影像服务 | 41 | 影像服务 |
@@ -47,6 +48,8 @@ class ImageService(db.Model): | @@ -47,6 +48,8 @@ class ImageService(db.Model): | ||
47 | create_time = Column(DateTime) | 48 | create_time = Column(DateTime) |
48 | update_time = Column(DateTime) | 49 | update_time = Column(DateTime) |
49 | description = Column(Text) | 50 | description = Column(Text) |
51 | + slice_scheme = Column(Text) | ||
52 | + extent = Column(String(256)) | ||
50 | images = db.relationship('Image', | 53 | images = db.relationship('Image', |
51 | secondary=dmdms_image_rel, | 54 | secondary=dmdms_image_rel, |
52 | backref='image_services', | 55 | backref='image_services', |
app/util/component/CoordinateTransform.py
0 → 100644
1 | +# coding=utf-8 | ||
2 | +#author: 4N | ||
3 | +#createtime: 2021/8/9 | ||
4 | +#email: nheweijun@sina.com | ||
5 | + | ||
6 | +# from osgeo import osr | ||
7 | +# class CoordinateTransform: | ||
8 | +# | ||
9 | +# def transform: | ||
10 | +# origin = osr.SpatialReference() | ||
11 | +# origin.ImportFromWkt(image.GetProjection()) | ||
12 | +# target = osr.SpatialReference() | ||
13 | +# | ||
14 | +# | ||
15 | +# target = origin.CloneGeogCS() | ||
16 | +# band_count = image.RasterCount | ||
17 | +# band: Band = image.GetRasterBand(1) | ||
18 | +# count = band.GetOverviewCount() | ||
19 | +# tran = osr.CoordinateTransformation(origin, target) | ||
20 | +# | ||
21 | +# nodatavalue = band.GetNoDataValue() |
@@ -33,4 +33,5 @@ class ParameterUtil: | @@ -33,4 +33,5 @@ class ParameterUtil: | ||
33 | new_para=dict() | 33 | new_para=dict() |
34 | for key in parameter.keys(): | 34 | for key in parameter.keys(): |
35 | new_para[key.lower()] = parameter[key] | 35 | new_para[key.lower()] = parameter[key] |
36 | - parameter = new_para | ||
36 | + parameter = new_para | ||
37 | + return parameter |
@@ -11,7 +11,7 @@ else | @@ -11,7 +11,7 @@ else | ||
11 | port=$1 | 11 | port=$1 |
12 | echo "端口设置为$1 ..." | 12 | echo "端口设置为$1 ..." |
13 | fi | 13 | fi |
14 | -docker run -d --name dmapmanager -e TZ="Asia/Shanghai" --restart=always -e ALLOW_IP_RANGE=0.0.0.0/0 -p $port:8840 -v $curPath:/usr/src/app -w /usr/src/app dci/dmapdms:3.0 gunicorn -c gun_conf.py run:app | 14 | +docker run -d --name dmapmanager -e TZ="Asia/Shanghai" --restart=always -e ALLOW_IP_RANGE=0.0.0.0/0 -p $port:8840 -v $curPath:/usr/src/app -w /usr/src/app dci/dmapdms:4.0 gunicorn -c gun_conf.py run:app |
15 | # 清除未完成的任务任务 | 15 | # 清除未完成的任务任务 |
16 | sleep 5 | 16 | sleep 5 |
17 | curl localhost:$port/release | 17 | curl localhost:$port/release |
@@ -3,4 +3,5 @@ from flask import Flask | @@ -3,4 +3,5 @@ from flask import Flask | ||
3 | from app import create_app | 3 | from app import create_app |
4 | app:Flask = create_app() | 4 | app:Flask = create_app() |
5 | if __name__ == '__main__': | 5 | if __name__ == '__main__': |
6 | - app.run(host="0.0.0.0", port="8840", threaded=True, debug=True) | ||
6 | + app.run(host="0.0.0.0", port="8840", threaded=True, debug=True) | ||
7 | + # app.run(host="0.0.0.0", port="8840", threaded=True) |
@@ -5,4 +5,16 @@ | @@ -5,4 +5,16 @@ | ||
5 | 5 | ||
6 | from pyDes import des,ECB,PAD_PKCS5 | 6 | from pyDes import des,ECB,PAD_PKCS5 |
7 | import base64 | 7 | import base64 |
8 | +import numpy | ||
9 | +import gzip | ||
10 | +import sys | ||
11 | +import json | ||
12 | +pixel_array = numpy.empty((256,256,3),dtype=int)+3 | ||
8 | 13 | ||
14 | + | ||
15 | + | ||
16 | +# 使用gzip 压缩传输 | ||
17 | +content = gzip.compress(pixel_array, 2) | ||
18 | + | ||
19 | +print(sys.getsizeof(json.dumps(pixel_array.tolist()))) | ||
20 | +print(sys.getsizeof((content))) |
请
注册
或
登录
后发表评论