function atraj_out = LEM_schedule_artillery(model,airways,atraj,theta,...
    hd,t_max,reservations,v0,alt1,alt2)
%

g = 9.81;
DELAY = 1;

atraj_out = atraj;

[len_traj,~] = size(atraj);
t = atraj(1,4);
done = 0;
while done==0   % check this delay
    done = 1;
    for k = 1:len_traj  % check every trajectory point against 3 models
        lanes = [];
        Idx = cell2mat(rangesearch(model.kdt,atraj(k,1:3),hd));
        if ~isempty(Idx)
            lanes = unique(model.lane(Idx));
        end
        OK = 1;
        if ~isempty(lanes)  % if lane near enough
            num_lanes = length(lanes);
            OK = 1;
            for p = 1:num_lanes  % check flights through lane
                OK = LEM_lane_OK(reservations,airways,lanes(p),...
                    atraj(k,:),hd);
                if OK==0;
                    done = 0;
                    break
                end
            end
        end
    end
    if done==0
        t = t + DELAY;
    end
end
atraj_out(:,4) = atraj_out(:,4) + t;
