%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                    LATEXtools                         %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  This  file  is  free software ;  it  is distributed  in  %
%%  the hope that  it  will  be  useful,  but  without  any  %
%%  warranty.  You  can  redistribute  it and/or modify  it  %
%%  under  the  terms  of  the  GNU  General Public License  %
%%  as  published  by  the   Free  Software  Foundation  at  %
%%       http://www.gnu.org/copyleft/gpl.html                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% function [lon,lat]=plot_SaralAltika(file_name,lonmin,lonmax,latmin,latmax,color)
%%
%% Plots tracks from SaralAltika
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 24/10/15 AD: adapted for both High resolution and low resolution input files
% 15/03/16 OR: added track labels (taken from file name, assumes filename
%              ends with XXX.txt where XXX is the track number and removed existing
%              labelling since it did not work
% 24/10/15 AD: modified for one tracks
% 20/10/15 LR: louise.rousselet@mio.osupytheas.fr : creation 
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [lon,lat]=plot_SaralAltika(file_name,lonmin,lonmax,latmin,latmax,color)
%%

track=load(['SaralAltika/',file_name]);
[nline,nrow]=size(file_name);
if nrow > 20
 tracename=file_name(12:14) ;
else
 tracename=file_name(end-6:end-4) ;
end
    
	%write track name
	%track_nb=char(file_name);
	id=find(track(:,1)<lonmax & track(:,1)>lonmin+5/60 & track(:,2)<latmax & track(:,2)>latmin+5/60); %position to write name in the window

	%id_valeurs=find(track(:,4)==23); %id_valeurs(1) is the first position where we have the max current values (23)

	m_plot(track(:,1),track(:,2),color,'Linewidth',2);
	%m_plot(track(id_valeurs(1):end,1),track(id_valeurs(1):end,2),'b-','Linewidth',1);

	if (isempty(id)==0)
        m_text(track(id(1),1),track(id(1),2),['  AltiKa ',tracename],'color',color(1));
	end
return
