function [scatterHandle, textHandles] = plotTimeDivergenceToGpsPositions(pAxesHandle, pTrajectory, pColor, pPlotAsMap)
%PLOTTRAJECTORYSURFACEPOSITIONS Summary of this function goes here
%   Detailed explanation goes here

%% Get required data
x = pTrajectory.timeDivergenceToGps.longitude;
y = pTrajectory.timeDivergenceToGps.latitude;
dates = pTrajectory.timeDivergenceToGps.date;

%% Hold axes

% make handle the current axes
axes(pAxesHandle);

hold(pAxesHandle, 'on');

if pPlotAsMap
    scatterHandle = scatterm( ...
        pAxesHandle, ...
        y, ...
        x, ...
        50, ...
        pColor, ...
        'filled' ...
    );
else
    scatterHandle = scatter( ...
        pAxesHandle, ...
        x, ...
        y, ...
        50, ...
        pColor, ...
        'filled' ...
    );
end

t = artoa.convert.rd2dmy(dates);
textHandles = cell(1, length(t));
if pPlotAsMap
    for i = 1:length(x)
        textHandles{i} = textm( ...
            y(i), ...
            x(i), ...
            {' '; [num2str(t(i, 3)) '-' pad(num2str(t(i, 2)), 2, 'left', '0') '-' pad(num2str(t(i, 1)), 2, 'left', '0') ', ' num2str(dates(i))]}, ...
            'FontSize', 10, ...
            'Color', pColor ...
        );
    end
else
    for i = 1:length(x)
        textHandles{i} = text( ...
            x(i), ...
            y(i), ...
            {' '; [num2str(t(i, 3)) '-' pad(num2str(t(i, 2)), 2, 'left', '0') '-' pad(num2str(t(i, 1)), 2, 'left', '0') ', ' num2str(dates(i))]}, ...
            'FontSize', 10, ...
            'Color', pColor ...
        );
    end
end

%% Resume axes
hold(pAxesHandle, 'off');

end

