[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 | *
|
---|
| 37 | * Changes:
|
---|
| 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 |
|
---|
[5161] | 58 | _webView = new QWebView(this);
|
---|
[5167] | 59 | connect(_webView, SIGNAL(loadFinished(bool)), this, SLOT(slotInitMap(bool)));
|
---|
| 60 |
|
---|
[5166] | 61 | loadHtmlPage();
|
---|
| 62 |
|
---|
[5161] | 63 | _webView->show();
|
---|
| 64 |
|
---|
[5228] | 65 | _statusLabel = new QLabel;
|
---|
[5161] | 66 |
|
---|
[5180] | 67 | // Layout
|
---|
| 68 | // ------
|
---|
[5228] | 69 | QHBoxLayout* statusLayout = new QHBoxLayout;
|
---|
| 70 | statusLayout->addWidget(_statusLabel);
|
---|
| 71 |
|
---|
[5180] | 72 | QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
---|
| 73 | mainLayout->addWidget(_webView);
|
---|
[5228] | 74 | mainLayout->addLayout(statusLayout);
|
---|
[5180] | 75 |
|
---|
| 76 | setLayout(mainLayout);
|
---|
[5161] | 77 | resize(60*ww, 60*ww);
|
---|
[5180] | 78 |
|
---|
[5161] | 79 | show();
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | // Destructor
|
---|
| 83 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 84 | bncMapWin::~bncMapWin() {
|
---|
| 85 | }
|
---|
| 86 |
|
---|
[5166] | 87 | //
|
---|
| 88 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 89 | void bncMapWin::loadHtmlPage() {
|
---|
| 90 |
|
---|
[5232] | 91 | bncSettings settings;
|
---|
| 92 |
|
---|
| 93 | QFile htmlFile;
|
---|
| 94 | if (settings.value("useOsmMap").toBool()) {
|
---|
| 95 | htmlFile.setFileName(":/map/map_osm.html");
|
---|
| 96 | }
|
---|
| 97 | else {
|
---|
| 98 | htmlFile.setFileName(":/map/map_gm.html");
|
---|
| 99 | }
|
---|
[5166] | 100 | if (!htmlFile.open(QFile::ReadOnly)) {
|
---|
[5213] | 101 | qDebug() << "bncMapWin:: cannot open html file";
|
---|
[5166] | 102 | return;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | QTextStream stream(&htmlFile);
|
---|
| 106 | QString html = stream.readAll();
|
---|
| 107 |
|
---|
| 108 | _webView->setHtml(html);
|
---|
| 109 | }
|
---|
| 110 |
|
---|
[5167] | 111 | //
|
---|
| 112 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 113 | void bncMapWin::slotInitMap(bool isOk) {
|
---|
| 114 | if (!isOk) {
|
---|
| 115 | return;
|
---|
| 116 | }
|
---|
[5246] | 117 | bncSettings settings;
|
---|
| 118 | int useTrace = (Qt::CheckState(settings.value("mapWinTrace").toInt()) == Qt::Checked) ? 1 : 0;
|
---|
| 119 | QString location = QString("%1, %2, %3").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8).arg(useTrace);
|
---|
[5167] | 120 | _webView->page()->mainFrame()->evaluateJavaScript(QString("initialize( %1 )").arg(location));
|
---|
[5177] | 121 | }
|
---|
[5175] | 122 |
|
---|
[5177] | 123 | //
|
---|
| 124 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5187] | 125 | void bncMapWin::gotoLocation(double lat, double lon) {
|
---|
[5180] | 126 | _currLat = lat;
|
---|
| 127 | _currLon = lon;
|
---|
[5253] | 128 | //// beg test
|
---|
| 129 | // _currLat += 0.00001;
|
---|
| 130 | // _currLon += 0.00001;
|
---|
| 131 | //// end test
|
---|
[5230] | 132 |
|
---|
| 133 | int latDeg, latMin;
|
---|
| 134 | double latSec;
|
---|
| 135 | deg2DMS(lat, latDeg, latMin, latSec);
|
---|
| 136 |
|
---|
| 137 | int lonDeg, lonMin;
|
---|
| 138 | double lonSec;
|
---|
| 139 | deg2DMS(lon, lonDeg, lonMin, lonSec);
|
---|
| 140 |
|
---|
| 141 | QString lblStr=QString("Latitude: %1 %2 %3 Longitude: %4 %5 %6")
|
---|
[5231] | 142 | .arg(latDeg).arg(latMin).arg(latSec,0,'f',4)
|
---|
| 143 | .arg(lonDeg).arg(lonMin).arg(lonSec,0,'f',4);
|
---|
[5230] | 144 | _statusLabel->setText(lblStr);
|
---|
| 145 |
|
---|
[5177] | 146 | QString location = QString("%1, %2").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8);
|
---|
| 147 | _webView->page()->mainFrame()->evaluateJavaScript(QString("gotoLocation( %1 )").arg(location));
|
---|
[5180] | 148 | }
|
---|
| 149 |
|
---|
| 150 | //
|
---|
| 151 | ////////////////////////////////////////////////////////////////////////////
|
---|
[5188] | 152 | void bncMapWin::slotNewPosition(bncTime /* time */, double xx, double yy, double zz) {
|
---|
| 153 | double xyz[3];
|
---|
| 154 | xyz[0] = xx;
|
---|
| 155 | xyz[1] = yy;
|
---|
| 156 | xyz[2] = zz;
|
---|
| 157 | double ell[3];
|
---|
| 158 | xyz2ell(xyz, ell);
|
---|
| 159 | gotoLocation(ell[0]*180.0/M_PI, ell[1]*180.0/M_PI);
|
---|
[5187] | 160 | }
|
---|
[5234] | 161 |
|
---|
| 162 | // Close Dialog gracefully
|
---|
| 163 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 164 | void bncMapWin::closeEvent(QCloseEvent* event) {
|
---|
| 165 | emit mapClosed();
|
---|
| 166 | QDialog::closeEvent(event);
|
---|
| 167 | }
|
---|