mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Extend GFS data and CGridPoint with surface pressure and temperature
This commit is contained in:
@@ -245,6 +245,11 @@ namespace BlackWxPlugin
|
||||
for (const GfsGridPoint &gfsGridPoint : m_gfsWeatherGrid)
|
||||
{
|
||||
CTemperatureLayerList temperatureLayers;
|
||||
|
||||
CAltitude surfaceAltitude (0, CAltitude::AboveGround, CLengthUnit::defaultUnit());
|
||||
CTemperatureLayer surfaceTemperature(surfaceAltitude, CTemperature(gfsGridPoint.surfaceTemperature, CTemperatureUnit::K()), {}, {});
|
||||
temperatureLayers.insert(surfaceTemperature);
|
||||
|
||||
CWindLayerList windLayers;
|
||||
for (auto isobaricLayerIt = gfsGridPoint.isobaricLayers.begin(); isobaricLayerIt != gfsGridPoint.isobaricLayers.end(); ++isobaricLayerIt)
|
||||
{
|
||||
@@ -283,10 +288,12 @@ namespace BlackWxPlugin
|
||||
cloudLayers.insert(cloudLayer);
|
||||
}
|
||||
|
||||
auto surfacePressure = PhysicalQuantities::CPressure { gfsGridPoint.surfacePressure, PhysicalQuantities::CPressureUnit::Pa() };
|
||||
|
||||
CLatitude latitude(gfsGridPoint.latitude, CAngleUnit::deg());
|
||||
CLongitude longitude(gfsGridPoint.longitude, CAngleUnit::deg());
|
||||
auto position = CCoordinateGeodetic { latitude, longitude, {0} };
|
||||
BlackMisc::Weather::CGridPoint gridPoint(position, cloudLayers, temperatureLayers, {}, windLayers);
|
||||
BlackMisc::Weather::CGridPoint gridPoint({}, position, cloudLayers, temperatureLayers, {}, windLayers, surfacePressure);
|
||||
m_weatherGrid.insert(gridPoint);
|
||||
}
|
||||
}
|
||||
@@ -467,8 +474,10 @@ namespace BlackWxPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
// http://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_temp4-0.shtml
|
||||
g2int parameterCategory = gfld->ipdtmpl[0];
|
||||
g2int parameterNumber = gfld->ipdtmpl[1];
|
||||
g2int typeFirstFixedSurface = gfld->ipdtmpl[9];
|
||||
g2int valueFirstFixedSurface = gfld->ipdtmpl[11];
|
||||
|
||||
std::array<g2int, 2> key { { parameterCategory, parameterNumber } };
|
||||
@@ -479,9 +488,21 @@ namespace BlackWxPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
double level = std::round(millibarToLevel(valueFirstFixedSurface));
|
||||
auto parameterValue = m_grib2ParameterTable[key];
|
||||
double level = 0;
|
||||
switch (typeFirstFixedSurface)
|
||||
{
|
||||
case GroundOrWaterSurface:
|
||||
level = 0;
|
||||
break;
|
||||
case IsobaricSurface:
|
||||
level = std::round(millibarToLevel(valueFirstFixedSurface));
|
||||
break;
|
||||
default:
|
||||
CLogMessage(this).warning("Unexpected first fixed surface type: %1") << typeFirstFixedSurface;
|
||||
return;
|
||||
}
|
||||
|
||||
auto parameterValue = m_grib2ParameterTable[key];
|
||||
switch (parameterValue.code)
|
||||
{
|
||||
case TMP:
|
||||
@@ -499,6 +520,7 @@ namespace BlackWxPlugin
|
||||
case PRMSL:
|
||||
break;
|
||||
case PRES:
|
||||
setCloudPressure(gfld->fld, level);
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
@@ -563,7 +585,8 @@ namespace BlackWxPlugin
|
||||
{
|
||||
for (auto gridPointIt = m_gfsWeatherGrid.begin(); gridPointIt < m_gfsWeatherGrid.end(); ++gridPointIt)
|
||||
{
|
||||
gridPointIt->isobaricLayers[level].temperature = fld[gridPointIt->fieldPosition];
|
||||
if (level > 0) { gridPointIt->isobaricLayers[level].temperature = fld[gridPointIt->fieldPosition]; }
|
||||
else { gridPointIt->surfaceTemperature = fld[gridPointIt->fieldPosition]; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,6 +646,15 @@ namespace BlackWxPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CWeatherDataGfs::setCloudPressure(const g2float *fld, double level)
|
||||
{
|
||||
for (auto gridPointIt = m_gfsWeatherGrid.begin(); gridPointIt < m_gfsWeatherGrid.end(); ++gridPointIt)
|
||||
{
|
||||
if (level > 0) { /* todo */ }
|
||||
else { gridPointIt->surfacePressure = fld[gridPointIt->fieldPosition]; }
|
||||
}
|
||||
}
|
||||
|
||||
void CWeatherDataGfs::setSurfaceRain(const g2float *fld)
|
||||
{
|
||||
for (auto gridPointIt = m_gfsWeatherGrid.begin(); gridPointIt < m_gfsWeatherGrid.end(); ++gridPointIt)
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace BlackWxPlugin
|
||||
|
||||
enum Grib2FixedSurfaceTypes
|
||||
{
|
||||
GroundOrWaterSurface = 1,
|
||||
IsobaricSurface = 100,
|
||||
LowCloudBottomLevel = 212,
|
||||
LowCloudTopLevel = 213,
|
||||
@@ -123,6 +124,8 @@ namespace BlackWxPlugin
|
||||
QHash<double, GfsIsobaricLayer> isobaricLayers;
|
||||
double surfaceRainRate = 0;
|
||||
double surfaceSnowRate = 0;
|
||||
double surfacePressure = 0;
|
||||
double surfaceTemperature = 0;
|
||||
};
|
||||
|
||||
QUrl getDownloadUrl() const;
|
||||
@@ -138,6 +141,7 @@ namespace BlackWxPlugin
|
||||
void setWindU(const g2float *fld, double level);
|
||||
void setCloudCoverage(const g2float *fld, int level);
|
||||
void setCloudLevel(const g2float *fld, int surfaceType, int level);
|
||||
void setCloudPressure(const g2float *fld, double level);
|
||||
void setSurfaceRain(const g2float *fld);
|
||||
void setSurfaceSnow(const g2float *fld);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user