ฉันยังใหม่กับการทำงานกับแผนที่และอัลกอริธึมการค้นหา ขณะนี้ฉันใช้แพ็คเกจ geopy
เพื่อรับระยะทางจาก Nominatim
from geopy.geocoders import Nominatim
from geopy.distance import vincenty
nom = Nominatim()
chicago = nom.geocode("chicago")
dallas = nom.geocode("dallas")
chicago_gps = (chicago.latitude, chicago.longitude)
dallas_gps = (dallas.latitude, dallas.longitude)
distance = vincenty(chicago_gps, dallas_gps).km
print('Distance in kms: {}'.format(distance))
print(chicago.raw)
เอาท์พุท
Distance in kms: 1294.7623005649557
{'lat': '41.8755546', 'osm_id': '122604', 'boundingbox': ['41.643919', '42.0230219', '-87.940101', '-87.5239841'], 'licence': 'Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright', 'lon': '-87.6244212', 'place_id': '178038280', 'class': 'place', 'icon': 'https://nominatim.openstreetmap.org/images/mapicons/poi_place_city.p.20.png', 'osm_type': 'relation', 'importance': 0.29566190262222, 'display_name': 'Chicago, Cook County, Illinois, United States of America', 'type': 'city'}
ดังนั้นสำหรับแต่ละสถานที่ ฉันสามารถคำนวณระยะทางได้ ตอนนี้มีคำถามสองสามข้อ
- เป็นระยะทางของสายการบินหรือไม่? OSM ยังให้ระยะเวลาการเดินทางเหมือนกับที่ Google ทำหรือไม่
- ฉันจะขอเส้นทางได้อย่างไรหากฉันต้องการไปจาก "ชิคาโก" ถึง "ดัลลัส" แบบ google มีวิธีที่เราได้รับเส้นทางโดยตรงจาก OSM นอกเหนือจากการใช้ APIs MapQuest ฯลฯ หรือไม่
- เราจะใช้ Traffic Layer ในโมเดลของเราได้อย่างไร ฉันต้องการทรัพยากรที่ดีในเรื่องนั้น และหากมีการนำ Python ไปใช้ก็จะดีมาก