from pathlib import Path

from flandre.utils.RfMeta import RfFrameMeta, RfSequenceMeta
from flandre.utils.archive import to_zip

if __name__ == '__main__':
    # rr = RfSequenceMeta
    tempdst = Path('/mnt/16T/private_dataset/ustemp')
    arr = []
    for (i,
         file) in enumerate(Path('/mnt/16T/private_dataset/New Folder/steel-top/').glob('*pwi.bin')):
        file = Path(file)
        x, y, _ = file.name.split('_')
        r = RfFrameMeta(encoder=0, robot_x=int(x) * 100, robot_y=int(y) * 100)
        arr.append((file, r))
    arr.sort(key=lambda item: (item[1].robot_y, item[1].robot_x))

    arg = []

    for i, item in enumerate(arr):
        file, meta = item
        meta.sequence_id = i
        print(file.name, meta.sequence_id, meta.robot_x, meta.robot_y)
        pic = file.with_suffix('.png')
        farr = []
        if pic.exists():
            farr.append((pic, '.png'))
        arg.append((file, meta, farr))

    to_zip(arg, tempdst, Path('/mnt/16T/private_dataset/us/steel-top,U=30,M=PWI,S=(256 1502).zip'))
