mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:10:04 +00:00 
			
		
		
		
	Add VIL-specific data level conversions
This commit is contained in:
		
							parent
							
								
									0a1754db84
								
							
						
					
					
						commit
						24062d0417
					
				
					 2 changed files with 32 additions and 4 deletions
				
			
		|  | @ -4,6 +4,7 @@ | |||
| 
 | ||||
| #include <array> | ||||
| #include <istream> | ||||
| #include <numbers> | ||||
| #include <set> | ||||
| #include <string> | ||||
| 
 | ||||
|  | @ -591,6 +592,20 @@ uint16_t ProductDescriptionBlock::number_of_levels() const | |||
|    return numberOfLevels; | ||||
| } | ||||
| 
 | ||||
| std::uint16_t ProductDescriptionBlock::log_start() const | ||||
| { | ||||
|    std::uint16_t logStart = std::numeric_limits<std::uint16_t>::max(); | ||||
| 
 | ||||
|    switch (p->productCode_) | ||||
|    { | ||||
|    case 134: | ||||
|       logStart = p->halfword(33); | ||||
|       break; | ||||
|    } | ||||
| 
 | ||||
|    return logStart; | ||||
| } | ||||
| 
 | ||||
| float ProductDescriptionBlock::log_offset() const | ||||
| { | ||||
|    float logOffset = 0.0f; | ||||
|  | @ -598,7 +613,7 @@ float ProductDescriptionBlock::log_offset() const | |||
|    switch (p->productCode_) | ||||
|    { | ||||
|    case 134: | ||||
|       logOffset = util ::DecodeFloat16(p->halfword(35)); | ||||
|       logOffset = util::DecodeFloat16(p->halfword(35)); | ||||
|       break; | ||||
|    } | ||||
| 
 | ||||
|  | @ -612,7 +627,7 @@ float ProductDescriptionBlock::log_scale() const | |||
|    switch (p->productCode_) | ||||
|    { | ||||
|    case 134: | ||||
|       logScale = util ::DecodeFloat16(p->halfword(34)); | ||||
|       logScale = util::DecodeFloat16(p->halfword(34)); | ||||
|       break; | ||||
|    } | ||||
| 
 | ||||
|  | @ -1007,6 +1022,18 @@ ProductDescriptionBlock::data_value(std::uint8_t level) const | |||
|          f = (level - dataOffset) / dataScale; | ||||
|          break; | ||||
| 
 | ||||
|       case 134: | ||||
|          if (level < log_start()) | ||||
|          { | ||||
|             f = (level - dataOffset) / dataScale; | ||||
|          } | ||||
|          else | ||||
|          { | ||||
|             f = static_cast<float>(std::pow<double>( | ||||
|                std::numbers::e, (level - log_offset()) / log_scale())); | ||||
|          } | ||||
|          break; | ||||
| 
 | ||||
|       default: | ||||
|          f = level * dataScale + dataOffset; | ||||
|          break; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat