import argparse
import os
from gps_transformer.transformer import transform_lat_lon

def main():
    parser = argparse.ArgumentParser(description="Transform GPS log files.")
    parser.add_argument("folder", type=str, help="Path to the folder containing log files")
    parser.add_argument("new_lat", type=float, help="New latitude value")
    parser.add_argument("new_lon", type=float, help="New longitude value")

    args = parser.parse_args()

    folder = args.folder
    new_lat = args.new_lat
    new_lon = args.new_lon

    if not os.path.exists(folder):
        print("Error: Folder does not exist.")
        return

    files = [f for f in os.listdir(folder) if f.endswith(".log")]

    if not files:
        print("No log files found in the folder.")
        return

    output_folder = os.path.join(folder, "output")
    os.makedirs(output_folder, exist_ok=True)

    for file in files:
        file_path = os.path.join(folder, file)
        transform_lat_lon(file_path, new_lat, new_lon, output_folder)

if __name__ == "__main__":
    main()
