[qt] add global projection functions
There are 3 methods in QMapboxGL which can be static method. QMapboxGL::metersPerPixelAtLatitude QMapboxGL::projectedMetersForCoordinate QMapboxGL::coordinateForProjectedMeters Add these functions into QMapbox namespace as global functions. The methods in QMapboxGL are kept for backward compatibility.
This commit is contained in:
committed by
Thiago Marcos P. Santos
parent
2deebc0efe
commit
26af7265c3
@@ -4,6 +4,7 @@
|
||||
#include <mbgl/util/default_styles.hpp>
|
||||
#include <mbgl/util/geometry.hpp>
|
||||
#include <mbgl/util/traits.hpp>
|
||||
#include <mbgl/util/projection.hpp>
|
||||
|
||||
#include <QOpenGLContext>
|
||||
|
||||
@@ -222,4 +223,30 @@ QVector<QPair<QString, QString> >& defaultStyles()
|
||||
return styles;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the amount of meters per pixel from a given \a latitude and \a zoom.
|
||||
*/
|
||||
double metersPerPixelAtLatitude(double latitude, double zoom)
|
||||
{
|
||||
return mbgl::Projection::getMetersPerPixelAtLatitude(latitude, zoom);
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the projected meters for a given \a coordinate object.
|
||||
*/
|
||||
ProjectedMeters projectedMetersForCoordinate(const Coordinate &coordinate)
|
||||
{
|
||||
auto projectedMeters = mbgl::Projection::projectedMetersForLatLng(mbgl::LatLng { coordinate.first, coordinate.second });
|
||||
return QMapbox::ProjectedMeters(projectedMeters.northing(), projectedMeters.easting());
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the coordinate for a given \a projectedMeters object.
|
||||
*/
|
||||
Coordinate coordinateForProjectedMeters(const ProjectedMeters &projectedMeters)
|
||||
{
|
||||
auto latLng = mbgl::Projection::latLngForProjectedMeters(mbgl::ProjectedMeters { projectedMeters.first, projectedMeters.second });
|
||||
return QMapbox::Coordinate(latLng.latitude(), latLng.longitude());
|
||||
}
|
||||
|
||||
} // namespace QMapbox
|
||||
|
||||
Reference in New Issue
Block a user