# automatically generated by the FlatBuffers compiler, do not modify

# namespace: FlatGeobuf

import flatbuffers
from flatbuffers.compat import import_numpy
from typing import Any
from typing import Optional
np = import_numpy()

class Geometry(object):
    __slots__ = ['_tab']

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

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

    # Geometry
    def Ends(self, j: int):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Uint32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
        return 0

    # Geometry
    def EndsAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint32Flags, o)
        return 0

    # Geometry
    def EndsLength(self) -> int:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Geometry
    def EndsIsNone(self) -> bool:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        return o == 0

    # Geometry
    def Xy(self, j: int):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        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

    # Geometry
    def XyAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float64Flags, o)
        return 0

    # Geometry
    def XyLength(self) -> int:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Geometry
    def XyIsNone(self) -> bool:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        return o == 0

    # Geometry
    def Z(self, j: int):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        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

    # Geometry
    def ZAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float64Flags, o)
        return 0

    # Geometry
    def ZLength(self) -> int:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Geometry
    def ZIsNone(self) -> bool:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        return o == 0

    # Geometry
    def M(self, j: int):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        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

    # Geometry
    def MAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float64Flags, o)
        return 0

    # Geometry
    def MLength(self) -> int:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Geometry
    def MIsNone(self) -> bool:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        return o == 0

    # Geometry
    def T(self, j: int):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        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

    # Geometry
    def TAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float64Flags, o)
        return 0

    # Geometry
    def TLength(self) -> int:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Geometry
    def TIsNone(self) -> bool:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        return o == 0

    # Geometry
    def Tm(self, j: int):
        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.Uint64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
        return 0

    # Geometry
    def TmAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint64Flags, o)
        return 0

    # Geometry
    def TmLength(self) -> int:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Geometry
    def TmIsNone(self) -> bool:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        return o == 0

    # Geometry
    def Type(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

    # Geometry
    def Parts(self, j: int) -> Optional['Geometry']:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            obj = Geometry()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Geometry
    def PartsLength(self) -> int:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Geometry
    def PartsIsNone(self) -> bool:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        return o == 0

def GeometryStart(builder: flatbuffers.Builder):
    builder.StartObject(8)

def Start(builder: flatbuffers.Builder):
    GeometryStart(builder)

def GeometryAddEnds(builder: flatbuffers.Builder, ends: int):
    builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(ends), 0)

def AddEnds(builder: flatbuffers.Builder, ends: int):
    GeometryAddEnds(builder, ends)

def GeometryStartEndsVector(builder, numElems: int) -> int:
    return builder.StartVector(4, numElems, 4)

def StartEndsVector(builder, numElems: int) -> int:
    return GeometryStartEndsVector(builder, numElems)

def GeometryAddXy(builder: flatbuffers.Builder, xy: int):
    builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(xy), 0)

def AddXy(builder: flatbuffers.Builder, xy: int):
    GeometryAddXy(builder, xy)

def GeometryStartXyVector(builder, numElems: int) -> int:
    return builder.StartVector(8, numElems, 8)

def StartXyVector(builder, numElems: int) -> int:
    return GeometryStartXyVector(builder, numElems)

def GeometryAddZ(builder: flatbuffers.Builder, z: int):
    builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(z), 0)

def AddZ(builder: flatbuffers.Builder, z: int):
    GeometryAddZ(builder, z)

def GeometryStartZVector(builder, numElems: int) -> int:
    return builder.StartVector(8, numElems, 8)

def StartZVector(builder, numElems: int) -> int:
    return GeometryStartZVector(builder, numElems)

def GeometryAddM(builder: flatbuffers.Builder, m: int):
    builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(m), 0)

def AddM(builder: flatbuffers.Builder, m: int):
    GeometryAddM(builder, m)

def GeometryStartMVector(builder, numElems: int) -> int:
    return builder.StartVector(8, numElems, 8)

def StartMVector(builder, numElems: int) -> int:
    return GeometryStartMVector(builder, numElems)

def GeometryAddT(builder: flatbuffers.Builder, t: int):
    builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(t), 0)

def AddT(builder: flatbuffers.Builder, t: int):
    GeometryAddT(builder, t)

def GeometryStartTVector(builder, numElems: int) -> int:
    return builder.StartVector(8, numElems, 8)

def StartTVector(builder, numElems: int) -> int:
    return GeometryStartTVector(builder, numElems)

def GeometryAddTm(builder: flatbuffers.Builder, tm: int):
    builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(tm), 0)

def AddTm(builder: flatbuffers.Builder, tm: int):
    GeometryAddTm(builder, tm)

def GeometryStartTmVector(builder, numElems: int) -> int:
    return builder.StartVector(8, numElems, 8)

def StartTmVector(builder, numElems: int) -> int:
    return GeometryStartTmVector(builder, numElems)

def GeometryAddType(builder: flatbuffers.Builder, type: int):
    builder.PrependUint8Slot(6, type, 0)

def AddType(builder: flatbuffers.Builder, type: int):
    GeometryAddType(builder, type)

def GeometryAddParts(builder: flatbuffers.Builder, parts: int):
    builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(parts), 0)

def AddParts(builder: flatbuffers.Builder, parts: int):
    GeometryAddParts(builder, parts)

def GeometryStartPartsVector(builder, numElems: int) -> int:
    return builder.StartVector(4, numElems, 4)

def StartPartsVector(builder, numElems: int) -> int:
    return GeometryStartPartsVector(builder, numElems)

def GeometryEnd(builder: flatbuffers.Builder) -> int:
    return builder.EndObject()

def End(builder: flatbuffers.Builder) -> int:
    return GeometryEnd(builder)
