mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:20:05 +00:00 
			
		
		
		
	Extract utility geographic and maplibre functions
This commit is contained in:
		
							parent
							
								
									1a411af3bc
								
							
						
					
					
						commit
						1c39464228
					
				
					 6 changed files with 83 additions and 21 deletions
				
			
		
							
								
								
									
										32
									
								
								scwx-qt/source/scwx/qt/util/maplibre.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								scwx-qt/source/scwx/qt/util/maplibre.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| #include <scwx/qt/util/maplibre.hpp> | ||||
| 
 | ||||
| #include <mbgl/util/constants.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace util | ||||
| { | ||||
| namespace maplibre | ||||
| { | ||||
| 
 | ||||
| glm::vec2 LatLongToScreenCoordinate(const QMapLibreGL::Coordinate& coordinate) | ||||
| { | ||||
|    static constexpr double RAD2DEG_D = 180.0 / M_PI; | ||||
| 
 | ||||
|    double latitude = std::clamp( | ||||
|       coordinate.first, -mbgl::util::LATITUDE_MAX, mbgl::util::LATITUDE_MAX); | ||||
|    glm::vec2 screen { | ||||
|       mbgl::util::LONGITUDE_MAX + coordinate.second, | ||||
|       -(mbgl::util::LONGITUDE_MAX - | ||||
|         RAD2DEG_D * | ||||
|            std::log(std::tan(M_PI / 4.0 + | ||||
|                              latitude * M_PI / mbgl::util::DEGREES_MAX)))}; | ||||
|    return screen; | ||||
| } | ||||
| 
 | ||||
| } // namespace maplibre
 | ||||
| } // namespace util
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat