clear all

sourceit=1; boxit=0; underway=0;
load wcoastline.dat
figure(1); clf; set(gcf,'color','w','position',[20 50 600 500],'menubar','none');

p=plot(wcoastline(:,1),wcoastline(:,2),'k'); set(p,'linewidth',2);
axis([-122.3 -121.75 36.55 37.15]); hold on
pltlim=axis;
plot_iso([200 500 800],pltlim,'b');
deg=setstr(176);

if sourceit
 % [x,y]=ginput(2);
 % load monitoring_xy
 %% Align with AVIRIS overflight transect, at center of 2nd flightline
 load ../../aviris/lowalt1
 y=y-.022; 	% flightline 2;
 [dist phas]=sw_dist(y,x,'km'); p=plot(x,y,'r'); set(p,'linewidth',2);

 ax=abs(x);
 lon1deg=floor(ax(1)); lon1min=(ax(1)-floor(ax(1)))*60;
 lat1deg=floor(y(1)); lat1min=(y(1)-floor(y(1)))*60;
 lon2deg=floor(ax(2)); lon2min=(ax(2)-floor(ax(2)))*60;
 lat2deg=floor(y(2)); lat2min=(y(2)-floor(y(2)))*60;
 pstr1=['[' int2str(lat1deg) deg int2str(lat1min) '''' ' N,' int2str(lon1deg) deg int2str(lon1min) '''' ' W]'];
 pstr2=['[' int2str(lat2deg) deg int2str(lat2min) '''' ' N,' int2str(lon2deg) deg int2str(lon2min) '''' ' W]'];
 t=text(-122.2,37.06,[pstr1 ' to ' pstr2]); set(t,'fontsize',12);

 pstr3=['[' num2str(y(1)) deg 'N, ' num2str(122) deg 'W] to ' '[' num2str(y(2)) deg 'N, ' num2str(122.25) 'W]'];
 t=text(-122.2,37.03,pstr3); set(t,'fontsize',12);

 t=text(-122.2,37.12,'source water monitoring transect');
 set(t,'fontweight','bold','fontsize',15,'color','r');
 t=text(-122.2,37.09,[int2str(round(dist)) ' km']);
 set(t,'fontweight','bold','fontsize',15,'color','r');
end

if boxit
 x=[-122.06 -122.12]; y=[36.9 36.9]; 
 y2=y-.03; y3=y2-.03; y4=y3-.03; 
 p=plot(x,y,'r'); set(p,'linewidth',2);
 p=plot(x,y2,'r'); set(p,'linewidth',2);
 p=plot(x,y3,'r'); set(p,'linewidth',2);
 t=text(-122.2,37.12,'AUV volume resolution');
 set(t,'fontweight','bold','fontsize',15,'color','r');
 t=text(-122.2,37.09,[int2str(round(dist)) ' km yoyo transects']);
 set(t,'fontweight','bold','fontsize',15,'color','r');
end

if underway
   load underwayxy; ydif=.02
   p=plot(x,y,'r'); set(p,'linewidth',2);
   LLstr=[decimal2degmin(x(1)) ' to ' decimal2degmin(x(2)) ' along ' decimal2degmin(y(1))];
   disp(['Transect 1: ' LLstr]);
 y=y-ydif; p=plot(x,y,'r'); set(p,'linewidth',2);
  LLstr=[decimal2degmin(x(1)) ' to ' decimal2degmin(x(2)) ' along ' decimal2degmin(y(1))];
   disp(['Transect 2: ' LLstr]);
y=y-ydif; p=plot(x,y,'r'); set(p,'linewidth',2);
  LLstr=[decimal2degmin(x(1)) ' to ' decimal2degmin(x(2)) ' along ' decimal2degmin(y(1))];
   disp(['Transect 3: ' LLstr]);
y=y-ydif; p=plot(x,y,'r'); set(p,'linewidth',2);
  LLstr=[decimal2degmin(x(1)) ' to ' decimal2degmin(x(2)) ' along ' decimal2degmin(y(1))];
   disp(['Transect 4: ' LLstr]);
y=y-ydif; p=plot(x,y,'r'); set(p,'linewidth',2);
   LLstr=[decimal2degmin(x(1)) ' to ' decimal2degmin(x(2)) ' along ' decimal2degmin(y(1))];
   disp(['Transect 5: ' LLstr]);

  load underwayxy; 
  
p=plot(x([2 2]),[y(1) y(1)-.02],'r'); set(p,'linewidth',2);
p=plot(x([2 2]),[y(1)-.04 y(1)-.06],'r'); set(p,'linewidth',2);
p=plot(x([1 1]),[y(1)-.02 y(1)-.04],'r'); set(p,'linewidth',2);
p=plot(x([1 1]),[y(1)-.06 y(1)-.08],'r'); set(p,'linewidth',2);

[dist phas]=sw_dist(y,x,'km');
disp(['Distance along individual flight line: ' num2str(dist) ' km']);
[dist2 phas]=sw_dist([y(1) y(1)+-.02],[x([1 1])],'km');
disp(['Distance between individual lines: ' num2str(dist) ' km']);
totdist = 5*dist+4*dist2;
disp(['Total distance : ' num2str(totdist) ' km']);
speed = 4.6*3.6;	% km/hour
tottime=totdist/speed;
t=text(-122.2,37.12,'twice daily underway mapping');
set(t,'fontweight','bold','fontsize',15,'color','r');
t=text(-122.2,37.09,[int2str(round(tottime)) ' hours required']);
set(t,'fontweight','bold','fontsize',15,'color','r');
end

llgrid(15);

t=text(-122.2,36.89,'200 m'); set(t,'fontweight','bold','fontsize',12,'color','b','rotation',-33);

