Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/runner/yours/YoursRunner.cpp
1 | // | 1 | // | ||
---|---|---|---|---|---|
2 | // This file is part of the Marble Virtual Globe. | 2 | // This file is part of the Marble Virtual Globe. | ||
3 | // | 3 | // | ||
4 | // This program is free software licensed under the GNU LGPL. You can | 4 | // This program is free software licensed under the GNU LGPL. You can | ||
5 | // find a copy of this license in LICENSE.txt in the top directory of | 5 | // find a copy of this license in LICENSE.txt in the top directory of | ||
6 | // the source code. | 6 | // the source code. | ||
7 | // | 7 | // | ||
8 | // Copyright 2010 Dennis Nienhüser <nienhueser@kde.org> | 8 | // Copyright 2010 Dennis Nienhüser <nienhueser@kde.org> | ||
9 | // Copyright 2016 Piotr Wójcik <chocimier@tlen.pl> | ||||
9 | // | 10 | // | ||
10 | 11 | | |||
11 | #include "YoursRunner.h" | 12 | #include "YoursRunner.h" | ||
12 | 13 | | |||
13 | #include "MarbleDebug.h" | 14 | #include "MarbleDebug.h" | ||
14 | #include "MarbleLocale.h" | 15 | #include "MarbleLocale.h" | ||
15 | #include "GeoDataDocument.h" | 16 | #include "GeoDataDocument.h" | ||
16 | #include "GeoDataPlacemark.h" | 17 | #include "GeoDataPlacemark.h" | ||
Show All 39 Lines | 47 | { | |||
56 | 57 | | |||
57 | double tLon = destination.longitude( GeoDataCoordinates::Degree ); | 58 | double tLon = destination.longitude( GeoDataCoordinates::Degree ); | ||
58 | double tLat = destination.latitude( GeoDataCoordinates::Degree ); | 59 | double tLat = destination.latitude( GeoDataCoordinates::Degree ); | ||
59 | 60 | | |||
60 | QString base = "http://www.yournavigation.org/api/1.0/gosmore.php"; | 61 | QString base = "http://www.yournavigation.org/api/1.0/gosmore.php"; | ||
61 | //QString base = "http://nroets.dev.openstreetmap.org/demo/gosmore.php"; | 62 | //QString base = "http://nroets.dev.openstreetmap.org/demo/gosmore.php"; | ||
62 | QString args = "?flat=%1&flon=%2&tlat=%3&tlon=%4"; | 63 | QString args = "?flat=%1&flon=%2&tlat=%3&tlon=%4"; | ||
63 | args = args.arg( fLat, 0, 'f', 6 ).arg( fLon, 0, 'f', 6 ).arg( tLat, 0, 'f', 6 ).arg( tLon, 0, 'f', 6 ); | 64 | args = args.arg( fLat, 0, 'f', 6 ).arg( fLon, 0, 'f', 6 ).arg( tLat, 0, 'f', 6 ).arg( tLon, 0, 'f', 6 ); | ||
64 | QString preferences = "&v=motorcar&fast=1&layer=mapnik"; | 65 | | ||
66 | QHash<QString, QVariant> settings = route->routingProfile().pluginSettings()[QStringLiteral("yours")]; | ||||
67 | QString transport = settings[QStringLiteral("transport")].toString(); | ||||
68 | QString fast; | ||||
69 | | ||||
70 | if (settings[QStringLiteral("method")] == QLatin1String("shortest")) { | ||||
71 | fast = "0"; | ||||
72 | } else { | ||||
73 | fast = "1"; | ||||
74 | } | ||||
75 | | ||||
76 | QString preferences = "&v=%1&fast=%2&layer=mapnik;"; | ||||
77 | preferences = preferences.arg(transport).arg(fast); | ||||
65 | QString request = base + args + preferences; | 78 | QString request = base + args + preferences; | ||
66 | // mDebug() << "GET: " << request; | 79 | // mDebug() << "GET: " << request; | ||
67 | 80 | | |||
68 | m_request = QNetworkRequest( QUrl( request ) ); | 81 | m_request = QNetworkRequest( QUrl( request ) ); | ||
82 | m_request.setRawHeader( "X-Yours-client", "Marble" ); | ||||
69 | 83 | | |||
70 | QEventLoop eventLoop; | 84 | QEventLoop eventLoop; | ||
71 | 85 | | |||
72 | QTimer timer; | 86 | QTimer timer; | ||
73 | timer.setSingleShot( true ); | 87 | timer.setSingleShot( true ); | ||
74 | timer.setInterval( 15000 ); | 88 | timer.setInterval( 15000 ); | ||
75 | 89 | | |||
76 | connect( &timer, SIGNAL(timeout()), | 90 | connect( &timer, SIGNAL(timeout()), | ||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |