 function [coordinates] = main
clear global % that is important to make sure that the global variable in the function GetSRTMData will be deleted before a new navigation started
start = 'Miami'; % 'Dachauer Straße 5, München, Deutschland'
destination = 'Orlando'; % ' Berliner Straße 5 Dortmund Germany &*$

route = {start,destination};
% Create valid start and destination expression
route = regexprep(route,'[^a-zA-Z0-9ÄäÜüÖöß\s]','');
route = regexprep(route,{'Ä','ä','Ü','ü','Ö','ö','ß'},{'Ae','ae','Ue','ue','Oe','oe','ss'});
route = regexprep(route,'  ','');
route = strtrim(route);
route = strrep(route,' ','+');

url = ['http://maps.google.com/maps?hl=en&q=' route{1} '+to+' route{2} '&um=1&ie=UTF-8&sa=N&tab=wl&output=kml'];
info = urlread(url);
idx = regexp(info,'GeometryCollection');
info = info(idx(1):idx(2));
coordinates = regexp(info,'(-)?\d+.\d+','match'); % get coordinates (lat/long/elevation)-->elevation is always zero
coordinates = transpose(reshape(coordinates,3,[]));
coordinates = str2double(coordinates);

pathinSRTM = uigetdir(pwd,'Select folder to save SRTM-files');
if pathinSRTM == 0
    return;
end
pathinSRTM = [pathinSRTM filesep];

for k = 1:size(coordinates,1)
    elevation = GetSRTMData_new([coordinates(k,1) coordinates(k,2)],pathinSRTM);
    if ~isempty(elevation)
        coordinates(k,3) = elevation;
    else
        return;
    end
end


