|
| 1 | +function countsARC = countAirRiskClass(lat_deg,lon_deg,alt_baro_ft,alt_geo_ft,geoname_id,varargin) |
1 | 2 | % Copyright 2018 - 2020, MIT Lincoln Laboratory
|
2 | 3 | % 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 | + |
4 | 6 | %% Input parser
|
5 | 7 | p = inputParser;
|
6 | 8 |
|
|
83 | 85 | lg = ~isnan(alt_geo_ft) & alt_geo_ft <= p.Results.maxAlt_ft & alt_geo_ft >= p.Results.minAlt_ft ;
|
84 | 86 |
|
85 | 87 | % Boundary of all coordinates
|
| 88 | + % This is used to identify points where we have ARC values |
86 | 89 | % convhull() is slightly faster than boundary(), but boundary will filter out
|
87 | 90 | % more points which makes the distance calculation below faster
|
88 | 91 | % Make sure we have enough points to a form a boundary (e.g. 2 points is a line)
|
|
98 | 101 | end
|
99 | 102 | end
|
100 | 103 |
|
| 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 | + |
101 | 108 | % 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'); |
103 | 110 |
|
104 | 111 | % 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)),:); |
106 | 113 |
|
107 | 114 | if ~isempty(iarc)
|
108 | 115 | % Sort by altitude
|
|
0 commit comments