mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 07:50:04 +00:00
Load color tables from settings
This commit is contained in:
parent
bcae7d9825
commit
b241703b40
16 changed files with 324 additions and 17 deletions
|
|
@ -35,6 +35,7 @@ public:
|
|||
ColorTable& operator=(ColorTable&&) noexcept;
|
||||
|
||||
boost::gil::rgba8_pixel_t Color(float value) const;
|
||||
bool IsValid() const;
|
||||
|
||||
static std::shared_ptr<ColorTable> Load(const std::string& filename);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ typedef util::Iterator<Level2Product,
|
|||
|
||||
const std::string& GetLevel2Name(Level2Product product);
|
||||
const std::string& GetLevel2Description(Level2Product product);
|
||||
const std::string& GetLevel2Palette(Level2Product product);
|
||||
const Level2Product GetLevel2Product(const std::string& id);
|
||||
|
||||
} // namespace common
|
||||
|
|
|
|||
13
wxdata/include/scwx/util/streams.hpp
Normal file
13
wxdata/include/scwx/util/streams.hpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <istream>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
std::istream& getline(std::istream& is, std::string& t);
|
||||
|
||||
} // namespace util
|
||||
} // namespace scwx
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
#include <scwx/common/color_table.hpp>
|
||||
#include <scwx/util/streams.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
|
|
@ -122,6 +123,11 @@ boost::gil::rgba8_pixel_t ColorTable::Color(float value) const
|
|||
return color;
|
||||
}
|
||||
|
||||
bool ColorTable::IsValid() const
|
||||
{
|
||||
return p->colorMap_.size() > 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<ColorTable> ColorTable::Load(const std::string& filename)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug)
|
||||
|
|
@ -132,7 +138,7 @@ std::shared_ptr<ColorTable> ColorTable::Load(const std::string& filename)
|
|||
std::ifstream f(filename, std::ios_base::in);
|
||||
|
||||
std::string line;
|
||||
while (std::getline(f, line))
|
||||
while (scwx::util::getline(f, line))
|
||||
{
|
||||
std::string token;
|
||||
std::istringstream tokens(line);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,16 @@ static const std::unordered_map<Level2Product, std::string> level2Description_ {
|
|||
{Level2Product::ClutterFilterPowerRemoved, "Clutter Filter Power Removed"},
|
||||
{Level2Product::Unknown, "?"}};
|
||||
|
||||
static const std::unordered_map<Level2Product, std::string> level2Palette_ {
|
||||
{Level2Product::Reflectivity, "BR"},
|
||||
{Level2Product::Velocity, "BV"},
|
||||
{Level2Product::SpectrumWidth, "SW"},
|
||||
{Level2Product::DifferentialReflectivity, "ZDR"},
|
||||
{Level2Product::DifferentialPhase, "PHI"},
|
||||
{Level2Product::CorrelationCoefficient, "CC"},
|
||||
{Level2Product::ClutterFilterPowerRemoved, "???"},
|
||||
{Level2Product::Unknown, "???"}};
|
||||
|
||||
const std::string& GetLevel2Name(Level2Product product)
|
||||
{
|
||||
return level2Name_.at(product);
|
||||
|
|
@ -37,6 +47,11 @@ const std::string& GetLevel2Description(Level2Product product)
|
|||
return level2Description_.at(product);
|
||||
}
|
||||
|
||||
const std::string& GetLevel2Palette(Level2Product product)
|
||||
{
|
||||
return level2Palette_.at(product);
|
||||
}
|
||||
|
||||
const Level2Product GetLevel2Product(const std::string& name)
|
||||
{
|
||||
auto result = std::find_if(
|
||||
|
|
|
|||
42
wxdata/source/scwx/util/streams.cpp
Normal file
42
wxdata/source/scwx/util/streams.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#include <scwx/util/streams.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
std::istream& getline(std::istream& is, std::string& t)
|
||||
{
|
||||
t.clear();
|
||||
|
||||
std::istream::sentry sentry(is, true);
|
||||
std::streambuf* sb = is.rdbuf();
|
||||
|
||||
while (true)
|
||||
{
|
||||
int c = sb->sbumpc();
|
||||
switch (c)
|
||||
{
|
||||
case '\n': return is;
|
||||
|
||||
case '\r':
|
||||
if (sb->sgetc() == '\n')
|
||||
{
|
||||
sb->sbumpc();
|
||||
}
|
||||
return is;
|
||||
|
||||
case std::streambuf::traits_type::eof():
|
||||
if (t.empty())
|
||||
{
|
||||
is.setstate(std::ios::eofbit);
|
||||
}
|
||||
return is;
|
||||
|
||||
default: t += static_cast<char>(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace scwx
|
||||
|
|
@ -10,8 +10,10 @@ 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/streams.hpp
|
||||
include/scwx/util/vectorbuf.hpp)
|
||||
set(SRC_UTIL source/scwx/util/rangebuf.cpp
|
||||
source/scwx/util/streams.cpp
|
||||
source/scwx/util/vectorbuf.cpp)
|
||||
set(HDR_WSR88D include/scwx/wsr88d/ar2v_file.hpp)
|
||||
set(SRC_WSR88D source/scwx/wsr88d/ar2v_file.cpp)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue