% 
% Select segments of various fix modes and types. 
% 

function [ segments, statistics ] = ...
    selectSegments( posData, key, parameters, statistics )

fixtype = posData(:,key.FIXTYPE);

segAuto = find( fixtype == 0 );
segDGPS = find( (fixtype == 1) | (fixtype == 2) );
segRtkFloat = find( (fixtype == 3) | (fixtype == 5) );
segRtkFix = find( (fixtype == 4) | (fixtype == 6) );
segOmni = find( fixtype == 7 );

% Generate Segments
segments.segList = {segAuto, segDGPS, segOmni, segRtkFloat, segRtkFix}; 
segments.segColor = {'b', 'm', 'k', 'c', 'r'};
segments.colorKey = 'auto=b, dgps=m, omni=k, rtkflt=c, rtkfix=r'; 
segments.segNames = {'Autonomous', 'DGPS', 'OmniStar', 'RTK Float' ...
                    'RTK Fixed'}; 
% Generate Statistics

statistics.epochs = length(fixtype);
for idx = 1:length(segments.segList)
  statistics.epochsBySeg(idx) = length(segments.segList{idx}); 
end
statistics.posTypeBySeg = segments.segNames; 

end