Documentation of dc


Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)


Function Synopsis

hh = drawcoasts ( lcst, lgrd, lbox, gridx, gridy ) ;

Help text

 function hh = drawcoasts ( lcst, lgrd, lbox, gridx, gridy ) ;

 script to overlay a rectangular coastline map on the graphics window.

 INPUT ARGUMENTS:

   lcst : linetype for coastlines (default is COASTTYPE,' ' = default)
   lgrd : linetype for gridlines (default is COASTGRID, ' ' = default)
   lbox : linetype for frame box (default: '-k', '' or 0 to skip)
  gridx : grid_spacing in x direction (default is GRDX_SPACING)
  gridy : grid_spacing in y direction (default is GRDY_SPACING)

 GLOBAL SETTINGS (most of which can be overridden by call arguments)

  FRAME       : plotting boundaries (see also frame)
  COASTWIDTH  : Coastline width
  COASTTYPE   : coastline type, set to 0 or '' for no coast
  COASTGRID   : grid line stype, set to 0 or '' for no gridline
  GRDX_SPACING: longitudinal grid spacing
  GRDY_SPACING: latitudinal grid spacing

 SEE ALSO : frame, polar_coasts

Cross-Reference Information

This function calls This function is called by

Listing of function dc

function hh = drawcoasts ( lcst, lgrd, lbox, gridx, gridy ) ;
 
%---------------------------------------------- Alexis Lau (May 1991)
% major modification for version 4.X           Alexis Lau (July 1993)
% rewritten                                    Alexis Lau (Feb 1994)
%
% Added "sort" to the yticks definition in the grid lines specification.
% MATLAB 5 needs the ticks to increase monotonically.
% 						Todd Mitchell, July 1997
%
% Same is true for the xticks, added sort(xtickts)
%                                               Christian Bantzer, 10/3/97

  global FRAME COASTWIDTH COASTTYPE COASTGRID GRDX_SPACING GRDY_SPACING
  global USE_LANDMASK
  global x_coasts y_coasts

  if USE_LANDMASK;
    landmask;
% return;
  end

% set parameters
  if nargin < 1; lcst = ' '; end;
  if nargin < 2; lgrd = ' '; end;
  if nargin < 3; lbox = ' '; end
  if nargin < 4; gridx = GRDX_SPACING; end
  if nargin < 5; gridy = GRDY_SPACING; end
  if strcmp(lcst,' '); lcst='-k'; end
  if strcmp(lgrd,' '); lgrd=':k'; end
  if strcmp(lbox,' '); lbox='-k'; end

%-------------------------------------------------------------------
% make sure plotting in the preset frame
%  frame;
  
% map is superimposed, will not affect existing display
  push_hold;
  
% frame box
  xl=get(gca,'xlim'); yl=get(gca,'ylim');
%  xl = FRAME(1:2); yl = FRAME(3:4);
  x0=xl(1); x1=xl(2); y0=yl(1); y1=yl(2);
%  if lbox; plot([x0 x0 x1 x1 x0],[y0 y1 y1 y0 y0],lbox); end;

% grid lines
  if ~USE_LANDMASK
  xticks = sort([ 0:-gridx:x0 gridx:gridx:x1 ]);
  yticks = sort( [ 0:-gridy:y0 gridy:gridy:y1 ] );
  manual_ticks('x',xticks,label_eastwest(xticks));
  manual_ticks('y',yticks,label_northsouth(yticks));
  end
  if lgrd
    vline(xticks,lgrd, FRAME(3:4)); 
    hline(yticks,lgrd);
  end;

% coastlines
  if lcst;
    x = []; y = [];
    nt1 = floor((x0+180)/360); nt2 = floor((x1+180-1.e-9)/360);
    for it = nt1:nt2;
      xtmp=x_coasts+it*360; ytmp=y_coasts;
      xy = find ( ~(isinrange(xtmp,xl) & isinrange(ytmp,yl)) );
      xtmp(xy)=nan*ones(size(xy)); ytmp(xy)=nan*ones(size(xy));
      x = [ x nan xtmp ]; y = [ y nan ytmp ];
    end;
    lcst
    h=fill(x,y,lcst); set(h,'linewidth',COASTWIDTH);
  end;

  pop_hold;

  if nargout==1; hh=h; end