#pragma once #ifndef _GEOOPERATOR_H #define _GEOOPERATOR_H #include "BaseConstVariable.h" #include #include #include #include #include #include #include /// /// 将经纬度转换为地固参心坐标系 /// /// 经纬度点--degree /// 投影坐标系点 Landpoint BASECONSTVARIABLEAPI LLA2XYZ(const Landpoint& LLA); void BASECONSTVARIABLEAPI LLA2XYZ(const Landpoint& LLA,Point3& XYZ); Eigen::MatrixXd BASECONSTVARIABLEAPI LLA2XYZ(Eigen::MatrixXd landpoint); double BASECONSTVARIABLEAPI getPixelSpacingInDegree(double pixelSpacingInMeter); double BASECONSTVARIABLEAPI getPixelSpacingInMeter(double pixelSpacingInDegree); /// /// 将地固参心坐标系转换为经纬度 /// /// 固参心坐标系 /// 经纬度--degree Landpoint BASECONSTVARIABLEAPI XYZ2LLA(const Landpoint& XYZ); void BASECONSTVARIABLEAPI XYZ2BLH_FixedHeight(double x, double y, double z, double ati, Landpoint& point); Landpoint BASECONSTVARIABLEAPI operator +(const Landpoint& p1, const Landpoint& p2); Landpoint BASECONSTVARIABLEAPI operator -(const Landpoint& p1, const Landpoint& p2); bool BASECONSTVARIABLEAPI operator ==(const Landpoint& p1, const Landpoint& p2); Landpoint BASECONSTVARIABLEAPI operator *(const Landpoint& p, double scale); double BASECONSTVARIABLEAPI getAngle(const Landpoint& a, const Landpoint& b); double BASECONSTVARIABLEAPI dot(const Landpoint& p1, const Landpoint& p2); double BASECONSTVARIABLEAPI getlength(const Landpoint& p1); Landpoint BASECONSTVARIABLEAPI crossProduct(const Landpoint& a, const Landpoint& b); Landpoint BASECONSTVARIABLEAPI getSlopeVector(const Landpoint& p0, const Landpoint& p1, const Landpoint& p2, const Landpoint& p3, const Landpoint& p4, bool inLBH=true); double BASECONSTVARIABLEAPI getlocalIncAngle(Landpoint& satepoint, Landpoint& landpoint, Landpoint& slopeVector); float BASECONSTVARIABLEAPI cross2d(Point3 a, Point3 b); Point3 BASECONSTVARIABLEAPI operator -(Point3 a, Point3 b); Point3 BASECONSTVARIABLEAPI operator +(Point3 a, Point3 b); double BASECONSTVARIABLEAPI operator /(Point3 a, Point3 b); // 矢量计算 struct Vector3D { double x, y, z; }; // 计算两点之间的距离 double BASECONSTVARIABLEAPI distance(const Vector3D& p1, const Vector3D& p2); // 计算点到直线的最短距离 double BASECONSTVARIABLEAPI pointToLineDistance(const Vector3D& point, const Vector3D& linePoint, const Vector3D& lineDirection); Vector3D BASECONSTVARIABLEAPI operator +(const Vector3D& p1, const Vector3D& p2); Vector3D BASECONSTVARIABLEAPI operator -(const Vector3D& p1, const Vector3D& p2); bool BASECONSTVARIABLEAPI operator ==(const Vector3D& p1, const Vector3D& p2); Vector3D BASECONSTVARIABLEAPI operator *(const Vector3D& p, double scale); Vector3D BASECONSTVARIABLEAPI operator *(double scale,const Vector3D& p ); double BASECONSTVARIABLEAPI getAngle(const Vector3D& a, const Vector3D& b); double BASECONSTVARIABLEAPI getCosAngle(const Vector3D& a, const Vector3D& b); double BASECONSTVARIABLEAPI dot(const Vector3D& p1, const Vector3D& p2); double BASECONSTVARIABLEAPI getlength(const Vector3D& p1); Vector3D BASECONSTVARIABLEAPI crossProduct(const Vector3D& a, const Vector3D& b); /// /// n1 /// n4 n0 n2 /// n3 /// /// /// /// /// /// /// Vector3D BASECONSTVARIABLEAPI getSlopeVector(const Vector3D& n0, const Vector3D& n1, const Vector3D& n2, const Vector3D& n3, const Vector3D& n4); struct CartesianCoordinates { double x, y, z; }; struct SphericalCoordinates { double r, theta, phi; }; SphericalCoordinates BASECONSTVARIABLEAPI cartesianToSpherical(const CartesianCoordinates& cartesian); CartesianCoordinates BASECONSTVARIABLEAPI sphericalToCartesian(const SphericalCoordinates& spherical); double BASECONSTVARIABLEAPI getlocalIncAngle(Vector3D& satepoint, Vector3D& landpoint, Vector3D& slopeVector); /** * @brief 将平面坐标分辨率(米)转换为经纬度分辨率(度) * @param sourceEPSG 平面坐标系 EPSG 码(如 UTM Zone 50N 对应 32650) * @param resolutionMeters 输入分辨率(单位:米) * @param refLon 参考点经度(十进制度,用于计算局部转换系数) * @param refLat 参考点纬度(十进制度,用于计算局部转换系数) * @param[out] degreePerPixelX 经度方向分辨率(度/像素) * @param[out] degreePerPixelY 纬度方向分辨率(度/像素) * @return 是否转换成功 */ bool BASECONSTVARIABLEAPI ConvertResolutionToDegrees( int sourceEPSG, double resolutionMeters, double refLon, double refLat, double& degreePerPixelX, double& degreePerPixelY ); #endif