qDebug() << __PRETTY_FUNCTION__ << "distance:" << m_route.totalDistance();
qDebug() << __PRETTY_FUNCTION__ << "estimated time:" << m_route.totalTime();
- foreach (QPointF point, m_route.geometryPoints())
- qDebug() << __PRETTY_FUNCTION__ << "geometry point:" << point.x() << point.y();
+ foreach (GeoCoordinate point, m_route.geometryPoints())
+ qDebug() << __PRETTY_FUNCTION__ << "geometry point:" << point;
foreach (RouteSegment segment, m_route.segments()) {
qDebug() << __PRETTY_FUNCTION__ << "segment:" << segment.instruction();
pen.setColor(LINE_COLOR);
pen.setCosmetic(true);
- QList<QPointF> points = route->geometryPoints();
+ QList<GeoCoordinate> points = route->geometryPoints();
for (int i = 1; i < points.count(); i++) {
- GeoCoordinate begin = GeoCoordinate(points.at(i - 1).y(), points.at(i - 1).x());
- SceneCoordinate sceneBegin = SceneCoordinate(begin);
- GeoCoordinate end = GeoCoordinate(points.at(i).y(), points.at(i).x());
- SceneCoordinate sceneEnd = SceneCoordinate(end);
- QGraphicsLineItem *line = new QGraphicsLineItem(QLineF(sceneBegin.toPointF(),
- sceneEnd.toPointF()));
+ SceneCoordinate begin = SceneCoordinate(points.at(i - 1));
+ SceneCoordinate end = SceneCoordinate(points.at(i));
+ QGraphicsLineItem *line = new QGraphicsLineItem(QLineF(begin.toPointF(),
+ end.toPointF()));
line->setPen(pen);
addToGroup(line);
}
qDebug() << __PRETTY_FUNCTION__;
}
-void Route::appendGeometryPoint(QPointF geometryPoint)
+void Route::appendGeometryPoint(GeoCoordinate geometryPoint)
{
qDebug() << __PRETTY_FUNCTION__;
return m_endPointName;
}
-const QList<QPointF>& Route::geometryPoints() const
+const QList<GeoCoordinate>& Route::geometryPoints() const
{
qDebug() << __PRETTY_FUNCTION__;
#define ROUTE_H
#include <QList>
-#include <QPointF>
#include <QString>
+#include "coordinates/geocoordinate.h"
#include "routesegment.h"
/**
*
* @param geometryPoint Geometry point
*/
- void appendGeometryPoint(QPointF geometryPoint);
+ void appendGeometryPoint(GeoCoordinate geometryPoint);
/**
* @brief Append a route segment to the route
*
* @returns Reference to list of geometry points
*/
- const QList<QPointF>& geometryPoints() const;
+ const QList<GeoCoordinate>& geometryPoints() const;
/**
* @brief Get list of route segments
int m_totalDistance; ///< route total distance in meters
int m_totalTime; ///< estimated route total time in seconds
- QList<QPointF> m_geometryPoints; ///< lat/lon coordinates of the route points
+ QList<GeoCoordinate> m_geometryPoints; ///< lat/lon coordinates of the route points
QList<RouteSegment> m_segments; ///< route segments
QString m_endPointName; ///< name of the route end point
#include <QtGlobal>
#include <QStringList>
#include <QNetworkReply>
-#include <QPointF>
#include <QCryptographicHash>
#if defined(Q_WS_MAEMO_5) & defined(ARMEL)
#endif
#include "common.h"
+#include "coordinates/geocoordinate.h"
#include "network/networkaccessmanager.h"
#include "parser.h"
#include "route.h"
foreach(QVariant routeGeometry, result["route_geometry"].toList()) {
QStringList list = routeGeometry.toStringList();
- route.appendGeometryPoint(QPointF(list.at(1).toDouble(), list.at(0).toDouble()));
+ route.appendGeometryPoint(GeoCoordinate(list.at(0).toDouble(),
+ list.at(1).toDouble()));
}
foreach(QVariant routeInstructions, result["route_instructions"].toList()) {
}
}
-void RoutingService::requestRoute(QPointF from, QPointF to)
+void RoutingService::requestRoute(GeoCoordinate from, GeoCoordinate to)
{
qDebug() << __PRETTY_FUNCTION__;
QString url = "http://routes.cloudmade.com/";
url.append(CLOUDMADE_API_KEY);
url.append("/api/0.3/");
- url.append(QString::number(from.x()) + "," + QString::number(from.y()) + ",");
- url.append(QString::number(to.x()) + "," + QString::number(to.y()));
+ url.append(QString::number(from.latitude()) + "," + QString::number(from.longitude()) + ",");
+ url.append(QString::number(to.latitude()) + "," + QString::number(to.longitude()));
url.append("/car/fastest.js?lang=en&units=km&token=");
if(m_token.isEmpty()) {
class QNetworkRequest;
class QUrl;
+class GeoCoordinate;
+
/**
* @brief RoutingService class for communicating with CloudMade server
* and parsing routing data
* @param from Start point of the route
* @param to End point of the route
*/
- void requestRoute(QPointF from, QPointF to);
+ void requestRoute(GeoCoordinate from, GeoCoordinate to);
private:
SOURCES += testroute.cpp \
../../../src/routing/route.cpp \
- ../../../src/routing/routesegment.cpp
+ ../../../src/routing/routesegment.cpp \
+ ../../../src/coordinates/scenecoordinate.cpp \
+ ../../../src/coordinates/geocoordinate.cpp
DEFINES += SRCDIR=\\\"$$PWD/\\\"
INCLUDEPATH += . \
HEADERS += \
../../../src/routing/route.h \
../../../src/routing/routingcommon.h \
- ../../../src/routing/routesegment.h
+ ../../../src/routing/routesegment.h \
+ ../../../src/coordinates/scenecoordinate.h \
+ ../../../src/coordinates/geocoordinate.h
DEFINES += QT_NO_DEBUG_OUTPUT
#include <QtCore/QString>
#include <QtTest/QtTest>
+#include "coordinates/geocoordinate.h"
#include "routing/routesegment.h"
#include "routing/route.h"
void TestRoute::geometryPoints()
{
// test points
- QPointF point1(12.3456, 54.3210);
- QPointF point2(65.5000, 25.0000);
- QPointF point3(-123.4567, 43.0987);
+ GeoCoordinate point1(12.3456, 54.3210);
+ GeoCoordinate point2(65.5000, 25.0000);
+ GeoCoordinate point3(-23.4567, 43.0987);
// create route with points
Route route;
route.appendGeometryPoint(point3);
// test points
- const QList<QPointF> &points = route.geometryPoints();
+ const QList<GeoCoordinate> &points = route.geometryPoints();
QVERIFY(points.count() == 3);
- QCOMPARE(points.at(0), point1);
- QCOMPARE(points.at(1), point2);
- QCOMPARE(points.at(2), point3);
+
+ QCOMPARE(points.at(0).latitude(), point1.latitude());
+ QCOMPARE(points.at(0).longitude(), point1.longitude());
+
+ QCOMPARE(points.at(1).latitude(), point2.latitude());
+ QCOMPARE(points.at(1).longitude(), point2.longitude());
+
+ QCOMPARE(points.at(2).latitude(), point3.latitude());
+ QCOMPARE(points.at(2).longitude(), point3.longitude());
}
void TestRoute::segments()