function draw_atlas2d(atlas, do_draw_map_cov, do_draw_map_ids, rot_angle)

if nargin < 4, rot_angle = 0; end
if nargin < 3, do_draw_map_ids = 0; end
if nargin < 2, do_draw_map_cov = 0; end

num_m = length(atlas.map);

colors = jet(num_m);
if num_m == 1
    colors = [0 0 1];
end
if 1
    rand('state',num_m);
    colors = rand(num_m,3);
end

Tvg = eye(3);
%Tvg = config2mat([0 0 (90-17)/180*pi]');
%Tvg = config2mat([0 0 (-14)/180*pi]');
Tvg = config2mat([0 0 rot_angle]');
%Tvg = inv(atlas.Tab(:,:,1,1));

held = ishold; 
Xr = zeros(2,num_m);
for i=1:num_m
    Tg = atlas.Tab(:,:,i,i);
    Tg = Tvg*Tg;
    lm = transfer_map(Tg,atlas.map(i));
   
    draw_localmap(lm, colors(i,:));
    hold on;
    
    if (do_draw_map_ids)
        x = Tg(1,3)+1*randn(1);
        y = Tg(2,3)+1*randn(1);
        text(x,y,num2str(i));
    end
    
    if (do_draw_map_cov)
        draw_configcov(Tg, atlas.Cab(:,:,i,i), 'r-');
    end
    
    if 1
        % draw adjacent links
        j = find(atlas.Adj(i,:));
        nj = length(j);
        X = zeros(3,2*nj);
        X(1:2,2:2:end) = reshape(atlas.Tab(1:2,3,i,j), [2 nj]);
        X(3,:)=1;
        X = Tg*X;
        g = find(atlas.Adj(i,j)>1); g=[2*g-1; 2*g];
        b = find(atlas.Adj(i,j)==1); b = [2*b-1; 2*b];
        
        plot(X(1,g(:)),X(2,g(:)), 'color', [.5 .5 .5]);
        if ~isempty(b)
            plot(X(1,b(:)),X(2,b(:)), 'color', 'm');
        end
    end
    
    Xr(:,i) = atlas.Tab(1:2,3,i,i);
    
    if 1
        % draw tracks
        %find where tracks jump
        X = [atlas.map(i).track(2:3,:)];
        X(3,:) = 1;
        X = Tg*X;
        jumps = find(diff(atlas.map(i).track(1,:))> 2);
        if ~isempty(jumps), X(:,jumps) = nan; end
        plot(X(1,:),X(2,:), 'color', colors(i,:));
    end
 
    if 0
        axis equal
        drawnow
    end
end


%gplot(atlas.Adj, Xr(1:2,:)', 'k');

axis equal
if (~held) hold off; end