From caa1a5837f67883843b5cf2214d61c9ab2893af9 Mon Sep 17 00:00:00 2001
From: Jacques Grelet <jacques.grelet@ird.fr>
Date: Tue, 5 Jul 2016 12:53:27 +0000
Subject: [PATCH] =?UTF-8?q?add=20an=20icon=20to=20plot=20ship=20track=20wi?=
 =?UTF-8?q?th=20Google=20Earth=20using=20KML=20Toolbox=20http://www.mathwo?=
 =?UTF-8?q?rks.com/matlabcentral/fileexchange/34694-kml-toolbox=20add=20an?=
 =?UTF-8?q?=20option/preference=20to=20display=20positions=20in=20DD=C2=B0?=
 =?UTF-8?q?MM.SS=20or=20decimal=20update=20Release=20notes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ReleaseNotes                   |   5 ++++
 tsg_icon/Google-Earth-icon.gif | Bin 0 -> 1042 bytes
 tsg_util/preferencesForm.m     |  28 +++++++++++++++++++-
 tsg_util/tsg_preferences.m     |   2 ++
 tsgqc.m                        |  47 +++++++++++++++++++++++++++++----
 5 files changed, 76 insertions(+), 6 deletions(-)
 create mode 100644 tsg_icon/Google-Earth-icon.gif

diff --git a/ReleaseNotes b/ReleaseNotes
index 5289101..6ea69c9 100644
--- a/ReleaseNotes
+++ b/ReleaseNotes
@@ -1,6 +1,11 @@
 Release notes
 TSG-QC   jacques.grelet@ird.fr
 
+v1.45.0 (2016-05-05)
+ - add an icon to plot ship track with Google Earth using KML Toolbox:
+   http://www.mathworks.com/matlabcentral/fileexchange/34694-kml-toolbox
+ - add an option/preference to display positions in DD°MM.SS or decimal
+
 v1.44.2 (2016-04-20)
  - move hardcoded constants in preferenceForm (jgrelet):
    tsg.cst.TSG_WS_TIMEDIFF, tsg.SSPS_STDMAX and tsg.cst.TSG_DT_SMOOTH
diff --git a/tsg_icon/Google-Earth-icon.gif b/tsg_icon/Google-Earth-icon.gif
new file mode 100644
index 0000000000000000000000000000000000000000..acc42c10f67d55a2e812d641420cd0c358814906
GIT binary patch
literal 1042
zcmZvbdsNc}9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0CNclWhyNenV4<}ZxY{xoE2iFYP#
z8+pgP(gMFVfvk|pY0{&E<R^=|GgbChPK|4PcOKQTwRXfvt}NS9LyVt!rTkM`?;73C
z?oD!|w^vKfv|VDRTb|u}u*Sf+{+K@1Rcy&J1P|lv{BBg|&11`NI~*uRP2I@%Yqych
z@p;o?>w7<hdbtpcDND@mu*TKC{+*Vu6U|!5G*{lQ_>Slf{M^qbbd5*s#dK$5!LD#8
zR(nnM>Jt&W`~GnCd8U{6k6#9~r}Ieu_LqHGSi{r1R#`nctl#GC1jAa9pXkmbD@$|m
F{TK5MlPLfI

literal 0
HcmV?d00001

diff --git a/tsg_util/preferencesForm.m b/tsg_util/preferencesForm.m
index 7ee13b4..01965ab 100644
--- a/tsg_util/preferencesForm.m
+++ b/tsg_util/preferencesForm.m
@@ -501,7 +501,7 @@ uicontrol(...
   'Style', 'Text', 'Fontsize', tsg.fontSize, 'FontWeight', 'bold',...
   'HorizontalAlignment', 'Left', ...
   'Position',[left, bottom, 2*length, height], ...
-  'String', 'Formats used for date');
+  'String', 'Formats used for date and positions');
 
 bottom = bottom - inc_y - height;
 if bottom < .1
@@ -566,6 +566,30 @@ if bottom < .1
   left = left + inc_x;
 end
 
+% display positions format 
+% ------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', ...
+  'Style', 'Text', 'Fontsize', tsg.fontSize-1, 'HorizontalAlignment', 'left', ...
+  'Position',[left, bottom, length, height], ...
+  'TooltipString', 'Formats used for positions, DD°MM.SS or decimal', ...
+  'String', 'Positions format');
+
+% display positions format 
+% ------------------------
+uicontrol(...
+  'Parent', hPreferencesFig, ...
+  'Units', 'normalized', 'Style', 'popupmenu', ...
+  'Fontsize', tsg.fontSize-2, 'BackgroundColor', 'w', ...
+  'HorizontalAlignment', 'right', ...
+  'Position', [left + length, bottom, length, height], ...
+  'TooltipString', 'Formats used for positions', ...
+  'String', tsg.preference.positions_format_string, ...
+  'Value', tsg.preference.positions_format_value, ...
+  'Tag', 'PREFERENCES_POSITIONS_FORMAT');
+
+
 % goto next column
 % ----------------
 bottom = 0.95;
@@ -770,6 +794,8 @@ uiwait(hPreferencesFig);
       get(prefs.PREFERENCES_PLOT_CONNECTED_LINE, 'value');
     tsg.preference.map_resolution = ...
       get(prefs.PREFERENCES_MAP_RESOLUTION, 'value');
+    tsg.preference.positions_format_value = ...
+      get(prefs.PREFERENCES_POSITIONS_FORMAT, 'value');
     % QC Tests
     tsg.preference.flow_min_string = ...
       get(prefs.PREFERENCES_FLOW_MIN, 'string');
diff --git a/tsg_util/tsg_preferences.m b/tsg_util/tsg_preferences.m
index 0c5962b..04eb35d 100644
--- a/tsg_util/tsg_preferences.m
+++ b/tsg_util/tsg_preferences.m
@@ -160,6 +160,8 @@ set(hTsgGUI,'Pointer','arrow');
     % -----------------------------------------
     preference.date_format_variable  = 'yyyymmddHHMMSS';
     preference.date_format_attribute = 'yyyymmddHHMMSS';
+    preference.positions_format_string = {'DD°MM.SS', '+-DD.CCCC'};
+    preference.positions_format_value = 1;
     
     % use in tsg-average by tsg.cst.TSG_DT_SMOOTH
     % this value in in minute
diff --git a/tsgqc.m b/tsgqc.m
index 3f22daf..58c7b67 100644
--- a/tsgqc.m
+++ b/tsgqc.m
@@ -11,7 +11,7 @@ function tsgqc( varargin )
 %  This file is part of tsgqc.
 %
 %    TSG-QC is free software; you can redistribute it and/or modify
-%    it under the terms of the GNU General Public License as published by
+%    it under the terms of the GNU General Public License as publDisplayished by
 %    the Free Software Foundation; either version 2 of the License, or
 %    (at your option) any later version.
 %
@@ -38,9 +38,9 @@ global GOSUD_FORMAT_VERSION
 % version number, may be used to initialize some files when it change
 % 0.90x -> 1.0RCx
 % -------------------------------------------------------------------
-VERSION      = 1.442;  % -> 1.44
-CHAR_VERSION = '1.442';
-DATE_VERSION = 'jan 20 2016';
+VERSION      = 1.450;  % -> 1.44
+CHAR_VERSION = '1.450';
+DATE_VERSION = 'july 5 2016';
 
 % netcdf file version, see DATA FORMAT TSG document:
 % CORTSG_format_gosud.doc
@@ -472,7 +472,7 @@ hTimelimitToggletool  = uitoggletool(...
   'OnCallback',  @SelectTime_OnMenuCallback);
 hMapToggletool  =   uitoggletool(...   % Open Map toolbar button
   'Parent',hToolbar,...
-  'TooltipString','Map and ship track',...
+  'TooltipString','Display ship track with m_map',...
   'Separator', 'on', ...
   'CData',iconRead(...
   [DEFAULT_PATH_FILE 'tsg_icon' filesep 'mapicon.mat']),...
@@ -482,6 +482,15 @@ hMapToggletool  =   uitoggletool(...   % Open Map toolbar button
   'Enable', 'off',...
   'OffCallback', @Map_OffMenuCallback,...
   'OnCallback',  @Map_OnMenuCallback);
+hGoogleEarthPushtool  = uipushtool(...   % Open Google Earth and plot track
+  'Parent',hToolbar,...
+  'TooltipString','Display ship track with Google Earth',...
+  'CData',iconRead(...
+  [DEFAULT_PATH_FILE 'tsg_icon' filesep 'Google-Earth-icon.gif']),...
+  'HandleVisibility','on', ...
+  'Tag','PUSHTOOL_GOOGLEARTH',...
+  'Enable', 'off',...
+  'ClickedCallback', @GoogleEarthMenuCallback);
 hClimToggletool  =   uitoggletool(...   % Open Climatology toolbar button
   'Parent',hToolbar,...
   'TooltipString','Climatology',...
@@ -549,6 +558,7 @@ hReportPushtool  = uipushtool(...   % Open Report saving button
   'Enable', 'off',...
   'ClickedCallback', @ReportMenuCallback);
 
+
 %% Dynamic text area
 %   -----------------------------------------------------------------------
 %  Dynamic text area that displays the loaded filename, date, position and
@@ -2477,9 +2487,15 @@ hrbInterpCancel = uicontrol( ...
         % ---------------------------------------------------------
         set( hInfoDateText, 'String',...
           datestr(tsg.DAYD(indCursor),'dd/mm/yyyy   HH:MM'));
+        if tsg.preference.positions_format_value == 1 
         set( hInfoLatText,  'String', dd2dm(tsg.LATX(indCursor), 0) );
         set( hInfoLongText, 'String', ...
           dd2dm(mod(tsg.LONX(indCursor) + 180, 360) - 180, 1) );
+        else
+                set( hInfoLatText,  'String', tsg.LATX(indCursor) );
+        set( hInfoLongText, 'String', ...
+          mod(tsg.LONX(indCursor) + 180, 360) - 180 );
+        end
         if ~isempty(tsg.SSPS)
           set( hInfoSSPSText, 'String', tsg.SSPS(indCursor) );
         end
@@ -3406,6 +3422,27 @@ end
 
   end
 
+%% GoogleEarthMenuCallback
+% -------------------------------------------------------------------
+% Callback function run when the Google Earth tool bar item is selected
+% -------------------------------------------------------------------
+  function GoogleEarthMenuCallback(hObject, eventdata)
+
+        % Get tsg application data
+    % ------------------------
+    tsg = getappdata( hMainFig, 'tsg_data' );
+    
+    % call KML Toolbox functions
+    % --------------------------
+    k = kml(tsg.CYCLE_MESURE);
+    
+    % Color value format must be passed as a character array according 
+    % to the format string 'AABBGGRR', eg: red = 'FF0000FF'
+    k.plot(tsg.LONX,tsg.LATX, 'linewidth', 2, 'linecolor', 'FF0000FF');
+    k.run;
+
+  end
+
 %% SaveMenuCallback
 % -------------------------------------------------------------------
 % Callback function run when the Save menu item is selected
-- 
GitLab