mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 07:20:04 +00:00 
			
		
		
		
	Infrastructure updates for multiple elevations
This commit is contained in:
		
							parent
							
								
									87581892a7
								
							
						
					
					
						commit
						19f1207384
					
				
					 8 changed files with 85 additions and 32 deletions
				
			
		|  | @ -180,17 +180,19 @@ void RadarProductManager::LoadLevel2Data(const std::string& filename) | |||
|    emit Level2DataLoaded(); | ||||
| } | ||||
| 
 | ||||
| std::shared_ptr<wsr88d::rda::ElevationScan> | ||||
| std::pair<float, std::shared_ptr<wsr88d::rda::ElevationScan>> | ||||
| RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType, | ||||
|                                    uint16_t                   elevation, | ||||
|                                    float                      elevation, | ||||
|                                    std::chrono::system_clock::time_point time) | ||||
| { | ||||
|    std::shared_ptr<wsr88d::rda::ElevationScan> radarData = nullptr; | ||||
|    float                                       elevationFound = 0.0f; | ||||
|    std::shared_ptr<wsr88d::rda::ElevationScan> radarData      = nullptr; | ||||
| 
 | ||||
|    if (p->level2VolumeScans_.size() > 0) | ||||
|    { | ||||
|       radarData = p->level2VolumeScans_.crbegin()->second->GetElevationScan( | ||||
|          dataBlockType, elevation, time); | ||||
|       std::tie(elevationFound, radarData) = | ||||
|          p->level2VolumeScans_.crbegin()->second->GetElevationScan( | ||||
|             dataBlockType, elevation, time); | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|  | @ -203,7 +205,7 @@ RadarProductManager::GetLevel2Data(wsr88d::rda::DataBlockType dataBlockType, | |||
|       }); | ||||
|    } | ||||
| 
 | ||||
|    return radarData; | ||||
|    return std::make_pair(elevationFound, radarData); | ||||
| } | ||||
| 
 | ||||
| } // namespace manager
 | ||||
|  |  | |||
|  | @ -33,9 +33,9 @@ public: | |||
|    void Initialize(); | ||||
|    void LoadLevel2Data(const std::string& filename); | ||||
| 
 | ||||
|    std::shared_ptr<wsr88d::rda::ElevationScan> | ||||
|    std::pair<float, std::shared_ptr<wsr88d::rda::ElevationScan>> | ||||
|    GetLevel2Data(wsr88d::rda::DataBlockType            dataBlockType, | ||||
|                  uint16_t                              elevation, | ||||
|                  float                                 elevation, | ||||
|                  std::chrono::system_clock::time_point time = {}); | ||||
| 
 | ||||
| signals: | ||||
|  |  | |||
|  | @ -44,8 +44,10 @@ public: | |||
|       std::shared_ptr<manager::RadarProductManager> radarProductManager) : | ||||
|        product_ {product}, | ||||
|        radarProductManager_ {radarProductManager}, | ||||
|        momentDataBlock0_ {nullptr}, | ||||
|        latitude_ {}, | ||||
|        longitude_ {}, | ||||
|        elevation_ {}, | ||||
|        range_ {}, | ||||
|        sweepTime_ {}, | ||||
|        colorTable_ {}, | ||||
|  | @ -81,6 +83,7 @@ public: | |||
| 
 | ||||
|    float latitude_; | ||||
|    float longitude_; | ||||
|    float elevation_; | ||||
|    float range_; | ||||
| 
 | ||||
|    std::chrono::system_clock::time_point sweepTime_; | ||||
|  | @ -122,6 +125,11 @@ Level2ProductView::color_table(uint16_t& minValue, uint16_t& maxValue) const | |||
|    } | ||||
| } | ||||
| 
 | ||||
| float Level2ProductView::elevation() const | ||||
| { | ||||
|    return p->elevation_; | ||||
| } | ||||
| 
 | ||||
| float Level2ProductView::range() const | ||||
| { | ||||
|    return p->range_; | ||||
|  | @ -276,8 +284,10 @@ void Level2ProductView::ComputeSweep() | |||
|    } | ||||
| 
 | ||||
|    // TODO: Pick this based on view settings
 | ||||
|    auto radarData = | ||||
|       p->radarProductManager_->GetLevel2Data(p->dataBlockType_, 0); | ||||
|    float                                       elevation; | ||||
|    std::shared_ptr<wsr88d::rda::ElevationScan> radarData; | ||||
|    std::tie(elevation, radarData) = | ||||
|       p->radarProductManager_->GetLevel2Data(p->dataBlockType_, 0.0f); | ||||
|    if (radarData == nullptr) | ||||
|    { | ||||
|       return; | ||||
|  | @ -308,6 +318,7 @@ void Level2ProductView::ComputeSweep() | |||
|    auto volumeData0 = radarData0->volume_data_block(); | ||||
|    p->latitude_     = volumeData0->latitude(); | ||||
|    p->longitude_    = volumeData0->longitude(); | ||||
|    p->elevation_    = elevation; | ||||
|    p->range_ = | ||||
|       momentData0->data_moment_range() + | ||||
|       momentData0->data_moment_range_sample_interval() * (gates - 0.5f); | ||||
|  | @ -464,16 +475,15 @@ void Level2ProductView::ComputeSweep() | |||
|          { | ||||
|             const uint16_t baseCoord = gate - 1; | ||||
| 
 | ||||
|             size_t offset1 = ((startRadial + radial) % common::MAX_RADIALS * | ||||
|             size_t offset1 = ((startRadial + radial) % radials * | ||||
|                                  common::MAX_DATA_MOMENT_GATES + | ||||
|                               baseCoord) * | ||||
|                              2; | ||||
|             size_t offset2 = offset1 + gateSize * 2; | ||||
|             size_t offset3 = | ||||
|                (((startRadial + radial + 1) % common::MAX_RADIALS) * | ||||
|                    common::MAX_DATA_MOMENT_GATES + | ||||
|                 baseCoord) * | ||||
|                2; | ||||
|             size_t offset3 = (((startRadial + radial + 1) % radials) * | ||||
|                                  common::MAX_DATA_MOMENT_GATES + | ||||
|                               baseCoord) * | ||||
|                              2; | ||||
|             size_t offset4 = offset3 + gateSize * 2; | ||||
| 
 | ||||
|             vertices[vIndex++] = coordinates[offset1]; | ||||
|  | @ -500,15 +510,14 @@ void Level2ProductView::ComputeSweep() | |||
|          { | ||||
|             const uint16_t baseCoord = gate; | ||||
| 
 | ||||
|             size_t offset1 = ((startRadial + radial) % common::MAX_RADIALS * | ||||
|             size_t offset1 = ((startRadial + radial) % radials * | ||||
|                                  common::MAX_DATA_MOMENT_GATES + | ||||
|                               baseCoord) * | ||||
|                              2; | ||||
|             size_t offset2 = (((startRadial + radial + 1) % radials) * | ||||
|                                  common::MAX_DATA_MOMENT_GATES + | ||||
|                               baseCoord) * | ||||
|                              2; | ||||
|             size_t offset2 = | ||||
|                (((startRadial + radial + 1) % common::MAX_RADIALS) * | ||||
|                    common::MAX_DATA_MOMENT_GATES + | ||||
|                 baseCoord) * | ||||
|                2; | ||||
| 
 | ||||
|             vertices[vIndex++] = p->latitude_; | ||||
|             vertices[vIndex++] = p->longitude_; | ||||
|  |  | |||
|  | @ -30,6 +30,7 @@ public: | |||
| 
 | ||||
|    const std::vector<boost::gil::rgba8_pixel_t>& | ||||
|          color_table(uint16_t& minValue, uint16_t& maxValue) const override; | ||||
|    float elevation() const override; | ||||
|    float range() const override; | ||||
|    std::chrono::system_clock::time_point sweep_time() const override; | ||||
|    const std::vector<float>&             vertices() const override; | ||||
|  |  | |||
|  | @ -40,6 +40,11 @@ RadarProductView::color_table(uint16_t& minValue, uint16_t& maxValue) const | |||
|    return DEFAULT_COLOR_TABLE; | ||||
| } | ||||
| 
 | ||||
| float RadarProductView::elevation() const | ||||
| { | ||||
|    return 0.0f; | ||||
| } | ||||
| 
 | ||||
| float RadarProductView::range() const | ||||
| { | ||||
|    return 0.0f; | ||||
|  |  | |||
|  | @ -27,6 +27,7 @@ public: | |||
| 
 | ||||
|    virtual const std::vector<boost::gil::rgba8_pixel_t>& | ||||
|                  color_table(uint16_t& minValue, uint16_t& maxValue) const; | ||||
|    virtual float elevation() const; | ||||
|    virtual float range() const; | ||||
|    virtual std::chrono::system_clock::time_point sweep_time() const; | ||||
|    virtual const std::vector<float>&             vertices() const = 0; | ||||
|  |  | |||
|  | @ -40,9 +40,9 @@ public: | |||
|    std::map<uint16_t, std::shared_ptr<rda::ElevationScan>> radar_data() const; | ||||
|    std::shared_ptr<const rda::VolumeCoveragePatternData>   vcp_data() const; | ||||
| 
 | ||||
|    std::shared_ptr<rda::ElevationScan> | ||||
|    std::pair<float, std::shared_ptr<rda::ElevationScan>> | ||||
|    GetElevationScan(rda::DataBlockType                    dataBlockType, | ||||
|                     uint16_t                              elevation, | ||||
|                     float                                 elevation, | ||||
|                     std::chrono::system_clock::time_point time) const; | ||||
| 
 | ||||
|    bool LoadFile(const std::string& filename); | ||||
|  |  | |||
|  | @ -106,21 +106,56 @@ std::shared_ptr<const rda::VolumeCoveragePatternData> Ar2vFile::vcp_data() const | |||
|    return p->vcpData_; | ||||
| } | ||||
| 
 | ||||
| std::shared_ptr<rda::ElevationScan> | ||||
| std::pair<float, std::shared_ptr<rda::ElevationScan>> | ||||
| Ar2vFile::GetElevationScan(rda::DataBlockType                    dataBlockType, | ||||
|                            uint16_t                              elevation, | ||||
|                            float                                 elevation, | ||||
|                            std::chrono::system_clock::time_point time) const | ||||
| { | ||||
|    std::shared_ptr<rda::ElevationScan> elevationScan = nullptr; | ||||
|    constexpr float scaleFactor = 8.0f / 0.043945f; | ||||
| 
 | ||||
|    // TODO: 88 = 0.5 degrees - this should be parameterized and searched
 | ||||
|    if (p->index_.contains(dataBlockType) && | ||||
|        p->index_.at(dataBlockType).contains(88)) | ||||
|    float                               elevationFound = 0.0f; | ||||
|    std::shared_ptr<rda::ElevationScan> elevationScan  = nullptr; | ||||
| 
 | ||||
|    uint16_t codedElevation = | ||||
|       static_cast<uint16_t>(std::lroundf(elevation * scaleFactor)); | ||||
| 
 | ||||
|    if (p->index_.contains(dataBlockType)) | ||||
|    { | ||||
|       return p->index_.at(dataBlockType).at(88); | ||||
|       auto scans = p->index_.at(dataBlockType); | ||||
| 
 | ||||
|       uint16_t lowerBound = scans.cbegin()->first; | ||||
|       uint16_t upperBound = scans.crbegin()->first; | ||||
| 
 | ||||
|       for (auto scan : scans) | ||||
|       { | ||||
|          if (scan.first > lowerBound && scan.first < codedElevation) | ||||
|          { | ||||
|             lowerBound = scan.first; | ||||
|          } | ||||
|          if (scan.first < upperBound && scan.first > codedElevation) | ||||
|          { | ||||
|             upperBound = scan.first; | ||||
|          } | ||||
|       } | ||||
| 
 | ||||
|       uint16_t lowerDelta = std::abs(static_cast<int32_t>(codedElevation) - | ||||
|                                      static_cast<int32_t>(lowerBound)); | ||||
|       uint16_t upperDelta = std::abs(static_cast<int32_t>(codedElevation) - | ||||
|                                      static_cast<int32_t>(upperBound)); | ||||
| 
 | ||||
|       if (lowerDelta < upperDelta) | ||||
|       { | ||||
|          elevationFound = lowerBound / scaleFactor; | ||||
|          elevationScan  = scans.at(lowerBound); | ||||
|       } | ||||
|       else | ||||
|       { | ||||
|          elevationFound = upperBound / scaleFactor; | ||||
|          elevationScan  = scans.at(upperBound); | ||||
|       } | ||||
|    } | ||||
| 
 | ||||
|    return elevationScan; | ||||
|    return std::make_pair(elevationFound, elevationScan); | ||||
| } | ||||
| 
 | ||||
| bool Ar2vFile::LoadFile(const std::string& filename) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat