mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 02:00:05 +00:00 
			
		
		
		
	Coded location logging
This commit is contained in:
		
							parent
							
								
									db4f37a37d
								
							
						
					
					
						commit
						7d503ec506
					
				
					 4 changed files with 101 additions and 0 deletions
				
			
		|  | @ -195,5 +195,38 @@ TEST(CodedLocation, NCMaine) | |||
|    EXPECT_DOUBLE_EQ(coordinates[12].longitude_, -69.21); | ||||
| } | ||||
| 
 | ||||
| TEST(CodedLocation, InvalidNC) | ||||
| { | ||||
|    std::vector<std::string> data = { | ||||
|       "LAT...LON 47316870 4721679 46466767 45436766 44756779", | ||||
|       "      44216834 43816943 43706970 43837006 44497009", | ||||
|       "      45306974 46356946 46976921"}; | ||||
| 
 | ||||
|    CodedLocation location; | ||||
|    bool          dataValid = location.Parse(data); | ||||
| 
 | ||||
|    EXPECT_EQ(dataValid, false); | ||||
| } | ||||
| 
 | ||||
| TEST(CodedLocation, EmptyData) | ||||
| { | ||||
|    std::vector<std::string> data = {}; | ||||
| 
 | ||||
|    CodedLocation location; | ||||
|    bool          dataValid = location.Parse(data); | ||||
| 
 | ||||
|    EXPECT_EQ(dataValid, false); | ||||
| } | ||||
| 
 | ||||
| TEST(CodedLocation, MalformedData) | ||||
| { | ||||
|    std::vector<std::string> data = {"LAT...LON 1360"}; | ||||
| 
 | ||||
|    CodedLocation location; | ||||
|    bool          dataValid = location.Parse(data); | ||||
| 
 | ||||
|    EXPECT_EQ(dataValid, false); | ||||
| } | ||||
| 
 | ||||
| } // namespace awips
 | ||||
| } // namespace scwx
 | ||||
|  |  | |||
|  | @ -86,5 +86,25 @@ TEST(CodedTimeMotionLocation, TwoCoordinates) | |||
|    EXPECT_DOUBLE_EQ(coordinates[1].longitude_, -81.98); | ||||
| } | ||||
| 
 | ||||
| TEST(CodedTimeMotionLocation, EmptyData) | ||||
| { | ||||
|    std::vector<std::string> data = {}; | ||||
| 
 | ||||
|    CodedTimeMotionLocation tml; | ||||
|    bool                    dataValid = tml.Parse(data); | ||||
| 
 | ||||
|    EXPECT_EQ(dataValid, false); | ||||
| } | ||||
| 
 | ||||
| TEST(CodedTimeMotionLocation, MalformedData) | ||||
| { | ||||
|    std::vector<std::string> data = {"TIME...MOT...LOC 2113Z 345DEG 42KT 2760"}; | ||||
| 
 | ||||
|    CodedTimeMotionLocation tml; | ||||
|    bool                    dataValid = tml.Parse(data); | ||||
| 
 | ||||
|    EXPECT_EQ(dataValid, false); | ||||
| } | ||||
| 
 | ||||
| } // namespace awips
 | ||||
| } // namespace scwx
 | ||||
|  |  | |||
|  | @ -114,6 +114,11 @@ bool CodedLocation::Parse(const StringRange& lines, const std::string& wfo) | |||
|          { | ||||
|             if (token->size() != 8) | ||||
|             { | ||||
|                BOOST_LOG_TRIVIAL(warning) | ||||
|                   << logPrefix_ | ||||
|                   << "Invalid National Center LAT...LON format: \"" << *token | ||||
|                   << "\""; | ||||
| 
 | ||||
|                dataValid = false; | ||||
|                break; | ||||
|             } | ||||
|  | @ -137,6 +142,27 @@ bool CodedLocation::Parse(const StringRange& lines, const std::string& wfo) | |||
|          } | ||||
|       } | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|       if (tokenList.empty()) | ||||
|       { | ||||
|          BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "LAT...LON not found"; | ||||
|       } | ||||
|       else | ||||
|       { | ||||
|          BOOST_LOG_TRIVIAL(warning) | ||||
|             << logPrefix_ | ||||
|             << "Malformed LAT...LON tokens: (0: " << tokenList.at(0) | ||||
|             << ", size: " << tokenList.size() << ")"; | ||||
| 
 | ||||
|          for (const auto& token : tokenList) | ||||
|          { | ||||
|             BOOST_LOG_TRIVIAL(debug) << logPrefix_ << token; | ||||
|          } | ||||
|       } | ||||
| 
 | ||||
|       dataValid = false; | ||||
|    } | ||||
| 
 | ||||
|    if (dataValid) | ||||
|    { | ||||
|  |  | |||
|  | @ -175,6 +175,28 @@ bool CodedTimeMotionLocation::Parse(const StringRange& lines, | |||
|          } | ||||
|       } | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|       if (tokenList.empty()) | ||||
|       { | ||||
|          BOOST_LOG_TRIVIAL(warning) | ||||
|             << logPrefix_ << "TIME...MOT...LOC not found"; | ||||
|       } | ||||
|       else | ||||
|       { | ||||
|          BOOST_LOG_TRIVIAL(warning) | ||||
|             << logPrefix_ | ||||
|             << "Malformed TIME...MOT...LOC tokens: (0: " << tokenList.at(0) | ||||
|             << ", size: " << tokenList.size() << ")"; | ||||
| 
 | ||||
|          for (const auto& token : tokenList) | ||||
|          { | ||||
|             BOOST_LOG_TRIVIAL(debug) << logPrefix_ << token; | ||||
|          } | ||||
|       } | ||||
| 
 | ||||
|       dataValid = false; | ||||
|    } | ||||
| 
 | ||||
|    return dataValid; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat