mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:30:05 +00:00 
			
		
		
		
	Use strong-typed units for angles and ranges in Digital Radar Data Generic Format
This commit is contained in:
		
							parent
							
								
									a9e1998632
								
							
						
					
					
						commit
						807d98d7ef
					
				
					 3 changed files with 54 additions and 48 deletions
				
			
		|  | @ -102,7 +102,7 @@ public: | ||||||
|    float                    longitude_; |    float                    longitude_; | ||||||
|    float                    elevationCut_; |    float                    elevationCut_; | ||||||
|    std::vector<float>       elevationCuts_; |    std::vector<float>       elevationCuts_; | ||||||
|    float              range_; |    units::kilometers<float> range_; | ||||||
|    uint16_t                 vcp_; |    uint16_t                 vcp_; | ||||||
| 
 | 
 | ||||||
|    std::chrono::system_clock::time_point sweepTime_; |    std::chrono::system_clock::time_point sweepTime_; | ||||||
|  | @ -212,7 +212,7 @@ float Level2ProductView::elevation() const | ||||||
| 
 | 
 | ||||||
| float Level2ProductView::range() const | float Level2ProductView::range() const | ||||||
| { | { | ||||||
|    return p->range_; |    return p->range_.value(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::chrono::system_clock::time_point Level2ProductView::sweep_time() const | std::chrono::system_clock::time_point Level2ProductView::sweep_time() const | ||||||
|  | @ -747,7 +747,8 @@ void Level2ProductViewImpl::ComputeCoordinates( | ||||||
|                  radials.end(), |                  radials.end(), | ||||||
|                  [&](std::uint32_t radial) |                  [&](std::uint32_t radial) | ||||||
|                  { |                  { | ||||||
|                     const float angle = (*radarData)[radial]->azimuth_angle(); |                     const units::degrees<float> angle = | ||||||
|  |                        (*radarData)[radial]->azimuth_angle(); | ||||||
| 
 | 
 | ||||||
|                     std::for_each(std::execution::par_unseq, |                     std::for_each(std::execution::par_unseq, | ||||||
|                                   gates.begin(), |                                   gates.begin(), | ||||||
|  | @ -765,7 +766,7 @@ void Level2ProductViewImpl::ComputeCoordinates( | ||||||
| 
 | 
 | ||||||
|                                      geodesic.Direct(radarLatitude, |                                      geodesic.Direct(radarLatitude, | ||||||
|                                                      radarLongitude, |                                                      radarLongitude, | ||||||
|                                                      angle, |                                                      angle.value(), | ||||||
|                                                      range, |                                                      range, | ||||||
|                                                      latitude, |                                                      latitude, | ||||||
|                                                      longitude); |                                                      longitude); | ||||||
|  | @ -831,13 +832,14 @@ Level2ProductView::GetBinLevel(const common::Coordinate& coordinate) const | ||||||
|       [&](std::uint32_t i) |       [&](std::uint32_t i) | ||||||
|       { |       { | ||||||
|          bool                        found = false; |          bool                        found = false; | ||||||
|          const float startAngle = (*radarData)[i]->azimuth_angle(); |          const units::degrees<float> startAngle = | ||||||
|          const float nextAngle = |             (*radarData)[i]->azimuth_angle(); | ||||||
|  |          const units::degrees<float> nextAngle = | ||||||
|             (*radarData)[(i + 1) % numRadials]->azimuth_angle(); |             (*radarData)[(i + 1) % numRadials]->azimuth_angle(); | ||||||
| 
 | 
 | ||||||
|          if (startAngle < nextAngle) |          if (startAngle < nextAngle) | ||||||
|          { |          { | ||||||
|             if (startAngle <= azi1 && azi1 < nextAngle) |             if (startAngle.value() <= azi1 && azi1 < nextAngle.value()) | ||||||
|             { |             { | ||||||
|                found = true; |                found = true; | ||||||
|             } |             } | ||||||
|  | @ -845,7 +847,7 @@ Level2ProductView::GetBinLevel(const common::Coordinate& coordinate) const | ||||||
|          else |          else | ||||||
|          { |          { | ||||||
|             // If the bin crosses 0/360 degrees, special handling is needed
 |             // If the bin crosses 0/360 degrees, special handling is needed
 | ||||||
|             if (startAngle <= azi1 || azi1 < nextAngle) |             if (startAngle.value() <= azi1 || azi1 < nextAngle.value()) | ||||||
|             { |             { | ||||||
|                found = true; |                found = true; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  | @ -3,6 +3,9 @@ | ||||||
| #include <scwx/util/iterator.hpp> | #include <scwx/util/iterator.hpp> | ||||||
| #include <scwx/wsr88d/rda/level2_message.hpp> | #include <scwx/wsr88d/rda/level2_message.hpp> | ||||||
| 
 | 
 | ||||||
|  | #include <units/angle.h> | ||||||
|  | #include <units/length.h> | ||||||
|  | 
 | ||||||
| namespace scwx | namespace scwx | ||||||
| { | { | ||||||
| namespace wsr88d | namespace wsr88d | ||||||
|  | @ -95,9 +98,9 @@ public: | ||||||
|    MomentDataBlock& operator=(MomentDataBlock&&) noexcept; |    MomentDataBlock& operator=(MomentDataBlock&&) noexcept; | ||||||
| 
 | 
 | ||||||
|    uint16_t                 number_of_data_moment_gates() const; |    uint16_t                 number_of_data_moment_gates() const; | ||||||
|    float       data_moment_range() const; |    units::kilometers<float> data_moment_range() const; | ||||||
|    uint16_t                 data_moment_range_raw() const; |    uint16_t                 data_moment_range_raw() const; | ||||||
|    float       data_moment_range_sample_interval() const; |    units::kilometers<float> data_moment_range_sample_interval() const; | ||||||
|    uint16_t                 data_moment_range_sample_interval_raw() const; |    uint16_t                 data_moment_range_sample_interval_raw() const; | ||||||
|    float                    snr_threshold() const; |    float                    snr_threshold() const; | ||||||
|    int16_t                  snr_threshold_raw() const; |    int16_t                  snr_threshold_raw() const; | ||||||
|  | @ -187,14 +190,14 @@ public: | ||||||
|    uint32_t              collection_time() const; |    uint32_t              collection_time() const; | ||||||
|    uint16_t              modified_julian_date() const; |    uint16_t              modified_julian_date() const; | ||||||
|    uint16_t              azimuth_number() const; |    uint16_t              azimuth_number() const; | ||||||
|    float       azimuth_angle() const; |    units::degrees<float> azimuth_angle() const; | ||||||
|    uint8_t               compression_indicator() const; |    uint8_t               compression_indicator() const; | ||||||
|    uint16_t              radial_length() const; |    uint16_t              radial_length() const; | ||||||
|    uint8_t               azimuth_resolution_spacing() const; |    uint8_t               azimuth_resolution_spacing() const; | ||||||
|    uint8_t               radial_status() const; |    uint8_t               radial_status() const; | ||||||
|    uint8_t               elevation_number() const; |    uint8_t               elevation_number() const; | ||||||
|    uint8_t               cut_sector_number() const; |    uint8_t               cut_sector_number() const; | ||||||
|    float       elevation_angle() const; |    units::degrees<float> elevation_angle() const; | ||||||
|    uint8_t               radial_spot_blanking_status() const; |    uint8_t               radial_spot_blanking_status() const; | ||||||
|    uint8_t               azimuth_indexing_mode() const; |    uint8_t               azimuth_indexing_mode() const; | ||||||
|    uint16_t              data_block_count() const; |    uint16_t              data_block_count() const; | ||||||
|  |  | ||||||
|  | @ -94,9 +94,9 @@ uint16_t MomentDataBlock::number_of_data_moment_gates() const | ||||||
|    return p->numberOfDataMomentGates_; |    return p->numberOfDataMomentGates_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float MomentDataBlock::data_moment_range() const | units::kilometers<float> MomentDataBlock::data_moment_range() const | ||||||
| { | { | ||||||
|    return p->dataMomentRange_ * 0.001f; |    return units::kilometers<float> {p->dataMomentRange_ * 0.001f}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uint16_t MomentDataBlock::data_moment_range_raw() const | uint16_t MomentDataBlock::data_moment_range_raw() const | ||||||
|  | @ -104,9 +104,10 @@ uint16_t MomentDataBlock::data_moment_range_raw() const | ||||||
|    return p->dataMomentRange_; |    return p->dataMomentRange_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float MomentDataBlock::data_moment_range_sample_interval() const | units::kilometers<float> | ||||||
|  | MomentDataBlock::data_moment_range_sample_interval() const | ||||||
| { | { | ||||||
|    return p->dataMomentRangeSampleInterval_ * 0.001f; |    return units::kilometers<float> {p->dataMomentRangeSampleInterval_ * 0.001f}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uint16_t MomentDataBlock::data_moment_range_sample_interval_raw() const | uint16_t MomentDataBlock::data_moment_range_sample_interval_raw() const | ||||||
|  | @ -575,9 +576,9 @@ uint16_t DigitalRadarDataGeneric::azimuth_number() const | ||||||
|    return p->azimuthNumber_; |    return p->azimuthNumber_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float DigitalRadarDataGeneric::azimuth_angle() const | units::degrees<float> DigitalRadarDataGeneric::azimuth_angle() const | ||||||
| { | { | ||||||
|    return p->azimuthAngle_; |    return units::degrees<float> {p->azimuthAngle_}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uint8_t DigitalRadarDataGeneric::compression_indicator() const | uint8_t DigitalRadarDataGeneric::compression_indicator() const | ||||||
|  | @ -610,9 +611,9 @@ uint8_t DigitalRadarDataGeneric::cut_sector_number() const | ||||||
|    return p->cutSectorNumber_; |    return p->cutSectorNumber_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float DigitalRadarDataGeneric::elevation_angle() const | units::degrees<float> DigitalRadarDataGeneric::elevation_angle() const | ||||||
| { | { | ||||||
|    return p->elevationAngle_; |    return units::degrees<float> {p->elevationAngle_}; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uint8_t DigitalRadarDataGeneric::radial_spot_blanking_status() const | uint8_t DigitalRadarDataGeneric::radial_spot_blanking_status() const | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat