mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 04:30:05 +00:00 
			
		
		
		
	Use LatLongToScreenCoordinate from maplibre utility in DrawItem
This commit is contained in:
		
							parent
							
								
									565734217b
								
							
						
					
					
						commit
						e3c6850a1e
					
				
					 1 changed files with 2 additions and 18 deletions
				
			
		|  | @ -1,4 +1,5 @@ | ||||||
| #include <scwx/qt/gl/draw/draw_item.hpp> | #include <scwx/qt/gl/draw/draw_item.hpp> | ||||||
|  | #include <scwx/qt/util/maplibre.hpp> | ||||||
| 
 | 
 | ||||||
| #include <string> | #include <string> | ||||||
| 
 | 
 | ||||||
|  | @ -82,23 +83,6 @@ void DrawItem::UseRotationProjection( | ||||||
|       uMVPMatrixLocation, 1, GL_FALSE, glm::value_ptr(projection)); |       uMVPMatrixLocation, 1, GL_FALSE, glm::value_ptr(projection)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // TODO: Refactor to utility class
 |  | ||||||
| static 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; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void DrawItem::UseMapProjection( | void DrawItem::UseMapProjection( | ||||||
|    const QMapLibreGL::CustomLayerRenderParameters& params, |    const QMapLibreGL::CustomLayerRenderParameters& params, | ||||||
|    GLint                                           uMVPMatrixLocation, |    GLint                                           uMVPMatrixLocation, | ||||||
|  | @ -120,7 +104,7 @@ void DrawItem::UseMapProjection( | ||||||
| 
 | 
 | ||||||
|    gl.glUniform2fv(uMapScreenCoordLocation, |    gl.glUniform2fv(uMapScreenCoordLocation, | ||||||
|                    1, |                    1, | ||||||
|                    glm::value_ptr(LatLongToScreenCoordinate( |                    glm::value_ptr(util::maplibre::LatLongToScreenCoordinate( | ||||||
|                       {params.latitude, params.longitude}))); |                       {params.latitude, params.longitude}))); | ||||||
| 
 | 
 | ||||||
|    gl.glUniformMatrix4fv( |    gl.glUniformMatrix4fv( | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat