mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 21:10:04 +00:00
Store elevation scans as a shared pointer to avoid needless copying
This commit is contained in:
parent
efeb87baaa
commit
ab616b0c62
6 changed files with 30 additions and 21 deletions
|
|
@ -180,12 +180,12 @@ void RadarProductManager::LoadLevel2Data(const std::string& filename)
|
||||||
emit Level2DataLoaded();
|
emit Level2DataLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<uint16_t, std::shared_ptr<wsr88d::rda::DigitalRadarData>>
|
std::shared_ptr<wsr88d::rda::ElevationScan>
|
||||||
RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
|
RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
|
||||||
uint8_t elevationIndex,
|
uint8_t elevationIndex,
|
||||||
std::chrono::system_clock::time_point time)
|
std::chrono::system_clock::time_point time)
|
||||||
{
|
{
|
||||||
std::map<uint16_t, std::shared_ptr<wsr88d::rda::DigitalRadarData>> radarData;
|
std::shared_ptr<wsr88d::rda::ElevationScan> radarData = nullptr;
|
||||||
|
|
||||||
if (p->level2VolumeScans_.size() > 0)
|
if (p->level2VolumeScans_.size() > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public:
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void LoadLevel2Data(const std::string& filename);
|
void LoadLevel2Data(const std::string& filename);
|
||||||
|
|
||||||
std::map<uint16_t, std::shared_ptr<wsr88d::rda::DigitalRadarData>>
|
std::shared_ptr<wsr88d::rda::ElevationScan>
|
||||||
GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
|
GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType,
|
||||||
uint8_t elevationIndex,
|
uint8_t elevationIndex,
|
||||||
std::chrono::system_clock::time_point time = {});
|
std::chrono::system_clock::time_point time = {});
|
||||||
|
|
|
||||||
|
|
@ -237,18 +237,20 @@ void Level2ProductView::ComputeSweep()
|
||||||
// TODO: Pick this based on view settings
|
// TODO: Pick this based on view settings
|
||||||
auto radarData =
|
auto radarData =
|
||||||
p->radarProductManager_->GetLevel2Data(p->dataBlockType_, 0);
|
p->radarProductManager_->GetLevel2Data(p->dataBlockType_, 0);
|
||||||
if (radarData.size() == 0)
|
if (radarData == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const common::RadialSize radialSize = (radarData.size() == 720) ?
|
const size_t radials = radarData->size();
|
||||||
common::RadialSize::_0_5Degree :
|
const common::RadialSize radialSize =
|
||||||
common::RadialSize::_1Degree;
|
(radials == common::MAX_0_5_DEGREE_RADIALS) ?
|
||||||
|
common::RadialSize::_0_5Degree :
|
||||||
|
common::RadialSize::_1Degree;
|
||||||
const std::vector<float>& coordinates =
|
const std::vector<float>& coordinates =
|
||||||
p->radarProductManager_->coordinates(radialSize);
|
p->radarProductManager_->coordinates(radialSize);
|
||||||
|
|
||||||
auto radarData0 = radarData[0];
|
auto radarData0 = (*radarData)[0];
|
||||||
auto momentData0 = radarData0->moment_data_block(p->dataBlockType_);
|
auto momentData0 = radarData0->moment_data_block(p->dataBlockType_);
|
||||||
p->momentDataBlock0_ = momentData0;
|
p->momentDataBlock0_ = momentData0;
|
||||||
|
|
||||||
|
|
@ -270,7 +272,6 @@ void Level2ProductView::ComputeSweep()
|
||||||
|
|
||||||
// Setup vertex vector
|
// Setup vertex vector
|
||||||
std::vector<float>& vertices = p->vertices_;
|
std::vector<float>& vertices = p->vertices_;
|
||||||
const size_t radials = radarData.size();
|
|
||||||
const uint32_t gates = momentData0->number_of_data_moment_gates();
|
const uint32_t gates = momentData0->number_of_data_moment_gates();
|
||||||
size_t vIndex = 0;
|
size_t vIndex = 0;
|
||||||
vertices.clear();
|
vertices.clear();
|
||||||
|
|
@ -311,7 +312,7 @@ void Level2ProductView::ComputeSweep()
|
||||||
const float startAngle = radarData0->azimuth_angle();
|
const float startAngle = radarData0->azimuth_angle();
|
||||||
const uint16_t startRadial = std::lroundf(startAngle * radialMultiplier);
|
const uint16_t startRadial = std::lroundf(startAngle * radialMultiplier);
|
||||||
|
|
||||||
for (auto radialPair : radarData)
|
for (auto radialPair : *radarData)
|
||||||
{
|
{
|
||||||
uint16_t radial = radialPair.first;
|
uint16_t radial = radialPair.first;
|
||||||
auto radialData = radialPair.second;
|
auto radialData = radialPair.second;
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,8 @@ public:
|
||||||
std::chrono::system_clock::time_point start_time() const;
|
std::chrono::system_clock::time_point start_time() const;
|
||||||
std::chrono::system_clock::time_point end_time() const;
|
std::chrono::system_clock::time_point end_time() const;
|
||||||
|
|
||||||
std::map<uint16_t,
|
std::map<uint16_t, std::shared_ptr<rda::ElevationScan>> radar_data() const;
|
||||||
std::map<uint16_t, std::shared_ptr<rda::DigitalRadarData>>>
|
std::shared_ptr<const rda::VolumeCoveragePatternData> vcp_data() const;
|
||||||
radar_data() const;
|
|
||||||
std::shared_ptr<const rda::VolumeCoveragePatternData> vcp_data() const;
|
|
||||||
|
|
||||||
bool LoadFile(const std::string& filename);
|
bool LoadFile(const std::string& filename);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <scwx/util/iterator.hpp>
|
||||||
#include <scwx/wsr88d/rda/message.hpp>
|
#include <scwx/wsr88d/rda/message.hpp>
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
|
|
@ -23,6 +24,9 @@ enum class DataBlockType
|
||||||
MomentCfp,
|
MomentCfp,
|
||||||
Unknown
|
Unknown
|
||||||
};
|
};
|
||||||
|
typedef util::
|
||||||
|
Iterator<DataBlockType, DataBlockType::MomentRef, DataBlockType::MomentCfp>
|
||||||
|
MomentDataBlockTypeIterator;
|
||||||
|
|
||||||
class DataBlockImpl;
|
class DataBlockImpl;
|
||||||
class ElevationDataBlockImpl;
|
class ElevationDataBlockImpl;
|
||||||
|
|
@ -30,8 +34,11 @@ class MomentDataBlockImpl;
|
||||||
class RadialDataBlockImpl;
|
class RadialDataBlockImpl;
|
||||||
class VolumeDataBlockImpl;
|
class VolumeDataBlockImpl;
|
||||||
|
|
||||||
|
class DigitalRadarData;
|
||||||
class DigitalRadarDataImpl;
|
class DigitalRadarDataImpl;
|
||||||
|
|
||||||
|
typedef std::map<uint16_t, std::shared_ptr<DigitalRadarData>> ElevationScan;
|
||||||
|
|
||||||
class DataBlock
|
class DataBlock
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,8 @@ public:
|
||||||
|
|
||||||
size_t numRecords_;
|
size_t numRecords_;
|
||||||
|
|
||||||
std::shared_ptr<rda::VolumeCoveragePatternData> vcpData_;
|
std::shared_ptr<rda::VolumeCoveragePatternData> vcpData_;
|
||||||
std::map<uint16_t,
|
std::map<uint16_t, std::shared_ptr<rda::ElevationScan>> radarData_;
|
||||||
std::map<uint16_t, std::shared_ptr<rda::DigitalRadarData>>>
|
|
||||||
radarData_;
|
|
||||||
|
|
||||||
std::list<std::stringstream> rawRecords_;
|
std::list<std::stringstream> rawRecords_;
|
||||||
};
|
};
|
||||||
|
|
@ -82,7 +80,7 @@ std::chrono::system_clock::time_point Ar2vFile::end_time() const
|
||||||
if (p->radarData_.size() > 0)
|
if (p->radarData_.size() > 0)
|
||||||
{
|
{
|
||||||
std::shared_ptr<rda::DigitalRadarData> lastRadial =
|
std::shared_ptr<rda::DigitalRadarData> lastRadial =
|
||||||
p->radarData_.crbegin()->second.crbegin()->second;
|
p->radarData_.crbegin()->second->crbegin()->second;
|
||||||
|
|
||||||
endTime = util::TimePoint(lastRadial->modified_julian_date(),
|
endTime = util::TimePoint(lastRadial->modified_julian_date(),
|
||||||
lastRadial->collection_time());
|
lastRadial->collection_time());
|
||||||
|
|
@ -91,7 +89,7 @@ std::chrono::system_clock::time_point Ar2vFile::end_time() const
|
||||||
return endTime;
|
return endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<uint16_t, std::map<uint16_t, std::shared_ptr<rda::DigitalRadarData>>>
|
std::map<uint16_t, std::shared_ptr<rda::ElevationScan>>
|
||||||
Ar2vFile::radar_data() const
|
Ar2vFile::radar_data() const
|
||||||
{
|
{
|
||||||
return p->radarData_;
|
return p->radarData_;
|
||||||
|
|
@ -289,7 +287,12 @@ void Ar2vFileImpl::ProcessRadarData(
|
||||||
uint16_t azimuthIndex = message->azimuth_number() - 1;
|
uint16_t azimuthIndex = message->azimuth_number() - 1;
|
||||||
uint16_t elevationIndex = message->elevation_number() - 1;
|
uint16_t elevationIndex = message->elevation_number() - 1;
|
||||||
|
|
||||||
radarData_[elevationIndex][azimuthIndex] = message;
|
if (radarData_[elevationIndex] == nullptr)
|
||||||
|
{
|
||||||
|
radarData_[elevationIndex] = std::make_shared<rda::ElevationScan>();
|
||||||
|
}
|
||||||
|
|
||||||
|
(*radarData_[elevationIndex])[azimuthIndex] = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace wsr88d
|
} // namespace wsr88d
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue