function map1( X1, X2, Y1, Y2, filename)
%
%  The function map1( X1, X2, Y1, Y2, filenames) reads the file
%  whose name is contained in the vector 'filename' and plots
%  a map contained in the coordinates X1<x<X1 and Y1<y<Y2, where
%  all the coordinates are in decimal degrees.
%  The format of the data contained in the file 'filename' can
%  be the same as the one contained in the SURFER's *.BLN files
%  For a nice plot of the sea too, I suggest using the subroutine
%  map2, which actually calls the present map1.
%
%  See also map2, seamap, bwmap2, bwmap1        
%
% ------------------------------------------------------------------
%  Written by Vassilis Zervakis, while at
%             AINCO-Interocean, Madrid, Spain, in December 1995
%-------------------------------------------------------------------
%                                              
%filepath = 'c:\geomaps\';
filenm = num2str(filename);
n = findstr('.',filenm);
dirs = findstr('\',filenm);
nn = length(dirs);
m = dirs(nn);
filebody = filenm(m+1:n-1);
filerr = filenm ;
eval(['load ',filerr]);
data = eval(filebody);
% --------read the file-------------------
[nn, mm] = size(data);
x = data(:,1);
y = data(:,2);
clear data;  
% --------find if the format is surfer-like------
i = 1;
surfer = 'no ';
xlabel('Longitude, degrees');
ylabel('Latitude, degrees');
while i <= nn-1,
   if (y(i)==0) | (y(i)==1) | (y(i)==2) | (y(i)==3) | (y(i) == 4),
% ------- format is surfer-like-------------------
      surfer = 'yes';
      mpoints = x(i);
      if (y(i) == 2) | (y(i) == 4),
        fill(x(i+1:i+mpoints),y(i+1:i+mpoints),'c'); 
       else
        fill(x(i+1:i+mpoints),y(i+1:i+mpoints),'y'); 
      end
      hold on;
      i = i + mpoints;
    else
      i = i + 1;
   end
end
% ------- format is NOT surfer-like------------------- 
if (surfer == 'no '),
    if y(i) ~= 5,
      fill(x(i+1:i+mpoints),y(i+1:i+mpoints),'y'); 
     else
      fill(x(i+1:i+mpoints),y(i+1:i+mpoints),'c'); 
    end
end
