tools package
Submodules
tools.location_tools module
- tools.location_tools.bounding_box(latitude: tuple[float, float], longitude: tuple[float, float]) str
Convert longitude and latitude to a string formatted as: “boundingBox={longitude[0]},{latitude[0]},{longitude[1]},{latitude[1]}” This conforms to the open Bus services API specifications: Bounding Box: Limit results to bus location data with vehicle position within the rectangular bounding box you set using co-ordinates: minLongitude, minLatitude, maxLongitude, maxLatitude.
- Args:
latitude (tuple[float, float]): The minimum and maximum latitudes of the box longitude (tuple[float, float]): The minimum and maximum longitudes of the box
- tools.location_tools.get_base_url(api_key=None, bus_data_url='https://data.bus-data.dft.gov.uk/api/v1/datafeed', **kwargs)
Gets the base URL of the Open Bus data API including the api key.
- Args:
api_key (APIKey): The API key. bus_data_url (str): The base URL of the bus data API.
Returns: Base URL for accessing the Open Bus data API using the API key.
- tools.location_tools.get_location_url(min_latitude: float, min_longitude: float, max_latitude: float, max_longitude: float, **kwargs)
Constructs the URL for accessing the location data from Open Bus data API.
- Args:
min_latitude (float): Minimum latitude of the area min_longitude (float): Minimum longitude of the area max_latitude (float): Maximum latitude of the area max_longitude (float): Maximum longitude of the area
Returns: URL for accessing the location data from Open Bus data API.
tools.output module
- tools.output.api_output(feed_url: str, get_fn=<function get_request>) bytes
Returns the content of a URL
- Args:
feed_url (str): Lookup URL
Returns: Content of URL in bytes
- tools.output.get_request(url: str)
tools.printer module
tools.version module
- tools.version.version_str() str
Gets the version of Open-Bus API from its metadata.
Returns: Version string