Exemplo n.º 1
0
def _are_valid_client_credentials(here_client: herepy.RoutingApi) -> bool:
    """Check if the provided credentials are correct using defaults."""
    known_working_origin = [38.9, -77.04833]
    known_working_destination = [39.0, -77.1]
    try:
        here_client.public_transport_timetable(
            known_working_origin,
            known_working_destination,
            True,
            [
                RouteMode[ROUTE_MODE_FASTEST],
                RouteMode[TRAVEL_MODE_CAR],
                RouteMode[TRAFFIC_MODE_ENABLED],
            ],
            arrival=None,
            departure="now",
        )
    except herepy.InvalidCredentialsError:
        return False
    return True
Exemplo n.º 2
0
print(response.as_dict())

# fetches a public transport route between two points
response = routing_api.public_transport(
    waypoint_a=[11.0, 12.0],
    waypoint_b=[15.0, 16.0],
    combine_change=True,
    modes=[RouteMode.publicTransport, RouteMode.fastest],
)
print(response.as_dict())

# fetches a public transport route between two points based on timetables
response = routing_api.public_transport_timetable(
    waypoint_a=[11.0, 12.0],
    waypoint_b=[15.0, 16.0],
    combine_change=True,
    modes=[RouteMode.publicTransport, RouteMode.fastest],
    departure="yyyy-mm-ddThh:mm:ss",
)
print(response.as_dict())

# calculates the fastest car route between two location
response = routing_api.location_near_motorway(
    waypoint_a=[11.0, 12.0],
    waypoint_b=[22.0, 23.0],
    modes=[RouteMode.car, RouteMode.fastest],
)
print(response.as_dict())

# calculates the fastest truck route between two location
response = routing_api.truck_route(