-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzdjecia_lotnicze_api.py
46 lines (37 loc) · 1.36 KB
/
zdjecia_lotnicze_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
from .constants import ZDJECIA_LOTNICZE_WMS_URL
from . import service_api
from .wms.utils import get_wms_objects
def getZdjeciaLotniczeListbyPoint1992(point):
"""Zwraca listę dostępnych do pobrania zdjęć lotniczych na podstawie
zapytania GetFeatureInfo z usługi WMS"""
x = point.x()
y = point.y()
layers = service_api.getAllLayers(url=ZDJECIA_LOTNICZE_WMS_URL, service='WMS')
PARAMS = {
'SERVICE': 'WMS',
'request': 'GetFeatureInfo',
'version': '1.1.1',
'layers': ','.join(layers),
'styles': '',
'srs': 'EPSG:2180',
'bbox': '%f,%f,%f,%f' % (x-50, y-50, x+50, y+50),
'width': '101',
'height': '101',
'format': 'image/png',
'transparent': 'true',
'query_layers': ','.join(layers),
'i': '50',
'j': '50',
'INFO_FORMAT': 'text/html'
}
resp = service_api.getRequest(params=PARAMS, url=ZDJECIA_LOTNICZE_WMS_URL)
return _convert_attributes(get_wms_objects(resp))
def _convert_attributes(elems_list):
for elem in elems_list:
if 'nrZdjÄcia' in elem:
elem['nrZdjecia'] = elem.get('nrZdjÄcia')
if 'nrZdjÄ\x99cia' in elem:
elem['nrZdjecia'] = elem.get('nrZdjÄ\x99cia')
elem['url'] = elem.get('adresUrlMiniatur') or 'brak zdjęcia'
return elems_list