mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 02:40:05 +00:00 
			
		
		
		
	Move overlay product layer below map symbology, improve logic for adding missing layers
This commit is contained in:
		
							parent
							
								
									7de1b1d57d
								
							
						
					
					
						commit
						5633a30e39
					
				
					 1 changed files with 21 additions and 91 deletions
				
			
		|  | @ -43,7 +43,6 @@ static const std::vector<types::LayerInfo> kDefaultLayers_ { | ||||||
|     types::InformationLayer::RadarSite, |     types::InformationLayer::RadarSite, | ||||||
|     false, |     false, | ||||||
|     {false, false, false, false}}, |     {false, false, false, false}}, | ||||||
|    {types::LayerType::Data, types::DataLayer::OverlayProduct, true}, |  | ||||||
|    {types::LayerType::Data, types::DataLayer::RadarRange, true}, |    {types::LayerType::Data, types::DataLayer::RadarRange, true}, | ||||||
|    {types::LayerType::Alert, awips::Phenomenon::Tornado, true}, |    {types::LayerType::Alert, awips::Phenomenon::Tornado, true}, | ||||||
|    {types::LayerType::Alert, awips::Phenomenon::SnowSquall, true}, |    {types::LayerType::Alert, awips::Phenomenon::SnowSquall, true}, | ||||||
|  | @ -51,6 +50,7 @@ static const std::vector<types::LayerInfo> kDefaultLayers_ { | ||||||
|    {types::LayerType::Alert, awips::Phenomenon::FlashFlood, true}, |    {types::LayerType::Alert, awips::Phenomenon::FlashFlood, true}, | ||||||
|    {types::LayerType::Alert, awips::Phenomenon::Marine, true}, |    {types::LayerType::Alert, awips::Phenomenon::Marine, true}, | ||||||
|    {types::LayerType::Map, types::MapLayer::MapSymbology, false}, |    {types::LayerType::Map, types::MapLayer::MapSymbology, false}, | ||||||
|  |    {types::LayerType::Data, types::DataLayer::OverlayProduct, true}, | ||||||
|    {types::LayerType::Radar, std::monostate {}, true}, |    {types::LayerType::Radar, std::monostate {}, true}, | ||||||
|    {types::LayerType::Map, types::MapLayer::MapUnderlay, false}, |    {types::LayerType::Map, types::MapLayer::MapUnderlay, false}, | ||||||
| }; | }; | ||||||
|  | @ -244,9 +244,6 @@ void LayerModel::Impl::ValidateLayerSettings(types::LayerVector& layers) | ||||||
| 
 | 
 | ||||||
|    // Validate immovable layers
 |    // Validate immovable layers
 | ||||||
|    std::vector<types::LayerVector::iterator> immovableIterators {}; |    std::vector<types::LayerVector::iterator> immovableIterators {}; | ||||||
|    types::LayerVector::iterator              radarSiteIterator {}; |  | ||||||
|    types::LayerVector::iterator              mapSymbologyIterator {}; |  | ||||||
|    types::LayerVector::iterator              mapUnderlayIterator {}; |  | ||||||
|    for (auto& immovableLayer : kImmovableLayers_) |    for (auto& immovableLayer : kImmovableLayers_) | ||||||
|    { |    { | ||||||
|       // Set the default displayed state for a layer that is not found
 |       // Set the default displayed state for a layer that is not found
 | ||||||
|  | @ -289,102 +286,35 @@ void LayerModel::Impl::ValidateLayerSettings(types::LayerVector& layers) | ||||||
|          it->displayed_ = displayed; |          it->displayed_ = displayed; | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       // Store positional iterators
 |  | ||||||
|       if (it->type_ == types::LayerType::Information) |  | ||||||
|       { |  | ||||||
|          switch (std::get<types::InformationLayer>(it->description_)) |  | ||||||
|          { |  | ||||||
|          case types::InformationLayer::RadarSite: |  | ||||||
|             radarSiteIterator = it; |  | ||||||
|             break; |  | ||||||
| 
 |  | ||||||
|          default: |  | ||||||
|             break; |  | ||||||
|          } |  | ||||||
|       } |  | ||||||
|       else if (it->type_ == types::LayerType::Map) |  | ||||||
|       { |  | ||||||
|          switch (std::get<types::MapLayer>(it->description_)) |  | ||||||
|          { |  | ||||||
|          case types::MapLayer::MapSymbology: |  | ||||||
|             mapSymbologyIterator = it; |  | ||||||
|             break; |  | ||||||
| 
 |  | ||||||
|          case types::MapLayer::MapUnderlay: |  | ||||||
|             mapUnderlayIterator = it; |  | ||||||
|             break; |  | ||||||
| 
 |  | ||||||
|          default: |  | ||||||
|             break; |  | ||||||
|          } |  | ||||||
|       } |  | ||||||
| 
 |  | ||||||
|       // Add the immovable iterator to the list
 |       // Add the immovable iterator to the list
 | ||||||
|       immovableIterators.push_back(it); |       immovableIterators.push_back(it); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|    // Validate data layers
 |    // Validate the remainder of the default layer list
 | ||||||
|    std::vector<types::LayerVector::iterator> dataIterators {}; |    auto previousLayer = layers.end(); | ||||||
|    for (const auto& dataLayer : types::DataLayerIterator()) |    for (auto defaultIt = kDefaultLayers_.rbegin(); | ||||||
|  |         defaultIt != kDefaultLayers_.rend(); | ||||||
|  |         ++defaultIt) | ||||||
|    { |    { | ||||||
|       // Find the data layer
 |       // Find the default layer in the current layer list
 | ||||||
|       auto it = std::find_if(layers.begin(), |       auto currentIt = | ||||||
|                              layers.end(), |          std::find_if(layers.begin(), | ||||||
|                              [&dataLayer](const types::LayerInfo& layer) |                       layers.end(), | ||||||
|                              { |                       [&defaultIt](const types::LayerInfo& layer) | ||||||
|                                 return layer.type_ == types::LayerType::Data && |                       { | ||||||
|                                        std::get<types::DataLayer>( |                          return layer.type_ == defaultIt->type_ && | ||||||
|                                           layer.description_) == dataLayer; |                                 layer.description_ == defaultIt->description_; | ||||||
|                              }); |                       }); | ||||||
| 
 | 
 | ||||||
|       if (it == layers.end()) |       // If the default layer was not found in the current layer list
 | ||||||
|  |       if (currentIt == layers.end()) | ||||||
|       { |       { | ||||||
|          // If this is the first data layer, insert after the radar site layer,
 |          // Insert before the previously found layer
 | ||||||
|          // otherwise, insert after the previous data layer
 |          currentIt = layers.insert(previousLayer, *defaultIt); | ||||||
|          types::LayerVector::iterator insertPosition = |  | ||||||
|             dataIterators.empty() ? radarSiteIterator + 1 : |  | ||||||
|                                     dataIterators.back() + 1; |  | ||||||
|          it = |  | ||||||
|             layers.insert(insertPosition, {types::LayerType::Data, dataLayer}); |  | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       dataIterators.push_back(it); |       // Store the current layer as the previous
 | ||||||
|    } |       previousLayer = currentIt; | ||||||
| 
 |  | ||||||
|    // Validate alert layers
 |  | ||||||
|    std::vector<types::LayerVector::iterator> alertIterators {}; |  | ||||||
|    for (auto& phenomenon : kAlertPhenomena_) |  | ||||||
|    { |  | ||||||
|       // Find the alert layer
 |  | ||||||
|       auto it = std::find_if(layers.begin(), |  | ||||||
|                              layers.end(), |  | ||||||
|                              [&phenomenon](const types::LayerInfo& layer) |  | ||||||
|                              { |  | ||||||
|                                 return layer.type_ == types::LayerType::Alert && |  | ||||||
|                                        std::get<awips::Phenomenon>( |  | ||||||
|                                           layer.description_) == phenomenon; |  | ||||||
|                              }); |  | ||||||
| 
 |  | ||||||
|       if (it == layers.end()) |  | ||||||
|       { |  | ||||||
|          // Insert before the map symbology layer
 |  | ||||||
|          it = layers.insert(mapSymbologyIterator, |  | ||||||
|                             {types::LayerType::Alert, phenomenon}); |  | ||||||
|       } |  | ||||||
| 
 |  | ||||||
|       alertIterators.push_back(it); |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    // Validate the radar layer
 |  | ||||||
|    auto it = std::find_if(layers.begin(), |  | ||||||
|                           layers.end(), |  | ||||||
|                           [](const types::LayerInfo& layer) |  | ||||||
|                           { return layer.type_ == types::LayerType::Radar; }); |  | ||||||
|    if (it == layers.end()) |  | ||||||
|    { |  | ||||||
|       // Insert before the map underlay layer
 |  | ||||||
|       it = layers.insert(mapUnderlayIterator, |  | ||||||
|                          {types::LayerType::Radar, std::monostate {}}); |  | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat