diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-02-10 17:28:12 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-02-21 15:26:46 +0200 |
commit | 177a27b48a2482685a13acc96d2ec8fc8e603fba (patch) | |
tree | 7fcb4b4c8ba6780551dc17fd3b849209d96affff /platform | |
parent | 051bd9ac93f0b2f9022c52e470c6e82e06382af1 (diff) | |
download | qtlocation-mapboxgl-177a27b48a2482685a13acc96d2ec8fc8e603fba.tar.gz |
[Qt] Added missing conversion helpers
Diffstat (limited to 'platform')
-rw-r--r-- | platform/qt/include/qmapbox.hpp | 3 | ||||
-rw-r--r-- | platform/qt/include/qmapboxgl.hpp | 3 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 26 |
3 files changed, 32 insertions, 0 deletions
diff --git a/platform/qt/include/qmapbox.hpp b/platform/qt/include/qmapbox.hpp index 6015cc3cf9..e11214f473 100644 --- a/platform/qt/include/qmapbox.hpp +++ b/platform/qt/include/qmapbox.hpp @@ -15,6 +15,9 @@ namespace QMapbox { typedef QPair<double, double> Coordinate; typedef QPair<Coordinate, double> CoordinateZoom; +// Reflects mbgl::ProjectedMeters<double>. +typedef QPair<double, double> ProjectedMeters; + // Reflects mbgl::{LineString,LinearRing,MultiPoint}<double>. typedef QList<Coordinate> Coordinates; diff --git a/platform/qt/include/qmapboxgl.hpp b/platform/qt/include/qmapboxgl.hpp index d5ec4b678f..f60ad8e677 100644 --- a/platform/qt/include/qmapboxgl.hpp +++ b/platform/qt/include/qmapboxgl.hpp @@ -198,6 +198,9 @@ public: void resize(const QSize &size, const QSize &framebufferSize); + double metersPerPixelAtLatitude(double latitude, double zoom) const; + QMapbox::ProjectedMeters projectedMetersForCoordinate(const QMapbox::Coordinate &) const; + QMapbox::Coordinate coordinateForProjectedMeters(const QMapbox::ProjectedMeters &) const; QPointF pixelForCoordinate(const QMapbox::Coordinate &) const; QMapbox::Coordinate coordinateForPixel(const QPointF &) const; diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index cf9d5f39d6..1c7d88bb9a 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -1119,6 +1119,32 @@ void QMapboxGL::addAnnotationIcon(const QString &name, const QImage &icon) } /*! + Returns the amount of meters per pixel from a given \a latitude and \a zoom. +*/ +double QMapboxGL::metersPerPixelAtLatitude(double latitude, double zoom) const +{ + return d_ptr->mapObj->getMetersPerPixelAtLatitude(latitude, zoom); +} + +/*! + Return the projected meters for a given \a coordinate object. +*/ +QMapbox::ProjectedMeters QMapboxGL::projectedMetersForCoordinate(const QMapbox::Coordinate &coordinate_) const +{ + auto projectedMeters = d_ptr->mapObj->projectedMetersForLatLng(mbgl::LatLng { coordinate_.first, coordinate_.second }); + return QMapbox::ProjectedMeters(projectedMeters.northing, projectedMeters.easting); +} + +/*! + Returns the coordinate for a given \a projectedMeters object. +*/ +QMapbox::Coordinate QMapboxGL::coordinateForProjectedMeters(const QMapbox::ProjectedMeters &projectedMeters) const +{ + auto latLng = d_ptr->mapObj->latLngForProjectedMeters(mbgl::ProjectedMeters { projectedMeters.first, projectedMeters.second }); + return QMapbox::Coordinate(latLng.latitude, latLng.longitude); +} + +/*! \fn QMapboxGL::pixelForCoordinate(const QMapbox::Coordinate &coordinate) const Returns the offset in pixels for \a coordinate. The origin pixel coordinate is |