function dist = dms_to_distance_earth ( lat1_dms, lon1_dms, lat2_dms, lon2_dms )

%*****************************************************************************80
%
%% DMS_TO_DISTANCE_EARTH finds the distance between two points on the earth.
%
%  Discussion:
%
%    The positions of the the points are given as longitude and
%    latitude, measured in degrees, minutes, and seconds.
%
%    The distance is measured on the surface of the earth, which
%    is approximated by a sphere.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license. 
%
%  Modified:
%
%    19 May 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer LAT1_DMS(4), LON1_DMS(4), the latitude and 
%    longitude of the first point.  The fourth
%    argument is +1/-1 for North/South latitude or East/West longitude.
%
%    Input, integer LAT2_DMS(4), LON2_DMS(4), the latitude and 
%    longitude of the second point.  The fourth
%    argument is +1/-1 for North/South latitude or East/West longitude.
%
%    Output, real DIST, the distance between the points, in miles.
%
  radius = 3958.89;

  lat1_rad = dms_to_radians ( lat1_dms );
  lon1_rad = dms_to_radians ( lon1_dms );

  lat2_rad = dms_to_radians ( lat2_dms );
  lon2_rad = dms_to_radians ( lon2_dms );

  theta = acos ( sin ( lat1_rad ) * sin ( lat2_rad ) ...
               + cos ( lat1_rad ) * cos ( lat2_rad ) ...
               * cos ( lon1_rad - lon2_rad ) );

  dist = radius * theta;

  return
end