function UR_display_flights_cor(corridors,flights)
% UR_display_flights_cor - display scheduled flights in corridors
% On input:
%     corridors (nx9 array): corridor data
%     flights (vector struct) flights in corridors
%       (k).flights (kx9 array)
% On output:
%     flights plot with x-axis as time and y-axis as corridor distance
%     [interactive: type in corridor number]
% Call:
%     UR_display_flights_cor(corridors,flights);
% Author:
%     T. Henderson
%     UU
%     Summer 2019
%

clf
hold on

num_cor = length(corridors(:,1));
min_times = Inf*ones(num_cor,1);
max_times = zeros(num_cor,1);
dists = zeros(num_cor,1);
for c = 1:num_cor
    dists(c) = norm(corridors(c,4:6)-corridors(c,1:3));
    c_flights = flights(c).flights;
    if ~isempty(c_flights)
        for f = 1:length(c_flights(:,1))
            if c_flights(f,2)>max_times(c)
                max_times(c) = c_flights(f,2);
            end
            if c_flights(f,1)<min_times(c)
                min_times(c) = c_flights(f,1);
            end
        end
    else
        min_times(c) = 0;
    end
end

c = input('Corridor: ');
while c>0&c<=num_cor
    clf
    hold on
    c_flights = flights(c).flights;
%    subplot(num_cor,1,c);
    plot([min_times(c),max_times(c)],[0,0],'k');
    plot([min_times(c),min_times(c)],[0,dists(c)],'k');
    plot([min_times(c),max_times(c)],[dists(c),dists(c)],'k');
    plot([max_times(c),max_times(c)],[dists(c),0],'k');
    if ~isempty(c_flights)
        for f = 1:length(c_flights(:,1))
            pt1 = [c_flights(f,1),0];
            pt2 = [c_flights(f,2),dists(c)];
            plot([pt1(1),pt2(1)],[pt1(2),pt2(2)],'b');
        end
    end
    c = input('Corridor: ');
end
