function testMissPos(hMainFig)
%
% Test if there are missing lon/lat positions in the TSG time series
% If yes, display Warning message and propose to run Interpolation module
%
% Message only if missing positions can be filled by interpolation
% i.e. surrounded by valid positions
%
% Input
% -----
% hMainFig ............ Handel to the main user interface
%
% Function called by 'OpenMenuCallback' in tqgqc.m 
%
% $Id$

% Get the data from the application GUI
% -------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');

% Look for records with Good Latitude/Longitude
% ---------------------------------------------
iGPLat = find( isnan(tsg.LATX) == 0 );
iGPLon = find( isnan(tsg.LONX) == 0 );

% Look for records with No Latitude/Longitude
% -------------------------------------------
iNPLat = find( isnan(tsg.LATX) == 1 );
iNPLon = find( isnan(tsg.LONX) == 1 );


% Test if fillable missing positions
% ----------------------------------
if (~isempty(iNPLat) && ~isempty(iGPLat) && (sum(iNPLat>min(iGPLat) & iNPLat<max(iGPLat))>0))...
        | (~isempty(iNPLon) && ~isempty(iGPLon) && (sum(iNPLon>min(iGPLon) & iNPLon<max(iGPLon))>0))
    
    message = { 'WARNING: Missing positions are detected'; ' ';...
        'Use the interpolate function to fill them'};
    
    % Display the message box and blocks execution until the msgbox is deleted.
    % -------------------------------------------------------------------------
    hMsg1 = msgbox(message,'Missing positions','warn', 'modal');
    uiwait(hMsg1);
    
end

% Save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg);


end
