mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 04:30:05 +00:00 
			
		
		
		
	Add map types string conversions
This commit is contained in:
		
							parent
							
								
									1217a13fb0
								
							
						
					
					
						commit
						10fe904011
					
				
					 2 changed files with 59 additions and 13 deletions
				
			
		|  | @ -2,6 +2,8 @@ | |||
| 
 | ||||
| #include <unordered_map> | ||||
| 
 | ||||
| #include <boost/algorithm/string.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
|  | @ -9,27 +11,65 @@ namespace qt | |||
| namespace types | ||||
| { | ||||
| 
 | ||||
| static const std::unordered_map<types::LayerType, std::string> layerTypeName_ { | ||||
|    {types::LayerType::Map, "Map"}, | ||||
|    {types::LayerType::Radar, "Radar"}, | ||||
|    {types::LayerType::Alert, "Alert"}, | ||||
|    {types::LayerType::Placefile, "Placefile"}, | ||||
|    {types::LayerType::Information, "Information"}}; | ||||
| static const std::unordered_map<LayerType, std::string> layerTypeName_ { | ||||
|    {LayerType::Map, "Map"}, | ||||
|    {LayerType::Radar, "Radar"}, | ||||
|    {LayerType::Alert, "Alert"}, | ||||
|    {LayerType::Placefile, "Placefile"}, | ||||
|    {LayerType::Information, "Information"}, | ||||
|    {LayerType::Unknown, "?"}}; | ||||
| 
 | ||||
| static const std::unordered_map<types::Layer, std::string> layerName_ { | ||||
|    {types::Layer::MapOverlay, "Map Overlay"}, | ||||
|    {types::Layer::ColorTable, "Color Table"}, | ||||
|    {types::Layer::MapSymbology, "Map Symbology"}, | ||||
|    {types::Layer::MapUnderlay, "Map Underlay"}}; | ||||
| static const std::unordered_map<Layer, std::string> layerName_ { | ||||
|    {Layer::MapOverlay, "Map Overlay"}, | ||||
|    {Layer::ColorTable, "Color Table"}, | ||||
|    {Layer::MapSymbology, "Map Symbology"}, | ||||
|    {Layer::MapUnderlay, "Map Underlay"}, | ||||
|    {Layer::Unknown, "?"}}; | ||||
| 
 | ||||
| static const std::unordered_map<MapTime, std::string> mapTimeName_ { | ||||
|    {MapTime::Live, "Live"}, {MapTime::Archive, "Archive"}}; | ||||
| 
 | ||||
| LayerType GetLayerType(const std::string& name) | ||||
| { | ||||
|    auto result = | ||||
|       std::find_if(layerTypeName_.cbegin(), | ||||
|                    layerTypeName_.cend(), | ||||
|                    [&](const std::pair<LayerType, std::string>& pair) -> bool | ||||
|                    { return boost::iequals(pair.second, name); }); | ||||
| 
 | ||||
|    if (result != layerTypeName_.cend()) | ||||
|    { | ||||
|       return result->first; | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|       return LayerType::Unknown; | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| std::string GetLayerTypeName(LayerType layerType) | ||||
| { | ||||
|    return layerTypeName_.at(layerType); | ||||
| } | ||||
| 
 | ||||
| Layer GetLayer(const std::string& name) | ||||
| { | ||||
|    auto result = | ||||
|       std::find_if(layerName_.cbegin(), | ||||
|                    layerName_.cend(), | ||||
|                    [&](const std::pair<Layer, std::string>& pair) -> bool | ||||
|                    { return boost::iequals(pair.second, name); }); | ||||
| 
 | ||||
|    if (result != layerName_.cend()) | ||||
|    { | ||||
|       return result->first; | ||||
|    } | ||||
|    else | ||||
|    { | ||||
|       return Layer::Unknown; | ||||
|    } | ||||
| } | ||||
| 
 | ||||
| std::string GetLayerName(Layer layer) | ||||
| { | ||||
|    return layerName_.at(layer); | ||||
|  |  | |||
|  | @ -15,7 +15,8 @@ enum class LayerType | |||
|    Radar, | ||||
|    Alert, | ||||
|    Placefile, | ||||
|    Information | ||||
|    Information, | ||||
|    Unknown | ||||
| }; | ||||
| 
 | ||||
| enum class Layer | ||||
|  | @ -23,7 +24,8 @@ enum class Layer | |||
|    MapOverlay, | ||||
|    ColorTable, | ||||
|    MapSymbology, | ||||
|    MapUnderlay | ||||
|    MapUnderlay, | ||||
|    Unknown | ||||
| }; | ||||
| 
 | ||||
| enum class AnimationState | ||||
|  | @ -46,8 +48,12 @@ enum class NoUpdateReason | |||
|    InvalidData | ||||
| }; | ||||
| 
 | ||||
| LayerType   GetLayerType(const std::string& name); | ||||
| std::string GetLayerTypeName(LayerType layerType); | ||||
| 
 | ||||
| Layer       GetLayer(const std::string& name); | ||||
| std::string GetLayerName(Layer layer); | ||||
| 
 | ||||
| std::string GetMapTimeName(MapTime mapTime); | ||||
| 
 | ||||
| } // namespace types
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat