mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 07:50:04 +00:00
Add toolbox for radar display control
This commit is contained in:
parent
cd5d60bc0b
commit
7c606b85ff
8 changed files with 325 additions and 6 deletions
35
wxdata/include/scwx/common/products.hpp
Normal file
35
wxdata/include/scwx/common/products.hpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include <scwx/util/iterator.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
|
||||
const std::string LEVEL2_GROUP_ID = "L2";
|
||||
|
||||
enum class Level2Product
|
||||
{
|
||||
Reflectivity,
|
||||
Velocity,
|
||||
SpectrumWidth,
|
||||
DifferentialReflectivity,
|
||||
DifferentialPhase,
|
||||
CorrelationCoefficient,
|
||||
ClutterFilterPowerRemoved,
|
||||
Unknown
|
||||
};
|
||||
typedef util::Iterator<Level2Product,
|
||||
Level2Product::Reflectivity,
|
||||
Level2Product::ClutterFilterPowerRemoved>
|
||||
Level2ProductIterator;
|
||||
|
||||
const std::string& GetLevel2Name(Level2Product product);
|
||||
const std::string& GetLevel2Description(Level2Product product);
|
||||
const Level2Product GetLevel2Product(const std::string& id);
|
||||
|
||||
} // namespace common
|
||||
} // namespace scwx
|
||||
35
wxdata/include/scwx/util/iterator.hpp
Normal file
35
wxdata/include/scwx/util/iterator.hpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
template<typename T, T beginValue, T endValue>
|
||||
class Iterator
|
||||
{
|
||||
typedef typename std::underlying_type<T>::type value_t;
|
||||
int value_;
|
||||
|
||||
public:
|
||||
Iterator(const T& v) : value_(static_cast<value_t>(v)) {}
|
||||
Iterator() : value_(static_cast<value_t>(beginValue)) {}
|
||||
Iterator operator++()
|
||||
{
|
||||
++value_;
|
||||
return *this;
|
||||
}
|
||||
T operator*() { return static_cast<T>(value_); }
|
||||
Iterator begin() { return *this; } // Default constructor
|
||||
Iterator end()
|
||||
{
|
||||
static const Iterator endIterator = ++Iterator(endValue);
|
||||
return endIterator;
|
||||
}
|
||||
bool operator!=(const Iterator& i) { return value_ != i.value_; }
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace scwx
|
||||
60
wxdata/source/scwx/common/products.cpp
Normal file
60
wxdata/source/scwx/common/products.cpp
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#include <scwx/common/products.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
|
||||
static const std::unordered_map<Level2Product, std::string> level2Name_ {
|
||||
{Level2Product::Reflectivity, "REF"},
|
||||
{Level2Product::Velocity, "VEL"},
|
||||
{Level2Product::SpectrumWidth, "SW"},
|
||||
{Level2Product::DifferentialReflectivity, "ZDR"},
|
||||
{Level2Product::DifferentialPhase, "PHI"},
|
||||
{Level2Product::CorrelationCoefficient, "RHO"},
|
||||
{Level2Product::ClutterFilterPowerRemoved, "CFP"},
|
||||
{Level2Product::Unknown, "?"}};
|
||||
|
||||
static const std::unordered_map<Level2Product, std::string> level2Description_ {
|
||||
{Level2Product::Reflectivity, "Reflectivity"},
|
||||
{Level2Product::Velocity, "Velocity"},
|
||||
{Level2Product::SpectrumWidth, "Spectrum Width"},
|
||||
{Level2Product::DifferentialReflectivity, "Differential Reflectivity"},
|
||||
{Level2Product::DifferentialPhase, "Differential Phase"},
|
||||
{Level2Product::CorrelationCoefficient, "Correlation Coefficient"},
|
||||
{Level2Product::ClutterFilterPowerRemoved, "Clutter Filter Power Removed"},
|
||||
{Level2Product::Unknown, "?"}};
|
||||
|
||||
const std::string& GetLevel2Name(Level2Product product)
|
||||
{
|
||||
return level2Name_.at(product);
|
||||
}
|
||||
|
||||
const std::string& GetLevel2Description(Level2Product product)
|
||||
{
|
||||
return level2Description_.at(product);
|
||||
}
|
||||
|
||||
const Level2Product GetLevel2Product(const std::string& name)
|
||||
{
|
||||
auto result = std::find_if(
|
||||
level2Name_.cbegin(),
|
||||
level2Name_.cend(),
|
||||
[&](const std::pair<Level2Product, std::string>& pair) -> bool {
|
||||
return pair.second == name;
|
||||
});
|
||||
|
||||
if (result != level2Name_.cend())
|
||||
{
|
||||
return result->first;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Level2Product::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace common
|
||||
} // namespace scwx
|
||||
|
|
@ -4,9 +4,12 @@ find_package(Boost)
|
|||
|
||||
set(HDR_COMMON include/scwx/common/color_table.hpp
|
||||
include/scwx/common/constants.hpp
|
||||
include/scwx/common/products.hpp
|
||||
include/scwx/common/types.hpp)
|
||||
set(SRC_COMMON source/scwx/common/color_table.cpp)
|
||||
set(HDR_UTIL include/scwx/util/rangebuf.hpp
|
||||
set(SRC_COMMON source/scwx/common/color_table.cpp
|
||||
source/scwx/common/products.cpp)
|
||||
set(HDR_UTIL include/scwx/util/iterator.hpp
|
||||
include/scwx/util/rangebuf.hpp
|
||||
include/scwx/util/vectorbuf.hpp)
|
||||
set(SRC_UTIL source/scwx/util/rangebuf.cpp
|
||||
source/scwx/util/vectorbuf.cpp)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue