diff --git a/tsg_util/updateTsgStruct.m b/tsg_util/updateTsgStruct.m new file mode 100644 index 0000000000000000000000000000000000000000..af236b07668f7cb12f843765d2a37e15c1c83b48 --- /dev/null +++ b/tsg_util/updateTsgStruct.m @@ -0,0 +1,45 @@ +function updateTsgStruct(hTsgGUI) +% +% This function is called after reading data and update tsg structure +% with common values +% +% Input +% ----- +% hTsgGUI ............ Handel to the main user interface +% +% $Id$ + +% Get the data from the application GUI +% ------------------------------------- +tsg = getappdata( hTsgGUI, 'tsg_data'); + +% get min and max values for position and set to globals attributes +% ----------------------------------------------------------------- +tsg.SOUTH_LATX = min(tsg.LATX); +tsg.NORTH_LATX = max(tsg.LATX); +tsg.WEST_LONX = min(tsg.LONX); +tsg.EAST_LONX = max(tsg.LONX); + +% get date start and end value and set to globals attributes +% ----------------------------------------------------------------- +date = datestr(min(tsg.DAYD),30); +tsg.DATE_START = [date(1:8) date(10:15)]; +date = datestr(max(tsg.DAYD),30); +tsg.DATE_END = [date(1:8) date(10:15)]; + +% Compute ship velocity from positions if sog not available +% --------------------------------------------------------- +if isempty(tsg.SPDC) + range = m_lldist(tsg.LONX,tsg.LATX); + ind = size(tsg.DAYD); + tsg.SPDC = zeros(size(ind)); + for i=1:length(tsg.DAYD)-1 + tsg.SPDC(i) = range(i) / ((tsg.DAYD(i+1)-tsg.DAYD(i)) * 24 * 1.854); + end + tsg.SPDC = [tsg.SPDC';0]; +end + +% Save tsg structure +% ------------------ +setappdata( hTsgGUI, 'tsg_data', tsg); + \ No newline at end of file