def traffic_congestion(bot, update, args):
    if args != []:
        if [True for j in args if ':' in j]:
            address = (''.join(args)).split(':')
            address1, address2 = address[0], address[1]
            try:
                lat, lon = get_coordinates(address2)
                ll, spn = get_ll_span(address1, [str(lat) + ',' + str(lon)],
                                      [address2])
            except:
                update.message.reply_text(
                    "Извини, но я не смог найти этот адрес :(")

        elif len(args) >= 1:
            address1 = args
            try:
                ll, spn = get_ll_span(address1, [], [])
            except:
                update.message.reply_text(
                    "Извини, но я не смог найти этот адрес :(")

        static_api_request = "http://static-maps.yandex.ru/1.x/?ll={}&l=map,trf&spn={}".format(
            ll, spn)
        bot.sendPhoto(update.message.chat.id, static_api_request)

    else:
        update.message.reply_text("Нет адреса")
Exemple #2
0
def geocoder(update, context):
    try:
        ll, spn = get_ll_span(update.message.text)
        if ll and spn:
            point = "{ll},pm2vvl".format(ll=ll)
            static_api_request = "http://static-maps.yandex.ru/1.x/?ll={ll}&spn={spn}&l=map&pt={point}".format(
                **locals())
            context.bot.sendPhoto(update.message.chat.id,
                                  static_api_request,
                                  caption=update.message.text)
        else:
            update.message.reply_text("По запросу ничего не найдено.")
    except RuntimeError as ex:
        update.message.reply_text(str(ex))
Exemple #3
0
def main():
    toponym_to_find = " ".join(sys.argv[1:])

    if toponym_to_find:
        lat, lon = get_coordinates(toponym_to_find)
        ll_spn = "ll={0},{1}&spn=0.005,0.005".format(lat, lon)
        show_map(ll_spn, "map")
        ll, spn = get_ll_span(toponym_to_find)
        ll_spn = "ll={ll}&spn={spn}".format(**locals())
        show_map(ll_spn, "map")
        point_param = "pt={ll}".format(**locals())
        show_map(ll_spn, "map", add_params=point_param)
    else:
        print('No data')
Exemple #4
0
def main():
    towns = [
        "Ярославль", "Нижний Новгород", "Казань", "Великий Новгород",
        "Архангельск", "Саратов", "Петрозаводск", "Астрахань"
    ]
    random.shuffle(towns)

    for town in towns:
        ll, spn = get_ll_span(town)
        map_type = "sat"
        if random.random() > 0.5:
            spn = "0.001,0.001"
            map_type = "map"
        ll_spn = "ll={ll}&spn={spn}".format(**locals())
        show_map(ll_spn, map_type)
Exemple #5
0
def main():
    toponym_to_find = " ".join(sys.argv[1:])

    if toponym_to_find:
        # Показываем карту с фиксированным масштабом.
        lat, lon = get_coordinates(toponym_to_find)
        ll_spn = "ll={0},{1}&spn=0.005,0.005".format(lat, lon)
        show_map(ll_spn, "map")

        # Показываем карту с масштабом, подобранным по заданному объекту.
        ll, spn = get_ll_span(toponym_to_find)
        ll_spn = "ll={ll}&spn={spn}".format(**locals())
        show_map(ll_spn, "map")

        # Добавляем исходную точку на карту.
        point_param = "pt={ll}".format(**locals())
        show_map(ll_spn, "map", add_params=point_param)
    else:
        print('No data')
Exemple #6
0
def param_get_spn():
    toponym_to_find = " ".join(sys.argv[1:])
    ll, spn = get_ll_span(toponym_to_find)
    coordinates = f"ll={ll}&spn={spn}"
    show_map(coordinates, "map")
    show_map(coordinates, "map", add_params=f"pt={ll}")
    ll = ll.split(",")
    ll = ",".join([str(float(ll[0]) / 1.00001), str(float(ll[1]))])
    return ll


def right(ll):
    ll = ll.split(",")
    ll = ",".join([str(float(ll[0]) * 1.00001), str(float(ll[1]))])
    return ll


size = width, height = 650, 500
screen = pygame.display.set_mode(size)
pygame.init()
toponym_to_find = get_toponym()
ll, spn = geocoder.get_ll_span(toponym_to_find)
finded_place = ll + "," + "pmgnm"
q = 0
mapp = button(q)
button2()
button3((255, 0, 0), 't')
u = 0
get_image(ll, spn, mapp, finded_place)
while 1:
    address_to_out = geocoder.geocode(toponym_to_find)['metaDataProperty']['GeocoderMetaData']['text']
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            raise SystemExit
        elif event.type == pygame.MOUSEBUTTONDOWN:
            x, y = event.pos
def main():
    toponym_to_find = " ".join(sys.argv[1:])
    longitude, lattitude = get_coordinates(toponym_to_find)
    ll = get_ll_span(f"ll={longitude},{lattitude}&spn=0.005,0.005")
    show_map(ll, "map")