www.gusucode.com > map 案例源码 matlab代码程序 > map/ComputeVisibilityForPointOnPeaksMapExample.m

    %% Compute Visibility for Point on Peaks Map
% Compute visibility for a point on the peaks map. Add the detailed
% information for the line of sight calculation between two points from
% |los2| .
%%
% Create the peak map and plot the visibility.

% Copyright 2015 The MathWorks, Inc.

Z = 500*peaks(100);
refvec = [1000 0 0];
[lat1,lon1,lat2,lon2] = deal(-0.027,0.05,-0.093,0.042);
     
[visgrid,visleg] = viewshed(Z,refvec,lat1,lon1,100);
[vis,visprofile,dist,zi,lattrk,lontrk] ...
   = los2(Z,refvec,lat1,lon1,lat2,lon2,100);

axesm('globe','geoid',earthRadius('meters'))
meshm(visgrid,visleg,size(Z),Z); 
axis tight
camposm(-10,-10,1e6)
camupm(0,0)
colormap(flipud(summer(2))) 
brighten(0.75)
shading interp 
camlight
h = lcolorbar({'obscured','visible'});
h.Position = [.875 .45 .02 .1];

plot3m(lattrk([1;end]),lontrk([1; end]), ...
   zi([1; end])+[100; 0],'r','linewidth',2)
plotm(lattrk(~visprofile),lontrk(~visprofile), ...
   zi(~visprofile),'r.','markersize',10)
plotm(lattrk(visprofile),lontrk(visprofile), ...
   zi(visprofile),'g.','markersize',10)