You can not select more than 25 topics
Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- #include "geo/private/util/angle_util.h"
- #include "geo/private/coord/web_mercator.h"
-
- namespace ns
- {
- namespace geo
- {
-
- static double g_delta = 20037508.34 / 180;
- static double g_1_delta = 180.0 / 20037508.34;
- static double g_PI_180 = c_pi() / 180.0;
- static double g_PI_360 = c_pi() / 360.0;
-
- PointD lonLat2WebMercator(const PointD& lonLat)
- {
- double x = lonLat.x * g_delta;
- double y = log(tan((90 + lonLat.y) * g_PI_360)) / g_PI_180;
- y = y * g_delta;
- return {x, y};
- }
-
- // Web墨卡托转经纬度
- PointD webMercator2LonLat(const PointD& mercator)
- {
- double x = mercator.x * g_1_delta;
- double y = mercator.y * g_1_delta;
- y = 180 * c_1_pi() * (2 * atan(exp(y * g_PI_180)) - c_pi_2());
- return {x, y};
- }
-
- } // namespace geo
- } // namespace ns
|