Merge pull request #2182 from SiboVG/issue-2180

[#2180] Recompute layers if null
This commit is contained in:
Sibo Van Gool 2023-04-12 22:06:42 +02:00 committed by GitHub
commit 49ce89f49f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,6 +36,10 @@ public abstract class InterpolatingAtmosphericModel implements AtmosphericModel
int n = (int) (altitude / DELTA);
double d = (altitude - n * DELTA) / DELTA;
AtmosphericConditions c = new AtmosphericConditions();
// TODO: LOW: levels[n] returned null in some cases, see GitHub issue #2180 for more information
if (levels[n] == null) {
computeLayers();
}
c.setTemperature(levels[n].getTemperature() * (1 - d) + levels[n + 1].getTemperature() * d);
c.setPressure(levels[n].getPressure() * (1 - d) + levels[n + 1].getPressure() * d);