function [ s_lon, s_lat ] = usa_sample_geo ( sample_num )

%*****************************************************************************80
%
%% USA_SAMPLE_GEO produces geometrically random sample points in the US.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    05 December 2016
%
%  Parameters:
%
%    Input, integer SAMPLE_NUM, the number of sample points desired.
%
%    Output, real S_LON(SAMPLE_NUM), S_LAT(SAMPLE_NUM), sample points.
%
  [ usa_lon, usa_lat ] = usa_shape_read ( );
%
%  Extract the LL bounding box for the Florida polygon.
%
  usa_lon_min = min ( usa_lon );
  usa_lon_max = max ( usa_lon );
  usa_lat_min = min ( usa_lat );
  usa_lat_max = max ( usa_lat );
%
%  Choose random LL points in the bounding box.
%  Accept them only if they are containined in the USA polygon.
%
  seed = 123456789;
  s_lon = zeros ( sample_num, 1 );
  s_lat = zeros ( sample_num, 1 );

  for i = 1 : sample_num
    inside = 0;
    while ( ~ inside )
      [ lon, seed ] = r8_uniform_ab ( usa_lon_min, usa_lon_max, seed );
      [ lat, seed ] = r8_uniform_ab ( usa_lat_min, usa_lat_max, seed );
      inside = inpolygon ( lon, lat, usa_lon, usa_lat );
      if ( inside )
        s_lon(i) = lon;
        s_lat(i) = lat;
        break
      end
    end
  end

  return
end
