%polyjoin: convert polygons or lines from cell array format to column vector form.
%input: latitundinal cell array and longitudinal cell array.
%output latitudinal column vector and longitudinal column vector.
%in cell array format each cell is a vector definition of a polygon
%function [lat, lon] = polyjoin(latcells, loncells)


function [lat, lon] = polyjoin(latcells, loncells)

%checks to make sure there are two arguments
if~(nargin == 2)
  error('Incorrect number of inputs')
endif

%checks to make sure all of the inputs are of type cell
if(~iscell(latcells) | ~iscell(loncells))
  error('Both latcells and loncells must be of cell type')
endif

%checks to make sure that each of the inputs have contents in them
if(isempty(latcells) | isempty(loncells))
    error('inputted cells must not be empty')
endif


%copies the first vector to lat and lon
lat = latcells{:};
lon = loncells{:};

%loop throug the cell array and expand the lat and lon vectors. placing NaN inbetween faces. 
for i =2:length(latcells)

  lat=[lat; NaN; latcells{i}];
  lon=[lon;NaN; loncells{i}];
  end

endfunction
