function [ lon, lat, pop, geoid ] = florida_census_reader ( filename )

%*****************************************************************************80
%
%% florida_census_reader() reads Florida census data.
%
%  Discussion:
%
%    This is the beginning of an evolving project to try to apply a
%    CVT iteration to the Florida Congressional District problem,
%    using population density.
%
%    The input file is a comma separated value (CSV) file.  
%
%    The MATLAB "table()" command can read the records. 
%    Note that the data file MUST include a header line of column labels, and
%    if it doesn't, MATLAB simply misreads the first data line as column labels
%    and prints the cryptic message 
%    "Warning: Variable names were modified to make them valid MATLAB identifiers",
%    which actually means "You didn't understand my format needs, and in
%    retaliation, I have now misread the first line of your data as column 
%    headers."
%
%    Each line of the file includes:
%    *1, the postal code ("FL")
%    *2, the geoid;
%    *3, the population;
%    *4, the housing count;
%    *5, land area (m^2);
%    *6, water area (m^2);
%    *7, land area (mi^2);
%    *8, water area (mi^2);
%    *9, latitude;
%    *10, longitude;
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    02 July 2016
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string FILENAME, the name of the file to be read.
%
%  Output:
%
%    real LON(N), LAT(N), the longitude and latitude of the block.
%
%    integer POP(N), the population of the city.
%
%    integer GEOID(N), the geographic id for the block.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'FLORIDA_CENSUS_READER:\n' );
  fprintf ( 1, '  Read a file which contains the latitude, longitude,\n' );
  fprintf ( 1, '  population and geoid for census blocks.\n' );
%
%  Read all the CSV data as a table.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  About to read the file "%s":\n', filename );
  T = readtable ( filename );
%
%  Extract the desired information as numeric arrays.
%
  geoid = table2array ( T(:,2) );
  pop = table2array ( T(:,3) );
  lat = table2array ( T(:,9) );
  lon = table2array ( T(:,10) );
%
%  Report number of records.
%
  n = length ( geoid );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Read %d records.\n', n );

  return
end

