mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:40: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 <unordered_map> | ||||||
| 
 | 
 | ||||||
|  | #include <boost/algorithm/string.hpp> | ||||||
|  | 
 | ||||||
| namespace scwx | namespace scwx | ||||||
| { | { | ||||||
| namespace qt | namespace qt | ||||||
|  | @ -9,27 +11,65 @@ namespace qt | ||||||
| namespace types | namespace types | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| static const std::unordered_map<types::LayerType, std::string> layerTypeName_ { | static const std::unordered_map<LayerType, std::string> layerTypeName_ { | ||||||
|    {types::LayerType::Map, "Map"}, |    {LayerType::Map, "Map"}, | ||||||
|    {types::LayerType::Radar, "Radar"}, |    {LayerType::Radar, "Radar"}, | ||||||
|    {types::LayerType::Alert, "Alert"}, |    {LayerType::Alert, "Alert"}, | ||||||
|    {types::LayerType::Placefile, "Placefile"}, |    {LayerType::Placefile, "Placefile"}, | ||||||
|    {types::LayerType::Information, "Information"}}; |    {LayerType::Information, "Information"}, | ||||||
|  |    {LayerType::Unknown, "?"}}; | ||||||
| 
 | 
 | ||||||
| static const std::unordered_map<types::Layer, std::string> layerName_ { | static const std::unordered_map<Layer, std::string> layerName_ { | ||||||
|    {types::Layer::MapOverlay, "Map Overlay"}, |    {Layer::MapOverlay, "Map Overlay"}, | ||||||
|    {types::Layer::ColorTable, "Color Table"}, |    {Layer::ColorTable, "Color Table"}, | ||||||
|    {types::Layer::MapSymbology, "Map Symbology"}, |    {Layer::MapSymbology, "Map Symbology"}, | ||||||
|    {types::Layer::MapUnderlay, "Map Underlay"}}; |    {Layer::MapUnderlay, "Map Underlay"}, | ||||||
|  |    {Layer::Unknown, "?"}}; | ||||||
| 
 | 
 | ||||||
| static const std::unordered_map<MapTime, std::string> mapTimeName_ { | static const std::unordered_map<MapTime, std::string> mapTimeName_ { | ||||||
|    {MapTime::Live, "Live"}, {MapTime::Archive, "Archive"}}; |    {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) | std::string GetLayerTypeName(LayerType layerType) | ||||||
| { | { | ||||||
|    return layerTypeName_.at(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) | std::string GetLayerName(Layer layer) | ||||||
| { | { | ||||||
|    return layerName_.at(layer); |    return layerName_.at(layer); | ||||||
|  |  | ||||||
|  | @ -15,7 +15,8 @@ enum class LayerType | ||||||
|    Radar, |    Radar, | ||||||
|    Alert, |    Alert, | ||||||
|    Placefile, |    Placefile, | ||||||
|    Information |    Information, | ||||||
|  |    Unknown | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| enum class Layer | enum class Layer | ||||||
|  | @ -23,7 +24,8 @@ enum class Layer | ||||||
|    MapOverlay, |    MapOverlay, | ||||||
|    ColorTable, |    ColorTable, | ||||||
|    MapSymbology, |    MapSymbology, | ||||||
|    MapUnderlay |    MapUnderlay, | ||||||
|  |    Unknown | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| enum class AnimationState | enum class AnimationState | ||||||
|  | @ -46,8 +48,12 @@ enum class NoUpdateReason | ||||||
|    InvalidData |    InvalidData | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | LayerType   GetLayerType(const std::string& name); | ||||||
| std::string GetLayerTypeName(LayerType layerType); | std::string GetLayerTypeName(LayerType layerType); | ||||||
|  | 
 | ||||||
|  | Layer       GetLayer(const std::string& name); | ||||||
| std::string GetLayerName(Layer layer); | std::string GetLayerName(Layer layer); | ||||||
|  | 
 | ||||||
| std::string GetMapTimeName(MapTime mapTime); | std::string GetMapTimeName(MapTime mapTime); | ||||||
| 
 | 
 | ||||||
| } // namespace types
 | } // namespace types
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat