function florida_voronoi ( lon, lat, tag )

%*****************************************************************************80
%
%% FLORIDA_VORONOI displays a Voronoi diagram based on some Florida cities.
%
%  Discussion:
%
%    MATLAB's 'voronoi()' command can be teased into drawing a Voronoi
%    diagram on a map made with the Mapping Toolbox.
%
%    The voronoi() command doesn't give good information on the lines
%    to infinity associated with a Voronoi diagram.  In order to get a
%    reasonable-looking diagram, we add a distant border of points which
%    we hope will guarantee that all the Voronoi regions with Florida
%    are completely drawn.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    28 June 2016
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'FLORIDA_VORONOI:\n' );
  fprintf ( 1, '  MATLAB version\n' );
  fprintf ( 1, '  Display a Voronoi diagram based on some Florida cities.\n' );
%
%  City names.
%
  tag = { ...
    'Pensacola', ...
    'Tallahassee', ...
    'Gainesville', ...
    'Jacksonville', ...
    'Orlando', ...
    'Tampa', ...
    'Miami', ...
    'Longboat Key' };
%
%  City latitudes.
%
  lat = [ ...
    30.433333; ...
    30.455000; ...
    29.651944; ...
    30.336944; ...
    28.415833; ...
    27.968056; ...
    25.775278; ...
    27.396944 ];
%
%  City longitudes.
%
  lon = [ ...
    -87.200000; ...
    -84.253333; ...
    -82.324722; ...
    -81.661389; ...
    -81.298889; ...
    -82.476389; ...
    -80.208889; ...
    -82.644722 ];
%
%  Open a new graphics figure.
%
  figure
%
%  Prepare a graphics axis suitable for a map of Florida.
%
  ax = usamap ( 'Florida' );
%
%  Call shaperead() to read the low-resolution data for the outline of Florida.
%
  florida_lo = shaperead ( 'usastatelo', ...
    'UseGeoCoords', true,...
    'Selector', { @ ( name ) strcmpi( name, 'Florida' ), 'Name' } );
%
%  florida_lo is an array (of just one element in this case) of structures.
%  BoundingBox is a component of that structure.
%  Retrieve the bounding box data so that we can create auxilliary nodes.
%
  lon_min = florida_lo(1).BoundingBox(1,1);
  lon_max = florida_lo(1).BoundingBox(2,1);
  lat_min = florida_lo(1).BoundingBox(1,2);
  lat_max = florida_lo(1).BoundingBox(2,2);
%
%  Display the outline of Florida, and fill it with a green with some blue.
%
  geoshow ( florida_lo, 'FaceColor', [ 0.3, 1.0, 0.675 ] );
%
%  Mark each city.
%
  for i = 1 : 8
    plotm ( lat(i), lon(i), 'b.', 'Markersize', 25 )
  end
%
%  Label each city.  Move the label up and to the right a bit.
%
  for i = 1 : 8
    textm ( lat(i) + 0.2, lon(i) + 0.2, tag(i), 'fontweight', 'bold' )
  end
%
%  We need to add a boundary of auxilliary points so that MATLAB's lazy
%  Voronoi function, which doesn't return lines to infinity, will be
%  tricked into giving us a good diagram for Florida.
%
  lat_max = lat_max + 2.0;
  lat_min = lat_min - 2.0;
  lon_max = lon_max + 2.0;
  lon_min = lon_min - 2.0;

  lon2 = lon;
  lat2 = lat;
  for i = 1 : 10
    x = lon_min;
    y = lat_max + ( i / 10.0 ) * ( lat_min - lat_max );
    lon2 = [ lon2; x ];
    lat2 = [ lat2; y ];
  end

  for i = 1 : 10
    x = lon_min + ( i / 10.0 ) * ( lon_max - lon_min );
    y = lat_min;
    lon2 = [ lon2; x ];
    lat2 = [ lat2; y ];
  end

  for i = 1 : 10
    x = lon_max;
    y = lat_min + ( i / 10.0 ) * ( lat_max - lat_min );
    lon2 = [ lon2; x ];
    lat2 = [ lat2; y ];
  end

  for i = 1 : 10
    x = lon_max + ( i / 10.0 ) * ( lon_min - lon_max );
    y = lat_max;
    lon2 = [ lon2; x ];
    lat2 = [ lat2; y ];
  end
%
%  Request the lists of X and Y coordinates of line segments that form
%  the (finite part of the) Voronoi diagram.
%
  [ vx, vy ] = voronoi ( lat2, lon2 );
%
%  Draw the line segments.
%
  linem ( vx, vy, 'b-' );
%
%  Save a copy of the plot.
%
  print ( '-dpng', 'florida_voronoi.png' )

  return
end
