source: trunk/PROGRAMMES/whorldmap.m @ 19

Last change on this file since 19 was 19, checked in by pinsard, 15 years ago

complete whorldmap.m octave warning

File size: 5.8 KB
Line 
1% WORLDMAP makes map of the world.
2function worldmap(axes,maxlat)
3%
4%        WORLDMAP([LONG_MIN LONG_MAX LAT_MIN LAT_MAX]) draws a
5%        coastline map of the world at about 1/2 degree
6%        resolution. WORLDMAP (called without arguments) draws
7%        the whole world with the Pacific in the center.
8%
9%        WORLDMAP('north',MAXLAT) draws a polar projection from the North
10%        pole out to latitude MAXLAT. MAP('south') does the same for
11%        the South pole (MAXLAT is optional in both cases, but is taken
12%        to lie in the same hemisphere as the pole).
13%       
14
15%Notes: RP (WHOI) 6/Dec/91
16%                 7/Nov/92  Changed for matlab4.0
17%                 17/Oct/93 New outline file.
18%                 14/Mar/94 Fixed polar projections, and changed name
19%                           to 'worldmap'.
20%             
21
22%+
23%
24% KNOWN PROBLEMS
25% ==============
26%
27% Following message appears :
28% ::
29%
30%  warning: function name `worldmap' does not agree with function file name `/.autofs/home/fplod/incas/tpoctave/tpacpandreg_ws/PROGRAMMES/whorldmap.m'
31%
32% function name unchanged because we are not original writer of this function
33%
34%
35% big output from mlint('whorldmap') !!
36%
37%
38% EVOLUTIONS
39% ==========
40%
41% $Id$
42%
43% - fplod 2009-08-25T09:32:28Z aedon.locean-ipsl.upmc.fr (Darwin)
44%
45%   * add missing octave warning on Erasemode
46%
47% - fplod 2009-08-21T13:34:38Z aedon.locean-ipsl.upmc.fr (Darwin)
48%
49%   * add ReStructured Text header
50%   * add octave warning on Erasemode
51%   * replace ``isstr`` by ``ischar`` to avoid following message :
52%     ::
53%
54%     warning: isstr is obsolete and will be removed from a future version of Octave, please use ischar instead
55%
56%   * preallocating nxl and nyl because undefined if octave is running
57%
58%-
59
60% change this line (if map.m is not in your default directory) to
61% "load <path>/coasts".
62load coasts
63
64
65shiftx=0;
66drawtwice=0;
67proj='rec';
68if (nargin<2), maxlat=40; else maxlat=abs(maxlat); end;
69
70if (maxlat>90); error('MAXLAT greater than 90!'); end;
71
72if (nargin>0),
73   if (ischar(axes)),
74      if (axes(1:3)=='nor'),
75         proj='npl';
76         axes=(90-maxlat)*[-1 1 -1 1];
77      elseif (axes(1:3)=='sou'),
78         proj='spl';
79         axes=(90-maxlat)*[-1 1 -1 1];
80      else
81         error('map: Unrecognized projection!');
82      end;
83   else         
84      axes=axes(:)';
85      if (max(size(axes)) ~= 4),
86         error('map: wrong number of limit args!');
87      end;
88      if ( (axes(4)-axes(3))>180. ),
89         error('map: Lat range greater than 180 degrees');
90      end;
91      if ( (axes(2)-axes(1))>360. ),
92         error('map: Long range greater than 360 degrees');
93      else
94         if (axes(1)<=-180. ),
95            shiftx=-360;
96            drawtwice=1;
97         elseif (axes(2)>180.),
98            shiftx=360;
99            drawtwice=1;
100         else
101            shiftx=0;
102            drawtwice=0;
103         end;
104      end;
105   end;
106else
107   axes=[-334 25 -90 90];
108   shiftx=-360;
109   drawtwice=1;
110end;
111     
112if (proj=='rec'),
113   lh=plot(coastlines(1,:)+shiftx,coastlines(2,:),'-');
114   if ~ exist('OCTAVE_VERSION','builtin')
115    set(lh,'Erasemode','none');
116   else
117    warning('www : octave do not know Erasemode property')
118   end
119elseif (proj=='npl'),
120   kk=find(coastlines(2,:)<maxlat);
121   xx=(90-coastlines(2,:)).*cos(coastlines(1,:)*pi/180-pi/2);
122   yy=(90-coastlines(2,:)).*sin(coastlines(1,:)*pi/180-pi/2);
123   xx(kk)=NaN*kk;
124   lh=plot(xx,yy,'-');
125   if ~ exist('OCTAVE_VERSION','builtin')
126    set(lh,'Erasemode','none');
127   else
128    warning('www : octave do not know Erasemode property')
129   end
130   set(gca,'aspect',[1 1]);
131
132elseif (proj=='spl'),
133   kk=find(coastlines(2,:)>-maxlat);
134   xx=(90+coastlines(2,:)).*cos(-coastlines(1,:)*pi/180+pi/2);
135   yy=(90+coastlines(2,:)).*sin(-coastlines(1,:)*pi/180+pi/2);
136   xx(kk)=NaN*kk;
137   lh=plot(xx,yy,'-');
138   if ~ exist('OCTAVE_VERSION','builtin')
139    set(lh,'Erasemode','none');
140   else
141    warning('www : octave do not know Erasemode property')
142   end
143   set(gca,'aspect',[1 1]);
144end;
145
146if (drawtwice),
147   line(coastlines(1,:),coastlines(2,:),'Linestyle','-',...
148   'Erasemode','none');
149end;
150
151
152if (proj=='rec'),
153 axis(axes);
154 xlb=get(gca,'Xticklabel');
155 [Nn,Mm]=size(xlb);
156 Mf=int2str(Mm);
157 nxl=zeros(Nn,Mm+1);
158 for kk=1:Nn,
159   zz=rem(str2num(xlb(kk,:))+540,360)-180;
160   if (zz<0), nxl(kk,:)=sprintf(['%' Mf '.0fW'],abs(zz));
161   elseif (zz>0)  nxl(kk,:)=sprintf(['%' Mf '.0fE'],(zz));
162   else nxl(kk,:)=sprintf(['%' Mf '.0f '],(zz));
163   end;
164 end;
165 set(gca,'Xticklabel',nxl)
166
167 yx=get(gca,'Ytick');
168 ylb=get(gca,'Yticklabel');
169 [Nn,Mm]=size(ylb);
170 Mf=int2str(Mm);
171 nyl=zeros(Nn,Mm+1);
172 for kk=1:Nn,
173   zz=str2num(ylb(kk,:));
174   if (zz<0), nyl(kk,:)=sprintf(['%' Mf '.0fS'],abs(zz));
175   elseif (zz>0)  nyl(kk,:)=sprintf(['%' Mf '.0fN'],(zz));
176   else nyl(kk,:)=sprintf(['%' Mf '.0f '],(zz));
177   end;
178 end;
179 set(gca,'Yticklabel',nyl)
180 set(gca,'Ytick',yx);  % Need this to reset position limits
181else  % polar projection
182  axis(axes);
183  set(gca,'visible','off');
184  for kk=10:10:(90-maxlat),
185    xx=kk*cos([0:10:360]*pi/180);
186    yy=kk*sin([0:10:360]*pi/180);
187    line(xx,yy,'color','w','linestyle',':');
188  end;
189  xx=(90-maxlat)*cos([0:5:360]*pi/180);
190  yy=(90-maxlat)*sin([0:5:360]*pi/180);
191  line(xx,yy,'color','w','linestyle','-');
192  for kk=10:10:(90-maxlat-2),
193    if (proj=='npl'),
194       text(0,kk,sprintf('%2.0fN',90-kk),'horizontal','center');
195    else
196       text(0,kk,sprintf('%2.0fS',90-kk),'horizontal','center');
197    end;
198  end;
199  for kk=0:30:359,
200    xx=[10 90-maxlat]*cos(kk*pi/180);
201    yy=[10 90-maxlat]*sin(kk*pi/180);
202    line(xx,yy,'color','w','linestyle',':');
203    if (kk<=180),nyl=sprintf('%3.0fE',kk);
204    else nyl=sprintf('%3.0fW',abs(360-kk)); end;
205    if (proj=='npl'),
206text(yy(2),-xx(2),nyl,'rotation',kk,'horizontal','center','vertical','top');
207    else
208text(yy(2),xx(2),nyl,'rotation',-kk,'horizontal','center','vertical','bottom');
209    end;
210  end;
211end;
212
213
214if (proj=='rec'), grid; end;
215
Note: See TracBrowser for help on using the repository browser.