mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 05:20:06 +00:00 
			
		
		
		
	Move code from map_widget and custom_layer_dialog to util/maplibre
This commit is contained in:
		
							parent
							
								
									fee00b737a
								
							
						
					
					
						commit
						a7c6be2bab
					
				
					 4 changed files with 64 additions and 66 deletions
				
			
		|  | @ -1,7 +1,9 @@ | |||
| #include <scwx/qt/util/maplibre.hpp> | ||||
| 
 | ||||
| #include <QMapLibre/Utils> | ||||
| #include <algorithm> | ||||
| #include <mbgl/util/constants.hpp> | ||||
| #include <re2/re2.h> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
|  | @ -120,6 +122,44 @@ void SetMapStyleUrl(const std::shared_ptr<map::MapContext>& mapContext, | |||
|    } | ||||
| } | ||||
| 
 | ||||
| std::string FindMapSymbologyLayer(const QStringList&              styleLayers, | ||||
|                                   const std::vector<std::string>& drawBelow) | ||||
| { | ||||
|    std::string before = "ferry"; | ||||
| 
 | ||||
|    for (const QString& qlayer : styleLayers) | ||||
|    { | ||||
|       const std::string layer = qlayer.toStdString(); | ||||
| 
 | ||||
|       // Draw below layers defined in map style
 | ||||
|       auto it = | ||||
|          std::ranges::find_if(drawBelow, | ||||
|                               [&layer](const std::string& styleLayer) -> bool | ||||
|                               { | ||||
|                                  // Perform case-insensitive matching
 | ||||
|                                  RE2 re {"(?i)" + styleLayer}; | ||||
|                                  if (re.ok()) | ||||
|                                  { | ||||
|                                     return RE2::FullMatch(layer, re); | ||||
|                                  } | ||||
|                                  else | ||||
|                                  { | ||||
|                                     // Fall back to basic comparison if RE
 | ||||
|                                     // doesn't compile
 | ||||
|                                     return layer == styleLayer; | ||||
|                                  } | ||||
|                               }); | ||||
| 
 | ||||
|       if (it != drawBelow.cend()) | ||||
|       { | ||||
|          before = layer; | ||||
|          break; | ||||
|       } | ||||
|    } | ||||
| 
 | ||||
|    return before; | ||||
| } | ||||
| 
 | ||||
| } // namespace maplibre
 | ||||
| } // namespace util
 | ||||
| } // namespace qt
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 AdenKoperczak
						AdenKoperczak