# automatically generated by the FlatBuffers compiler, do not modify

# namespace: foxglove

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

# A navigation satellite fix for any Global Navigation Satellite System
class LocationFix(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = LocationFix()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsLocationFix(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # LocationFix
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # Timestamp of the message
    # LocationFix
    def Timestamp(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = o + self._tab.Pos
            from .Time import Time
            obj = Time()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Frame for the sensor. Latitude and longitude readings are at the origin of the frame.
    # LocationFix
    def FrameId(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # Latitude in degrees
    # LocationFix
    def Latitude(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
        return 0.0

    # Longitude in degrees
    # LocationFix
    def Longitude(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
        return 0.0

    # Altitude in meters
    # LocationFix
    def Altitude(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
        return 0.0

    # Position covariance (m^2) defined relative to a tangential plane through the reported position. The components are East, North, and Up (ENU), in row-major order.
    # length 9
    # LocationFix
    def PositionCovariance(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Float64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
        return 0

    # LocationFix
    def PositionCovarianceAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float64Flags, o)
        return 0

    # LocationFix
    def PositionCovarianceLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # LocationFix
    def PositionCovarianceIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        return o == 0

    # If `position_covariance` is available, `position_covariance_type` must be set to indicate the type of covariance.
    # LocationFix
    def PositionCovarianceType(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
        return 0

def LocationFixStart(builder): builder.StartObject(7)
def Start(builder):
    return LocationFixStart(builder)
def LocationFixAddTimestamp(builder, timestamp): builder.PrependStructSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(timestamp), 0)
def AddTimestamp(builder, timestamp):
    return LocationFixAddTimestamp(builder, timestamp)
def LocationFixAddFrameId(builder, frameId): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(frameId), 0)
def AddFrameId(builder, frameId):
    return LocationFixAddFrameId(builder, frameId)
def LocationFixAddLatitude(builder, latitude): builder.PrependFloat64Slot(2, latitude, 0.0)
def AddLatitude(builder, latitude):
    return LocationFixAddLatitude(builder, latitude)
def LocationFixAddLongitude(builder, longitude): builder.PrependFloat64Slot(3, longitude, 0.0)
def AddLongitude(builder, longitude):
    return LocationFixAddLongitude(builder, longitude)
def LocationFixAddAltitude(builder, altitude): builder.PrependFloat64Slot(4, altitude, 0.0)
def AddAltitude(builder, altitude):
    return LocationFixAddAltitude(builder, altitude)
def LocationFixAddPositionCovariance(builder, positionCovariance): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(positionCovariance), 0)
def AddPositionCovariance(builder, positionCovariance):
    return LocationFixAddPositionCovariance(builder, positionCovariance)
def LocationFixStartPositionCovarianceVector(builder, numElems): return builder.StartVector(8, numElems, 8)
def StartPositionCovarianceVector(builder, numElems):
    return LocationFixStartPositionCovarianceVector(builder, numElems)
def LocationFixAddPositionCovarianceType(builder, positionCovarianceType): builder.PrependUint8Slot(6, positionCovarianceType, 0)
def AddPositionCovarianceType(builder, positionCovarianceType):
    return LocationFixAddPositionCovarianceType(builder, positionCovarianceType)
def LocationFixEnd(builder): return builder.EndObject()
def End(builder):
    return LocationFixEnd(builder)