from typing import Any, List
from numpy.linalg import norm

from numpy.typing import ArrayLike
from pandas import NA

from spatz.dataset import ArrayLike, Dataset
from spatz.logger import ArrayLike, Logger
from spatz.sensors import Sensor
from spatz.transforms import Transform

# WG84 googlen (world model GPS)
       


class GPS(Sensor):
    def __init__(self, dataset: Dataset, logger: Logger, transforms: List[Transform] = []):
        """GPS Module which provides the following information:
        - Longitude (in °)
        - Latitiude (in °)
        - Altitude (in m)
        """
        super().__init__(dataset, logger, transforms)

    def _get_data(self) -> ArrayLike:
        vel = norm(self._dataset.get_velocity())

        # TODO: At which speed do we assume that GPS becomes unreliable?
        if vel / self._dataset.get_mach_number() > 1:
            return NA
        
        x = self._dataset.fetch_values(['latitude', 'longitude', 'altitude'])
        x = self._sensor_specific_effects(x)

        return x
