import json
import random
import pandas as pd
from geoplotlib.utils import haversine

with open("../paths/endpointsWGS84.json", 'r') as file:
	endpoints = json.load(file)["features"]

tugs = pd.read_excel("../20230405_Tugs.xlsx", dtype={"MMSI": str})

tugss = []
times = []
route_src = []
route_tgt = []
tasks = []
T = 0
for i in range(100):
	src = random.choice(endpoints)
	tgt = random.choice(endpoints)
	d = haversine(src["geometry"]["x"], src["geometry"]["y"], tgt["geometry"]["x"], tgt["geometry"]["y"])
	T += d / random.normalvariate(5, 3)
	tugss.append(random.choice(tugs["MMSI"]))
	times.append(T)
	route_src.append(src["attributes"]["NUMMER"])
	route_tgt.append(tgt["attributes"]["NUMMER"])
	tasks.append(random.choice(["tugging", "sailing"]))

res = pd.DataFrame(data={"mmsi": tugss, "start": times, "source": route_src, "target": route_tgt, "task": tasks})
res.to_csv("plan.csv", index=False)