0001 function latlonoverlay(latlon,numbering)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 latstep=latlon{1};
0014 lonstep=latlon{2};
0015 resolution=latlon{3};
0016 color=latlon{4};
0017
0018 if ~iscell(numbering),
0019 numbering=0;
0020 else
0021 latgap=numbering{1};
0022 longap=numbering{2};
0023 colornumber=numbering{3};
0024 latangle=numbering{4};
0025 lonangle=numbering{5};
0026 numbering=1;
0027 end
0028
0029
0030 lat=-90:resolution:0;
0031 lon=0:resolution:360;
0032
0033 xlimits=xlim;
0034 ylimits=ylim;
0035
0036 for i=1:length(lon),
0037 if(rem(lon(i),lonstep)==0)
0038 latitudes=lat';
0039 longitudes=lon(i)*ones(length(latitudes),1);
0040 [x,y]=ll2xy(latitudes,longitudes);
0041 pos=find(x<=xlimits(2) & x>=xlimits(1) & y<=ylimits(2) & y>=ylimits(1));
0042 if length(pos)<=1,
0043 continue;
0044 end
0045 x=x(pos);y=y(pos);
0046
0047 l=line(x,y,'Color',color);
0048 if numbering,
0049 disp(['Specifiy where to put number for longitude ' num2str(lon(i))]);
0050 [xcorner,ycorner]=ginput(1);
0051
0052
0053 ind=find_point(x,y,xcorner,ycorner); xcorner=x(ind); ycorner=y(ind);
0054 if length(x(1:ind))>10,
0055 xcorner2=x(ind-10); ycorner2=y(ind-10);
0056 else
0057 xcorner2=x(ind-1); ycorner2=y(ind-1);
0058 end
0059 angle=(180)/pi*atan2((ycorner2-ycorner),(xcorner2-xcorner))+lonangle;
0060
0061 if (xcorner>xlimits(1) & xcorner<xlimits(2) & ycorner>ylimits(1) & ycorner<ylimits(2)),
0062 th=text(xcorner,ycorner,[num2str(lon(i)) '^{\circ}']);set(th,'Color',colornumber,'Rotation',angle,'FontSize',16,'HorizontalAlignment','center','VerticalAlignment','middle');
0063
0064
0065 delete(l);
0066 line(x(1:ind-longap),y(1:ind-longap),'Color',color);hold on;
0067 line(x(ind+longap:end),y(ind+longap:end),'Color',color);
0068 end
0069
0070 end
0071 end
0072 end
0073
0074 for i=1:length(lat),
0075 if(rem(lat(i),latstep)==0)
0076 longitudes=lon';
0077 latitudes=lat(i)*ones(length(longitudes),1);
0078 [x,y]=ll2xy(latitudes,longitudes);
0079 pos=find(x<=xlimits(2) & x>=xlimits(1) & y<=ylimits(2) & y>=ylimits(1));
0080 if length(pos)<=1,
0081 continue;
0082 end
0083 x=x(pos);y=y(pos);
0084
0085 l=line(x,y,'Color',color);
0086
0087 if numbering,
0088 disp(['Specifiy where to put number for latitude ' num2str(lat(i))]);
0089 [xcorner,ycorner]=ginput(1);
0090
0091
0092 ind=find_point(x,y,xcorner,ycorner); xcorner=x(ind); ycorner=y(ind);
0093 if length(x(1:ind))>10,
0094 xcorner2=x(ind-10); ycorner2=y(ind-10);
0095 else
0096 xcorner2=x(ind-1); ycorner2=y(ind-1);
0097 end
0098 angle=(180)/pi*atan2((ycorner2-ycorner),(xcorner2-xcorner))+latangle;
0099
0100 if (xcorner>xlimits(1) & xcorner<xlimits(2) & ycorner>ylimits(1) & ycorner<ylimits(2)),
0101 th=text(xcorner,ycorner,[num2str(lat(i)) '^{\circ}']);set(th,'Color',colornumber,'Rotation',angle,'FontSize',16,'HorizontalAlignment','center','VerticalAlignment','middle');
0102
0103
0104 delete(l);
0105 line(x(1:ind-latgap),y(1:ind-latgap),'Color',color);hold on;
0106 line(x(ind+latgap:end),y(ind+latgap:end),'Color',color);
0107 end
0108
0109 end
0110
0111 end
0112 end