mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 15:00: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
|
|
@ -13,6 +13,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||
|
||||
find_package(Boost)
|
||||
find_package(glm)
|
||||
find_package(proj)
|
||||
|
||||
# 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.
|
||||
|
|
@ -96,11 +97,13 @@ qt_add_executable(scwx-qt
|
|||
|
||||
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
|
||||
Qt${QT_VERSION_MAJOR}::OpenGLWidgets
|
||||
Boost::log
|
||||
qmapboxgl
|
||||
opengl32
|
||||
glm::glm)
|
||||
glm::glm
|
||||
PROJ::proj)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#include <scwx/qt/map/radar_range_layer.hpp>
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include <geodesic.h>
|
||||
#include <glm/glm.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
|
|
@ -11,18 +12,21 @@ namespace qt
|
|||
|
||||
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)
|
||||
{
|
||||
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 angleDelta = glm::radians<float>(0.5f);
|
||||
constexpr float angleDelta = 0.5f;
|
||||
constexpr float angleDeltaH = angleDelta / 2.0f;
|
||||
|
||||
const QMapbox::Coordinate radar {38.6986, -90.6828};
|
||||
const QMapbox::ProjectedMeters radarMeters {
|
||||
QMapbox::projectedMetersForCoordinate(radar)};
|
||||
const QMapbox::Coordinate radar {38.6986, -90.6828};
|
||||
|
||||
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)
|
||||
{
|
||||
const float sinTheta = std::sinf(angle);
|
||||
const float cosTheta = std::cosf(angle);
|
||||
double latitude;
|
||||
double longitude;
|
||||
|
||||
const float x = range * sinTheta + radarMeters.second;
|
||||
const float y = range * cosTheta + radarMeters.first;
|
||||
geod_direct(&g,
|
||||
radar.first,
|
||||
radar.second,
|
||||
angle,
|
||||
range,
|
||||
&latitude,
|
||||
&longitude,
|
||||
nullptr);
|
||||
|
||||
QMapbox::Coordinate point {QMapbox::coordinateForProjectedMeters({y, x})};
|
||||
|
||||
geometry.append(point);
|
||||
geometry.append({latitude, longitude});
|
||||
|
||||
angle += angleDelta;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue