1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 23:03:22 +02:00
GPXSee/src/map/proj/webmercator.cpp

23 lines
581 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));
}
bool WebMercator::operator==(const CT &ct) const
{
const WebMercator *other = dynamic_cast<const WebMercator*>(&ct);
return (other != 0);
}