ErrEllipseHepler.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. /// 获取误差椭圆的长轴(m)、短轴(m)、倾角(°)
  35. /// </summary>
  36. /// <param name="posLon"></param>
  37. /// <param name="posLat"></param>
  38. /// <param name="mainEph"></param>
  39. /// <param name="adajEph"></param>
  40. /// <param name="cdbPos"></param>
  41. /// <param name="RefGeod"></param>
  42. /// <param name="DtoErrus"></param>
  43. /// <param name="EphErrm"></param>
  44. /// <param name="outputErrPoint"></param>
  45. /// <returns></returns>
  46. public static ErrEllipseResDto ErrorEllipse2X1D(double posLon, double posLat, double[] mainEph, double[] adajEph, double[] cdbPos, double[] RefGeod, double DtoErrus, double EphErrm, bool outputErrPoint)
  47. {
  48. //IEnumerable<double> res = new List<double>();
  49. int LOP_Len = 0;
  50. double Pe = 0.5;
  51. IntPtr LOP_ValuePtr = Error_Ellipse_2X1D(
  52. mainEph,
  53. adajEph,
  54. cdbPos,
  55. RefGeod,
  56. new double[3] { posLon, posLat, 0 },
  57. DtoErrus * 1e-6,
  58. EphErrm,//单位m
  59. Pe, ref LOP_Len);
  60. double[] LOP_Value = new double[LOP_Len];
  61. if (LOP_Len > 0)
  62. {
  63. Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
  64. }
  65. ErrEllipseResDto res = new ErrEllipseResDto();
  66. res.LongRadius = LOP_Value[LOP_Value.Length - 3];
  67. res.ShortRadius = LOP_Value[LOP_Value.Length - 2];
  68. res.DipAngle = LOP_Value[LOP_Value.Length - 1];
  69. if (outputErrPoint)
  70. {
  71. int count = LOP_Value.Length - 3;
  72. for (int i = 0; i < count; i += 2)//13 ---01 23 45 67 89
  73. {
  74. res.GeoPoints.Add(new GeoPoint()
  75. {
  76. Lon = LOP_Value[i],
  77. Lat = LOP_Value[i + 1],
  78. });
  79. }
  80. }
  81. return res;
  82. }
  83. }
  84. }