%
% Relys on idt.northings, eastings and Psi.  These are computed and added to
% the idt struct in deltaT.m. 
% 
  linewidth = 2;
  lstr={};
  if exist( 'wlpFigPtr' ) ~= 1
    wlpFigPtr= figure;
    set( wlpFigPtr, 'Name', 'Estimated Wall Location', 'DeleteFcn', 'clear wlpFigPtr' );
    set(gcf,'position',position)
    wlpFontsize=20;
    wlpFontweight='normal';
    set(gca,'fontsize',wlpFontsize,'fontweigh',wlpFontweight)
    set(gcf,'defaultaxesfontsize',wlpFontsize,'defaulttextfontsize', ...
	    wlpFontsize)
    wlpAxesPtr = gca;
  else
    figure(wlpFigPtr);
  end
%
% Filter out all the time points from the WaypointWallLog that are not
% strictly increasing.  This happens each time a new WaypointWall starts. 
%
  wlpIndx = find(diff(wpw.data(:,1)));

  wlpPlotPtrVeh = plot(wpw.data(:,wpw.eastings), wpw.data(:,wpw.northings), 'b.');
  hold on
  lstr(length(lstr)+1,1) = {'Vehicle'};

  if( exist('delay') == 0 ) delay = 0; end
  if( delay >= 0 )
    psiDelayed = [NaN(delay,1); wpw.data( 1:end-delay, wpw.psi ) ];
  else
    delay = -delay;
    psiDelayed = [wpw.data( delay+1:end, wpw.psi ); NaN(delay,1)];
  end
  
  beamAngle_B = (wpw.data(:,wpw.beamIndxMin) - 150)*pi/180;
  beamAngle_N = beamAngle_B + psiDelayed;
  
   wlpPlotPtrW = ...
       plot( sin( beamAngle_N ) .* wpw.data(:,wpw.minBeamRange)  +  ...
	     wpw.data(:,wpw.eastings),...
             cos( beamAngle_N ) .* wpw.data(:,wpw.minBeamRange)  +  ...
	     wpw.data(:,wpw.northings),...
   		      'k.');
  lstr(length(lstr)+1,1) = {'Minimum Range'};

  beamAngle_B = (wpw.data(:,wpw.beamIndxLS) - 150)*pi/180;
  beamAngle_N = beamAngle_B + psiDelayed;

   wlpPlotPtrWLS = ...
       plot( sin( beamAngle_N ) .* wpw.data(:,wpw.rangeLS)  +  ...
	     wpw.data(:,wpw.eastings),...
             cos( beamAngle_N ) .* wpw.data(:,wpw.rangeLS)  +  ...
	     wpw.data(:,wpw.northings),...
   		      'g.');
  lstr(length(lstr)+1,1) = {'Least Squares'};

  beamAngle_B = (wpw.data(:,wpw.beamIndxLSMedian) - 150)*pi/180;
  beamAngle_N = beamAngle_B + psiDelayed;

   wlpPlotPtrWLSM = ...
       plot( sin( beamAngle_N ) .* wpw.data(:,wpw.rangeLSMedian)  +  ...
	     wpw.data(:,wpw.eastings),...
             cos( beamAngle_N ) .* wpw.data(:,wpw.rangeLSMedian)  +  ...
	     wpw.data(:,wpw.northings),...
   		      'm.');
  lstr(length(lstr)+1,1) = {'Least Squares with Median Filter'};


    
  %xlims = get(gca,'xlim');
  %ylims = get(gca,'ylim');
  
 if( exist( 'dataWP' ) == 1 & min(size(dataWP)) > 1 )
   plot( (dataWP(:,3)), (dataWP(:,2)), ...
	 'r','linewidth', linewidth)
   lstr(length(lstr)+1,1) = {'Trackline'};
   plot( (dataWP(:,3)), (dataWP(:,2)), ...
	 'gd','linewidth', linewidth)
   lstr(length(lstr)+1,1) = {'Waypoints'};
   sizeDataWP = size(dataWP);
   if( sizeDataWP(2) > 3 )
     plot( (dataWP(:,5)), (dataWP(:,4)), ...
	   'k-','linewidth', linewidth)
     lstr(length(lstr)+1,1) = {'Starboard Corridor Edge'};
     plot( (dataWP(:,7)), (dataWP(:,6)), ...
	   'k-','linewidth', linewidth)
     lstr(length(lstr)+1,1) = {'Port Corridor Edge'};
   end
 end
 
 %set(gca,'xlim', xlims);
 %set(gca,'ylim', ylims);

  zoom off
  %
  % Now if you zoom, the axes are wrong.
  %
  axis equal;
  xTickArray = cellstr(num2str(get(gca,'xtick')','%d'));
  set(gca,'xticklabel', xTickArray);
  %set(gca,'xticklabel',cellstr(num2str(get(gca,'xtick')','%d')))
  set(gca,'yticklabel',cellstr(num2str(get(gca,'ytick')','%d')))
 
  
  legend(lstr, 'location','best')
  % if( strcmp(idt.dataSource,'DynamicControlLog') & ~idt.computeValues ) 
  %   northingsWall = idt.northings + cos(idt.Psi)
  %   wlpPlotPtr = plot(dataDC(:,1), dataDC(:,rangeToWall),'x');
  % else
  %   fprintf('wallPlot: Post-processing not implemented.\n');
  % end
  grid on
  xlabel('Meters');
  ylabel('Meters');
  title(['Estimates of Wall Location ', titleStr]);

