function varargout = drawBoundaries(areaName)
% function drawBoundaries(areaName)
% 
% draw basemap for NADCON5 regions of analysis:
%   CONUS             contiguous US
%   Alaska            all islands which are not mainland
%   PR                Puerto Rico 
%   VI                Virgin Islands
%   Hawaii            all Hawaiian islands
%   AS                American Samoa
%   Guam              Guam
%   CNMI              Commonwealth of the Northern
%                         Mariana Islands
% 
% call this function to create basemap, before overlay vectors

% defaults
areaList = {};
basemapName = [];

% load list of filesnames
switch lower(areaName)
    case 'conus'
        basemapName = 'continental us';
    case 'alaska'
        basemapName = 'alaska';
        %areaList = {'AK'}; % seemingly duplicated by 'borders'
    case 'pr'
        areaList = {'PR'};
    case 'vi'
        areaList = {'VQ'};
    case 'hawaii'
        areaList = {'HI'};
    case 'as'
        areaList = {'AS'};
    case 'guam'
        areaList = {'GQ'};
    case 'cnmi'
        areaList = {'CQ'};
    otherwise
        error('areaName not recognized')
end

% draw state boundaries
if ~isempty(basemapName)
    borders(basemapName,'k');
end

hold on; % hold figure

% supplement with GMT files, if needed for area
bb = strrep(userpath,';','\');
str = sprintf('%s//boundaries/',bb);
for k = 1:length(areaList)
    % get list of files for each area
    ff = dir(sprintf('%s%s*.gmt',str,areaList{k}));
    for i = 1:length(ff)
        % load and plot file
        x{i} = load([str ff(i).name]);
        plot(x{i}(:,1)-360, x{i}(:,2),'k'); hold on
    end
end

axis equal
grid on

% set boundaries as specified in Data/grid.parameters
[nm,n,s,w,e] = textread(char('Q:/shared/VERTCON3/Data/grid.parameters'),...
    '%s %f %f %f %f','headerlines',2);
q = find(strcmp(nm,areaName)==1);
axis([w(q)-360 e(q)-360 s(q) n(q)])


return

function d = listFiles(prefix)
  for i = 1:length(prefix)
      d{i} = ff.name;
  end
return