ErrEllipseHepler.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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_Analysis0415";
  17. /// <summary>
  18. /// 两星一地误差椭圆
  19. /// </summary>
  20. /// <param name="main_eph">主星位置 长度6</param>
  21. /// <param name="neigh_eph">邻星位置 长度6</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"></param>
  27. /// <param name="Pe">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">主星位置 长度6</param>
  37. /// <param name="neigh_eph">邻星位置 长度6</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"></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. /// 获取误差椭圆的长轴(m)、短轴(m)、倾角(°)
  51. /// </summary>
  52. /// <param name="posLon"></param>
  53. /// <param name="posLat"></param>
  54. /// <param name="mainEph"></param>
  55. /// <param name="adajEph"></param>
  56. /// <param name="cdbPos"></param>
  57. /// <param name="RefGeod"></param>
  58. /// <param name="DtoErrus"></param>
  59. /// <param name="EphErrm"></param>
  60. /// <param name="outputErrPoint"></param>
  61. /// <returns></returns>
  62. public static ErrEllipseResDto ErrorEllipse2X1D(double posLon, double posLat, double[] mainEph, double[] adajEph, double[] cdbPos, double[] RefGeod, double DtoErrus, double EphErrm, bool outputErrPoint)
  63. {
  64. //IEnumerable<double> res = new List<double>();
  65. int LOP_Len = 0;
  66. double Pe = 0.5;
  67. IntPtr LOP_ValuePtr = Error_Ellipse_2X1D(
  68. mainEph,
  69. adajEph,
  70. cdbPos,
  71. RefGeod,
  72. new double[3] { posLon, posLat, 0 },
  73. DtoErrus * 1e-6,
  74. EphErrm,//单位m
  75. Pe, ref LOP_Len);
  76. double[] LOP_Value = new double[LOP_Len];
  77. if (LOP_Len > 0)
  78. {
  79. Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
  80. }
  81. ErrEllipseResDto res = new ErrEllipseResDto();
  82. res.LongRadius = LOP_Value[LOP_Value.Length - 3];
  83. res.ShortRadius = LOP_Value[LOP_Value.Length - 2];
  84. res.DipAngle = LOP_Value[LOP_Value.Length - 1];
  85. if (outputErrPoint)
  86. {
  87. int count = LOP_Value.Length - 3;
  88. for (int i = 0; i < count; i += 2)//13 ---01 23 45 67 89
  89. {
  90. res.GeoPoints.Add(new GeoPoint()
  91. {
  92. Lon = LOP_Value[i],
  93. Lat = LOP_Value[i + 1],
  94. });
  95. }
  96. }
  97. return res;
  98. }
  99. /// <summary>
  100. /// 获取误差椭圆的长轴(m)、短轴(m)、倾角(°)
  101. /// </summary>
  102. /// <param name="posLon"></param>
  103. /// <param name="posLat"></param>
  104. /// <param name="mainEph"></param>
  105. /// <param name="adajEph"></param>
  106. /// <param name="cdbPos"></param>
  107. /// <param name="DtoErrus"></param>
  108. /// <param name="EphErrm"></param>
  109. /// <param name="outputErrPoint"></param>
  110. /// <returns></returns>
  111. public static ErrEllipseResDto ErrorEllipse2X1DNoRef(double posLon, double posLat, double[] mainEph, double[] adajEph, double[] cdbPos, double DtoErrus, double EphErrm, bool outputErrPoint)
  112. {
  113. //IEnumerable<double> res = new List<double>();
  114. int LOP_Len = 0;
  115. double Pe = 0.5;
  116. IntPtr LOP_ValuePtr = Error_Ellipse_2X1D_NoRef(
  117. mainEph,
  118. adajEph,
  119. cdbPos,
  120. new double[3] { posLon, posLat, 0 },
  121. DtoErrus * 1e-6,
  122. EphErrm,//单位m
  123. Pe, ref LOP_Len);
  124. double[] LOP_Value = new double[LOP_Len];
  125. if (LOP_Len > 0)
  126. {
  127. Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
  128. }
  129. ErrEllipseResDto res = new ErrEllipseResDto();
  130. res.LongRadius = LOP_Value[LOP_Value.Length - 3];
  131. res.ShortRadius = LOP_Value[LOP_Value.Length - 2];
  132. res.DipAngle = LOP_Value[LOP_Value.Length - 1];
  133. if (outputErrPoint)
  134. {
  135. int count = LOP_Value.Length - 3;
  136. for (int i = 0; i < count; i += 2)//13 ---01 23 45 67 89
  137. {
  138. res.GeoPoints.Add(new GeoPoint()
  139. {
  140. Lon = LOP_Value[i],
  141. Lat = LOP_Value[i + 1],
  142. });
  143. }
  144. }
  145. return res;
  146. }
  147. }
  148. }