123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- using DPP_YH_Core.Extensions;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using XdCxRhDW.Dto;
- namespace XdCxRhDW.Api
- {
- /// <summary>
- /// 误差椭圆帮助类
- /// </summary>
- public static class ErrEllipseHepler
- {
- private const string ErrellipDll = @"AddIns\GDOP误差椭圆\DLL_GDOP_Analysis0623";
- /// <summary>
- /// 两星一地带参误差椭圆
- /// </summary>
- /// <param name="main_eph">主星星历 长度3</param>
- /// <param name="neigh_eph">邻星星历 长度3</param>
- /// <param name="cdbAnt">超短站位置 长度3</param>
- /// <param name="refStation">参考站位置 长度3</param>
- /// <param name="Select_Point">定位点经纬高 长度3</param>
- /// <param name="dto_err">时差误差(s)</param>
- /// <param name="eph_err">星历误差(m)</param>
- /// <param name="Pe">概率,范围(0,1),默认0.5</param>
- /// <param name="LOP_Len">输出参数</param>
- /// <returns></returns>
- [DllImport(ErrellipDll, EntryPoint = "Error_Ellipse_2X1D", CallingConvention = CallingConvention.Cdecl)]
- private extern static IntPtr Error_Ellipse_2X1D(double[] main_eph, double[] neigh_eph, double[] cdbAnt, double[] refStation, double[] Select_Point, double dto_err,
- double eph_err, double Pe, ref int LOP_Len);
- /// <summary>
- /// 两星一地误差椭圆
- /// </summary>
- /// <param name="main_eph">主星位置 长度3</param>
- /// <param name="neigh_eph">邻星位置 长度3</param>
- /// <param name="cdbAnt">超短波 长度3</param>
- /// <param name="refStation">参考站 长度3</param>
- /// <param name="Select_Point">定位点 长度3</param>
- /// <param name="dto_err">时差误差(s)</param>
- /// <param name="eph_err">星历误差(m)</param>
- /// <param name="Pe">0.5</param>
- /// <param name="LOP_Len"></param>
- /// <returns></returns>
- [DllImport(ErrellipDll, EntryPoint = "Error_Ellipse_2X1D_NoRef", CallingConvention = CallingConvention.Cdecl)]
- private extern static IntPtr Error_Ellipse_2X1D_NoRef(double[] main_eph, double[] neigh_eph, double[] cdbAnt, double[] Select_Point, double dto_err,
- double eph_err, double Pe, ref int LOP_Len);
- /// <summary>
- /// 两星一地带参误差椭圆
- /// </summary>
- /// <param name="posLon">定位点经度</param>
- /// <param name="posLat">定位点纬度</param>
- /// <param name="mainEph">主星xyz,长度=3</param>
- /// <param name="adajEph">邻星xyz,长度=3</param>
- /// <param name="cdbPos">超短波位置(长度=2或3)</param>
- /// <param name="RefGeod">参考站位置(长度=2或3)</param>
- /// <param name="DtoErrus">时差误差(us)</param>
- /// <param name="EphErrm">星历误差(m)</param>
- /// <param name="outputErrPoint">是否输出椭圆Geo点</param>
- /// <param name="pe">概率(范围0-1,默认0.5)</param>
- /// <returns></returns>
- public static ErrEllipseResDto ErrorEllipse2X1D(double posLon, double posLat, double[] mainEph, double[] adajEph, double[] cdbPos, double[] RefGeod, double DtoErrus, double EphErrm, bool outputErrPoint, double pe = 0.5)
- {
- if (cdbPos.Length == 2)
- {
- cdbPos = cdbPos.Concat(new double[1] { 0 }).ToArray();
- }
- if (RefGeod.Length == 2)
- {
- RefGeod = RefGeod.Concat(new double[1] { 0 }).ToArray();
- }
- int LOP_Len = 0;
- IntPtr LOP_ValuePtr = Error_Ellipse_2X1D(
- mainEph,
- adajEph,
- cdbPos,
- RefGeod,
- new double[3] { posLon, posLat, 0 },
- DtoErrus * 1e-6,
- EphErrm,//单位m
- pe, ref LOP_Len);
- double[] LOP_Value = new double[LOP_Len];
- if (LOP_Len > 0)
- {
- Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
- }
- ErrEllipseResDto res = new ErrEllipseResDto();
- res.LongRadius = LOP_Value[LOP_Value.Length - 3];
- res.ShortRadius = LOP_Value[LOP_Value.Length - 2];
- res.DipAngle = LOP_Value[LOP_Value.Length - 1];
- if (outputErrPoint)
- {
- int count = LOP_Value.Length - 3;
- for (int i = 0; i < count; i += 2)
- {
- res.GeoPoints.Add(new GeoPoint()
- {
- Lon = LOP_Value[i],
- Lat = LOP_Value[i + 1],
- });
- }
- }
- return res;
- }
- /// <summary>
- /// 两星一地无参误差椭圆
- /// </summary>
- /// <param name="posLon">定位点经度</param>
- /// <param name="posLat">定位点纬度</param>
- /// <param name="mainEph">主星xyz,长度=3</param>
- /// <param name="adajEph">邻星xyz,长度=3</param>
- /// <param name="cdbPos">超短波位置(长度=2或3)</param>
- /// <param name="DtoErrus">时差误差(us)</param>
- /// <param name="EphErrm">星历误差(m)</param>
- /// <param name="outputErrPoint">是否输出椭圆Geo点</param>
- /// <param name="pe">概率(范围0-1,默认0.5)</param>
- /// <returns></returns>
- public static ErrEllipseResDto ErrorEllipse2X1DNoRef(double posLon, double posLat, double[] mainEph, double[] adajEph, double[] cdbPos, double DtoErrus, double EphErrm, bool outputErrPoint,double pe = 0.5)
- {
- if (cdbPos.Length == 2)
- {
- cdbPos = cdbPos.Concat(new double[1] { 0 }).ToArray();
- }
- int LOP_Len = 0;
- double Pe = 0.5;
- IntPtr LOP_ValuePtr = Error_Ellipse_2X1D_NoRef(
- mainEph,
- adajEph,
- cdbPos,
- new double[3] { posLon, posLat, 0 },
- DtoErrus * 1e-6,
- EphErrm,//单位m
- Pe, ref LOP_Len);
- double[] LOP_Value = new double[LOP_Len];
- if (LOP_Len > 0)
- {
- Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
- }
- ErrEllipseResDto res = new ErrEllipseResDto();
- res.LongRadius = LOP_Value[LOP_Value.Length - 3];
- res.ShortRadius = LOP_Value[LOP_Value.Length - 2];
- res.DipAngle = LOP_Value[LOP_Value.Length - 1];
- if (outputErrPoint)
- {
- int count = LOP_Value.Length - 3;
- for (int i = 0; i < count; i += 2)
- {
- res.GeoPoints.Add(new GeoPoint()
- {
- Lon = LOP_Value[i],
- Lat = LOP_Value[i + 1],
- });
- }
- }
- return res;
- }
- }
- }
|