mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:00:04 +00:00 
			
		
		
		
	Support TIME...MOT...LOC with motion between 0-255 knots
NWSI 10-1701 specified 0-99 knots is valid, but sometimes text products are published with a larger value
This commit is contained in:
		
							parent
							
								
									2af6993d1a
								
							
						
					
					
						commit
						704b9e03b9
					
				
					 1 changed files with 15 additions and 4 deletions
				
			
		|  | @ -39,7 +39,7 @@ CodedTimeMotionLocation::CodedTimeMotionLocation() : | ||||||
| CodedTimeMotionLocation::~CodedTimeMotionLocation() = default; | CodedTimeMotionLocation::~CodedTimeMotionLocation() = default; | ||||||
| 
 | 
 | ||||||
| CodedTimeMotionLocation::CodedTimeMotionLocation( | CodedTimeMotionLocation::CodedTimeMotionLocation( | ||||||
|    CodedTimeMotionLocation&&) noexcept                    = default; |    CodedTimeMotionLocation&&) noexcept = default; | ||||||
| CodedTimeMotionLocation& CodedTimeMotionLocation::operator=( | CodedTimeMotionLocation& CodedTimeMotionLocation::operator=( | ||||||
|    CodedTimeMotionLocation&&) noexcept = default; |    CodedTimeMotionLocation&&) noexcept = default; | ||||||
| 
 | 
 | ||||||
|  | @ -140,12 +140,23 @@ bool CodedTimeMotionLocation::Parse(const StringRange& lines, | ||||||
| 
 | 
 | ||||||
|       // Speed: <sp>KT
 |       // Speed: <sp>KT
 | ||||||
|       std::string speed = tokenList.at(3); |       std::string speed = tokenList.at(3); | ||||||
|       if (speed.size() >= 3 && speed.size() <= 4 && speed.ends_with("KT")) |       if (speed.size() >= 3 && speed.size() <= 5 && speed.ends_with("KT")) | ||||||
|       { |       { | ||||||
|          try |          try | ||||||
|          { |          { | ||||||
|             p->speed_ = static_cast<uint8_t>( |             // NWSI 10-1701 specifies a valid speed range of 0-99 knots.
 | ||||||
|                std::stoul(speed.substr(0, speed.size() - 2))); |             // However, sometimes text products are published with a larger
 | ||||||
|  |             // value. Instead, allow a value up to 255 knots.
 | ||||||
|  |             auto parsedSpeed = std::stoul(speed.substr(0, speed.size() - 2)); | ||||||
|  |             if (parsedSpeed <= 255u) | ||||||
|  |             { | ||||||
|  |                p->speed_ = static_cast<uint8_t>(parsedSpeed); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                logger_->warn("Invalid speed: \"{}\"", speed); | ||||||
|  |                dataValid = false; | ||||||
|  |             } | ||||||
|          } |          } | ||||||
|          catch (const std::exception& ex) |          catch (const std::exception& ex) | ||||||
|          { |          { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat