Nematillo Ochilov
1.03K subscribers
337 photos
124 videos
383 files
685 links
Buxoro viloyati Gʻijduvon tumanida istiqomat qiluvchi dasturchi, @Nematillo_Ochilov

youtube.com/c/nematilloochilov
@NematilloOchilov - blog
@pythonuz - Python darslari
@js_uz - Java Script
@MQLUZ - Savdo robotlari
@sjtbot - Test kalitlarini tekshirish
Download Telegram
Bir manzildan ikkinchi manzilgacha bo'lgan yo'l masofasini aniqlash.

Bir manzildan ikkinchi manzilgacha bo'lgan yo'l masofasini aniqlash (to'g'ri chiziq bo'ylab emas yo'l bo'ylab) va taxminiy avtomobilda borish vaqtini ushbu funksiya yordamida bepul aniqlaymiz.1 kunda 22000 ta masofani tekshirish uchun so'rov yuborish mumkin.

import requests
import random


def route_distance(start, end): # yo'l masofasini o'lchash funksiyasi
keys_openrouteservice = [ # openrouteservice bepul kalitlari
"5b3ce3597851110001cf6248db84a52feecd456dbb2a4ee52a35ee4f",
"5b3ce3597851110001cf6248b44db44b33c64508afa658b8673c9580",
"5b3ce3597851110001cf6248701a505f4a83471da001d266b2860ac6",
"5b3ce3597851110001cf6248cbd8b98cf94b49998c93ca0605780f15",
"5b3ce3597851110001cf62480bea960faed84e018b953afbd3510ae7",
"5b3ce3597851110001cf62485788356becfe4894aba648ee6673baab",
"58d904a497c67e00015b45fc8129a6e7cd6d44aca2c1c45b56810512",
"5b3ce3597851110001cf6248e268bd7907a2427ba90d7d9555c20aac",
"5b3ce3597851110001cf6248e29e876eaf39498bb0b0b2ad0863e216",
"5b3ce3597851110001cf6248065eabf9d1e1454bbef78fe96f3016ec",
"5b3ce3597851110001cf62488ad066f5960f48e28aae44a1f27a245c"
]
key = random.choice(keys_openrouteservice) # taxminiy kalitlarni tanlash
url2 = f'https://api.openrouteservice.org/v2/directions/driving-car?api_key=' \
f'{key}&start={start}&end={end}'
d = requests.get(url2) # manzillar orasidagi yo'lni o'lshash uchun so'rov yuborish
z = d.json()['features'][0]['properties']['segments'][0]
distance = round(float(z['distance'])/1000, 2) # masofa km
duration = round(float(z['duration'])/60, 0) # vaqt minut
return [distance, duration]


rd = route_distance(
"69.241732,41.311668", # Istiqlol san'at saroyi
"69.316101,41.348023" # Toshkent botanika bog'i
)
print(f'Masofa: {rd[0]} km, Avtomobilda taxminiy borish vaqti: {rd[1]} minut')

>>> Masofa: 9.92 km, Avtomobilda taxminiy borish vaqti: 12.0 minut

#road #route #km #metr #gps #maps #free #xarita #online


Kanalga bepul obuna bo'lish👇
https://t.me/joinchat/AAAAAD6YXE73Trzz2TcWdw
Nematillo Ochilov
Location
Istalgan manzildagi telegram foydalanuvchilarini ko'rish uslubi.

Pyrogram kutubxonasida ushbu uslub orqali istalgan kordinatalardagi Nearby guruhlarni va guruhdagi foydalanuvchilarni ko'rishingiz mumkin.


Bu uslubni qayerda qo'llash foydaliroq?

Manzilga
aloqador guruh ochganda va guruhga aynan o'sha manzil foydalanuvchilarini guruhga qo'shish kerak bo'lganda ushbu uslub ayni muddao.
Masalan Toshkent shahrida kiyimlar do'koningiz bor va do'koningizda savdo hajmi susaygan.Bunday vaziyatda telegramda guruh ochib Toshkent shahrida istiqomat qilayotganlarni guruhga qo'shib mahsulotlarni reklama qilishingiz mumkin.


Yuqoridagi kodda Tashkent city kordinatasi namuna qilib ko'rsatilgan.

Manba: https://docs.pyrogram.org/api/methods/get_nearby_chats

#pyrogram #nearby #km #metr #gps #maps #free #xarita #online

@NematilloOchilov