function [X,Y,vals,labI]=mp_omerc(optn,varargin) % MP_TMERC Oblique Mercator projection % This function should not be used directly; instead it is % is accessed by various high-level functions named M_*. % Rich Pawlowicz (rich@ocgy.ubc.ca) 2/Apr/1997 % % This software is provided "as is" without warranty of any kind. But % it's mine, so you can't sell it. % % Mathematical formulas for the projections and thie inverses are taken from % % Snyder, John P., Map Projections used by the US Geological Survey, % Geol. Surv. Bull. 1532, 2nd Edition, USGPO, Washington D.C., 1983. % % The oblique mercator is a cylindrical projection around an arbitrary % great-circle route. This is a handy projection for coastlines and so % forth. % Oblique Mercator - cylindrical conformal global MAP_PROJECTION MAP_VAR_LIST name={'Oblique Mercator'}; pi180=pi/180; switch optn, case 'name', X=name; case {'usage','set'} X=char({[' ''' varargin{1} ''''],... ' <,''lon'',[value1 value2]>',... ' <,''lat'',[value1 value2]>',... ' <,''asp'',value>',... ' <,''dir'',( ''horizontal'' | ''vertical'' )'}); case 'get', X=char([' Projection: ' MAP_PROJECTION.name ' (function: ' MAP_PROJECTION.routine ')'],... [' longitudes: ' num2str(MAP_VAR_LIST.ulongs)],... [' latitudes: ' num2str(MAP_VAR_LIST.ulats) ],... [' Aspect ratio: ' num2str(MAP_VAR_LIST.aspect)],... [' Baseline direction ' MAP_VAR_LIST.direc]); case 'initialize', MAP_VAR_LIST=[]; MAP_PROJECTION.name=varargin{1}; MAP_VAR_LIST.ulongs=[-132 -125]; MAP_VAR_LIST.ulats=[56 40]; MAP_VAR_LIST.aspect=0.5; MAP_VAR_LIST.direc='ver'; MAP_VAR_LIST.rectbox='on'; % THis is always the case for this projection; it's just % too difficult to comtemplate the other possibility k=2; while k=MAP_VAR_LIST.xlims(2)-eps*10 | ... Y<=MAP_VAR_LIST.ylims(1)+eps*10 | Y>=MAP_VAR_LIST.ylims(2)-eps*10; [X,Y]=mu_util('clip',varargin{4},X,MAP_VAR_LIST.xlims(1),XMAP_VAR_LIST.xlims(2),Y); [Y,X]=mu_util('clip',varargin{4},Y,MAP_VAR_LIST.ylims(1),YMAP_VAR_LIST.ylims(2),X); end; case 'xy2ll', l_0=MAP_VAR_LIST.rpolelong+pi/2; switch MAP_VAR_LIST.direc(1:3), case 'hor', Y=asin( sin(MAP_VAR_LIST.rpolelat)*tanh(varargin{2}) ... +cos(MAP_VAR_LIST.rpolelat)*sin(varargin{1})./cosh(varargin{2}) )/pi180; X=(l_0+atan2( sin(MAP_VAR_LIST.rpolelat)*sin(varargin{1}) ... -cos(MAP_VAR_LIST.rpolelat)*sinh(varargin{2}), cos(varargin{1}) ) )/pi180; case 'ver', Y=asin( sin(MAP_VAR_LIST.rpolelat)*tanh(-varargin{1}) ... +cos(MAP_VAR_LIST.rpolelat)*sin(varargin{2})./cosh(-varargin{1}) )/pi180; X=(l_0+atan2( sin(MAP_VAR_LIST.rpolelat)*sin(varargin{2}) ... -cos(MAP_VAR_LIST.rpolelat)*sinh(-varargin{1}), cos(varargin{2}) ) )/pi180; end; case 'xgrid', [X,Y,vals,labI]=mu_util('xgrid',MAP_VAR_LIST.longs,MAP_VAR_LIST.lats,varargin{1},31,varargin{2:3}); case 'ygrid', [X,Y,vals,labI]=mu_util('ygrid',MAP_VAR_LIST.lats,MAP_VAR_LIST.longs,varargin{1},31,varargin{2:3}); case 'box', [X,Y]=mu_util('box',2); end;