Frelonics
HomeServicesScrumAbout UsSample: MATLABSample: C++

Line Of Sight Determination Panamint Mts
function [ output_args ] = los_panamint( input_args )
%los_panamint -- Line Of Sight from Mt Whitney across Panamint Range

%%%% MATLAB Articles
%%% Determining and Visualizing Visibility Across Terrain
%%% los2
%%% Draping Data on Elevation Maps
%%% Digital Elevation Model Files from USGS
%%% Data Grid Values Along a Path
%%% Reading Elevation Data Interactively
%%% Shading and Lighting Terrain Maps
%%% Surface Relief Shading



% figure settings - no menus, no toolbar
set(gcf, 'Name', 'LOS_Panamint', ...
  'NumberTitle', 'off', ...
  'Toolbar', 'none', ...
  'MenuBar', 'none' );


%%%% Determine availability of of terain data
%%%% console commands
%%% show which DTED files you need
% dteds( [36.0 37.0], [-118.5 -116.0]);

%%%% read a DTED file
% [Z, refvec] = dted('fresno-e');
% [Z, refvec] = dted('death_valley-w');
% [Z, refvec] = dted('death_valley-e');
% mydir = 'dted';
% mylats = [36.0 37.0];
% mylongs = [-119.0 -116.0];
% [Z, refvec] = dted('n37.dt0', 1, mylats, mylongs);
% [Z, refvec] = dted('n37.dt1', 1, [36.0 37.0], [-119.0 -116.0])

% %%% show which USGS DEM files you need
% usgsdems( [36.0 37.0], [-118.5 -116.0]);

%%%% read a DEM file
% [Z, refvec] = usgsdem('fresno-e', 5);
% [Z, refvec] = usgsdem('death_valley-w', 5);
% [Z, refvec] = usgsdem('death_valley-e', 5);
% [Z, refvec] = usgsdem( 'death_valley-w', 5, [36 37], [-119 -116]);
% [Z, refvec] = usgsdem( 'fresno-e' 'death_valley-e' 'death_valley-w', 5, [36 37], [-119 -116]);
% usgsdems( [36.0 37.0], [-119.0 -116.0]);
% mydir = 'c:\aldridge\matlab\mapping';
% [Z, refvec] = usgsdem( usgsdems( [36.0 37.0], [-119.0 -116.0]), 5, [36 37], [-119 -116]);



%%%% ETOPO
%% Read and display the ETOPO5 data from the directory 'etopo5'
%% downsampled by a factor of 10.
% [Z, refvec] = etopo('etopo5.dos', 10);



%%%% GTOPO
%% Read and display the GTOPO30 data from given directory
mydir = 'C:\aldridge\matlab\mapping\gtopo30';
mylats = [35.5 37.33];
mylongs = [-118.75 -116.67];
[Z, refvec] = gtopo30(mydir, 1, mylats, mylongs);


% axesm robinson
axesm('MapProjection','eqdcylin', 'FLatLimit', [mylats(1) mylats(2)], 'FLonLimit', [mylongs(1) mylongs(2)] ); % Death Valley

geoshow(Z, refvec, 'DisplayType', 'surface');
colormap(demcmap(Z));
tightmap;


%%%% LOS Problem
%%% Data Grid Values Along A Path
%%% Mapprofile

%%% test points along 118 W
% pt_mt = [36.35 -118.00];
% pt_lo = [36.30 -118.00];
%% Mt Whitney -- 36-34'34" N 118-17'42" W
%% Telescope Pk- 36-10 N 117-05 W
%% Badwater CA - 36-15'49" N 116-50'20" W
%% Owens Lake -- 36-27 N 118-00 W
%%% pt_mt -- Mt Whitney, pt_lo -- Badwater, CA
%%% dms - deg min secs format
% pt_mt = [3634.34 -11817.42];
% pt_lo = [3614.49 -11650.20];
%%% decimal degrees format 
dpt_mt = [36.575 -118.295];
dpt_lo = [36.25 -116.84];

%%%% Notes on Co-ords
%%% gtopo30 uses decimal co-ords
%%% axesm uses decimal co-ords
%%% plot uses decimal co-ords
%%% los2 uses degrees-minutes-seconds, chart co-ords

% dpt_mt = dms2deg(pt_mt);
% dpt_lo = dms2deg(pt_lo);
plotm( dpt_mt, 'b+' );
plotm( dpt_lo, 'bx' );


pt_mt = deg2dms( dpt_mt );
pt_lo = deg2dms( dpt_mt );

% great circle distance
% ldist = distance( 'gc', pt_mt, pt_lo, 'nm' );
ldist = distance( dpt_mt, dpt_lo );
set(gcf, 'Name', sprintf('Distance: %5.2f', ldist*60 ) );
linem( [dpt_mt(1) dpt_lo(1)], [dpt_mt(2) dpt_lo(2)], 'g', 'LineWidth', 2 );


% mapprofile( Z, refvez, [36.52 36.25], [-118.27 -116.83] );
try
  %%% los2 returns 1 for visible and 0 for not
  lviz = los2( Z, refvec, pt_mt(1)/100, pt_mt(2)/100, pt_lo(1)/100, pt_lo(2)/100 ); 
  str_los = 'Not Visible';
  if( lviz == 1 )
  str_los = 'Visible'
  end;
% set(gcf, 'Name', str_los );
catch
  msgbox('Failed on: los2()', 'los_panamint','error');  
end; 


%%% elevations along a path
[zz rng lat lon] = mapprofile( Z, refvec, [dpt_mt(1) dpt_lo(1)], [dpt_mt(2) dpt_lo(2)] );
figure;
plot(rng, zz, 'r');
grid on;

% wait for user to move on
k = waitforbuttonpress;

close;