решение задания 5 + 6

This commit is contained in:
2023-01-30 21:46:21 +07:00
parent 94480dcd0c
commit 11fd0dbce9
5 changed files with 135 additions and 4 deletions
+4 -2
View File
@@ -3,10 +3,11 @@ import requests
from PIL import Image
def get_img_map(delta: float, cords: tuple, variant_map: str) -> None:
def get_img_map(delta: float, cords: tuple, variant_map: str, org_point: str) -> None:
"""
Функция обращается к api yandex и создаёт картинку карты по переданным данным
:param org_point: str - координаты организации, куда надо точку поставить
:param delta: float - разрешение карты
:param cords: tuple - 2 координаты точки
:param variant_map: str - вариант карты
@@ -15,7 +16,8 @@ def get_img_map(delta: float, cords: tuple, variant_map: str) -> None:
params = {
"ll": ",".join([str(cords[0]), str(cords[1])]),
"spn": ",".join([str(delta), str(delta)]),
"l": variant_map
"l": variant_map,
"pt": "{0},pm2dgl".format(org_point)
}
response = requests.get("http://static-maps.yandex.ru/1.x/", params=params)
# print(response.text)
+14
View File
@@ -0,0 +1,14 @@
import requests
def search_organization_pos(search_text: str) -> tuple:
geocoder_api_server = "http://geocode-maps.yandex.ru/1.x/"
geocoder_params = {
"apikey": "40d1649f-0493-4b70-98ba-98533de7710b",
"geocode": search_text,
"format": "json"}
response = requests.get(geocoder_api_server, params=geocoder_params)
toponym = response.json()["response"]["GeoObjectCollection"]["featureMember"][0]["GeoObject"]
point = [float(i) for i in toponym["Point"]["pos"].split(" ")]
toponym_longitude, toponym_lattitude = toponym["Point"]["pos"].split(" ")
return "{0},{1}".format(point[0], point[1]), toponym_longitude, toponym_lattitude