ErrEllipseHelper.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. using DevExpress.Charts.Native;
  2. using DevExpress.Internal.WinApi.Windows.UI.Notifications;
  3. using DevExpress.XtraPrinting;
  4. using Newtonsoft.Json;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Diagnostics;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Runtime.InteropServices;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using XdDw.App.Api.时差线;
  14. using XdDw.App.DTO;
  15. using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
  16. namespace XdDw.App.Api.低轨GDOP误差椭圆
  17. {
  18. public class ErrorEllipseDTFOTSOption
  19. {
  20. /// <summary>
  21. /// 主星星历
  22. /// </summary>
  23. public double[] MsEph { get; set; }
  24. /// <summary>
  25. /// 邻星星历
  26. /// </summary>
  27. public double[] NsEph { get; set; }
  28. /// <summary>
  29. /// 参考站位置
  30. /// </summary>
  31. public double[] RefGeod { get; set; }
  32. /// <summary>
  33. /// 定位点
  34. /// </summary>
  35. public double[] SelectPoint { get; set; }
  36. /// <summary>
  37. /// 时差误差(s)
  38. /// </summary>
  39. public double DtoErr { get; set; }
  40. /// <summary>
  41. /// 频差误差(Hz)
  42. /// </summary>
  43. public double DfoErr { get; set; }
  44. /// <summary>
  45. /// 星历位置误差
  46. /// </summary>
  47. public double EphPosErr { get; set; }
  48. /// <summary>
  49. ///星历速度误差
  50. /// </summary>
  51. public double EphVelErr { get; set; }
  52. /// <summary>
  53. /// 上行频点1(Hz)
  54. /// </summary>
  55. public double fu1 { get; set; }
  56. /// <summary>
  57. /// 上行频点2(Hz)
  58. /// </summary>
  59. public double fu2 { get; set; }
  60. /// <summary>
  61. /// 概率 默认0.5
  62. /// </summary>
  63. public double Pe { get; set; } = 0.5;
  64. }
  65. public class ErrorEllipseDTO2X1DOption
  66. {
  67. /// <summary>
  68. /// 主星星历
  69. /// </summary>
  70. public double[] MsEph { get; set; }
  71. /// <summary>
  72. /// 邻星星历
  73. /// </summary>
  74. public double[] NsEph { get; set; }
  75. /// <summary>
  76. /// 超短波位置
  77. /// </summary>
  78. public double[] CDBAnt { get; set; }
  79. /// <summary>
  80. /// 参考站位置
  81. /// </summary>
  82. public double[] RefGeod { get; set; }
  83. /// <summary>
  84. /// 定位点
  85. /// </summary>
  86. public double[] SelectPoint { get; set; }
  87. /// <summary>
  88. /// 时差误差(s)
  89. /// </summary>
  90. public double DtoErr { get; set; }
  91. /// <summary>
  92. /// 星历误差
  93. /// </summary>
  94. public double EphErr { get; set; }
  95. /// <summary>
  96. /// 概率 默认0.5
  97. /// </summary>
  98. public double Pe { get; set; } = 0.5;
  99. }
  100. public class ErrorEllipseDTO1XOption
  101. {
  102. /// <summary>
  103. /// 第一时刻星历
  104. /// </summary>
  105. public double[] MsEph { get; set; }
  106. /// <summary>
  107. ///第二时刻星历
  108. /// </summary>
  109. public double[] NsEph1 { get; set; }
  110. /// <summary>
  111. /// 第三时刻星历
  112. /// </summary>
  113. public double[] NsEph2 { get; set; }
  114. /// <summary>
  115. /// 定位点
  116. /// </summary>
  117. public double[] SelectPoint { get; set; }
  118. /// <summary>
  119. /// 频差误差(Hz)
  120. /// </summary>
  121. public double DfoErr { get; set; }
  122. /// <summary>
  123. /// 星历位置误差
  124. /// </summary>
  125. public double EphPosErr { get; set; }
  126. /// <summary>
  127. ///星历速度误差
  128. /// </summary>
  129. public double EphVelErr { get; set; }
  130. /// <summary>
  131. /// 上行频点(Hz)
  132. /// </summary>
  133. public double fu { get; set; }
  134. /// <summary>
  135. /// 概率 默认0.5
  136. /// </summary>
  137. public double Pe { get; set; } = 0.5;
  138. }
  139. public static class ErrEllipseHelper
  140. {
  141. private const string GDOPDll = @"Api\低轨GDOP误差椭圆\GDOP\DLL_GD64.dll";
  142. /// <summary>
  143. /// 两星一地误差椭圆
  144. /// </summary>
  145. /// <param name="main_eph">主星位置 长度6</param>
  146. /// <param name="neigh_eph">邻星位置 长度6</param>
  147. /// <param name="cdbAnt">超短波 长度3</param>
  148. /// <param name="refStation">参考站 长度3</param>
  149. /// <param name="Select_Point">定位点 长度3</param>
  150. /// <param name="dto_err">时差误差(s)</param>
  151. /// <param name="eph_err"></param>
  152. /// <param name="Pe">0.5</param>
  153. /// <param name="LOP_Len"></param>
  154. /// <returns></returns>
  155. [DllImport(GDOPDll, EntryPoint = "Error_Ellipse_2X1D", CallingConvention = CallingConvention.Cdecl)]
  156. public extern static IntPtr Error_Ellipse_2X1D(double[] main_eph, double[] neigh_eph, double[] cdbAnt, double[] refStation, double[] Select_Point, double dto_err,
  157. double eph_err, double Pe, ref int LOP_Len);
  158. [DllImport(GDOPDll, CallingConvention = CallingConvention.Cdecl)]
  159. public static extern void freeBuff(IntPtr buf);
  160. public static IEnumerable<(double lon, double lat)> ErrorEllipse2X1D(ErrorEllipseDTO2X1DOption opt)
  161. {
  162. int LOP_Len = 0;
  163. IntPtr LOP_ValuePtr = Error_Ellipse_2X1D(
  164. opt.MsEph,
  165. opt.NsEph,
  166. opt.CDBAnt,
  167. opt.RefGeod,
  168. opt.SelectPoint,
  169. opt.DtoErr,
  170. opt.EphErr,
  171. opt.Pe, ref LOP_Len);
  172. return ParseResult(LOP_ValuePtr, LOP_Len);
  173. }
  174. private static IEnumerable<(double lon, double lat)> ParseResult(IntPtr LOP_ValuePtr, int LOP_Len)
  175. {
  176. List<DtoLinePoint> list = new List<DtoLinePoint>();
  177. double[] LOP_Value = new double[LOP_Len];
  178. if (LOP_Len > 0)
  179. {
  180. Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
  181. int len = LOP_Len / 2;
  182. for (int i = 0; i < len; i++)
  183. {
  184. int temp = i * 2;
  185. list.Add(new DtoLinePoint()
  186. {
  187. Lon = LOP_Value[temp],
  188. Lat = LOP_Value[temp + 1]
  189. });
  190. }
  191. }
  192. var Lines = list.Select(p => (p.Lon, p.Lat));
  193. return Lines;
  194. }
  195. }
  196. }