ErrEllipseHepler.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. using DPP_YH_Core.Extensions;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Runtime.InteropServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using XdCxRhDW.Dto;
  9. namespace XdCxRhDW.Api
  10. {
  11. /// <summary>
  12. /// 误差椭圆帮助类
  13. /// </summary>
  14. public static class ErrEllipseHepler
  15. {
  16. private const string ErrellipDll = @"AddIns\GDOP误差椭圆\DLL_GDOP_Analysis0623";
  17. /// <summary>
  18. /// 两星一地带参误差椭圆
  19. /// </summary>
  20. /// <param name="main_eph">主星星历 长度3</param>
  21. /// <param name="neigh_eph">邻星星历 长度3</param>
  22. /// <param name="cdbAnt">超短站位置 长度3</param>
  23. /// <param name="refStation">参考站位置 长度3</param>
  24. /// <param name="Select_Point">定位点经纬高 长度3</param>
  25. /// <param name="dto_err">时差误差(s)</param>
  26. /// <param name="eph_err">星历误差(m)</param>
  27. /// <param name="Pe">概率,范围(0,1),默认0.5</param>
  28. /// <param name="LOP_Len">输出参数</param>
  29. /// <returns></returns>
  30. [DllImport(ErrellipDll, EntryPoint = "Error_Ellipse_2X1D", CallingConvention = CallingConvention.Cdecl)]
  31. private extern static IntPtr Error_Ellipse_2X1D(double[] main_eph, double[] neigh_eph, double[] cdbAnt, double[] refStation, double[] Select_Point, double dto_err,
  32. double eph_err, double Pe, ref int LOP_Len);
  33. /// <summary>
  34. /// 两星一地误差椭圆
  35. /// </summary>
  36. /// <param name="main_eph">主星位置 长度3</param>
  37. /// <param name="neigh_eph">邻星位置 长度3</param>
  38. /// <param name="cdbAnt">超短波 长度3</param>
  39. /// <param name="refStation">参考站 长度3</param>
  40. /// <param name="Select_Point">定位点 长度3</param>
  41. /// <param name="dto_err">时差误差(s)</param>
  42. /// <param name="eph_err">星历误差(m)</param>
  43. /// <param name="Pe">0.5</param>
  44. /// <param name="LOP_Len"></param>
  45. /// <returns></returns>
  46. [DllImport(ErrellipDll, EntryPoint = "Error_Ellipse_2X1D_NoRef", CallingConvention = CallingConvention.Cdecl)]
  47. private extern static IntPtr Error_Ellipse_2X1D_NoRef(double[] main_eph, double[] neigh_eph, double[] cdbAnt, double[] Select_Point, double dto_err,
  48. double eph_err, double Pe, ref int LOP_Len);
  49. /// <summary>
  50. /// 两星一地带参误差椭圆
  51. /// </summary>
  52. /// <param name="posLon">定位点经度</param>
  53. /// <param name="posLat">定位点纬度</param>
  54. /// <param name="mainEph">主星xyz,长度=3</param>
  55. /// <param name="adajEph">邻星xyz,长度=3</param>
  56. /// <param name="cdbPos">超短波位置(长度=2或3)</param>
  57. /// <param name="RefGeod">参考站位置(长度=2或3)</param>
  58. /// <param name="DtoErrus">时差误差(us)</param>
  59. /// <param name="EphErrm">星历误差(m)</param>
  60. /// <param name="outputErrPoint">是否输出椭圆Geo点</param>
  61. /// <param name="pe">概率(范围0-1,默认0.5)</param>
  62. /// <returns></returns>
  63. 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)
  64. {
  65. if (cdbPos.Length == 2)
  66. {
  67. cdbPos = cdbPos.Concat(new double[1] { 0 }).ToArray();
  68. }
  69. if (RefGeod.Length == 2)
  70. {
  71. RefGeod = RefGeod.Concat(new double[1] { 0 }).ToArray();
  72. }
  73. int LOP_Len = 0;
  74. IntPtr LOP_ValuePtr = Error_Ellipse_2X1D(
  75. mainEph,
  76. adajEph,
  77. cdbPos,
  78. RefGeod,
  79. new double[3] { posLon, posLat, 0 },
  80. DtoErrus * 1e-6,
  81. EphErrm,//单位m
  82. pe, ref LOP_Len);
  83. double[] LOP_Value = new double[LOP_Len];
  84. if (LOP_Len > 0)
  85. {
  86. Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
  87. }
  88. ErrEllipseResDto res = new ErrEllipseResDto();
  89. res.LongRadius = LOP_Value[LOP_Value.Length - 3];
  90. res.ShortRadius = LOP_Value[LOP_Value.Length - 2];
  91. res.DipAngle = LOP_Value[LOP_Value.Length - 1];
  92. if (outputErrPoint)
  93. {
  94. int count = LOP_Value.Length - 3;
  95. for (int i = 0; i < count; i += 2)
  96. {
  97. res.GeoPoints.Add(new GeoPoint()
  98. {
  99. Lon = LOP_Value[i],
  100. Lat = LOP_Value[i + 1],
  101. });
  102. }
  103. }
  104. return res;
  105. }
  106. /// <summary>
  107. /// 两星一地无参误差椭圆
  108. /// </summary>
  109. /// <param name="posLon">定位点经度</param>
  110. /// <param name="posLat">定位点纬度</param>
  111. /// <param name="mainEph">主星xyz,长度=3</param>
  112. /// <param name="adajEph">邻星xyz,长度=3</param>
  113. /// <param name="cdbPos">超短波位置(长度=2或3)</param>
  114. /// <param name="DtoErrus">时差误差(us)</param>
  115. /// <param name="EphErrm">星历误差(m)</param>
  116. /// <param name="outputErrPoint">是否输出椭圆Geo点</param>
  117. /// <param name="pe">概率(范围0-1,默认0.5)</param>
  118. /// <returns></returns>
  119. public static ErrEllipseResDto ErrorEllipse2X1DNoRef(double posLon, double posLat, double[] mainEph, double[] adajEph, double[] cdbPos, double DtoErrus, double EphErrm, bool outputErrPoint,double pe = 0.5)
  120. {
  121. if (cdbPos.Length == 2)
  122. {
  123. cdbPos = cdbPos.Concat(new double[1] { 0 }).ToArray();
  124. }
  125. int LOP_Len = 0;
  126. double Pe = 0.5;
  127. IntPtr LOP_ValuePtr = Error_Ellipse_2X1D_NoRef(
  128. mainEph,
  129. adajEph,
  130. cdbPos,
  131. new double[3] { posLon, posLat, 0 },
  132. DtoErrus * 1e-6,
  133. EphErrm,//单位m
  134. Pe, ref LOP_Len);
  135. double[] LOP_Value = new double[LOP_Len];
  136. if (LOP_Len > 0)
  137. {
  138. Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
  139. }
  140. ErrEllipseResDto res = new ErrEllipseResDto();
  141. res.LongRadius = LOP_Value[LOP_Value.Length - 3];
  142. res.ShortRadius = LOP_Value[LOP_Value.Length - 2];
  143. res.DipAngle = LOP_Value[LOP_Value.Length - 1];
  144. if (outputErrPoint)
  145. {
  146. int count = LOP_Value.Length - 3;
  147. for (int i = 0; i < count; i += 2)
  148. {
  149. res.GeoPoints.Add(new GeoPoint()
  150. {
  151. Lon = LOP_Value[i],
  152. Lat = LOP_Value[i + 1],
  153. });
  154. }
  155. }
  156. return res;
  157. }
  158. }
  159. }