[5161] | 1 | // Part of BNC, a utility for retrieving decoding and
|
---|
| 2 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
| 3 | //
|
---|
| 4 | // Copyright (C) 2007
|
---|
| 5 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
| 6 | // http://www.bkg.bund.de
|
---|
| 7 | // Czech Technical University Prague, Department of Geodesy
|
---|
| 8 | // http://www.fsv.cvut.cz
|
---|
| 9 | //
|
---|
| 10 | // Email: euref-ip@bkg.bund.de
|
---|
| 11 | //
|
---|
| 12 | // This program is free software; you can redistribute it and/or
|
---|
| 13 | // modify it under the terms of the GNU General Public License
|
---|
| 14 | // as published by the Free Software Foundation, version 2.
|
---|
| 15 | //
|
---|
| 16 | // This program is distributed in the hope that it will be useful,
|
---|
| 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | // GNU General Public License for more details.
|
---|
| 20 | //
|
---|
| 21 | // You should have received a copy of the GNU General Public License
|
---|
| 22 | // along with this program; if not, write to the Free Software
|
---|
| 23 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 24 |
|
---|
| 25 | /* -------------------------------------------------------------------------
|
---|
| 26 | * BKG NTRIP Client
|
---|
| 27 | * -------------------------------------------------------------------------
|
---|
| 28 | *
|
---|
| 29 | * Class: bncMapWin
|
---|
| 30 | *
|
---|
[5188] | 31 | * Purpose: Displays the Google Map
|
---|
[5161] | 32 | *
|
---|
| 33 | * Author: L. Mervart
|
---|
| 34 | *
|
---|
| 35 | * Created: 08-Jun-2013
|
---|
| 36 | *
|
---|
[8909] | 37 | * Changes: A. Stuerze
|
---|
[5161] | 38 | *
|
---|
| 39 | * -----------------------------------------------------------------------*/
|
---|
| 40 |
|
---|
| 41 | #include "map/bncmapwin.h"
|
---|
[5232] | 42 | #include "bncsettings.h"
|
---|
[5188] | 43 | #include "bncutils.h"
|
---|
[5161] | 44 |
|
---|
| 45 | // Constructor
|
---|
| 46 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 47 | bncMapWin::bncMapWin(QWidget* parent) : QDialog(parent) {
|
---|
| 48 |
|
---|
| 49 | const int ww = QFontMetrics(font()).width('w');
|
---|
| 50 |
|
---|
[5180] | 51 | setWindowTitle("BNC: Map View");
|
---|
[5161] | 52 |
|
---|
[5229] | 53 | // Current Coordinates
|
---|
| 54 | // -------------------
|
---|
| 55 | _currLat = 50.09057949; // BKG latitude
|
---|
| 56 | _currLon = 8.66496871; // BKG longitude
|
---|
[5180] | 57 |
|
---|
[8260] | 58 | _webView = new QWebEngineView(this);
|
---|
| 59 |
|
---|
[5167] | 60 | connect(_webView, SIGNAL(loadFinished(bool)), this, SLOT(slotInitMap(bool)));
|
---|
| 61 |
|
---|
[6446] | 62 | // Plot Required Station
|
---|
| 63 | // ---------------------
|
---|
| 64 | bncSettings settings;
|
---|
| 65 | _staID = settings.value("PPP/plotCoordinates").toByteArray();
|
---|
| 66 |
|
---|
[5166] | 67 | loadHtmlPage();
|
---|
| 68 |
|
---|
[8260] | 69 | _webView->show();
|
---|
[5161] | 70 |
|
---|
[5228] | 71 | _statusLabel = new QLabel;
|
---|
[5161] | 72 |
|
---|
[5180] | 73 | // Layout
|
---|
| 74 | // ------
|
---|
[5228] | 75 | QHBoxLayout* statusLayout = new QHBoxLayout;
|
---|
| 76 | statusLayout->addWidget(_statusLabel);
|
---|
| 77 |
|
---|
[5180] | 78 | QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
---|
| 79 | mainLayout->addWidget(_webView);
|
---|
[5228] | 80 | mainLayout->addLayout(statusLayout);
|
---|
[5180] | 81 |
|
---|
| 82 | setLayout(mainLayout);
|
---|
[5161] | 83 | resize(60*ww, 60*ww);
|
---|
[5180] | 84 |
|
---|
[5161] | 85 | show();
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | // Destructor
|
---|
| 89 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 90 | bncMapWin::~bncMapWin() {
|
---|
| 91 | }
|
---|
| 92 |
|
---|
[8260] | 93 | //
|
---|
[5166] | 94 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 95 | void bncMapWin::loadHtmlPage() {
|
---|
| 96 |
|
---|
[5232] | 97 | bncSettings settings;
|
---|
| 98 |
|
---|
| 99 | QFile htmlFile;
|
---|
[5956] | 100 | if (settings.value("PPP/useOpenStreetMap").toBool()) {
|
---|
[5232] | 101 | htmlFile.setFileName(":/map/map_osm.html");
|
---|
| 102 | }
|
---|
| 103 | else {
|
---|
| 104 | htmlFile.setFileName(":/map/map_gm.html");
|
---|
| 105 | }
|
---|
[5166] | 106 | if (!htmlFile.open(QFile::ReadOnly)) {
|
---|
[5213] | 107 | qDebug() << "bncMapWin:: cannot open html file";
|
---|
[5166] | 108 | return;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | QTextStream stream(&htmlFile);
|
---|
| 112 | QString html = stream.readAll();
|
---|
| 113 |
|
---|
| 114 | _webView->setHtml(html);
|
---|
| 115 | }
|
---|
| 116 |
|
---|
[8260] | 117 | //
|
---|
[5167] | 118 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 119 | void bncMapWin::slotInitMap(bool isOk) {
|
---|
| 120 | if (!isOk) {
|
---|
| 121 | return;
|
---|
| 122 | }
|
---|
[5246] | 123 | bncSettings settings;
|
---|
[5956] | 124 | int mapWinDotSize = settings.value("PPP/mapWinDotSize").toInt();
|
---|
[5305] | 125 | int mapWinDotColor = 1;
|
---|
[5956] | 126 | if (settings.value("PPP/mapWinDotColor").toString() == "yellow") {
|
---|
[5305] | 127 | mapWinDotColor = 2;
|
---|
| 128 | }
|
---|
| 129 | QString location = QString("%1, %2, %3, %4").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8).arg(mapWinDotSize).arg(mapWinDotColor);
|
---|
[8909] | 130 | _webView->page()->runJavaScript(QString("gotoLocation( %1 )").arg(location));
|
---|
[5177] | 131 | }
|
---|
[5175] | 132 |
|
---|
[8260] | 133 | //
|
---|
[5177] | 134 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5187] | 135 | void bncMapWin::gotoLocation(double lat, double lon) {
|
---|
[5180] | 136 | _currLat = lat;
|
---|
| 137 | _currLon = lon;
|
---|
[5253] | 138 | //// beg test
|
---|
| 139 | // _currLat += 0.00001;
|
---|
| 140 | // _currLon += 0.00001;
|
---|
| 141 | //// end test
|
---|
[5230] | 142 |
|
---|
| 143 | int latDeg, latMin;
|
---|
| 144 | double latSec;
|
---|
| 145 | deg2DMS(lat, latDeg, latMin, latSec);
|
---|
| 146 |
|
---|
| 147 | int lonDeg, lonMin;
|
---|
| 148 | double lonSec;
|
---|
| 149 | deg2DMS(lon, lonDeg, lonMin, lonSec);
|
---|
| 150 |
|
---|
| 151 | QString lblStr=QString("Latitude: %1 %2 %3 Longitude: %4 %5 %6")
|
---|
[5231] | 152 | .arg(latDeg).arg(latMin).arg(latSec,0,'f',4)
|
---|
| 153 | .arg(lonDeg).arg(lonMin).arg(lonSec,0,'f',4);
|
---|
[5230] | 154 | _statusLabel->setText(lblStr);
|
---|
| 155 |
|
---|
[5177] | 156 | QString location = QString("%1, %2").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8);
|
---|
[8909] | 157 | _webView->page()->runJavaScript(QString("gotoLocation( %1 )").arg(location));
|
---|
[5180] | 158 | }
|
---|
| 159 |
|
---|
[8260] | 160 | //
|
---|
[5180] | 161 | ////////////////////////////////////////////////////////////////////////////
|
---|
[6446] | 162 | void bncMapWin::slotNewPosition(QByteArray staID, bncTime /* time */, QVector<double> xx) {
|
---|
| 163 | if (!_staID.isEmpty() && _staID != staID) {
|
---|
| 164 | return;
|
---|
| 165 | }
|
---|
[5188] | 166 | double ell[3];
|
---|
[5879] | 167 | xyz2ell(xx.data(), ell);
|
---|
[5188] | 168 | gotoLocation(ell[0]*180.0/M_PI, ell[1]*180.0/M_PI);
|
---|
[5187] | 169 | }
|
---|
[5234] | 170 |
|
---|
| 171 | // Close Dialog gracefully
|
---|
| 172 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 173 | void bncMapWin::closeEvent(QCloseEvent* event) {
|
---|
| 174 | emit mapClosed();
|
---|
| 175 | QDialog::closeEvent(event);
|
---|
| 176 | }
|
---|