from typing import Annotated
import typer
from pathlib import Path
from .bag import BagNav
from .interactive_b_spline import InteractiveCurve

app = typer.Typer(invoke_without_command=True)

@app.command(name='interact')
def interact(
        bag_path: Annotated[Path, typer.Argument()] = None,
        origin_lat: Annotated[float, typer.Option()] = 40,
        origin_lon: Annotated[float, typer.Option()] = 116,
        origin_alt: Annotated[float, typer.Option()] = 0,
):
    bag = BagNav(origin_lat, origin_lon, origin_alt, bag_path)
    interactive = InteractiveCurve(4, 100, bag.enus)
    try:
        bag.save_to_bag(interactive.spline_curve.evalpts)
    except ValueError:
        pass

if __name__ == '__main__':
    app()
