%
% PURPOSE: Write a subset of navplot to a kml file for plotting in Google Earth.
%
% CHANGELOG:  1. May 2009 rsm.  Initial.
%             2.
%
%
kml.navstr = ge_plot3(dataNav(:,31)*180/pi, dataNav(:,30)*180/pi, ...
                      -dataNav(:,mDepth),...
                      'lineColor', 'FF008888',...
                      'lineWidth',2,...
                      'extrude',1);

kml.navstrk= ge_plot3(dataNav(:,31)*180/pi, dataNav(:,30)*180/pi, ...
                      -dataNav(:,mDepth),...
                      'lineColor', 'FFFFFFFF',...
                      'lineWidth',3,...
                      'extrude',0);

kml.gpslen = length(gps);


if(0)
  %
  % I can't get this to work.  Very disappointing.  
  %
  kml.gpslon                     = NaN*ones(2*kml.gpslen,1);
  kml.gpslon(1:2:2*kml.gpslen)   = -gps(:, longitude)*180/pi;

  kml.gpslat                     = NaN*ones(2*kml.gpslen,1);
  kml.gpslat(1:2:2*kml.gpslen)   =  gps(:, latitude)*180/pi;

  kml.gpsdepth                   = NaN*ones(2*kml.gpslen,1);
  kml.gpsdepth(1:2:2*kml.gpslen) = 0*ones(kml.gpslen,1);

  kml.gpsstr = ge_plot3(kml.gpslon, kml.gpslat, kml.gpsdepth,...
                        'lineColor', 'FFFF0000',...
                        'lineWidth',2 );
end


kml.indx = find(diff(gps(:,1))>300);

kml.gpsdepth = zeros(length(gps),1);
kml.gpsdepth(kml.indx)  = NaN;

kml.gpslon = -gps(:,longitude)*180/pi;
kml.gpslon(kml.indx) = NaN;

kml.gpslat = gps(:,latitude)*180/pi;
kml.gpslat(kml.indx)  = NaN;

kml.gpsstr = ge_plot3(kml.gpslon, kml.gpslat, kml.gpsdepth,...
                        'lineColor', 'FFFF0000',...
                        'lineWidth',4 );

if(~sum(strcmp(fields(kml),'filename')))
  kml.filename=input('Please enter kml.filename= a string.kml ');
end

ge_output(kml.filename, [kml.gpsstr kml.navstrk kml.navstr ]);
