% loadPositionFile.m

function [key, posData] = loadPositionFile( parameters )

disp('Loading position file.');

%% Don't process if we are reloading file. 
if ( parameters.reloadFile )  
  load ( 'analyzePosData.mat' );
  return;
end

%% Select the type of data file to use 
if ( parameters.posRecType == 29 )  
  posFileName = 'rec29.txt';
  rec29key;
else
  posFileName = 'rec11.txt';
  rec11key;
end

% If we are using an extracted file, overwrite the default file names.
if ( parameters.useExtractedFile )
  posFileName = parameters.fileName; 
end

posData = load (posFileName);
clear posFileName; 

%% Save the data file for future reload
if ( parameters.saveMatFile )
  save ( 'analyzePosData.mat' );
end

return;

