function [URL] = pathurl(archive, pass_times, StartColumn, ...
    EndColumn, StartRow, EndRow, dset_stride, ranges, variable, server)
%----------------------------------------------------------------------------
%
% This function takes the pass_times matrix from pathcat along with
% information from the caller about which rows and columns to read and
% returns a vector of URLs.
%
% Formal parameters:
% archive: Name of .m file containing metadata about this dataset. 
% pass_times: Matrix from pathcat.
% StartColumnumn, ...: Integers denoting the obvious stuff about the data's
% matrix. 
% dset_stride: The stride value to use when reading the data. 
% nvars: Not used.
%
% NB: pass_times: This is a matrix of time with the year, day and
% ascending/descending flag of each hit. Note that the day here is the
% calendar day and the flag uses 0 for ascending and 1 for descending.

% The return values are:
% URL: A vector of URLs, one for each element of pass_times.
%
% 
% $Id: pathurl.m,v 1.4 1998/11/09 20:26:57 dbyrne Exp $
%
%----------------------------------------------------------------------------

% $Log: pathurl.m,v $
% Revision 1.4  1998/11/09 20:26:57  dbyrne
% *** empty log message ***
%
% Revision 1.5  1998/11/06 16:11:29  root
% It works!!!  Just waiting for new catalogue server.
%
% Revision 1.4  1998/11/05 16:01:55  root
% Changed LonVector and LatVector to be used if no Lon returned and tried the update function.
% DataScale and DataNull should now be optional!
%
% Revision 1.3  1998/11/05 13:48:11  root
% *** empty log message ***
%
% Revision 1.2  1998/09/09 16:10:28  dbyrne
% Fixed numerous small bugs.
%
% Revision 1.1  1998/05/17 14:18:11  dbyrne
% *** empty log message ***
%
% Revision 1.1  1997/11/29 02:42:41  jimg
% Added.
%

%global TemporaryTime

variable = deblank(variable);
server = deblank(server);
% Change the row/col  constraint information to string.
StartRow = num2str(StartRow);
dset_stride = num2str(dset_stride);
EndRow = num2str(EndRow);

StartColumn = num2str(StartColumn);
EndColumn = num2str(EndColumn);

year = num2str(pass_times(1));

% print day with leading zeros.
day = sprintf('%3.3i', pass_times(2));

% decode attitude.
if (pass_times(3) == 0)
    attitude = 'a';
else
    attitude = 'd';
end
if (pass_times(3) == 0)
    directory = [ 'ascending/09km/' year '/' ];
else
    directory = [ 'descending/09km/' year '/' ];
end

img_name = [ year day 'h09d' attitude '-gdm.hdf.Z' ];

constraint = [ '?' variable ...
	   '[' StartRow ':' dset_stride ':' EndRow ']' ...
	   '[' StartColumn ':' dset_stride ':' EndColumn ']'];

URL = [ server directory img_name constraint ];

% I'm not sure just what TemporaryTime should really contain, but here I load
% it with the last two digits of year, three digits of day and the time where
% I assume the an ascending pass corresponds to 2:00 am and descending to
% 2:00 pm (as HHMMSS).
if (pass_times(3) == 0)
    % ascending
    TemporaryTime = sprintf('%2.2i%3.3i%s', year, day, '020000');
else
    % descending
    TemporaryTime = sprintf('%2.2i%3.3i%s', year, day, '220000');
end    

return;
