Skip to content
Snippets Groups Projects
Commit c57ea724 authored by leprob001's avatar leprob001
Browse files

Removed custom mercator projection functions.

parent dc9d44d5
No related merge requests found
function yo = imerc(y);
%IMERC inverse mercator projection
%-----------
%yo = 2 * atan(exp(y)) - pi/2;
%yo = yo/pi*180;
%-----------
c1 = 0.19231594611859;
c2 = 0.3773144885e-3;
yo = 2 * atan(exp(y)) - pi/2;
yo = yo/pi*180;
yo = yo + sin(yo/90*pi)*c1 + sin(yo/45*pi)*c2;
function [yo] = merc(y)
% MERC transfer coordinates according Mercator projection.
% Yo = MERC(Y) returns the mercator-transformed of Y.
a = 6378137.000;
b = 6356752.314;
e = sqrt(a^2-b^2)/a;
rad = pi/180;
s = e * sin(y*rad);
yo = log(tan(pi./4 + (y*rad)/2) .* (((1-s)./(1+s)) .^ (e/2) ));
yo = real(yo);
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment