traveltime-dev / traveltime-python-sdk

TravelTime SDK for Python programming language
https://docs.traveltime.com/
MIT License
20 stars 5 forks source link

unreachable destinations #59

Closed SergeyAnufriev closed 1 year ago

SergeyAnufriev commented 1 year ago

Please explain why some locations can not be reached

from traveltimepy import TravelTimeSdk, PublicTransport, Property, Location, Coordinates import asyncio from datetime import datetime

home_location = Location(id='47', coords=Coordinates(lat=52.590357, lng=-1.808594))

not_reachable = [Location(id='x1', coords=Coordinates(lat=53.022800, lng=-2.601700)), Location(id='x2', coords=Coordinates(lat=52.361301, lng=-0.120953)), Location(id='x3', coords=Coordinates(lat=50.436962, lng=-4.259314)), Location(id='x4', coords=Coordinates(lat=52.361301, lng=-0.120953))]

locations = [home_location] + not_reachable search_ids = {'47': ['x1', 'x2', 'x3', 'x4']}

async def main():

results = await sdk.time_filter_async(
locations=locations,
search_ids=search_ids,
transportation=PublicTransport(),
properties=[Property.TRAVEL_TIME, Property.FARES],
departure_time=datetime.now(),
travel_time=14400)
print(results)

asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) asyncio.run(main())

program output:

[TimeFilterResult(search_id='47', locations=[], unreachable=['x1', 'x2', 'x3', 'x4'])]

Process finished with exit code 0

danielnaumau commented 1 year ago

Because some locations cannot be reached with the specified transportation type and travel time. If you change public transport to driving, most of them will become reachable.

danielnaumau commented 1 year ago

Plus I strongly recommend not to leave API keys in a public repository.