29 |
getFormat(format) |
getFormat(format) |
30 |
calcFormat(formats) |
calcFormat(formats) |
31 |
|
|
32 |
|
getFormats() |
33 |
|
getLayers() |
34 |
|
getLayerTitle() |
35 |
|
|
36 |
|
getWMSFormat() |
37 |
|
setWMSFormat(format) |
38 |
|
|
39 |
GetMapImg(width, height, bbox) |
GetMapImg(width, height, bbox) |
40 |
|
|
41 |
Requirements: |
Requirements: |
101 |
self.bbox = None |
self.bbox = None |
102 |
self.latlonbbox = None |
self.latlonbbox = None |
103 |
self.error_msg = None |
self.error_msg = None |
104 |
self.layer_name = None |
self.wms_layers = [] |
105 |
self.capabilities = None |
self.capabilities = None |
106 |
|
|
107 |
# Change the cursor to demonstrate that we're busy but working |
# Change the cursor to demonstrate that we're busy but working |
116 |
'%s') % url |
'%s') % url |
117 |
return |
return |
118 |
top_layer = foo[0] |
top_layer = foo[0] |
119 |
self.layer_name = top_layer |
self.wms_layers = [top_layer] |
120 |
|
|
121 |
# first projection of the top layer |
# first projection of the top layer |
122 |
foo = self.capabilities.getLayerSRS(top_layer) |
foo = self.capabilities.getLayerSRS(top_layer) |
238 |
return None, None |
return None, None |
239 |
|
|
240 |
|
|
241 |
|
def getFormats(self): |
242 |
|
""" |
243 |
|
Return the list of supported image formats by the WMS server |
244 |
|
|
245 |
|
These formats may be used in the WMS GetMap request. Data is |
246 |
|
retrieved from the included WMSCapabilities object. |
247 |
|
|
248 |
|
The called method from WMSCapabilities will default to |
249 |
|
'image/jpeg' if no format is recognised in XML Capabilities, |
250 |
|
assuming that JPEG will always be supported on the server side |
251 |
|
with this encoding. |
252 |
|
""" |
253 |
|
return self.capabilities.getFormats() |
254 |
|
|
255 |
|
|
256 |
|
def getLayers(self): |
257 |
|
""" |
258 |
|
Return the list of layer names supported by the WMS server |
259 |
|
|
260 |
|
Data is retrieved from the included WMSCapabilities object. |
261 |
|
|
262 |
|
Only named layers will be returned, since a layer may have a |
263 |
|
title but doesn't have to have a name associated to it as |
264 |
|
well. If no layers were found, an empty list is returned. |
265 |
|
""" |
266 |
|
return self.capabilities.getLayers() |
267 |
|
|
268 |
|
|
269 |
|
def getLayerTitle(self, layer): |
270 |
|
""" |
271 |
|
Return the title of the named layer |
272 |
|
|
273 |
|
Data is retrieved from the included WMSCapabilities object. |
274 |
|
|
275 |
|
If no such title or no such layer exists, an empty string is |
276 |
|
returned. |
277 |
|
""" |
278 |
|
return self.capabilities.getLayerTitle(layer) |
279 |
|
|
280 |
|
|
281 |
|
def getWMSFormat(self): |
282 |
|
""" |
283 |
|
Return the image format that is used for WMS GetMap requests |
284 |
|
""" |
285 |
|
return self.wmsformat |
286 |
|
|
287 |
|
|
288 |
|
def setWMSFormat(self, format): |
289 |
|
""" |
290 |
|
Set the image format that is used for WMS GetMap requests |
291 |
|
|
292 |
|
format -- format, one of getFormats() |
293 |
|
""" |
294 |
|
self.wmsformat = format |
295 |
|
|
296 |
|
|
297 |
|
def getVisibleLayers(self): |
298 |
|
""" |
299 |
|
Return the list of names for all visible layers |
300 |
|
|
301 |
|
""" |
302 |
|
return self.wms_layers |
303 |
|
|
304 |
|
|
305 |
|
def setVisibleLayers(self, layers): |
306 |
|
""" |
307 |
|
Set the list of names for all visible layers |
308 |
|
|
309 |
|
""" |
310 |
|
self.wms_layers = layers |
311 |
|
|
312 |
|
|
313 |
def GetMapImg(self, width, height, bbox): |
def GetMapImg(self, width, height, bbox): |
314 |
""" |
""" |
315 |
Retrieve a new map from the WMS server and return it |
Retrieve a new map from the WMS server and return it |
333 |
|
|
334 |
wms_response = wmsclient.getMap(self.url, self.wmsformat, width, height, |
wms_response = wmsclient.getMap(self.url, self.wmsformat, width, height, |
335 |
epsg_id, bbox_dict, |
epsg_id, bbox_dict, |
336 |
[self.layer_name], version = self.capabilities.getVersion()) |
self.wms_layers, version = self.capabilities.getVersion()) |
337 |
ThubanEndBusyCursor() |
ThubanEndBusyCursor() |
338 |
return wms_response, self.format |
return wms_response, self.format |