from dataclasses import dataclass
from datetime import datetime
import geopy.distance


@dataclass
class DAF:
    """
    "Datenaufzeichnung für automatisiertes Fahren" (DAF), see 2021_DSE_Exercise_V1.0_Final.pdf page 7
    """

    vehicle_identification_number: str
    gps_location: geopy.Point
    velocity: float
    near_crash_event: bool
    timestamp: datetime

    def to_dict(self):
        return {'vehicle_identification_number': self.vehicle_identification_number,
                'gps_location': {'latitude': self.gps_location.latitude,
                                 'longitude': self.gps_location.longitude
                                 },
                'velocity': self.velocity,
                'near_crash_event': self.near_crash_event,
                'timestamp': self.timestamp.timestamp()
                }
