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.car_route( known_working_origin, known_working_destination, [ herepy.RouteMode[ROUTE_MODE_FASTEST], herepy.RouteMode[TRAVEL_MODE_CAR], herepy.RouteMode[TRAFFIC_MODE_DISABLED], ], ) except herepy.InvalidCredentialsError: return False return True
RoutingMetric, RoutingApiSpanField, ) routing_api = RoutingApi(api_key="api_key") # fetches a bicycle route between two points response = routing_api.bicycle_route( waypoint_a=[41.9798, -87.8801], waypoint_b=[41.9043, -87.9216] ) print(response.as_dict()) # fetches a driving route between two points response = routing_api.car_route( waypoint_a=[11.0, 12.0], waypoint_b=[22.0, 23.0], modes=[RouteMode.car, RouteMode.fastest], ) print(response.as_dict()) # fetches a pedastrian route between two points response = routing_api.pedastrian_route( waypoint_a=[11.0, 12.0], waypoint_b=[22.0, 23.0], modes=[RouteMode.pedestrian, RouteMode.fastest], ) print(response.as_dict()) # fetches a intermediate route from three points response = routing_api.intermediate_route( waypoint_a=[11.0, 12.0],
id_max = id_final for row in data_table: cur = connection.cursor() # fetches a bicycle route between two points response = routing_api.bicycle_route(waypoint_a=[row[1], row[2]], waypoint_b=[row[3], row[4]]) response = response.as_dict() distance_bic = response['response']['route'][0]['summary']['distance'] time_bic = response['response']['route'][0]['summary']['baseTime'] # print("bicycle",distance_bic) # print("bicycle",time_bic) # fetches a driving route between two points response = routing_api.car_route( waypoint_a=[row[1], row[2]], waypoint_b=[row[3], row[4]], modes=[RouteMode.car, RouteMode.fastest], ) response = response.as_dict() distance_car = response['response']['route'][0]['summary']['distance'] time_car = response['response']['route'][0]['summary']['baseTime'] # print("car",distance_car) # print("car",time_car) # fetches a pedastrian route between two points response = routing_api.pedastrian_route( waypoint_a=[row[1], row[2]], waypoint_b=[row[3], row[4]], modes=[RouteMode.pedestrian, RouteMode.fastest], ) response = response.as_dict()