Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
V1.XX.X
[QMS-622] Update BRouter setup (install from github)
[QMS-623] remove use of QTimer in brouter startup error detection
[QMS-623] Remove use of QTimer in brouter startup error detection
[QMS-624] Fix crashes while using BRouter
[QMS-630] BRouter on-the-fly routing cannot be canceled

V1.17.0
Expand Down
13 changes: 7 additions & 6 deletions src/qmapshack/gis/rte/router/CRouterBRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ QString CRouterBRouter::getOptions() {
void CRouterBRouter::routerSelected() { getBRouterVersion(); }

bool CRouterBRouter::hasFastRouting() {
return setup->installMode == CRouterBRouterSetup::eModeLocal && setup->isLocalBRouterValid && checkFastRecalc->isChecked();
return setup->installMode == CRouterBRouterSetup::eModeLocal && setup->isLocalBRouterValid &&
checkFastRecalc->isChecked();
}

QNetworkRequest CRouterBRouter::getRequest(const QVector<QPointF>& routePoints, const QList<IGisItem*>& nogos) const {
Expand Down Expand Up @@ -282,7 +283,7 @@ QNetworkRequest CRouterBRouter::getRequest(const QVector<QPointF>& routePoints,
return QNetworkRequest(url);
}

int CRouterBRouter::calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords, qreal* costs) {
int CRouterBRouter::calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords, qreal* costs) noexcept(false) {
if (!hasFastRouting()) {
return -1;
}
Expand All @@ -296,7 +297,7 @@ int CRouterBRouter::calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& c
}

int CRouterBRouter::synchronousRequest(const QVector<QPointF>& points, const QList<IGisItem*>& nogos, QPolygonF& coords,
qreal* costs = nullptr) {
qreal* costs = nullptr) noexcept(false) {
if (!mutex.tryLock()) {
// skip further on-the-fly-requests as long a previous request is still running
return -1;
Expand Down Expand Up @@ -380,12 +381,12 @@ int CRouterBRouter::synchronousRequest(const QVector<QPointF>& points, const QLi
}
}
} catch (const QString& msg) {
coords.clear();
reply->deleteLater();
mutex.unlock();
if (!msg.isEmpty()) {
reply->deleteLater();
mutex.unlock();
throw tr("Bad response from server: %1").arg(msg);
}
return -1;
}

reply->deleteLater();
Expand Down
5 changes: 3 additions & 2 deletions src/qmapshack/gis/rte/router/CRouterBRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class CRouterBRouter : public IRouter, private Ui::IRouterBRouter {
static CRouterBRouter& self() { return *pSelf; }

void calcRoute(const IGisItem::key_t& key) override;
int calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords, qreal* costs = nullptr) override;
int calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords,
qreal* costs = nullptr) noexcept(false) override;
bool hasFastRouting() override;
QString getOptions() override;
void routerSelected() override;
Expand All @@ -70,7 +71,7 @@ class CRouterBRouter : public IRouter, private Ui::IRouterBRouter {
bool isMinimumVersion(int major, int minor, int patch) const;
void updateBRouterStatus() const;
int synchronousRequest(const QVector<QPointF>& points, const QList<IGisItem*>& nogos, QPolygonF& coords,
qreal* costs);
qreal* costs) noexcept(false);
QNetworkRequest getRequest(const QVector<QPointF>& routePoints, const QList<IGisItem*>& nogos) const;
QUrl getServiceUrl() const;

Expand Down
12 changes: 10 additions & 2 deletions src/qmapshack/gis/rte/router/CRouterOptimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include "CRouterOptimization.h"

#include <QDebug>

#include "gis/GeoMath.h"
#include "gis/rte/router/CRouterSetup.h"
#include "helpers/CProgressDialog.h"
Expand Down Expand Up @@ -237,10 +239,16 @@ const CRouterOptimization::routing_cache_item_t* CRouterOptimization::getRoute(c

if (!routingCache[start_key].contains(end_key)) {
routing_cache_item_t cacheItem;
int response = CRouterSetup::self().calcRoute(start, end, cacheItem.route, &cacheItem.costs);
if (response < 0) {
try {
int response = CRouterSetup::self().calcRoute(start, end, cacheItem.route, &cacheItem.costs);
if (response < 0) {
return nullptr;
}
} catch (const QString& msg) {
qWarning() << msg;
return nullptr;
}

routingCache[start_key][end_key] = cacheItem;

qreal airToCostFactor = cacheItem.costs / GPS_Math_DistanceQuick(start.x(), start.y(), end.x(), end.y());
Expand Down
3 changes: 2 additions & 1 deletion src/qmapshack/gis/rte/router/CRouterRoutino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ void CRouterRoutino::calcRoute(const IGisItem::key_t& key) {
CCanvas::triggerCompleteUpdate(CCanvas::eRedrawGis);
}

int CRouterRoutino::calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords, qreal* costs = nullptr) {
int CRouterRoutino::calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords,
qreal* costs = nullptr) noexcept(false) {
if (!mutex.tryLock()) {
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/qmapshack/gis/rte/router/CRouterRoutino.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CRouterRoutino : public IRouter, private Ui::IRouterRoutino {
static CRouterRoutino& self() { return *pSelf; }

void calcRoute(const IGisItem::key_t& key) override;
int calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords, qreal* costs) override;
int calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords, qreal* costs) noexcept(false) override;

bool hasFastRouting() override;

Expand Down
2 changes: 1 addition & 1 deletion src/qmapshack/gis/rte/router/CRouterSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void CRouterSetup::calcRoute(const IGisItem::key_t& key) {
}
}

int CRouterSetup::calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords, qreal* costs) {
int CRouterSetup::calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords, qreal* costs) noexcept(false) {
IRouter* router = dynamic_cast<IRouter*>(stackedWidget->currentWidget());
if (router) {
return router->calcRoute(p1, p2, coords, costs);
Expand Down
2 changes: 1 addition & 1 deletion src/qmapshack/gis/rte/router/CRouterSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CRouterSetup : public QWidget, private Ui::IRouterSetup {
virtual ~CRouterSetup();

void calcRoute(const IGisItem::key_t& key);
int calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords, qreal* costs = nullptr);
int calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords, qreal* costs = nullptr) noexcept(false);
QString getOptions();

bool hasFastRouting();
Expand Down
3 changes: 2 additions & 1 deletion src/qmapshack/gis/rte/router/IRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class IRouter : public QWidget {
virtual ~IRouter();

virtual void calcRoute(const IGisItem::key_t& key) = 0;
virtual int calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords, qreal* costs = nullptr) = 0;
virtual int calcRoute(const QPointF& p1, const QPointF& p2, QPolygonF& coords,
qreal* costs = nullptr) noexcept(false) = 0;
virtual bool hasFastRouting() { return fastRouting; }

virtual QString getOptions() = 0;
Expand Down