mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:50:06 +00:00 
			
		
		
		
	Added WFOs to the county database c++ code
This commit is contained in:
		
							parent
							
								
									412c85647c
								
							
						
					
					
						commit
						6b4045081e
					
				
					 2 changed files with 46 additions and 0 deletions
				
			
		|  | @ -31,6 +31,7 @@ typedef std::unordered_map<char, StateMap>           FormatMap; | |||
| static bool                                         initialized_ {false}; | ||||
| static FormatMap                                    countyDatabase_; | ||||
| static std::unordered_map<std::string, std::string> stateMap_; | ||||
| static std::unordered_map<std::string, std::string> wfoMap_; | ||||
| 
 | ||||
| void Initialize() | ||||
| { | ||||
|  | @ -168,6 +169,39 @@ void Initialize() | |||
|       sqlite3_free(errorMessage); | ||||
|    } | ||||
| 
 | ||||
|    // Query database for WFOs
 | ||||
|    rc = sqlite3_exec( | ||||
|       db, | ||||
|       "SELECT id, city_state FROM wfos", | ||||
|       [](void* /* param */, | ||||
|          int    columns, | ||||
|          char** columnText, | ||||
|          char** /* columnName */) -> int | ||||
|       { | ||||
|          int status = 0; | ||||
| 
 | ||||
|          if (columns == 2) | ||||
|          { | ||||
|             wfoMap_.emplace(columnText[0], columnText[1]); | ||||
|          } | ||||
|          else | ||||
|          { | ||||
|             logger_->error( | ||||
|                "WFO database format error, invalid number of columns: {}", | ||||
|                columns); | ||||
|             status = -1; | ||||
|          } | ||||
| 
 | ||||
|          return status; | ||||
|       }, | ||||
|       nullptr, | ||||
|       &errorMessage); | ||||
|    if (rc != SQLITE_OK) | ||||
|    { | ||||
|       logger_->error("SQL error: {}", errorMessage); | ||||
|       sqlite3_free(errorMessage); | ||||
|    } | ||||
| 
 | ||||
|    // Close database
 | ||||
|    sqlite3_close(db); | ||||
| 
 | ||||
|  | @ -230,6 +264,16 @@ const std::unordered_map<std::string, std::string>& GetStates() | |||
|    return stateMap_; | ||||
| } | ||||
| 
 | ||||
| const std::unordered_map<std::string, std::string>& GetWFOs() | ||||
| { | ||||
|    return wfoMap_; | ||||
| } | ||||
| 
 | ||||
| const std::string& GetWFOName(const std::string& wfoId) | ||||
| { | ||||
|    return wfoMap_.at(wfoId); | ||||
| } | ||||
| 
 | ||||
| } // namespace CountyDatabase
 | ||||
| } // namespace config
 | ||||
| } // namespace qt
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 AdenKoperczak
						AdenKoperczak