mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-12-01 07:01:16 +01:00
17 lines
438 B
C++
17 lines
438 B
C++
#include <cmath>
|
|
#include "common/coordinates.h"
|
|
#include "common/wgs84.h"
|
|
#include "webmercator.h"
|
|
|
|
PointD WebMercator::ll2xy(const Coordinates &c) const
|
|
{
|
|
return PointD(deg2rad(c.lon()) * WGS84_RADIUS,
|
|
log(tan(M_PI_4 + deg2rad(c.lat())/2.0)) * WGS84_RADIUS);
|
|
}
|
|
|
|
Coordinates WebMercator::xy2ll(const PointD &p) const
|
|
{
|
|
return Coordinates(rad2deg(p.x() / WGS84_RADIUS),
|
|
rad2deg(2.0 * atan(exp(p.y() / WGS84_RADIUS)) - M_PI_2));
|
|
}
|