function path = LEM_interactive_map(aEB)
% interactive = allows to pick launch and land sites
% on input: 
%   aEB (vector struct): roads information
% on output:
%   path (vector struct): A list of nodes of the shortest path. 
% call
%   path = LEM_interactive_map(aEB);
% Author
%   Vista Marston
%   UU
%   Winter 2020


% Display figure
clf;
LEM_show_roads(aEB)

% Variables needed
launchNumber = 1;
landNumber = 1;
vertexes = aEB.lane_vertexes;
%vertexes = aEB.vertexes;

% Launch Sites
pause(10);
mouseClick = get(gca, 'CurrentPoint');
x = mouseClick(1, 1);
y = mouseClick(1, 2);
disp("X position: " + num2str(x) + ", Y position " + num2str(y));

% Assign shortest Path to first launching site
delt_x = x - vertexes(1, 1);
delt_y = y - vertexes(1, 2);
shorestPoint = sqrt((delt_x)^2 + (delt_y)^2);

% Finds the closest Launching site
for index = 2:length(vertexes)
    % Access the Coordinates Points of launching sites
    launch_x = vertexes(index, 1);
    launch_y = vertexes(index, 2);
    delt_x = launch_x - x;
    delt_y = launch_y - y;
    checkPoint = sqrt((delt_x)^2 + (delt_y)^2);
    if checkPoint < shorestPoint
        shorestPoint = checkPoint;
        launchNumber = index;
    end
end
disp("Launch Node " + launchNumber);

% Land Sites
pause(5);
mouseClick = get(gca, 'CurrentPoint');
x = mouseClick(1, 1);
y = mouseClick(1, 2);
disp("X position: " + num2str(x) + ", Y position " + num2str(y));
delt_x = x - vertexes(1,1);
delt_y = y - vertexes(1, 2);
shorestPoint = sqrt((delt_x)^2 + (delt_y)^2);

% Finds the closest Landing site
for index = 2:length(vertexes)
    % Access the Coordinates Points of launching sites
    land_x = vertexes(index, 1);
    land_y = vertexes(index, 2);
    delt_x = land_x - x;
    delt_y = land_y - y;
    checkPoint = sqrt((delt_x)^2 + (delt_y)^2);
    if checkPoint < shorestPoint
        shorestPoint = checkPoint;
        landNumber = index;
    end
end
disp("Land Node " + landNumber);

[path1, d] = shortestpath(aEB.G,launchNumber,landNumber);
LEM_show_path(aEB, path1, 'r', 4);
path = path1;