source: ntrip/trunk/BNC/src/map/bncmapwin.cpp@ 10298

Last change on this file since 10298 was 9966, checked in by stuerze, 22 months ago

minor changes

File size: 5.0 KB
RevLine 
[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 *
[9246]31 * Purpose: Displays the Open Street 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////////////////////////////////////////////////////////////////////////////
47bncMapWin::bncMapWin(QWidget* parent) : QDialog(parent) {
48
[9807]49 _initMap = false;
50
[5161]51 const int ww = QFontMetrics(font()).width('w');
52
[5180]53 setWindowTitle("BNC: Map View");
[5161]54
[5229]55 // Current Coordinates
56 // -------------------
57 _currLat = 50.09057949; // BKG latitude
58 _currLon = 8.66496871; // BKG longitude
[5180]59
[8260]60 _webView = new QWebEngineView(this);
61
[5167]62 connect(_webView, SIGNAL(loadFinished(bool)), this, SLOT(slotInitMap(bool)));
63
[6446]64 // Plot Required Station
65 // ---------------------
66 bncSettings settings;
67 _staID = settings.value("PPP/plotCoordinates").toByteArray();
68
[5166]69 loadHtmlPage();
70
[8260]71 _webView->show();
[5161]72
[5228]73 _statusLabel = new QLabel;
[5161]74
[5180]75 // Layout
76 // ------
[5228]77 QHBoxLayout* statusLayout = new QHBoxLayout;
78 statusLayout->addWidget(_statusLabel);
79
[5180]80 QVBoxLayout* mainLayout = new QVBoxLayout(this);
81 mainLayout->addWidget(_webView);
[5228]82 mainLayout->addLayout(statusLayout);
[5180]83
84 setLayout(mainLayout);
[5161]85 resize(60*ww, 60*ww);
[5180]86
[5161]87 show();
[9807]88
[5161]89}
90
91// Destructor
92////////////////////////////////////////////////////////////////////////////
93bncMapWin::~bncMapWin() {
94}
95
[8260]96//
[5166]97////////////////////////////////////////////////////////////////////////////
98void bncMapWin::loadHtmlPage() {
99
[5232]100 QFile htmlFile;
[9237]101 htmlFile.setFileName(":/map/map_osm.html");
[5166]102 if (!htmlFile.open(QFile::ReadOnly)) {
[5213]103 qDebug() << "bncMapWin:: cannot open html file";
[5166]104 return;
105 }
106
107 QTextStream stream(&htmlFile);
108 QString html = stream.readAll();
109
110 _webView->setHtml(html);
111}
112
[8260]113//
[5167]114////////////////////////////////////////////////////////////////////////////
115void bncMapWin::slotInitMap(bool isOk) {
116 if (!isOk) {
117 return;
118 }
[9807]119 _initMap = true;
120
[5246]121 bncSettings settings;
[5956]122 int mapWinDotSize = settings.value("PPP/mapWinDotSize").toInt();
[5305]123 int mapWinDotColor = 1;
[5956]124 if (settings.value("PPP/mapWinDotColor").toString() == "yellow") {
[5305]125 mapWinDotColor = 2;
126 }
127 QString location = QString("%1, %2, %3, %4").arg(_currLat,0,'f',8).arg(_currLon,0,'f',8).arg(mapWinDotSize).arg(mapWinDotColor);
[9243]128 _webView->page()->runJavaScript(QString("initialize( %1 )").arg(location));
[5177]129}
[5175]130
[8260]131//
[5177]132////////////////////////////////////////////////////////////////////////////
[5187]133void bncMapWin::gotoLocation(double lat, double lon) {
[9807]134 if (!lat && !lon) {
135 return;
136 }
[5180]137 _currLat = lat;
138 _currLon = lon;
[9966]139 // beg test
140 _currLat += 0.00001;
141 _currLon += 0.00001;
142 // end test
[5230]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]162void bncMapWin::slotNewPosition(QByteArray staID, bncTime /* time */, QVector<double> xx) {
163 if (!_staID.isEmpty() && _staID != staID) {
164 return;
165 }
[9807]166 if (!_initMap) {
167 return;
168 }
[5188]169 double ell[3];
[9807]170 if (xyz2ell(xx.data(), ell) == failure) {
171 return;
172 }
[5188]173 gotoLocation(ell[0]*180.0/M_PI, ell[1]*180.0/M_PI);
[5187]174}
[5234]175
176// Close Dialog gracefully
177////////////////////////////////////////////////////////////////////////////
178void bncMapWin::closeEvent(QCloseEvent* event) {
179 emit mapClosed();
180 QDialog::closeEvent(event);
181}
Note: See TracBrowser for help on using the repository browser.