mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 14:50:05 +00:00
Eliminating radar movement. Still need to fix radar scale. At 460km from radar, error in bin distance is up to 15km.
This commit is contained in:
parent
516983ab09
commit
c1233cd984
4 changed files with 35 additions and 33 deletions
|
|
@ -62,10 +62,11 @@ void MapWidget::changeStyle()
|
||||||
currentStyleIndex = 0;
|
currentStyleIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapWidget::AddLayers()
|
void MapWidget::AddLayers()
|
||||||
{
|
{
|
||||||
// QMapboxGL::addCustomLayer will take ownership of the QScopedPointer
|
// QMapboxGL::addCustomLayer will take ownership of the QScopedPointer
|
||||||
QScopedPointer<QMapbox::CustomLayerHostInterface> pHost(new RadarLayer());
|
QScopedPointer<QMapbox::CustomLayerHostInterface> pHost(new RadarLayer(map_));
|
||||||
|
|
||||||
QString before = "ferry";
|
QString before = "ferry";
|
||||||
|
|
||||||
|
|
@ -167,11 +168,7 @@ void MapWidget::wheelEvent(QWheelEvent* ev)
|
||||||
factor = factor > -1 ? factor : 1 / factor;
|
factor = factor > -1 ? factor : 1 / factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
|
||||||
map_->scaleBy(1 + factor, ev->position());
|
map_->scaleBy(1 + factor, ev->position());
|
||||||
#else
|
|
||||||
map_->scaleBy(1 + factor, ev->pos());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ev->accept();
|
ev->accept();
|
||||||
}
|
}
|
||||||
|
|
@ -179,10 +176,10 @@ void MapWidget::wheelEvent(QWheelEvent* ev)
|
||||||
void MapWidget::initializeGL()
|
void MapWidget::initializeGL()
|
||||||
{
|
{
|
||||||
map_.reset(new QMapboxGL(nullptr, settings_, size(), pixelRatio()));
|
map_.reset(new QMapboxGL(nullptr, settings_, size(), pixelRatio()));
|
||||||
connect(map_.data(), SIGNAL(needsRendering()), this, SLOT(update()));
|
connect(map_.get(), SIGNAL(needsRendering()), this, SLOT(update()));
|
||||||
|
|
||||||
// Set default location to KLSX.
|
// Set default location to KLSX.
|
||||||
map_->setCoordinateZoom(QMapbox::Coordinate(38.6986, -90.6828), 14);
|
map_->setCoordinateZoom(QMapbox::Coordinate(38.6986, -90.6828), 11);
|
||||||
|
|
||||||
QString styleUrl = qgetenv("MAPBOX_STYLE_URL");
|
QString styleUrl = qgetenv("MAPBOX_STYLE_URL");
|
||||||
if (styleUrl.isEmpty())
|
if (styleUrl.isEmpty())
|
||||||
|
|
@ -209,9 +206,9 @@ void MapWidget::paintGL()
|
||||||
|
|
||||||
void MapWidget::mapChanged(QMapboxGL::MapChange mapChange)
|
void MapWidget::mapChanged(QMapboxGL::MapChange mapChange)
|
||||||
{
|
{
|
||||||
if (mapChange == QMapboxGL::MapChangeDidFinishLoadingStyle)
|
switch (mapChange)
|
||||||
{
|
{
|
||||||
AddLayers();
|
case QMapboxGL::MapChangeDidFinishLoadingStyle: AddLayers(); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <QMapboxGL>
|
#include <QMapboxGL>
|
||||||
|
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QScopedPointer>
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
class QKeyEvent;
|
class QKeyEvent;
|
||||||
|
|
@ -42,8 +43,8 @@ private:
|
||||||
|
|
||||||
QPointF lastPos_;
|
QPointF lastPos_;
|
||||||
|
|
||||||
QMapboxGLSettings settings_;
|
QMapboxGLSettings settings_;
|
||||||
QScopedPointer<QMapboxGL> map_;
|
std::shared_ptr<QMapboxGL> map_;
|
||||||
|
|
||||||
uint64_t frameDraws_ = 0;
|
uint64_t frameDraws_ = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
#define _USE_MATH_DEFINES
|
|
||||||
|
|
||||||
#include <scwx/qt/map/radar_layer.hpp>
|
#include <scwx/qt/map/radar_layer.hpp>
|
||||||
#include <scwx/qt/util/shader_program.hpp>
|
#include <scwx/qt/util/shader_program.hpp>
|
||||||
|
|
||||||
|
|
@ -21,7 +19,8 @@ static const std::string logPrefix_ = "[scwx::qt::map::radar_layer] ";
|
||||||
class RadarLayerImpl
|
class RadarLayerImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit RadarLayerImpl() :
|
explicit RadarLayerImpl(std::shared_ptr<QMapboxGL> map) :
|
||||||
|
map_(map),
|
||||||
gl_(),
|
gl_(),
|
||||||
shaderProgram_(),
|
shaderProgram_(),
|
||||||
uMVPMatrixLocation_(GL_INVALID_INDEX),
|
uMVPMatrixLocation_(GL_INVALID_INDEX),
|
||||||
|
|
@ -33,6 +32,8 @@ public:
|
||||||
}
|
}
|
||||||
~RadarLayerImpl() = default;
|
~RadarLayerImpl() = default;
|
||||||
|
|
||||||
|
std::shared_ptr<QMapboxGL> map_;
|
||||||
|
|
||||||
QOpenGLFunctions_3_3_Core gl_;
|
QOpenGLFunctions_3_3_Core gl_;
|
||||||
|
|
||||||
ShaderProgram shaderProgram_;
|
ShaderProgram shaderProgram_;
|
||||||
|
|
@ -43,7 +44,10 @@ public:
|
||||||
GLsizeiptr numVertices_;
|
GLsizeiptr numVertices_;
|
||||||
};
|
};
|
||||||
|
|
||||||
RadarLayer::RadarLayer() : p(std::make_unique<RadarLayerImpl>()) {}
|
RadarLayer::RadarLayer(std::shared_ptr<QMapboxGL> map) :
|
||||||
|
p(std::make_unique<RadarLayerImpl>(map))
|
||||||
|
{
|
||||||
|
}
|
||||||
RadarLayer::~RadarLayer() = default;
|
RadarLayer::~RadarLayer() = default;
|
||||||
|
|
||||||
RadarLayer::RadarLayer(RadarLayer&&) noexcept = default;
|
RadarLayer::RadarLayer(RadarLayer&&) noexcept = default;
|
||||||
|
|
@ -69,10 +73,11 @@ void RadarLayer::initialize()
|
||||||
static std::array<GLfloat, MAX_RADIALS * MAX_DATA_MOMENT_GATES * 6 * 2>
|
static std::array<GLfloat, MAX_RADIALS * MAX_DATA_MOMENT_GATES * 6 * 2>
|
||||||
vertices;
|
vertices;
|
||||||
|
|
||||||
constexpr float angleDelta = 0.5f * static_cast<float>(M_PI) / 180.0f;
|
constexpr float angleDelta = glm::radians<float>(0.5f);
|
||||||
|
constexpr float angleDeltaH = angleDelta / 2.0f;
|
||||||
|
|
||||||
float angle1 = 0;
|
float angle1 = -angleDeltaH;
|
||||||
float angle2 = angleDelta;
|
float angle2 = angleDeltaH;
|
||||||
|
|
||||||
GLsizeiptr index = 0;
|
GLsizeiptr index = 0;
|
||||||
|
|
||||||
|
|
@ -162,28 +167,25 @@ void RadarLayer::render(const QMapbox::CustomLayerRenderParameters& params)
|
||||||
|
|
||||||
p->shaderProgram_.Use();
|
p->shaderProgram_.Use();
|
||||||
|
|
||||||
float metersPerPixel =
|
const QMapbox::Coordinate radar(38.6986, -90.6828);
|
||||||
|
|
||||||
|
const float metersPerPixel =
|
||||||
QMapbox::metersPerPixelAtLatitude(params.latitude, params.zoom);
|
QMapbox::metersPerPixelAtLatitude(params.latitude, params.zoom);
|
||||||
|
|
||||||
const float scale = 1000.0f / metersPerPixel * 2.0f;
|
const float scale = 1000.0f / metersPerPixel * 2.0f;
|
||||||
const float xScale = scale / params.width;
|
const float xScale = scale / params.width;
|
||||||
const float yScale = scale / params.height;
|
const float yScale = scale / params.height;
|
||||||
|
|
||||||
const QMapbox::Coordinate radar(38.6986, -90.6828);
|
QPointF radarScreen = p->map_->pixelForCoordinate(radar);
|
||||||
|
const float xTranslate =
|
||||||
const QMapbox::ProjectedMeters radarMeters =
|
(radarScreen.x() - (params.width * 0.5f)) / params.width * 2.0f;
|
||||||
QMapbox::projectedMetersForCoordinate(radar);
|
const float yTranslate =
|
||||||
const QMapbox::ProjectedMeters mapMeters =
|
-(radarScreen.y() - (params.height * 0.5f)) / params.height * 2.0f;
|
||||||
QMapbox::projectedMetersForCoordinate(
|
|
||||||
{params.latitude, params.longitude});
|
|
||||||
|
|
||||||
const float yTranslate = (radarMeters.first - mapMeters.first) * 0.001f;
|
|
||||||
const float xTranslate = (radarMeters.second - mapMeters.second) * 0.001f;
|
|
||||||
|
|
||||||
glm::mat4 uMVPMatrix(1.0f);
|
glm::mat4 uMVPMatrix(1.0f);
|
||||||
uMVPMatrix = glm::scale(uMVPMatrix, glm::vec3(xScale, yScale, 1.0f));
|
|
||||||
uMVPMatrix =
|
uMVPMatrix =
|
||||||
glm::translate(uMVPMatrix, glm::vec3(xTranslate, yTranslate, 0.0f));
|
glm::translate(uMVPMatrix, glm::vec3(xTranslate, yTranslate, 0.0f));
|
||||||
|
uMVPMatrix = glm::scale(uMVPMatrix, glm::vec3(xScale, yScale, 1.0f));
|
||||||
uMVPMatrix = glm::rotate(uMVPMatrix,
|
uMVPMatrix = glm::rotate(uMVPMatrix,
|
||||||
glm::radians<float>(params.bearing),
|
glm::radians<float>(params.bearing),
|
||||||
glm::vec3(0.0f, 0.0f, 1.0f));
|
glm::vec3(0.0f, 0.0f, 1.0f));
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
#include <qmapboxgl.hpp>
|
#pragma once
|
||||||
|
|
||||||
|
#include <QMapboxGL>
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
|
|
@ -10,7 +12,7 @@ class RadarLayerImpl;
|
||||||
class RadarLayer : public QMapbox::CustomLayerHostInterface
|
class RadarLayer : public QMapbox::CustomLayerHostInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit RadarLayer();
|
explicit RadarLayer(std::shared_ptr<QMapboxGL> map);
|
||||||
~RadarLayer();
|
~RadarLayer();
|
||||||
|
|
||||||
RadarLayer(const RadarLayer&) = delete;
|
RadarLayer(const RadarLayer&) = delete;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue