30 lines
726 B
Python
30 lines
726 B
Python
"""Data models for journey times processing."""
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
@dataclass
|
|
class Destination:
|
|
"""A destination point for journey planning."""
|
|
|
|
lat: float
|
|
lon: float
|
|
name: str
|
|
naptan_id: str | None = None
|
|
|
|
def to_tfl_location(self) -> str:
|
|
"""Convert to TfL API location string."""
|
|
if self.naptan_id:
|
|
return self.naptan_id
|
|
return f"{self.lat},{self.lon}"
|
|
|
|
|
|
@dataclass
|
|
class JourneyResult:
|
|
"""Result of a journey time calculation for a postcode."""
|
|
|
|
postcode: str
|
|
public_transport_easy_minutes: int | None = None
|
|
cycling_minutes: int | None = None
|
|
public_transport_quick_minutes: int | None = None
|
|
error: str | None = None
|