mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 18:30:06 +00:00 
			
		
		
		
	Add additional alert display columns
- State, counties, start and end time
This commit is contained in:
		
							parent
							
								
									8fe7d5da6e
								
							
						
					
					
						commit
						fdd981899f
					
				
					 8 changed files with 126 additions and 15 deletions
				
			
		|  | @ -355,6 +355,9 @@ | ||||||
|           <property name="placeholderText"> |           <property name="placeholderText"> | ||||||
|            <string>Filter</string> |            <string>Filter</string> | ||||||
|           </property> |           </property> | ||||||
|  |           <property name="clearButtonEnabled"> | ||||||
|  |            <bool>true</bool> | ||||||
|  |           </property> | ||||||
|          </widget> |          </widget> | ||||||
|         </item> |         </item> | ||||||
|         <item> |         <item> | ||||||
|  |  | ||||||
|  | @ -86,14 +86,24 @@ void TextEventManager::Impl::HandleMessage( | ||||||
| { | { | ||||||
|    auto segments = message->segments(); |    auto segments = message->segments(); | ||||||
| 
 | 
 | ||||||
|    // If there are no segments, if the first segment has no header, or if there
 |    // If there are no segments, skip this message
 | ||||||
|    // is no VTEC string, skip this message
 |    if (segments.empty()) | ||||||
|    if (segments.empty() || !segments[0]->header_.has_value() || |  | ||||||
|        segments[0]->header_->vtecString_.empty()) |  | ||||||
|    { |    { | ||||||
|       return; |       return; | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |    for (auto& segment : segments) | ||||||
|  |    { | ||||||
|  |       // If a segment has no header, or if there is no VTEC string, skip this
 | ||||||
|  |       // message. A segmented message corresponding to a text event should have
 | ||||||
|  |       // this information.
 | ||||||
|  |       if (!segment->header_.has_value() || | ||||||
|  |           segment->header_->vtecString_.empty()) | ||||||
|  |       { | ||||||
|  |          return; | ||||||
|  |       } | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|    std::unique_lock lock(textEventMutex_); |    std::unique_lock lock(textEventMutex_); | ||||||
| 
 | 
 | ||||||
|    // Find a matching event in the event map
 |    // Find a matching event in the event map
 | ||||||
|  |  | ||||||
|  | @ -1,7 +1,10 @@ | ||||||
| #include <scwx/qt/model/alert_model.hpp> | #include <scwx/qt/model/alert_model.hpp> | ||||||
|  | #include <scwx/qt/manager/text_event_manager.hpp> | ||||||
| #include <scwx/qt/types/qt_types.hpp> | #include <scwx/qt/types/qt_types.hpp> | ||||||
| #include <scwx/common/geographic.hpp> | #include <scwx/common/geographic.hpp> | ||||||
| #include <scwx/util/logger.hpp> | #include <scwx/util/logger.hpp> | ||||||
|  | #include <scwx/util/strings.hpp> | ||||||
|  | #include <scwx/util/time.hpp> | ||||||
| 
 | 
 | ||||||
| #include <format> | #include <format> | ||||||
| 
 | 
 | ||||||
|  | @ -36,6 +39,11 @@ public: | ||||||
|    explicit AlertModelImpl(); |    explicit AlertModelImpl(); | ||||||
|    ~AlertModelImpl() = default; |    ~AlertModelImpl() = default; | ||||||
| 
 | 
 | ||||||
|  |    static std::string GetCounties(const types::TextEventKey& key); | ||||||
|  |    static std::string GetState(const types::TextEventKey& key); | ||||||
|  |    static std::string GetStartTime(const types::TextEventKey& key); | ||||||
|  |    static std::string GetEndTime(const types::TextEventKey& key); | ||||||
|  | 
 | ||||||
|    QList<types::TextEventKey> textEventKeys_; |    QList<types::TextEventKey> textEventKeys_; | ||||||
| 
 | 
 | ||||||
|    GeographicLib::Geodesic geodesic_; |    GeographicLib::Geodesic geodesic_; | ||||||
|  | @ -85,13 +93,16 @@ QVariant AlertModel::data(const QModelIndex& index, int role) const | ||||||
|          return QString::fromStdString( |          return QString::fromStdString( | ||||||
|             awips::GetSignificanceText(textEventKey.significance_)); |             awips::GetSignificanceText(textEventKey.significance_)); | ||||||
|       case kColumnState: |       case kColumnState: | ||||||
|          return QString::fromStdString("?"); |          return QString::fromStdString(AlertModelImpl::GetState(textEventKey)); | ||||||
|       case kColumnCounties: |       case kColumnCounties: | ||||||
|          return QString::fromStdString("?"); |          return QString::fromStdString( | ||||||
|  |             AlertModelImpl::GetCounties(textEventKey)); | ||||||
|       case kColumnStartTime: |       case kColumnStartTime: | ||||||
|          return QString::fromStdString("?"); |          return QString::fromStdString( | ||||||
|  |             AlertModelImpl::GetStartTime(textEventKey)); | ||||||
|       case kColumnEndTime: |       case kColumnEndTime: | ||||||
|          return QString::fromStdString("?"); |          return QString::fromStdString( | ||||||
|  |             AlertModelImpl::GetEndTime(textEventKey)); | ||||||
|       case kColumnDistance: |       case kColumnDistance: | ||||||
|          if (role == Qt::DisplayRole) |          if (role == Qt::DisplayRole) | ||||||
|          { |          { | ||||||
|  | @ -158,11 +169,7 @@ AlertModel::headerData(int section, Qt::Orientation orientation, int role) const | ||||||
| 
 | 
 | ||||||
| void AlertModel::HandleAlert(const types::TextEventKey& alertKey) | void AlertModel::HandleAlert(const types::TextEventKey& alertKey) | ||||||
| { | { | ||||||
|    logger_->trace("Handle alert: {}, {}, {}, {}", |    logger_->trace("Handle alert: {}", alertKey.ToString()); | ||||||
|                   alertKey.etn_, |  | ||||||
|                   alertKey.officeId_, |  | ||||||
|                   awips::GetPhenomenonText(alertKey.phenomenon_), |  | ||||||
|                   awips::GetSignificanceText(alertKey.significance_)); |  | ||||||
| 
 | 
 | ||||||
|    double distanceInMeters; |    double distanceInMeters; | ||||||
| 
 | 
 | ||||||
|  | @ -190,7 +197,7 @@ void AlertModel::HandleAlert(const types::TextEventKey& alertKey) | ||||||
|                            0.0, // TODO: textEvent->longitude(),
 |                            0.0, // TODO: textEvent->longitude(),
 | ||||||
|                            distanceInMeters); |                            distanceInMeters); | ||||||
| 
 | 
 | ||||||
|       const int   row         = 0; // TODO
 |       const int   row         = p->textEventKeys_.indexOf(alertKey); | ||||||
|       QModelIndex topLeft     = createIndex(row, kFirstColumn); |       QModelIndex topLeft     = createIndex(row, kFirstColumn); | ||||||
|       QModelIndex bottomRight = createIndex(row, kLastColumn); |       QModelIndex bottomRight = createIndex(row, kLastColumn); | ||||||
| 
 | 
 | ||||||
|  | @ -232,6 +239,43 @@ AlertModelImpl::AlertModelImpl() : | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | std::string AlertModelImpl::GetCounties(const types::TextEventKey& key) | ||||||
|  | { | ||||||
|  |    auto   messageList = manager::TextEventManager::Instance().message_list(key); | ||||||
|  |    auto&  lastMessage = messageList.back(); | ||||||
|  |    size_t segmentCount = lastMessage->segment_count(); | ||||||
|  |    auto   lastSegment  = lastMessage->segment(segmentCount - 1); | ||||||
|  |    return util::ToString(lastSegment->header_->ugc_.fips_ids()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | std::string AlertModelImpl::GetState(const types::TextEventKey& key) | ||||||
|  | { | ||||||
|  |    auto   messageList = manager::TextEventManager::Instance().message_list(key); | ||||||
|  |    auto&  lastMessage = messageList.back(); | ||||||
|  |    size_t segmentCount = lastMessage->segment_count(); | ||||||
|  |    auto   lastSegment  = lastMessage->segment(segmentCount - 1); | ||||||
|  |    return util::ToString(lastSegment->header_->ugc_.states()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | std::string AlertModelImpl::GetStartTime(const types::TextEventKey& key) | ||||||
|  | { | ||||||
|  |    auto  messageList  = manager::TextEventManager::Instance().message_list(key); | ||||||
|  |    auto& firstMessage = messageList.front(); | ||||||
|  |    auto  firstSegment = firstMessage->segment(0); | ||||||
|  |    return util::TimeString( | ||||||
|  |       firstSegment->header_->vtecString_[0].pVtec_.event_begin()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | std::string AlertModelImpl::GetEndTime(const types::TextEventKey& key) | ||||||
|  | { | ||||||
|  |    auto   messageList = manager::TextEventManager::Instance().message_list(key); | ||||||
|  |    auto&  lastMessage = messageList.back(); | ||||||
|  |    size_t segmentCount = lastMessage->segment_count(); | ||||||
|  |    auto   lastSegment  = lastMessage->segment(segmentCount - 1); | ||||||
|  |    return util::TimeString( | ||||||
|  |       lastSegment->header_->vtecString_[0].pVtec_.event_end()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| } // namespace model
 | } // namespace model
 | ||||||
| } // namespace qt
 | } // namespace qt
 | ||||||
| } // namespace scwx
 | } // namespace scwx
 | ||||||
|  |  | ||||||
|  | @ -1,5 +1,7 @@ | ||||||
| #include <scwx/qt/types/text_event_key.hpp> | #include <scwx/qt/types/text_event_key.hpp> | ||||||
| 
 | 
 | ||||||
|  | #include <format> | ||||||
|  | 
 | ||||||
| #include <boost/container_hash/hash.hpp> | #include <boost/container_hash/hash.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx | ||||||
|  | @ -11,6 +13,15 @@ namespace types | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "scwx::qt::types::text_event_key"; | static const std::string logPrefix_ = "scwx::qt::types::text_event_key"; | ||||||
| 
 | 
 | ||||||
|  | std::string TextEventKey::ToString() const | ||||||
|  | { | ||||||
|  |    return std::format("{}, {}, {}, {}", | ||||||
|  |                       officeId_, | ||||||
|  |                       awips::GetPhenomenonText(phenomenon_), | ||||||
|  |                       awips::GetSignificanceText(significance_), | ||||||
|  |                       etn_); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| bool TextEventKey::operator==(const TextEventKey& o) const | bool TextEventKey::operator==(const TextEventKey& o) const | ||||||
| { | { | ||||||
|    return (officeId_ == o.officeId_ && phenomenon_ == o.phenomenon_ && |    return (officeId_ == o.officeId_ && phenomenon_ == o.phenomenon_ && | ||||||
|  |  | ||||||
|  | @ -19,7 +19,8 @@ struct TextEventKey | ||||||
|    { |    { | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    bool operator==(const TextEventKey& o) const; |    std::string ToString() const; | ||||||
|  |    bool        operator==(const TextEventKey& o) const; | ||||||
| 
 | 
 | ||||||
|    std::string         officeId_; |    std::string         officeId_; | ||||||
|    awips::Phenomenon   phenomenon_; |    awips::Phenomenon   phenomenon_; | ||||||
|  |  | ||||||
							
								
								
									
										14
									
								
								wxdata/include/scwx/util/strings.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								wxdata/include/scwx/util/strings.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | #include <string> | ||||||
|  | #include <vector> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace util | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | std::string ToString(const std::vector<std::string>& v); | ||||||
|  | 
 | ||||||
|  | } // namespace util
 | ||||||
|  | } // namespace scwx
 | ||||||
							
								
								
									
										26
									
								
								wxdata/source/scwx/util/strings.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								wxdata/source/scwx/util/strings.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,26 @@ | ||||||
|  | #include <scwx/util/strings.hpp> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace util | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | std::string ToString(const std::vector<std::string>& v) | ||||||
|  | { | ||||||
|  |    std::string value {}; | ||||||
|  | 
 | ||||||
|  |    for (const std::string& s : v) | ||||||
|  |    { | ||||||
|  |       if (!value.empty()) | ||||||
|  |       { | ||||||
|  |          value += ", "; | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       value += s; | ||||||
|  |    } | ||||||
|  | 
 | ||||||
|  |    return value; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | } // namespace util
 | ||||||
|  | } // namespace scwx
 | ||||||
|  | @ -58,6 +58,7 @@ set(HDR_UTIL include/scwx/util/environment.hpp | ||||||
|              include/scwx/util/map.hpp |              include/scwx/util/map.hpp | ||||||
|              include/scwx/util/rangebuf.hpp |              include/scwx/util/rangebuf.hpp | ||||||
|              include/scwx/util/streams.hpp |              include/scwx/util/streams.hpp | ||||||
|  |              include/scwx/util/strings.hpp | ||||||
|              include/scwx/util/threads.hpp |              include/scwx/util/threads.hpp | ||||||
|              include/scwx/util/time.hpp |              include/scwx/util/time.hpp | ||||||
|              include/scwx/util/vectorbuf.hpp) |              include/scwx/util/vectorbuf.hpp) | ||||||
|  | @ -67,6 +68,7 @@ set(SRC_UTIL source/scwx/util/environment.cpp | ||||||
|              source/scwx/util/logger.cpp |              source/scwx/util/logger.cpp | ||||||
|              source/scwx/util/rangebuf.cpp |              source/scwx/util/rangebuf.cpp | ||||||
|              source/scwx/util/streams.cpp |              source/scwx/util/streams.cpp | ||||||
|  |              source/scwx/util/strings.cpp | ||||||
|              source/scwx/util/time.cpp |              source/scwx/util/time.cpp | ||||||
|              source/scwx/util/threads.cpp |              source/scwx/util/threads.cpp | ||||||
|              source/scwx/util/vectorbuf.cpp) |              source/scwx/util/vectorbuf.cpp) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat