geopro/external/gpr3dviewer/CoordinateTransform.h

49 lines
2.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef COORDINATETRANSFORM_H
#define COORDINATETRANSFORM_H
#include <cmath>
class CoordinateTransform {
public:
// CGCS2000 椭球参数
static constexpr double A = 6378137.0; // 长半轴 (m)
static constexpr double F = 1.0 / 298.257222101; // 扁率
static constexpr double E2 = 2.0 * F - F * F; // 第一偏心率平方
static constexpr double E12 = E2 / (1.0 - E2); // 第二偏心率平方
static constexpr double FALSE_EASTING = 500000.0; // 东偏移 (m)
static constexpr double EARTH_RADIUS = 6378137.0; // Web Mercator 地球半径
static constexpr double PI = 3.14159265358979323846;
static constexpr double DEG2RAD = PI / 180.0;
static constexpr double RAD2DEG = 180.0 / PI;
// 从 CGCS2000 东向坐标(Y)自动推断 3° 带带号
// 假设 Y 格式为zone*1e6 + 500000 + easting或纯自然值
static int detectZoneFromCgcsY(double cgcsY);
// 带号 → 中央经线(度)
static double centralMeridianFromZone(int zone);
// CGCS2000 平面坐标 → WGS84 经纬度(弧度)
// cgcsX: 北向坐标(m), cgcsY: 东向坐标(m, 可含带号)
static void cgcs2000ToWgs84(double cgcsX, double cgcsY, int zone,
double &latRad, double &lonRad);
// WGS84 经纬度(弧度) → CGCS2000 平面坐标
static void wgs84ToCgcs2000(double latRad, double lonRad, int zone,
double &cgcsX, double &cgcsY);
// WGS84 经纬度(弧度) ↔ Web Mercator 平面坐标(米)
static void wgs84ToWebMercator(double latRad, double lonRad, double &mx, double &my);
static void webMercatorToWgs84(double mx, double my, double &latRad, double &lonRad);
private:
// 子午线弧长(从赤道到纬度 B 的弧长)
static double meridianArc(double latRad);
// 子午线弧长反解:已知弧长 X求底点纬度 Bf
static double meridianArcInverse(double x);
};
#endif // COORDINATETRANSFORM_H