function astHelperVisualization(long,lat,longFix,latFix,plotType)
% ASTHELPERVISUALIZATION This helper function that supports the Celestial
% Navigation Example. It uses as inputs the waypoints and the solution
% obtained from sight reduction.

% Copyright 2012-2017 The MathWorks, Inc.

switch plotType
    case 'Map'
        % This part of the code is executed if the Mapping Toolbox(TM) is
        % available.
        
        % Open Map figure.
        figure
        
        % Load coastal data for America and the French Polynesia.
        load('astKonTikiLandAreas','landAreas')
        
        % Set the figure parameters so that geoshow plot the correct land
        % areas with mercator projection.
        axesm('mercator','MapLatLimit',[-20 20],'MapLonLimit',[-150 -70], ...
            'ParallelLabel','on','MeridianLabel','on','Frame','on')
        
        % Plot land areas.
        geoshow(landAreas,'FaceColor',[1 1 .5],'EdgeColor',[.6 .6 .6]);
        
        % Plot actual latitude and latitude.
        geoshow(lat,long)
        
        % Plot latitude and longitude solutions.
        geoshow(latFix,longFix,'Color','g')
        
        % Plot grid.
        gridm('MLineLimit',[20 -20],'MLineLocation',5,'PlineLimit',[-70 -150],...
            'PLineLocation',5,'FontSize',8)   
        
    case 'Plot'
        % This part of the code uses MATLAB native code.
        
        % Set up date axis.
        startDate = datenum(1947,4,28);
        endDate = startDate+length(lat)-1;
        dateVector = startDate:1:endDate;
        numDateTicks = 10;
        hXTick = startDate:((endDate-startDate)/(numDateTicks-1)):endDate;
        hXTickLabel = datestr(hXTick,'mm/dd');
        
        % Open latitude/longitude figure.
        figure
        
        % Plot actual latitude/longitude and solutions.
        plot(long,lat,'x-',longFix,latFix,'o-r')
        grid on
        axis equal
        xlabel('Longitude (deg)')
        ylabel('Latitude (deg)')
        legend('Track','Reduction Solution')
        
        % Open relative error figure.
        figure
        
        % Plot longitude relative error.
        subplot(211)
        plot(dateVector,longFix-long)
        set(gca,'XtickMode','manual');
        set(gca,'XTick',hXTick,'XTickLabel',hXTickLabel);
%         datetick('x',6)
        axis('tight')
        grid on
        ylabel('Error in Longitude (deg)')
        title('Relative error in Latitude and Longitude')
        
        % Plot latitude error
        subplot(212)
        plot(dateVector,latFix-lat)
        set(gca,'XtickMode','manual');
        set(gca,'XTick',hXTick,'XTickLabel',hXTickLabel);
%         datetick('x',6)
        axis('tight')
        grid on
        xlabel('Date [mm/dd]')
        ylabel('Error in Latitude (deg)')
end

%[EOF]
