Initial indexing capability

This commit is contained in:
Dan Paulat 2021-11-13 01:15:53 -06:00
parent ab616b0c62
commit 3e92847901
6 changed files with 153 additions and 54 deletions

View file

@ -31,10 +31,12 @@ public:
numRecords_ {0},
rawRecords_(),
vcpData_ {nullptr},
radarData_ {} {};
radarData_ {},
index_ {} {};
~Ar2vFileImpl() = default;
void HandleMessage(std::shared_ptr<rda::Message>& message);
void IndexFile();
void LoadLDMRecords(std::ifstream& f);
void ParseLDMRecords();
void ProcessRadarData(std::shared_ptr<rda::DigitalRadarData> message);
@ -50,6 +52,10 @@ public:
std::shared_ptr<rda::VolumeCoveragePatternData> vcpData_;
std::map<uint16_t, std::shared_ptr<rda::ElevationScan>> radarData_;
std::map<rda::DataBlockType,
std::map<uint16_t, std::shared_ptr<rda::ElevationScan>>>
index_;
std::list<std::stringstream> rawRecords_;
};
@ -100,6 +106,23 @@ std::shared_ptr<const rda::VolumeCoveragePatternData> Ar2vFile::vcp_data() const
return p->vcpData_;
}
std::shared_ptr<rda::ElevationScan>
Ar2vFile::GetElevationScan(rda::DataBlockType dataBlockType,
uint16_t elevation,
std::chrono::system_clock::time_point time) const
{
std::shared_ptr<rda::ElevationScan> elevationScan = nullptr;
// TODO: 88 = 0.5 degrees - this should be parameterized and searched
if (p->index_.contains(dataBlockType) &&
p->index_.at(dataBlockType).contains(88))
{
return p->index_.at(dataBlockType).at(88);
}
return elevationScan;
}
bool Ar2vFile::LoadFile(const std::string& filename)
{
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "LoadFile(" << filename << ")";
@ -151,6 +174,8 @@ bool Ar2vFile::LoadFile(const std::string& filename)
p->LoadLDMRecords(f);
}
p->IndexFile();
return fileValid;
}
@ -295,5 +320,44 @@ void Ar2vFileImpl::ProcessRadarData(
(*radarData_[elevationIndex])[azimuthIndex] = message;
}
void Ar2vFileImpl::IndexFile()
{
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Indexing file";
for (auto elevationCut : radarData_)
{
uint16_t elevationAngle =
vcpData_->elevation_angle_raw(elevationCut.first);
rda::WaveformType waveformType =
vcpData_->waveform_type(elevationCut.first);
std::shared_ptr<rda::DigitalRadarData> radial0 =
(*elevationCut.second)[0];
for (rda::DataBlockType dataBlockType :
rda::MomentDataBlockTypeIterator())
{
if (dataBlockType == rda::DataBlockType::MomentRef &&
(waveformType ==
rda::WaveformType::ContiguousDopplerWithAmbiguityResolution ||
waveformType == rda::WaveformType::
ContiguousDopplerWithoutAmbiguityResolution))
{
// Reflectivity data is contained within both surveillance and
// doppler modes. Surveillance mode produces a better image.
continue;
}
auto momentData = radial0->moment_data_block(dataBlockType);
if (momentData != nullptr)
{
// TODO: Handle multiple elevation scans
index_[dataBlockType][elevationAngle] = elevationCut.second;
}
}
}
}
} // namespace wsr88d
} // namespace scwx

View file

@ -219,12 +219,30 @@ double VolumeCoveragePatternData::elevation_angle(uint16_t e) const
return p->elevationCuts_[e].elevationAngle_ * ANGLE_DATA_SCALE;
}
uint16_t VolumeCoveragePatternData::elevation_angle_raw(uint16_t e) const
{
return p->elevationCuts_[e].elevationAngle_;
}
uint8_t VolumeCoveragePatternData::channel_configuration(uint16_t e) const
{
return p->elevationCuts_[e].channelConfiguration_;
}
uint8_t VolumeCoveragePatternData::waveform_type(uint16_t e) const
WaveformType VolumeCoveragePatternData::waveform_type(uint16_t e) const
{
switch (p->elevationCuts_[e].waveformType_)
{
case 1: return WaveformType::ContiguousSurveillance;
case 2: return WaveformType::ContiguousDopplerWithAmbiguityResolution;
case 3: return WaveformType::ContiguousDopplerWithoutAmbiguityResolution;
case 4: return WaveformType::Batch;
case 5: return WaveformType::StaggeredPulsePair;
default: return WaveformType::Unknown;
}
}
uint8_t VolumeCoveragePatternData::waveform_type_raw(uint16_t e) const
{
return p->elevationCuts_[e].waveformType_;
}