function [] = axes2mercator(pAxesHandle, pInverse) %AXES2MERCATOR Converts the given axes and all its children to mercator projection. % Detailed explanation goes here %% Get required variables children = pAxesHandle.Children; if nargin == 1 pInverse = false; end %% Check if already converted if strcmp(pAxesHandle.UserData, 'mercator') warning([mfilename ': Given axes has already been converted to mercator! Skipping...']); return; end %% Set units pAxesHandle.Units = 'norm'; %% Convert every children for i = 1:length(children) currentChild = children(i); % get position, depending on type switch (currentChild.Type) case 'image' disp('Image discovered, skipping...'); continue; case 'text' if pInverse currentChild.Position(2) = artoa.convert.mercator.imerc( ... currentChild.Position(2) ... ); else currentChild.Position(2) = artoa.convert.mercator.merc( ... currentChild.Position(2) ... ); end otherwise if pInverse currentChild.YData = artoa.convert.mercator.imerc( ... currentChild.YData ... ); else currentChild.YData = artoa.convert.mercator.merc( ... currentChild.YData ... ); end end end %% Set corrected limits if pInverse pAxesHandle.YLim = artoa.convert.mercator.imerc(pAxesHandle.YLim); else pAxesHandle.YLim = artoa.convert.mercator.merc([pAxesHandle.YLim(1) - 1, pAxesHandle.YLim(2) + 1]); end %% Save state to axes pAxesHandle.UserData = 'mercator'; end