Skip to content

Trip

Solves the Traveling Salesman Problem using a greedy heuristic (farthest-insertion algorithm).

Examples:

>>> res = osrm_py.Trip(trip_params)

Parameters:

Name Type Description Default
trip_params TripParameters

TripParameters Object.

required

Returns:

Type Description
json

Raises:

Type Description
RuntimeError

On invalid TripParameters.

Source code in osrm/osrm_ext.pyi
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
def Trip(self, arg: TripParameters, /) -> Object:
    """
    Solves the Traveling Salesman Problem using a greedy heuristic (farthest-insertion algorithm).

    Examples:
                    >>> res = osrm_py.Trip(trip_params)

    Args:
                    trip_params (osrm.TripParameters): TripParameters Object.

    Returns:
                    (json): [A Trip JSON Response](https://project-osrm.org/docs/v5.24.0/api/#trip-service).

    Raises:
                    RuntimeError: On invalid TripParameters.
    """

Trip Parameters

Bases: RouteParameters

Source code in osrm/osrm_ext.pyi
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
def __init__(self) -> None:
    r"""
    Instantiates an instance of BaseParameters.

    Note:
                    This is the parent class to many parameter classes, and not intended to be used on its own.

    Args:
                    coordinates (list of floats pairs): Pairs of Longitude and Latitude Coordinates. (default [])
                    hints (list): Hint from previous request to derive position in street network. (default [])
                    radiuses (list of floats): Limits the search to given radius in meters. (default [])
                    bearings (list of int pairs): Limits the search to segments with given bearing in degrees towards true north in clockwise direction. (default [])
                    approaches (list): Keep waypoints on curb side. (default [])
                    generate_hints (bool): Adds a hint to the response which can be used in subsequent requests. (default True)
                    exclude (list of strings): Additive list of classes to avoid. (default [])
                    snapping (string 'default' | 'any'): 'default' snapping avoids is_startpoint edges, 'any' will snap to any edge in the graph. (default \'\')

    Returns:
                    __init__ (osrm.osrm_ext.BaseParameters): A BaseParameter object, that is the parent object to many other Parameter objects.
                    IsValid (bool): A bool value denoting validity of parameter values.

    Attributes:
                    coordinates (list of floats pairs): Pairs of longitude & latitude coordinates.
                    hints (list): Hint from previous request to derive position in street network.
                    radiuses (list of floats): Limits the search to given radius in meters.
                    bearings (list of int pairs): Limits the search to segments with given bearing in degrees towards true north in clockwise direction.
                    approaches (list): Keep waypoints on curb side.
                    exclude (list of strings): Additive list of classes to avoid, order does not matter.
                    format (string): Specifies response type - currently only 'json' is supported.
                    generate_hints (bool): Adds a hint to the response which can be used in subsequent requests.
                    skip_waypoints (list): Removes waypoints from the response.
                    snapping (string): 'default' snapping avoids is_startpoint edges, 'any' will snap to any edge in the graph.
    """