summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-02-02 16:38:24 +0200
committerThiago Marcos P. Santos <thiago@mapbox.com>2016-04-20 20:55:51 +0300
commit19e11293676db729909e10659f3e0710a251a03b (patch)
tree830650dd1a9a885df8df05d60c521a8f90273200
parentdd075d53edaa34d530bdd4a876ab329f9de45f44 (diff)
downloadqtlocation-mapboxgl-19e11293676db729909e10659f3e0710a251a03b.tar.gz
[Qt] Add the QMapbox header with QMapbox datatypes
-rw-r--r--platform/qt/app/mapwindow.cpp2
-rw-r--r--platform/qt/include/QMapbox1
-rw-r--r--platform/qt/include/qmapbox.hpp28
-rw-r--r--platform/qt/include/qmapboxgl.hpp38
-rw-r--r--platform/qt/platform.gyp1
-rw-r--r--platform/qt/src/qmapboxgl.cpp30
6 files changed, 59 insertions, 41 deletions
diff --git a/platform/qt/app/mapwindow.cpp b/platform/qt/app/mapwindow.cpp
index 83e0ceab5f..474363039f 100644
--- a/platform/qt/app/mapwindow.cpp
+++ b/platform/qt/app/mapwindow.cpp
@@ -18,7 +18,7 @@ MapWindow::MapWindow(const QMapboxGLSettings &settings)
connect(&m_map, SIGNAL(needsRendering()), this, SLOT(updateGL()));
// Set default location to Helsinki.
- m_map.setCoordinateZoom(QMapboxGL::Coordinate(60.170448, 24.942046), 14);
+ m_map.setCoordinateZoom(QMapbox::Coordinate(60.170448, 24.942046), 14);
changeStyle();
diff --git a/platform/qt/include/QMapbox b/platform/qt/include/QMapbox
new file mode 100644
index 0000000000..a8479c09aa
--- /dev/null
+++ b/platform/qt/include/QMapbox
@@ -0,0 +1 @@
+#include "qmapbox.hpp"
diff --git a/platform/qt/include/qmapbox.hpp b/platform/qt/include/qmapbox.hpp
new file mode 100644
index 0000000000..8877d730bb
--- /dev/null
+++ b/platform/qt/include/qmapbox.hpp
@@ -0,0 +1,28 @@
+#ifndef QMAPBOX_H
+#define QMAPBOX_H
+
+#include <QList>
+#include <QPair>
+#include <QString>
+
+// This header follows the Qt coding style: https://wiki.qt.io/Qt_Coding_Style
+
+namespace QMapbox {
+
+typedef QPair<double, double> Coordinate;
+typedef QList<Coordinate> Coordinates;
+typedef QList<Coordinates> CoordinateSegments;
+
+typedef quint32 AnnotationID;
+typedef QList<AnnotationID> AnnotationIDs;
+
+typedef QPair<Coordinate, QString> PointAnnotation;
+typedef QList<PointAnnotation> PointAnnotations;
+
+// FIXME: We need to add support for custom style properties
+typedef QPair<CoordinateSegments, QString> ShapeAnnotation;
+typedef QList<ShapeAnnotation> ShapeAnnotations;
+
+}
+
+#endif // QMAPBOX_H
diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp
index b817d5226b..01538268d7 100644
--- a/platform/qt/include/qmapboxgl.hpp
+++ b/platform/qt/include/qmapboxgl.hpp
@@ -1,8 +1,8 @@
#ifndef QMAPBOXGL_H
#define QMAPBOXGL_H
+#include <QMapbox>
#include <QObject>
-#include <QPair>
#include <QPointF>
class QImage;
@@ -77,20 +77,6 @@ class Q_DECL_EXPORT QMapboxGL : public QObject
Q_PROPERTY(double pitch READ pitch WRITE setPitch)
public:
- typedef QPair<double, double> Coordinate;
- typedef QList<Coordinate> Coordinates;
- typedef QList<Coordinates> CoordinateSegments;
-
- typedef quint32 AnnotationID;
- typedef QList<AnnotationID> AnnotationIDs;
-
- typedef QPair<Coordinate, QString> PointAnnotation;
- typedef QList<PointAnnotation> PointAnnotations;
-
- // FIXME: We need to add support for custom style properties
- typedef QPair<CoordinateSegments, QString> ShapeAnnotation;
- typedef QList<ShapeAnnotation> ShapeAnnotations;
-
// Determines the orientation of the map.
enum NorthOrientation {
NorthUpwards, // Default
@@ -135,9 +121,9 @@ public:
NorthOrientation northOrientation() const;
void setNorthOrientation(NorthOrientation);
- Coordinate coordinate() const;
- void setCoordinate(const Coordinate &);
- void setCoordinateZoom(const Coordinate &, double zoom);
+ QMapbox::Coordinate coordinate() const;
+ void setCoordinate(const QMapbox::Coordinate &);
+ void setCoordinateZoom(const QMapbox::Coordinate &, double zoom);
void setGestureInProgress(bool inProgress);
@@ -147,14 +133,14 @@ public:
void setClasses(const QStringList &);
QStringList getClasses() const;
- AnnotationID addPointAnnotation(const PointAnnotation &);
- AnnotationIDs addPointAnnotations(const PointAnnotations &);
+ QMapbox::AnnotationID addPointAnnotation(const QMapbox::PointAnnotation &);
+ QMapbox::AnnotationIDs addPointAnnotations(const QMapbox::PointAnnotations &);
- AnnotationID addShapeAnnotation(const ShapeAnnotation &);
- AnnotationIDs addShapeAnnotations(const ShapeAnnotations &);
+ QMapbox::AnnotationID addShapeAnnotation(const QMapbox::ShapeAnnotation &);
+ QMapbox::AnnotationIDs addShapeAnnotations(const QMapbox::ShapeAnnotations &);
- void removeAnnotation(AnnotationID);
- void removeAnnotations(const AnnotationIDs &);
+ void removeAnnotation(QMapbox::AnnotationID);
+ void removeAnnotations(const QMapbox::AnnotationIDs &);
bool isRotating() const;
bool isScaling() const;
@@ -169,8 +155,8 @@ public:
void addAnnotationIcon(const QString &name, const QImage &sprite);
- QPointF pixelForCoordinate(const Coordinate &) const;
- Coordinate coordinateForPixel(const QPointF &) const;
+ QPointF pixelForCoordinate(const QMapbox::Coordinate &) const;
+ QMapbox::Coordinate coordinateForPixel(const QPointF &) const;
void setMargins(const QMargins &margins);
QMargins margins() const;
diff --git a/platform/qt/platform.gyp b/platform/qt/platform.gyp
index 0ab6169dd6..3e52a5cb27 100644
--- a/platform/qt/platform.gyp
+++ b/platform/qt/platform.gyp
@@ -42,6 +42,7 @@
'../default/sqlite3.cpp',
'../default/string_stdlib.cpp',
'../default/thread.cpp',
+ 'include/qmapbox.hpp',
'include/qmapboxgl.hpp',
'qmapbox.qrc',
'src/async_task.cpp',
diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp
index 1992f9aad6..ed6f8566a1 100644
--- a/platform/qt/src/qmapboxgl.cpp
+++ b/platform/qt/src/qmapboxgl.cpp
@@ -18,6 +18,8 @@
#include <memory>
+using namespace QMapbox;
+
QMapboxGLSettings::QMapboxGLSettings()
: m_mapMode(QMapboxGLSettings::ContinuousMap)
, m_contextMode(QMapboxGLSettings::UniqueGLContext)
@@ -189,7 +191,7 @@ double QMapboxGL::maximumZoom() const
return d_ptr->mapObj->getMaxZoom();
}
-QMapboxGL::Coordinate QMapboxGL::coordinate() const
+Coordinate QMapboxGL::coordinate() const
{
const mbgl::LatLng& latLng = d_ptr->mapObj->getLatLng(d_ptr->margins);
return Coordinate(latLng.latitude, latLng.longitude);
@@ -294,24 +296,24 @@ QStringList QMapboxGL::getClasses() const
return classNames;
}
-mbgl::PointAnnotation fromQMapboxGLPointAnnotation(const QMapboxGL::PointAnnotation &pointAnnotation) {
- const QMapboxGL::Coordinate &coordinate = pointAnnotation.first;
+mbgl::PointAnnotation fromPointAnnotation(const PointAnnotation &pointAnnotation) {
+ const Coordinate &coordinate = pointAnnotation.first;
const QString &icon = pointAnnotation.second;
return { { coordinate.first, coordinate.second }, icon.toStdString() };
}
-QMapboxGL::AnnotationID QMapboxGL::addPointAnnotation(const PointAnnotation &pointAnnotation)
+AnnotationID QMapboxGL::addPointAnnotation(const PointAnnotation &pointAnnotation)
{
- return d_ptr->mapObj->addPointAnnotation(fromQMapboxGLPointAnnotation(pointAnnotation));
+ return d_ptr->mapObj->addPointAnnotation(fromPointAnnotation(pointAnnotation));
}
-QMapboxGL::AnnotationIDs QMapboxGL::addPointAnnotations(const PointAnnotations &pointAnnotations)
+AnnotationIDs QMapboxGL::addPointAnnotations(const PointAnnotations &pointAnnotations)
{
std::vector<mbgl::PointAnnotation> mbglPointAnnotations;
mbglPointAnnotations.reserve(pointAnnotations.size());
for (const PointAnnotation &pointAnnotation : pointAnnotations) {
- mbglPointAnnotations.emplace_back(fromQMapboxGLPointAnnotation(pointAnnotation));
+ mbglPointAnnotations.emplace_back(fromPointAnnotation(pointAnnotation));
}
AnnotationIDs ids;
@@ -322,18 +324,18 @@ QMapboxGL::AnnotationIDs QMapboxGL::addPointAnnotations(const PointAnnotations &
return ids;
}
-mbgl::ShapeAnnotation fromQMapboxGLShapeAnnotation(const QMapboxGL::ShapeAnnotation &shapeAnnotation) {
- const QMapboxGL::CoordinateSegments &segments = shapeAnnotation.first;
+mbgl::ShapeAnnotation fromQMapboxGLShapeAnnotation(const ShapeAnnotation &shapeAnnotation) {
+ const CoordinateSegments &segments = shapeAnnotation.first;
const QString &styleLayer = shapeAnnotation.second;
mbgl::AnnotationSegments mbglAnnotationSegments;
mbglAnnotationSegments.reserve(segments.size());
- for (const QMapboxGL::Coordinates &coordinates : segments) {
+ for (const Coordinates &coordinates : segments) {
mbgl::AnnotationSegment mbglAnnotationSegment;
mbglAnnotationSegment.reserve(coordinates.size());
- for (const QMapboxGL::Coordinate &coordinate : coordinates) {
+ for (const Coordinate &coordinate : coordinates) {
mbgl::LatLng mbglCoordinate(coordinate.first, coordinate.second);
mbglAnnotationSegment.emplace_back(mbglCoordinate);
}
@@ -344,12 +346,12 @@ mbgl::ShapeAnnotation fromQMapboxGLShapeAnnotation(const QMapboxGL::ShapeAnnotat
return { mbglAnnotationSegments, styleLayer.toStdString() };
}
-QMapboxGL::AnnotationID QMapboxGL::addShapeAnnotation(const ShapeAnnotation &shapeAnnotation)
+AnnotationID QMapboxGL::addShapeAnnotation(const ShapeAnnotation &shapeAnnotation)
{
return d_ptr->mapObj->addShapeAnnotation(fromQMapboxGLShapeAnnotation(shapeAnnotation));
}
-QMapboxGL::AnnotationIDs QMapboxGL::addShapeAnnotations(const ShapeAnnotations &shapeAnnotations)
+AnnotationIDs QMapboxGL::addShapeAnnotations(const ShapeAnnotations &shapeAnnotations)
{
std::vector<mbgl::ShapeAnnotation> mbglShapeAnnotations;
mbglShapeAnnotations.reserve(shapeAnnotations.size());
@@ -450,7 +452,7 @@ QPointF QMapboxGL::pixelForCoordinate(const Coordinate &coordinate_) const
return QPointF(pixel.x, pixel.y);
}
-QMapboxGL::Coordinate QMapboxGL::coordinateForPixel(const QPointF &pixel) const
+Coordinate QMapboxGL::coordinateForPixel(const QPointF &pixel) const
{
const mbgl::LatLng latLng =
d_ptr->mapObj->latLngForPixel(mbgl::ScreenCoordinate { pixel.x(), pixel.y() });