traveltime-dev / traveltime-python-sdk

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

Support for combined transport types (Cycling + Ferry and Cycling + Public Transport) in TravelTime API POST request #85

Closed sampeters1 closed 10 months ago

sampeters1 commented 10 months ago

I'm generating isochrones via a POST request to the TravelTime API and want to set transportation to Cycling + Ferry and Cycling + Public Transport. However, it seems I can only select one from PublicTransport, Driving, Ferry, Walking, Cycling, or DrivingTrain.

Is there no support for these combined transport types in a Python POST request?

arnasbr commented 10 months ago

Cycling + Ferry is already present under the Ferry transportation type, example:

    results = await sdk.time_map_geojson_async(
        coordinates=[Coordinates(lat=41.507609, lng=-0.128315)],
        departure_time=datetime.now(),
        transportation=Ferry(type="cycling+ferry"),
    )

Same applies to Driving + Ferry or simply Ferry image

Currently in the process of adding support for Cycling + Public Transport

sampeters1 commented 10 months ago

Thanks for clarifying!

arnasbr commented 10 months ago

Support for Cycling + Public Transport added. Will update to newest release shortly.

sampeters1 commented 10 months ago

Under which Class is Cycling + Public Transport present?

Cycling(type="cycling+public_transport") gives

ValidationError: 1 validation error for Cycling type unexpected value; permitted: 'cycling' (type=value_error.const; given=cycling+public_transport; permitted=('cycling',))

while PublicTransport(type="cycling+public_transport") results in

ValidationError: 1 validation error for PublicTransport type unexpected value; permitted: 'public_transport', 'train', 'bus', 'coach' (type=value_error.const; given=cycling+public_transport; permitted=('public_transport', 'train', 'bus', 'coach'))

I'm using traveltimepy version 3.7.0.

arnasbr commented 10 months ago

@sampeters1 Sorry for the late reply.

https://github.com/traveltime-dev/traveltime-python-sdk/blob/master/traveltimepy/dto/transportation.py

You are getting this error, because cycling+public_transport is not implemented under the PublicTransport or Cycling class.

cycling+public_transport has it's own separate class (see the picture or the code itself):

image

to use it, instead of PublicTransport(type="cycling+public_transport") or Cycling(type="cycling+public_transport"), you would simply do CyclingPublicTransport().

TLDR; It's under a separate CyclingPublicTransport() class

Let me know if you have any more questions!