mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 07:20:04 +00:00 
			
		
		
		
	Stub for selecting radar product on successful file load
This commit is contained in:
		
							parent
							
								
									2000f3acb1
								
							
						
					
					
						commit
						7c44bafeb5
					
				
					 8 changed files with 68 additions and 43 deletions
				
			
		|  | @ -207,6 +207,8 @@ void MainWindow::on_actionOpen_triggered() | ||||||
|    dialog->setNameFilter(tr(nexradFilter.c_str())); |    dialog->setNameFilter(tr(nexradFilter.c_str())); | ||||||
|    dialog->setAttribute(Qt::WA_DeleteOnClose); |    dialog->setAttribute(Qt::WA_DeleteOnClose); | ||||||
| 
 | 
 | ||||||
|  |    map::MapWidget* currentMap = p->activeMap_; | ||||||
|  | 
 | ||||||
|    // Make sure the parent window properly repaints on close
 |    // Make sure the parent window properly repaints on close
 | ||||||
|    connect( |    connect( | ||||||
|       dialog, |       dialog, | ||||||
|  | @ -234,22 +236,13 @@ void MainWindow::on_actionOpen_triggered() | ||||||
|             { |             { | ||||||
|                std::shared_ptr<types::RadarProductRecord> record = |                std::shared_ptr<types::RadarProductRecord> record = | ||||||
|                   request->radar_product_record(); |                   request->radar_product_record(); | ||||||
|                std::shared_ptr<wsr88d::Ar2vFile>   level2File = nullptr; |  | ||||||
|                std::shared_ptr<wsr88d::Level3File> level3File = nullptr; |  | ||||||
| 
 | 
 | ||||||
|                if (record != nullptr) |                if (record != nullptr) | ||||||
|                { |                { | ||||||
|                   level2File = record->level2_file(); |                   currentMap->SelectRadarProduct(record->radar_id(), | ||||||
|                   level3File = record->level3_file(); |                                                  record->radar_product_group(), | ||||||
|                } |                                                  record->radar_product(), | ||||||
| 
 |                                                  record->time()); | ||||||
|                if (level2File != nullptr) |  | ||||||
|                { |  | ||||||
|                   // TODO: Handle
 |  | ||||||
|                } |  | ||||||
|                else if (level3File != nullptr) |  | ||||||
|                { |  | ||||||
|                   // TODO: Handle
 |  | ||||||
|                } |                } | ||||||
|                else |                else | ||||||
|                { |                { | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ | ||||||
| #include <scwx/qt/map/radar_product_layer.hpp> | #include <scwx/qt/map/radar_product_layer.hpp> | ||||||
| #include <scwx/qt/map/radar_range_layer.hpp> | #include <scwx/qt/map/radar_range_layer.hpp> | ||||||
| #include <scwx/qt/view/radar_product_view_factory.hpp> | #include <scwx/qt/view/radar_product_view_factory.hpp> | ||||||
|  | #include <scwx/util/time.hpp> | ||||||
| 
 | 
 | ||||||
| #include <QApplication> | #include <QApplication> | ||||||
| #include <QColor> | #include <QColor> | ||||||
|  | @ -246,6 +247,17 @@ void MapWidget::SelectRadarProduct(common::Level2Product product) | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void MapWidget::SelectRadarProduct(const std::string&        radarId, | ||||||
|  |                                    common::RadarProductGroup group, | ||||||
|  |                                    const std::string&        product, | ||||||
|  |                                    std::chrono::system_clock::time_point time) | ||||||
|  | { | ||||||
|  |    BOOST_LOG_TRIVIAL(debug) | ||||||
|  |       << logPrefix_ << "SelectRadarProduct(" << radarId << ", " | ||||||
|  |       << common::GetRadarProductGroupName(group) << ", " << product << ", " | ||||||
|  |       << util::TimeString(time) << ")"; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void MapWidget::SetActive(bool isActive) | void MapWidget::SetActive(bool isActive) | ||||||
| { | { | ||||||
|    p->context_->settings_.isActive_ = isActive; |    p->context_->settings_.isActive_ = isActive; | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <scwx/common/products.hpp> | #include <scwx/common/products.hpp> | ||||||
| 
 | 
 | ||||||
|  | #include <chrono> | ||||||
| #include <memory> | #include <memory> | ||||||
| 
 | 
 | ||||||
| #include <QMapboxGL> | #include <QMapboxGL> | ||||||
|  | @ -39,6 +40,10 @@ public: | ||||||
| 
 | 
 | ||||||
|    void SelectElevation(float elevation); |    void SelectElevation(float elevation); | ||||||
|    void SelectRadarProduct(common::Level2Product product); |    void SelectRadarProduct(common::Level2Product product); | ||||||
|  |    void SelectRadarProduct(const std::string&                    radarId, | ||||||
|  |                            common::RadarProductGroup             group, | ||||||
|  |                            const std::string&                    product, | ||||||
|  |                            std::chrono::system_clock::time_point time); | ||||||
|    void SetActive(bool isActive); |    void SetActive(bool isActive); | ||||||
|    void SetMapParameters(double latitude, |    void SetMapParameters(double latitude, | ||||||
|                          double longitude, |                          double longitude, | ||||||
|  |  | ||||||
|  | @ -1,13 +1,9 @@ | ||||||
| // Enable chrono formatters
 |  | ||||||
| #ifndef __cpp_lib_format |  | ||||||
| #   define __cpp_lib_format 202110L |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #include <scwx/qt/map/overlay_layer.hpp> | #include <scwx/qt/map/overlay_layer.hpp> | ||||||
| #include <scwx/qt/gl/draw/rectangle.hpp> | #include <scwx/qt/gl/draw/rectangle.hpp> | ||||||
| #include <scwx/qt/gl/shader_program.hpp> | #include <scwx/qt/gl/shader_program.hpp> | ||||||
| #include <scwx/qt/gl/text_shader.hpp> | #include <scwx/qt/gl/text_shader.hpp> | ||||||
| #include <scwx/qt/util/font.hpp> | #include <scwx/qt/util/font.hpp> | ||||||
|  | #include <scwx/util/time.hpp> | ||||||
| 
 | 
 | ||||||
| #include <chrono> | #include <chrono> | ||||||
| #include <execution> | #include <execution> | ||||||
|  | @ -105,18 +101,9 @@ void OverlayLayer::Render(const QMapbox::CustomLayerRenderParameters& params) | ||||||
| 
 | 
 | ||||||
|    if (p->sweepTimeNeedsUpdate_ && context()->radarProductView_ != nullptr) |    if (p->sweepTimeNeedsUpdate_ && context()->radarProductView_ != nullptr) | ||||||
|    { |    { | ||||||
|       using namespace std::chrono; |       p->sweepTimeString_ = | ||||||
|       auto sweepTime = |          scwx::util::TimeString(context()->radarProductView_->sweep_time(), | ||||||
|          time_point_cast<seconds>(context()->radarProductView_->sweep_time()); |                                 std::chrono::current_zone()); | ||||||
| 
 |  | ||||||
|       if (sweepTime.time_since_epoch().count() != 0) |  | ||||||
|       { |  | ||||||
|          zoned_time         zt = {current_zone(), sweepTime}; |  | ||||||
|          std::ostringstream os; |  | ||||||
|          os << zt; |  | ||||||
|          p->sweepTimeString_ = os.str(); |  | ||||||
|       } |  | ||||||
| 
 |  | ||||||
|       p->sweepTimeNeedsUpdate_ = false; |       p->sweepTimeNeedsUpdate_ = false; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -102,7 +102,7 @@ | ||||||
| <context> | <context> | ||||||
|     <name>scwx::qt::main::MainWindow</name> |     <name>scwx::qt::main::MainWindow</name> | ||||||
|     <message> |     <message> | ||||||
|         <location filename="../source/scwx/qt/main/main_window.cpp" line="259"/> |         <location filename="../source/scwx/qt/main/main_window.cpp" line="252"/> | ||||||
|         <source>Unrecognized NEXRAD Product:</source> |         <source>Unrecognized NEXRAD Product:</source> | ||||||
|         <translation type="unfinished"></translation> |         <translation type="unfinished"></translation> | ||||||
|     </message> |     </message> | ||||||
|  |  | ||||||
|  | @ -10,5 +10,8 @@ namespace util | ||||||
| std::chrono::system_clock::time_point TimePoint(uint16_t modifiedJulianDate, | std::chrono::system_clock::time_point TimePoint(uint16_t modifiedJulianDate, | ||||||
|                                                 uint32_t milliseconds); |                                                 uint32_t milliseconds); | ||||||
| 
 | 
 | ||||||
|  | std::string TimeString(std::chrono::system_clock::time_point time, | ||||||
|  |                        const std::chrono::time_zone* timeZone = nullptr); | ||||||
|  | 
 | ||||||
| } // namespace util
 | } // namespace util
 | ||||||
| } // namespace scwx
 | } // namespace scwx
 | ||||||
|  |  | ||||||
|  | @ -8,9 +8,9 @@ namespace common | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::unordered_map<RadarProductGroup, std::string> | static const std::unordered_map<RadarProductGroup, std::string> | ||||||
|    productGroupName_ {{RadarProductGroup::Level2, "L2"}, |    radarProductGroupName_ {{RadarProductGroup::Level2, "L2"}, | ||||||
|                       {RadarProductGroup::Level3, "L3"}, |                            {RadarProductGroup::Level3, "L3"}, | ||||||
|                       {RadarProductGroup::Unknown, "?"}}; |                            {RadarProductGroup::Unknown, "?"}}; | ||||||
| 
 | 
 | ||||||
| static const std::unordered_map<Level2Product, std::string> level2Name_ { | static const std::unordered_map<Level2Product, std::string> level2Name_ { | ||||||
|    {Level2Product::Reflectivity, "REF"}, |    {Level2Product::Reflectivity, "REF"}, | ||||||
|  | @ -42,20 +42,20 @@ static const std::unordered_map<Level2Product, std::string> level2Palette_ { | ||||||
|    {Level2Product::ClutterFilterPowerRemoved, "???"}, |    {Level2Product::ClutterFilterPowerRemoved, "???"}, | ||||||
|    {Level2Product::Unknown, "???"}}; |    {Level2Product::Unknown, "???"}}; | ||||||
| 
 | 
 | ||||||
| const std::string& GetProductGroupName(RadarProductGroup group) | const std::string& GetRadarProductGroupName(RadarProductGroup group) | ||||||
| { | { | ||||||
|    return productGroupName_.at(group); |    return radarProductGroupName_.at(group); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| RadarProductGroup GetProductGroup(const std::string& name) | RadarProductGroup GetRadarProductGroup(const std::string& name) | ||||||
| { | { | ||||||
|    auto result = std::find_if( |    auto result = std::find_if( | ||||||
|       productGroupName_.cbegin(), |       radarProductGroupName_.cbegin(), | ||||||
|       productGroupName_.cend(), |       radarProductGroupName_.cend(), | ||||||
|       [&](const std::pair<RadarProductGroup, std::string>& pair) -> bool |       [&](const std::pair<RadarProductGroup, std::string>& pair) -> bool | ||||||
|       { return pair.second == name; }); |       { return pair.second == name; }); | ||||||
| 
 | 
 | ||||||
|    if (result != productGroupName_.cend()) |    if (result != radarProductGroupName_.cend()) | ||||||
|    { |    { | ||||||
|       return result->first; |       return result->first; | ||||||
|    } |    } | ||||||
|  |  | ||||||
|  | @ -1,3 +1,8 @@ | ||||||
|  | // Enable chrono formatters
 | ||||||
|  | #ifndef __cpp_lib_format | ||||||
|  | #   define __cpp_lib_format 202110L | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
| #include <scwx/util/time.hpp> | #include <scwx/util/time.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx | ||||||
|  | @ -5,8 +10,8 @@ namespace scwx | ||||||
| namespace util | namespace util | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| std::chrono::system_clock::time_point | std::chrono::system_clock::time_point TimePoint(uint16_t modifiedJulianDate, | ||||||
| TimePoint(uint16_t modifiedJulianDate, uint32_t milliseconds) |                                                 uint32_t milliseconds) | ||||||
| { | { | ||||||
|    using namespace std::chrono; |    using namespace std::chrono; | ||||||
|    using sys_days       = time_point<system_clock, days>; |    using sys_days       = time_point<system_clock, days>; | ||||||
|  | @ -16,5 +21,25 @@ TimePoint(uint16_t modifiedJulianDate, uint32_t milliseconds) | ||||||
|           std::chrono::milliseconds {milliseconds}; |           std::chrono::milliseconds {milliseconds}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace qt
 | std::string TimeString(std::chrono::system_clock::time_point time, | ||||||
|  |                        const std::chrono::time_zone*         timeZone) | ||||||
|  | { | ||||||
|  |    using namespace std::chrono; | ||||||
|  |    auto               timeInSeconds = time_point_cast<seconds>(time); | ||||||
|  |    std::ostringstream os; | ||||||
|  | 
 | ||||||
|  |    if (timeZone != nullptr) | ||||||
|  |    { | ||||||
|  |       zoned_time zt = {current_zone(), timeInSeconds}; | ||||||
|  |       os << zt; | ||||||
|  |    } | ||||||
|  |    else | ||||||
|  |    { | ||||||
|  |       os << timeInSeconds; | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    return os.str(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | } // namespace util
 | ||||||
| } // namespace scwx
 | } // namespace scwx
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat