Skip to content

Commit 5b5d0ef

Browse files
authored
Merge pull request #5 from mit-ll/master
Bug fix for boundary k in countAirRiskClass
2 parents cf8435d + 65af84e commit 5b5d0ef

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

countAirRiskClass.m

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
function countsARC = countAirRiskClass(lat_deg,lon_deg,alt_baro_ft,alt_geo_ft,geoname_id,varargin)
12
% Copyright 2018 - 2020, MIT Lincoln Laboratory
23
% SPDX-License-Identifier: BSD-2-Clause
3-
function countsARC = countAirRiskClass(lat_deg,lon_deg,alt_baro_ft,alt_geo_ft,geoname_id,varargin)
4+
% SEE ALSO calcAircraftFrequency_4 countAirspaceAltitude
5+
46
%% Input parser
57
p = inputParser;
68

@@ -83,6 +85,7 @@
8385
lg = ~isnan(alt_geo_ft) & alt_geo_ft <= p.Results.maxAlt_ft & alt_geo_ft >= p.Results.minAlt_ft ;
8486

8587
% Boundary of all coordinates
88+
% This is used to identify points where we have ARC values
8689
% convhull() is slightly faster than boundary(), but boundary will filter out
8790
% more points which makes the distance calculation below faster
8891
% Make sure we have enough points to a form a boundary (e.g. 2 points is a line)
@@ -98,11 +101,15 @@
98101
end
99102
end
100103

104+
% If the track is a straight line, boundary will return an
105+
% empty [] array. This will cause InPolygon below to seg fault
106+
if isempty(k); k = 1:1:numel(lat_deg); end;
107+
101108
% Find index of Tadmin by comparing geoname ids
102-
idxAdmin = arrayfun(@(x)(find(x == Tadmin.gn_id)),geoname_id);
109+
[~,idxAdmin,~] = intersect(Tadmin.gn_id,geoname_id,'stable');
103110

104111
% Filter ARC files based on iso_3166_2
105-
iarc = Tarc(ismember(Tarc.iso_3166_2,Tadmin.iso_3166_2(unique(idxAdmin))),:);
112+
iarc = Tarc(ismember(Tarc.iso_3166_2,Tadmin.iso_3166_2(idxAdmin)),:);
106113

107114
if ~isempty(iarc)
108115
% Sort by altitude

0 commit comments

Comments
 (0)