mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:40:04 +00:00 
			
		
		
		
	Draw radar range circle using geodesic projection
This commit is contained in:
		
							parent
							
								
									9b6582cd95
								
							
						
					
					
						commit
						c3037d6d38
					
				
					 4 changed files with 29 additions and 15 deletions
				
			
		|  | @ -16,6 +16,7 @@ conan_cmake_configure(REQUIRES boost/1.76.0 | ||||||
|                                glm/0.9.9.8 |                                glm/0.9.9.8 | ||||||
|                                gtest/cci.20210126 |                                gtest/cci.20210126 | ||||||
|                                openssl/1.1.1k |                                openssl/1.1.1k | ||||||
|  |                                proj/8.1.0 | ||||||
|                                vulkan-loader/1.2.172 |                                vulkan-loader/1.2.172 | ||||||
|                       GENERATORS cmake |                       GENERATORS cmake | ||||||
|                                  cmake_find_package |                                  cmake_find_package | ||||||
|  | @ -29,7 +30,7 @@ conan_cmake_autodetect(settings) | ||||||
| 
 | 
 | ||||||
| conan_cmake_install(PATH_OR_REFERENCE . | conan_cmake_install(PATH_OR_REFERENCE . | ||||||
|                     BUILD missing |                     BUILD missing | ||||||
|                     REMOTE conan-center |                     REMOTE conancenter | ||||||
|                     SETTINGS ${settings}) |                     SETTINGS ${settings}) | ||||||
| 
 | 
 | ||||||
| include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								external/mapbox-gl-native.cmake
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								external/mapbox-gl-native.cmake
									
										
									
									
										vendored
									
									
								
							|  | @ -9,6 +9,8 @@ find_package(ZLIB) | ||||||
| target_include_directories(mbgl-core PRIVATE ${ZLIB_INCLUDE_DIRS}) | target_include_directories(mbgl-core PRIVATE ${ZLIB_INCLUDE_DIRS}) | ||||||
| target_link_libraries(mbgl-core INTERFACE ${ZLIB_LIBRARIES}) | target_link_libraries(mbgl-core INTERFACE ${ZLIB_LIBRARIES}) | ||||||
| 
 | 
 | ||||||
|  | set(MBGL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/mapbox-gl-native/include PARENT_SCOPE) | ||||||
|  | 
 | ||||||
| set_target_properties(mbgl-qt PROPERTIES EXCLUDE_FROM_ALL True) | set_target_properties(mbgl-qt PROPERTIES EXCLUDE_FROM_ALL True) | ||||||
| set_target_properties(mbgl-test-runner PROPERTIES EXCLUDE_FROM_ALL True) | set_target_properties(mbgl-test-runner PROPERTIES EXCLUDE_FROM_ALL True) | ||||||
| set_target_properties(mbgl-vendor-icu PROPERTIES EXCLUDE_FROM_ALL True) | set_target_properties(mbgl-vendor-icu PROPERTIES EXCLUDE_FROM_ALL True) | ||||||
|  |  | ||||||
|  | @ -13,6 +13,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||||||
| 
 | 
 | ||||||
| find_package(Boost) | find_package(Boost) | ||||||
| find_package(glm) | find_package(glm) | ||||||
|  | find_package(proj) | ||||||
| 
 | 
 | ||||||
| # QtCreator supports the following variables for Android, which are identical to qmake Android variables. | # QtCreator supports the following variables for Android, which are identical to qmake Android variables. | ||||||
| # Check https://doc.qt.io/qt/deployment-android.html for more information. | # Check https://doc.qt.io/qt/deployment-android.html for more information. | ||||||
|  | @ -96,11 +97,13 @@ qt_add_executable(scwx-qt | ||||||
| 
 | 
 | ||||||
| qt6_create_translation_scwx(QM_FILES ${scwx-qt_SOURCE_DIR} ${TS_FILES}) | qt6_create_translation_scwx(QM_FILES ${scwx-qt_SOURCE_DIR} ${TS_FILES}) | ||||||
| 
 | 
 | ||||||
| target_include_directories(scwx-qt PRIVATE ${scwx-qt_SOURCE_DIR}/source) | target_include_directories(scwx-qt PRIVATE ${scwx-qt_SOURCE_DIR}/source | ||||||
|  |                                            ${MBGL_INCLUDE_DIR}) | ||||||
| 
 | 
 | ||||||
| target_link_libraries(scwx-qt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets | target_link_libraries(scwx-qt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets | ||||||
|                                       Qt${QT_VERSION_MAJOR}::OpenGLWidgets |                                       Qt${QT_VERSION_MAJOR}::OpenGLWidgets | ||||||
|                                       Boost::log |                                       Boost::log | ||||||
|                                       qmapboxgl |                                       qmapboxgl | ||||||
|                                       opengl32 |                                       opengl32 | ||||||
|                                       glm::glm) |                                       glm::glm | ||||||
|  |                                       PROJ::proj) | ||||||
|  |  | ||||||
|  | @ -1,8 +1,9 @@ | ||||||
| #include <scwx/qt/map/radar_range_layer.hpp> | #include <scwx/qt/map/radar_range_layer.hpp> | ||||||
| 
 | 
 | ||||||
| #include <boost/log/trivial.hpp> | #include <boost/log/trivial.hpp> | ||||||
| 
 | #include <geodesic.h> | ||||||
| #include <glm/glm.hpp> | #include <glm/glm.hpp> | ||||||
|  | #include <mbgl/util/constants.hpp> | ||||||
| 
 | 
 | ||||||
| namespace scwx | namespace scwx | ||||||
| { | { | ||||||
|  | @ -11,18 +12,21 @@ namespace qt | ||||||
| 
 | 
 | ||||||
| static const std::string logPrefix_ = "[scwx::qt::map::radar_range_layer] "; | static const std::string logPrefix_ = "[scwx::qt::map::radar_range_layer] "; | ||||||
| 
 | 
 | ||||||
|  | static constexpr double EARTH_FLATTENING = 1 / 298.257223563; | ||||||
|  | 
 | ||||||
| void RadarRangeLayer::Add(std::shared_ptr<QMapboxGL> map, const QString& before) | void RadarRangeLayer::Add(std::shared_ptr<QMapboxGL> map, const QString& before) | ||||||
| { | { | ||||||
|    BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Add()"; |    BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "Add()"; | ||||||
| 
 | 
 | ||||||
|  |    geod_geodesic g; | ||||||
|  |    geod_init(&g, mbgl::util::EARTH_RADIUS_M, EARTH_FLATTENING); | ||||||
|  | 
 | ||||||
|    constexpr float range = 460.0f * 1000.0f; |    constexpr float range = 460.0f * 1000.0f; | ||||||
| 
 | 
 | ||||||
|    constexpr float angleDelta  = glm::radians<float>(0.5f); |    constexpr float angleDelta  = 0.5f; | ||||||
|    constexpr float angleDeltaH = angleDelta / 2.0f; |    constexpr float angleDeltaH = angleDelta / 2.0f; | ||||||
| 
 | 
 | ||||||
|    const QMapbox::Coordinate      radar {38.6986, -90.6828}; |    const QMapbox::Coordinate radar {38.6986, -90.6828}; | ||||||
|    const QMapbox::ProjectedMeters radarMeters { |  | ||||||
|       QMapbox::projectedMetersForCoordinate(radar)}; |  | ||||||
| 
 | 
 | ||||||
|    float angle = -angleDeltaH; |    float angle = -angleDeltaH; | ||||||
| 
 | 
 | ||||||
|  | @ -30,15 +34,19 @@ void RadarRangeLayer::Add(std::shared_ptr<QMapboxGL> map, const QString& before) | ||||||
| 
 | 
 | ||||||
|    for (uint16_t azimuth = 0; azimuth <= 720; ++azimuth) |    for (uint16_t azimuth = 0; azimuth <= 720; ++azimuth) | ||||||
|    { |    { | ||||||
|       const float sinTheta = std::sinf(angle); |       double latitude; | ||||||
|       const float cosTheta = std::cosf(angle); |       double longitude; | ||||||
| 
 | 
 | ||||||
|       const float x = range * sinTheta + radarMeters.second; |       geod_direct(&g, | ||||||
|       const float y = range * cosTheta + radarMeters.first; |                   radar.first, | ||||||
|  |                   radar.second, | ||||||
|  |                   angle, | ||||||
|  |                   range, | ||||||
|  |                   &latitude, | ||||||
|  |                   &longitude, | ||||||
|  |                   nullptr); | ||||||
| 
 | 
 | ||||||
|       QMapbox::Coordinate point {QMapbox::coordinateForProjectedMeters({y, x})}; |       geometry.append({latitude, longitude}); | ||||||
| 
 |  | ||||||
|       geometry.append(point); |  | ||||||
| 
 | 
 | ||||||
|       angle += angleDelta; |       angle += angleDelta; | ||||||
|    } |    } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat