mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 14:50:05 +00:00
Radar product manager load file functionality
This commit is contained in:
parent
3829b77994
commit
f7b8778e0d
2 changed files with 76 additions and 0 deletions
|
|
@ -2,10 +2,12 @@
|
|||
#include <scwx/common/constants.hpp>
|
||||
#include <scwx/qt/config/radar_site.hpp>
|
||||
#include <scwx/util/threads.hpp>
|
||||
#include <scwx/wsr88d/nexrad_file_factory.hpp>
|
||||
|
||||
#include <deque>
|
||||
#include <execution>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/range/irange.hpp>
|
||||
|
|
@ -23,6 +25,13 @@ namespace manager
|
|||
static const std::string logPrefix_ =
|
||||
"[scwx::qt::manager::radar_product_manager] ";
|
||||
|
||||
typedef std::function<std::shared_ptr<wsr88d::NexradFile>()>
|
||||
CreateNexradFileFunction;
|
||||
|
||||
static void LoadNexradFile(CreateNexradFileFunction load,
|
||||
FileLoadCompleteFunction onComplete,
|
||||
QObject* context);
|
||||
|
||||
static constexpr uint32_t NUM_RADIAL_GATES_0_5_DEGREE =
|
||||
common::MAX_0_5_DEGREE_RADIALS * common::MAX_DATA_MOMENT_GATES;
|
||||
static constexpr uint32_t NUM_RADIAL_GATES_1_DEGREE =
|
||||
|
|
@ -36,6 +45,8 @@ static constexpr uint32_t NUM_COORIDNATES_1_DEGREE =
|
|||
static std::unordered_map<std::string, std::shared_ptr<RadarProductManager>>
|
||||
instanceMap_;
|
||||
|
||||
static std::shared_mutex fileLoadMutex_;
|
||||
|
||||
class RadarProductManagerImpl
|
||||
{
|
||||
public:
|
||||
|
|
@ -199,6 +210,60 @@ void RadarProductManager::Initialize()
|
|||
p->initialized_ = true;
|
||||
}
|
||||
|
||||
void RadarProductManager::LoadData(std::istream& is,
|
||||
FileLoadCompleteFunction onComplete,
|
||||
QObject* context)
|
||||
{
|
||||
LoadNexradFile(
|
||||
[=, &is]() -> std::shared_ptr<wsr88d::NexradFile> {
|
||||
return wsr88d::NexradFileFactory::Create(is);
|
||||
},
|
||||
onComplete,
|
||||
context);
|
||||
}
|
||||
|
||||
void RadarProductManager::LoadFile(const std::string& filename,
|
||||
FileLoadCompleteFunction onComplete,
|
||||
QObject* context)
|
||||
{
|
||||
LoadNexradFile(
|
||||
[=]() -> std::shared_ptr<wsr88d::NexradFile> {
|
||||
return wsr88d::NexradFileFactory::Create(filename);
|
||||
},
|
||||
onComplete,
|
||||
context);
|
||||
}
|
||||
|
||||
static void LoadNexradFile(CreateNexradFileFunction load,
|
||||
FileLoadCompleteFunction onComplete,
|
||||
QObject* context)
|
||||
{
|
||||
scwx::util::async(
|
||||
[=]()
|
||||
{
|
||||
std::unique_lock lock(fileLoadMutex_);
|
||||
std::shared_ptr<wsr88d::NexradFile> nexradFile = load();
|
||||
|
||||
// TODO: Store and index
|
||||
// - Should this impact arguments sent back in onComplete?
|
||||
|
||||
lock.unlock();
|
||||
|
||||
if (onComplete != nullptr)
|
||||
{
|
||||
if (context == nullptr)
|
||||
{
|
||||
onComplete(nexradFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMetaObject::invokeMethod(context,
|
||||
[=]() { onComplete(nexradFile); });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void RadarProductManager::LoadLevel2Data(const std::string& filename)
|
||||
{
|
||||
std::shared_ptr<wsr88d::Ar2vFile> ar2vFile =
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <scwx/common/types.hpp>
|
||||
#include <scwx/qt/config/radar_site.hpp>
|
||||
#include <scwx/wsr88d/ar2v_file.hpp>
|
||||
#include <scwx/wsr88d/level3_file.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
|
@ -16,6 +17,9 @@ namespace qt
|
|||
namespace manager
|
||||
{
|
||||
|
||||
typedef std::function<void(std::shared_ptr<wsr88d::NexradFile>)>
|
||||
FileLoadCompleteFunction;
|
||||
|
||||
class RadarProductManagerImpl;
|
||||
|
||||
class RadarProductManager : public QObject
|
||||
|
|
@ -45,6 +49,13 @@ public:
|
|||
static std::shared_ptr<RadarProductManager>
|
||||
Instance(const std::string& radarSite);
|
||||
|
||||
static void LoadData(std::istream& is,
|
||||
FileLoadCompleteFunction onComplete,
|
||||
QObject* context = nullptr);
|
||||
static void LoadFile(const std::string& filename,
|
||||
FileLoadCompleteFunction onComplete,
|
||||
QObject* context = nullptr);
|
||||
|
||||
signals:
|
||||
void Level2DataLoaded();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue