1
0
Fork 0

Launcher: fix navaid map default scaling.

This commit is contained in:
James Turner 2017-04-15 14:17:54 +01:00
parent f2d5f18da6
commit b006ef5c78
2 changed files with 11 additions and 12 deletions

View file

@ -35,17 +35,17 @@
#include "QtLauncher_fwd.hxx" #include "QtLauncher_fwd.hxx"
/* equatorial and polar earth radius */ /* equatorial and polar earth radius */
const float rec = 6378137; // earth radius, equator (?) const double rec = 6378137; // earth radius, equator (?)
const float rpol = 6356752.314f; // earth radius, polar (?) const double rpol = 6356752.314; // earth radius, polar (?)
const double MINIMUM_SCALE = 0.002; const double MINIMUM_SCALE = 0.002;
//Returns Earth radius at a given latitude (Ellipsoide equation with two equal axis) //Returns Earth radius at a given latitude (Ellipsoide equation with two equal axis)
static float earth_radius_lat( float lat ) static double earth_radius_lat( double lat )
{ {
double a = cos(lat)/rec; double a = cos(lat)/rec;
double b = sin(lat)/rpol; double b = sin(lat)/rpol;
return 1.0f / sqrt( a * a + b * b ); return 1.0 / sqrt( a * a + b * b );
} }
BaseDiagram::BaseDiagram(QWidget* pr) : BaseDiagram::BaseDiagram(QWidget* pr) :
@ -98,7 +98,7 @@ void BaseDiagram::extendRect(QRectF &r, const QPointF &p)
} }
} }
void BaseDiagram::paintEvent(QPaintEvent* pe) void BaseDiagram::paintEvent(QPaintEvent*)
{ {
QPainter p(this); QPainter p(this);
p.setRenderHints(QPainter::Antialiasing); p.setRenderHints(QPainter::Antialiasing);
@ -592,9 +592,9 @@ void BaseDiagram::extendBounds(const QPointF& p)
// but the groundnet is for // but the groundnet is for
// https://en.wikipedia.org/wiki/Salar_de_Atacama_Airport // https://en.wikipedia.org/wiki/Salar_de_Atacama_Airport
// causing a rather large airport boundary. // causing a rather large airport boundary.
QPointF v = (p - m_bounds.center()); QVector2D v(p - m_bounds.center());
if (v.manhattanLength() > 20000) { if (v.length() > 100000.0f) {
qWarning() << "Excessively distant point" << p << v.manhattanLength(); qWarning() << "Excessively distant point" << p << v.length();
return; return;
} }

View file

@ -104,10 +104,10 @@ void NavaidDiagram::doComputeBounds()
{ {
extendBounds(project(m_geod)); extendBounds(project(m_geod));
// project three points around the base location at 40nm to give some // project four points around the base location at 20nm to give some
// coverage // coverage
for (int i=0; i<3; ++i) { for (int i=0; i<4; ++i) {
SGGeod pt = SGGeodesy::direct(m_geod, i * 120, SG_NM_TO_METER * 40.0); SGGeod pt = SGGeodesy::direct(m_geod, i * 90, SG_NM_TO_METER * 20.0);
extendBounds(project(pt)); extendBounds(project(pt));
} }
@ -116,5 +116,4 @@ void NavaidDiagram::doComputeBounds()
SGGeod offsetPos = SGGeodesy::direct(m_geod, m_offsetBearingDeg, d); SGGeod offsetPos = SGGeodesy::direct(m_geod, m_offsetBearingDeg, d);
extendBounds(project(offsetPos)); extendBounds(project(offsetPos));
} }
} }