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 | *
|
---|
31 | * Purpose: Displays the Google Map
|
---|
32 | *
|
---|
33 | * Author: L. Mervart
|
---|
34 | *
|
---|
35 | * Created: 08-Jun-2013
|
---|
36 | *
|
---|
37 | * Changes: A. Stuerze
|
---|
38 | *
|
---|
39 | * -----------------------------------------------------------------------*/
|
---|
40 |
|
---|
41 | #include "map/bncmapwin.h"
|
---|
42 | #include "bncsettings.h"
|
---|
43 | #include "bncutils.h"
|
---|
44 |
|
---|
45 | // Constructor
|
---|
46 | ////////////////////////////////////////////////////////////////////////////
|
---|
47 | bncMapWin::bncMapWin(QWidget* parent) : QDialog(parent) {
|
---|
48 |
|
---|
49 | const int ww = QFontMetrics(font()).width('w');
|
---|
50 |
|
---|
51 | setWindowTitle("BNC: Map View");
|
---|
52 |
|
---|
53 | // Current Coordinates
|
---|
54 | // -------------------
|
---|
55 | _currLat = 50.09057949; // BKG latitude
|
---|
56 | _currLon = 8.66496871; // BKG longitude
|
---|
57 |
|
---|
58 | _webView = new QWebEngineView(this);
|
---|
59 |
|
---|
60 | connect(_webView, SIGNAL(loadFinished(bool)), this, SLOT(slotInitMap(bool)));
|
---|
61 |
|
---|
62 | // Plot Required Station
|
---|
63 | // ---------------------
|
---|
64 | bncSettings settings;
|
---|
65 | _staID = settings.value("PPP/plotCoordinates").toByteArray();
|
---|
66 |
|
---|
67 | loadHtmlPage();
|
---|
68 |
|
---|
69 | _webView->show();
|
---|
70 |
|
---|
71 | _statusLabel = new QLabel;
|
---|
72 |
|
---|
73 | // Layout
|
---|
74 | // ------
|
---|
75 | QHBoxLayout* statusLayout = new QHBoxLayout;
|
---|
76 | statusLayout->addWidget(_statusLabel);
|
---|
77 |
|
---|
78 | QVBoxLayout* mainLayout = new QVBoxLayout(this);
|
---|
79 | mainLayout->addWidget(_webView);
|
---|
80 | mainLayout->addLayout(statusLayout);
|
---|
81 |
|
---|
82 | setLayout(mainLayout);
|
---|
83 | resize(60*ww, 60*ww);
|
---|
84 |
|
---|
85 | show();
|
---|
86 | }
|
---|
87 |
|
---|
88 | // Destructor
|
---|
89 | ////////////////////////////////////////////////////////////////////////////
|
---|
90 | bncMapWin::~bncMapWin() {
|
---|
91 | }
|
---|
92 |
|
---|
93 | //
|
---|
94 | ////////////////////////////////////////////////////////////////////////////
|
---|
95 | void bncMapWin::loadHtmlPage() {
|
---|
96 |
|
---|
97 | bncSettings settings;
|
---|
98 |
|
---|
99 | QFile htmlFile;
|
---|
100 | htmlFile.setFileName(":/map/map_osm.html");
|
---|
101 | if (!htmlFile.open(QFile::ReadOnly)) {
|
---|
102 | qDebug() << "bncMapWin:: cannot open html file";
|
---|
103 | return;
|
---|
104 | }
|
---|
105 |
|
---|
106 | QTextStream stream(&htmlFile);
|
---|
107 | QString html = stream.readAll();
|
---|
108 |
|
---|
109 | _webView->setHtml(html);
|
---|
110 | }
|
---|
111 |
|
---|
112 | //
|
---|
113 | ////////////////////////////////////////////////////////////////////////////
|
---|
114 | void bncMapWin::slotInitMap(bool isOk) {
|
---|
115 | if (!isOk) {
|
---|
116 | return;
|
---|
117 | }
|
---|
118 | bncSettings settings;
|
---|
119 | int mapWinDotSize = settings.value("PPP/mapWinDotSize").toInt();
|
---|
120 | int mapWinDotColor = 1;
|
---|
121 | if (settings.value("PPP/mapWinDotColor").toString() == "yellow") {
|
---|
122 | mapWinDotColor = 2;
|
---|
123 | }
|
---|
124 | QString location = QString("%1, %2, %3, %4").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8).arg(mapWinDotSize).arg(mapWinDotColor);
|
---|
125 | _webView->page()->runJavaScript(QString("gotoLocation( %1 )").arg(location));
|
---|
126 | }
|
---|
127 |
|
---|
128 | //
|
---|
129 | ////////////////////////////////////////////////////////////////////////////
|
---|
130 | void bncMapWin::gotoLocation(double lat, double lon) {
|
---|
131 | _currLat = lat;
|
---|
132 | _currLon = lon;
|
---|
133 | //// beg test
|
---|
134 | // _currLat += 0.00001;
|
---|
135 | // _currLon += 0.00001;
|
---|
136 | //// end test
|
---|
137 |
|
---|
138 | int latDeg, latMin;
|
---|
139 | double latSec;
|
---|
140 | deg2DMS(lat, latDeg, latMin, latSec);
|
---|
141 |
|
---|
142 | int lonDeg, lonMin;
|
---|
143 | double lonSec;
|
---|
144 | deg2DMS(lon, lonDeg, lonMin, lonSec);
|
---|
145 |
|
---|
146 | QString lblStr=QString("Latitude: %1 %2 %3 Longitude: %4 %5 %6")
|
---|
147 | .arg(latDeg).arg(latMin).arg(latSec,0,'f',4)
|
---|
148 | .arg(lonDeg).arg(lonMin).arg(lonSec,0,'f',4);
|
---|
149 | _statusLabel->setText(lblStr);
|
---|
150 |
|
---|
151 | QString location = QString("%1, %2").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8);
|
---|
152 | _webView->page()->runJavaScript(QString("gotoLocation( %1 )").arg(location));
|
---|
153 | }
|
---|
154 |
|
---|
155 | //
|
---|
156 | ////////////////////////////////////////////////////////////////////////////
|
---|
157 | void bncMapWin::slotNewPosition(QByteArray staID, bncTime /* time */, QVector<double> xx) {
|
---|
158 | if (!_staID.isEmpty() && _staID != staID) {
|
---|
159 | return;
|
---|
160 | }
|
---|
161 | double ell[3];
|
---|
162 | xyz2ell(xx.data(), ell);
|
---|
163 | gotoLocation(ell[0]*180.0/M_PI, ell[1]*180.0/M_PI);
|
---|
164 | }
|
---|
165 |
|
---|
166 | // Close Dialog gracefully
|
---|
167 | ////////////////////////////////////////////////////////////////////////////
|
---|
168 | void bncMapWin::closeEvent(QCloseEvent* event) {
|
---|
169 | emit mapClosed();
|
---|
170 | QDialog::closeEvent(event);
|
---|
171 | }
|
---|