function [isvis, canShowObstruction, obsLoc, obsEl]=computeLOSUsingTerrainProfile(observerSite, observerCoords, criticalAngle, lats, lons, map)% Initialize outputs to correspond to no-obstruction case
isvis =true;
canShowObstruction =false;
obsLoc =[];
obsEl =[];% Return early ifnot enough data points. Analysis requires at least three
% points: two end points and one middle point.ifnumel(lats)<=2return
end
% Compute visibility status by looking for first obstruction along terrain
% between observer and target, which islocatedwhereelevation angle from
% observer isgreater than angle between observer and target. 通过查找沿地形的第一个障碍物来计算可见性状态在观察点和目标之间,该仰角大于观察点和目标之间的角度。
rxprofile =rxsite('Name', 'internal.terrainsamplesite',...% Specify to avoid default site naming
'AntennaHeight',0,...
'Latitude',lats(2:end-1),...
'Longitude',lons(2:end-1));[~, el]=angle(observerSite, rxprofile, 'euclidean', 'Map', map,...
'SourceAntennaSiteCoordinates', observerCoords);
obstructionInd =find(el >= criticalAngle,1);
isvis =isempty(obstructionInd);% If first sample isobstruction, assume there iscomplete obstruction
%(i.e. no point to show asvisible)
canShowObstruction = obstructionInd ~=1;% Compute obstruction point
if~isvis
obstructingSite =rxprofile(obstructionInd);
obstruction = rfprop.internal.AntennaSiteCoordinates.createFromAntennaSites(...
obstructingSite, map);
obsLoc = obstruction.DisplayLatitudeLongitude;
obsEl = obstruction.SurfaceHeightAboveTerrainReference;
end
end