def test_scooter_route(): """Test routing API for scooter route.""" ls = LS(api_key=LS_API_KEY) _ = ls.scooter_route( origin=[52.51375, 13.42462], destination=[52.52332, 13.42800], via=[(52.52426, 13.43000)], return_results=[ROUTING_RETURN.polyline, ROUTING_RETURN.elevation], departure_time=datetime.now(), spans=[ROUTING_SPANS.names], )
def test_scooter_route(): """Test routing API for scooter route.""" ls = LS(api_key=LS_API_KEY) scooter = Scooter(allow_highway=True) _ = ls.scooter_route( origin=[52.51375, 13.42462], destination=[52.52332, 13.42800], via=[(52.52426, 13.43000)], return_results=[ROUTING_RETURN.polyline, ROUTING_RETURN.elevation], departure_time=datetime.now(), spans=[ROUTING_SPANS.names], scooter=scooter, exclude=["IND", "NZL", "AUS"], )
def route( ctx, transport_mode, origin, destination, via, routing_mode, alternatives, lang, apikey, raw, display, ): """ find route between two or more locations. """ apikey = apikey or os.environ.get("HERE_APIKEY") if apikey is None: raise ApiKeyNotFoundError( "Please pass HERE API KEY as --apikey or set it as environment " "variable in HERE_APIKEY " ) ctx.obj["apikey"] = apikey ls = LS(api_key=apikey) if transport_mode == "car": result = ls.car_route( origin=origin.split(","), destination=destination.split(","), via=via if via else None, routing_mode=routing_mode, alternatives=alternatives, lang=lang, return_results=[ ROUTING_RETURN.polyline, ROUTING_RETURN.elevation, ROUTING_RETURN.instructions, ROUTING_RETURN.actions, ], ) elif transport_mode == "truck": result = ls.truck_route( origin=origin.split(","), destination=destination.split(","), via=via if via else None, routing_mode=routing_mode, alternatives=alternatives, lang=lang, return_results=[ ROUTING_RETURN.polyline, ROUTING_RETURN.elevation, ROUTING_RETURN.instructions, ROUTING_RETURN.actions, ], ) elif transport_mode == "pedestrian": result = ls.pedestrian_route( origin=origin.split(","), destination=destination.split(","), via=via if via else None, routing_mode=routing_mode, alternatives=alternatives, lang=lang, return_results=[ ROUTING_RETURN.polyline, ROUTING_RETURN.elevation, ROUTING_RETURN.instructions, ROUTING_RETURN.actions, ], ) elif transport_mode == "bicycle": result = ls.bicycle_route( origin=origin.split(","), destination=destination.split(","), via=via if via else None, routing_mode=routing_mode, alternatives=alternatives, lang=lang, return_results=[ ROUTING_RETURN.polyline, ROUTING_RETURN.elevation, ROUTING_RETURN.instructions, ROUTING_RETURN.actions, ], ) elif transport_mode == "scooter": result = ls.scooter_route( origin=origin.split(","), destination=destination.split(","), via=via if via else None, routing_mode=routing_mode, alternatives=alternatives, lang=lang, return_results=[ ROUTING_RETURN.polyline, ROUTING_RETURN.elevation, ROUTING_RETURN.instructions, ROUTING_RETURN.actions, ], ) if raw: click.secho(json.dumps(result.response, indent=2), fg="green") elif display: geo_display(json.dumps(result.to_geojson(), indent=2)) else: click.secho(json.dumps(result.routes, indent=2), fg="green")