Skip to content
Snippets Groups Projects
plot_map.m 4.08 KiB
Newer Older
function plot_map(hTsgGUI, hPlotAxes)
% Function to plot the earth map and ship trackline
%
% Input
% -----
% hTsgGUI ............ Handel to the main user interface
% hPlotAxes .......... Handels to the graphic axes
%
% Output
% ------
%
% Library : 'M_MAP'
% note that a decimal degree notation is used, so that a longitude of 120�
% PROBLEM NOT YET RESOLVED
%    Does M_MAP use 0-360� or -180�-180� covention ?
%
% $Id$

% Retrieve named application data
% -------------------------------
tsg = getappdata( hTsgGUI, 'tsg_data');

% Get the Geographic limit of the TSG time series
% -----------------------------------------------
dateLim = get(hPlotAxes(1), 'Xlim');
ind = find( tsg.DAYD >= dateLim(1) & tsg.DAYD <= dateLim(2));

if ~isempty( ind )
  latMin = min( tsg.LATX(ind) );
  if latMin < -90
    latMin = -90;
  end
  latMax = max( tsg.LATX(ind) );
  if latMax > 90
    latMax = 90;
  end
  lonMin = min( tsg.LONX(ind) );
  lonMax = max( tsg.LONX(ind) );
  
  %oversize window due to the large frame
  %--------------------------------------
  latRange = (latMax-latMin);
  latMin = max(latMin - 0.05*latRange, -90);
  latMax = min(latMax + 0.05*latRange, 90);
  lonRange = (lonMax-lonMin);
  lonMin = lonMin - 0.03*lonRange;
  lonMax = lonMax + 0.03*lonRange;
  % Positionning the right axes
  % ----------------------------
  axes(hPlotAxes(4));
  % Use of Mercator projection
  % --------------------------
  m_proj('Mercator','lat',[latMin latMax],'long',[lonMin lonMax]);
  switch tsg.preference.map_resolution
      case 1
          % Low-resolution coast lines
          % --------------------------
          m_coast('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST');
      case 2
          % Medium-resolution coast lines
          % -----------------------------
          m_gshhs_l('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST');

      case 3
          % High-resolution coast lines
          % ----------------------------
          m_gshhs_i('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST');

      otherwise
          tsg.preference.map_resolution=1;
          % Low-resolution coast lines
          % --------------------------
          m_coast('patch',[.7 .7 .7], 'TAG', 'TAG_PLOT4_LINE_COAST');

  end
  %m_grid('box','fancy','tickdir','in', ...
  %       'ytick', [-70:20:70],...
  %       'xtick', [-180:40:180],...
  %       'Fontsize', [10]);
  m_grid('box','fancy','tickdir','in', 'TAG', 'TAG_PLOT4_LINE_GRID', 'Fontsize', 10);

  % Plot the ship track - Check if LAT-LON in deg-decimal
  % -----------------------------------------------------
  %m_line(tsg.LONX,tsg.LATX, 'TAG', 'TAG_PLOT4_LINE_SHIPTRACK', 'marker','.','markersize',3,'color','b');
  %   m_line(tsg.LONX,tsg.LATX, 'LineStyle', 'none', 'marker','*','markersize',2,'color','b');

  % Plot using QC
  % -------------

  % get list of keys from hashtable tsg.qc.hash, defined inside
  % tsg_initialisation.m
  % -----------------------------------------------------------

  % Plot Sample/TSG differences on axe 2
  % iterate (loop) on each key store inside hastable
  % ------------------------------------------------
  for key = qc_list

    % get  some values in hashtable
    % -----------------------------
    qcState = tsg.qc.hash.(key).state;
    qcCode  = tsg.qc.hash.(key).code;
    qcColor = tsg.qc.hash.(key).color;

    % plot tsg salinity sample with right code/color
    % ----------------------------------------------
    ind = find( tsg.SSPS_QC == qcCode & isnan(tsg.SSPS) == 0);
    if ~isempty( ind )
      m_line(tsg.LONX(ind),tsg.LATX(ind), 'LineStyle', 'none', 'marker','*',...
             'markersize',2,'color',qcColor);
    end
  end
  title( ['Cruise: ' tsg.file.name],'fontsize',14,'fontweight','bold');
    
    
  hLines = get(hPlotAxes(4), 'Children');
  for i=1:length(hLines)
    set(hLines(i), 'Tag', ['TAG_PLOT4_LINE_MAP' int2str(i)]);
  end

end