123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- 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
- {
- public class ErrorEllipseX1Option
- {
- /// <summary>
- /// 第一时刻星历
- /// </summary>
- public double[] MsEph { get; set; }
- /// <summary>
- ///第二时刻星历
- /// </summary>
- public double[] NsEph1 { get; set; }
- /// <summary>
- /// 第三时刻星历
- /// </summary>
- public double[] NsEph2 { get; set; }
- /// <summary>
- /// 定位点
- /// </summary>
- public double[] SelectPoint { get; set; }
- /// <summary>
- /// 频差误差(Hz)
- /// </summary>
- public double DfoErr { get; set; }
- /// <summary>
- /// 星历位置误差
- /// </summary>
- public double EphPosErr { get; set; }
- /// <summary>
- ///星历速度误差
- /// </summary>
- public double EphVelErr { get; set; }
- /// <summary>
- /// 上行频点(Hz)
- /// </summary>
- public double fu { get; set; }
- /// <summary>
- /// 概率 默认0.5
- /// </summary>
- public double Pe { get; set; } = 0.5;
- }
- public class ErrorEllipseX2Option
- {
- /// <summary>
- /// 主星星历
- /// </summary>
- public double[] MsEph { get; set; }
- /// <summary>
- /// 邻星星历
- /// </summary>
- public double[] NsEph { get; set; }
- /// <summary>
- /// 参考站位置
- /// </summary>
- public double[] RefGeod { get; set; }
- /// <summary>
- /// 定位点
- /// </summary>
- public double[] SelectPoint { get; set; }
- /// <summary>
- /// 时差误差(s)
- /// </summary>
- public double DtoErr { get; set; }
- /// <summary>
- /// 频差误差(Hz)
- /// </summary>
- public double DfoErr { get; set; }
- /// <summary>
- /// 星历位置误差
- /// </summary>
- public double EphPosErr { get; set; }
- /// <summary>
- ///星历速度误差
- /// </summary>
- public double EphVelErr { get; set; }
- /// <summary>
- /// 上行频点1(Hz)
- /// </summary>
- public double fu1 { get; set; }
- /// <summary>
- /// 上行频点2(Hz)
- /// </summary>
- public double fu2 { get; set; }
- /// <summary>
- /// 概率 默认0.5
- /// </summary>
- public double Pe { get; set; } = 0.5;
- }
- public class ErrorEllipseX3Option
- {
- /// <summary>
- /// 主星星历
- /// </summary>
- public double[] MsEph { get; set; }
- /// <summary>
- /// 邻星星历
- /// </summary>
- public double[] NsEph1 { get; set; }
- /// <summary>
- /// 邻星星历
- /// </summary>
- public double[] NsEph2 { get; set; }
- /// <summary>
- /// 参考站位置
- /// </summary>
- public double[] RefGeod { get; set; }
- /// <summary>
- /// 定位点
- /// </summary>
- public double[] SelectPoint { get; set; }
- /// <summary>
- /// 时差误差(s)
- /// </summary>
- public double DtoErr { get; set; }
- /// <summary>
- /// 频差误差(Hz)
- /// </summary>
- public double DfoErr { get; set; }
- /// <summary>
- /// 星历位置误差
- /// </summary>
- public double EphPosErr { get; set; }
- /// <summary>
- ///星历速度误差
- /// </summary>
- public double EphVelErr { get; set; }
- /// <summary>
- /// 上行频点1(Hz)
- /// </summary>
- public double fu1 { get; set; }
- /// <summary>
- /// 上行频点2(Hz)
- /// </summary>
- public double fu2 { get; set; }
- /// <summary>
- /// 概率 默认0.5
- /// </summary>
- public double Pe { get; set; } = 0.5;
- }
- public class ErrorEllipse2X1DOption
- {
- /// <summary>
- /// 主星星历
- /// </summary>
- public double[] MsEph { get; set; }
- /// <summary>
- /// 邻星星历
- /// </summary>
- public double[] NsEph { get; set; }
- /// <summary>
- /// 超短波位置
- /// </summary>
- public double[] CDBAnt { get; set; }
- /// <summary>
- /// 参考站位置
- /// </summary>
- public double[] RefGeod { get; set; }
- /// <summary>
- /// 定位点
- /// </summary>
- public double[] SelectPoint { get; set; }
- /// <summary>
- /// 时差误差(s)
- /// </summary>
- public double DtoErr { get; set; }
- /// <summary>
- /// 星历误差
- /// </summary>
- public double EphErr { get; set; }
- /// <summary>
- /// 概率 默认0.5
- /// </summary>
- public double Pe { get; set; } = 0.5;
- }
- public static class LeoErrorEllipseHelper
- {
- private const string errorEllipseDll = @"AddIns\低轨\DLL_GD64.dll";
- /// <summary>
- /// 低轨双星误差椭圆
- /// </summary>
- /// <param name="main_eph">主星位置 长度6</param>
- /// <param name="neigh_eph">邻星位置 长度6</param>
- /// <param name="ref_pos">参考位置 长度3</param>
- /// <param name="Select_Point">定位点长度3</param>
- /// <param name="dto_err">时差误差(s)</param>
- /// <param name="dfo_err">频差误差(Hz)</param>
- /// <param name="eph_pos_err"></param>
- /// <param name="eph_vel_err"></param>
- /// <param name="fu"></param>
- /// <param name="Pe">0.5</param>
- /// <param name="LOP_Len"></param>
- /// <returns></returns>
- [DllImport(errorEllipseDll, EntryPoint = "Error_Ellipse_DTFO", CallingConvention = CallingConvention.Cdecl)]
- public extern static IntPtr Error_Ellipse_DTFO(double[] main_eph, double[] neigh_eph, double[] ref_pos, double[] Select_Point, double dto_err, double dfo_err,
- double eph_pos_err, double eph_vel_err, double fu1, double fu2, double Pe, ref int LOP_Len);
- /// <summary>
- /// 两星一地误差椭圆
- /// </summary>
- /// <param name="main_eph">主星位置 长度6</param>
- /// <param name="neigh_eph">邻星位置 长度6</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"></param>
- /// <param name="Pe">0.5</param>
- /// <param name="LOP_Len"></param>
- /// <returns></returns>
- [DllImport(errorEllipseDll, EntryPoint = "Error_Ellipse_2X1D", CallingConvention = CallingConvention.Cdecl)]
- public 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"></param>
- /// <param name="neigh_eph1"></param>
- /// <param name="neigh_eph2"></param>
- /// <param name="Select_Point"></param>
- /// <param name="dfo_err"></param>
- /// <param name="eph_pos_err"></param>
- /// <param name="eph_vel_err"></param>
- /// <param name="fu"></param>
- /// <param name="Pe"></param>
- /// <param name="LOP_Len"></param>
- /// <returns></returns>
- [DllImport(errorEllipseDll, EntryPoint = "Error_Ellipse_2DFO", CallingConvention = CallingConvention.Cdecl)]
- public extern static IntPtr Error_Ellipse_2DFO(double[] main_eph, double[] neigh_eph1, double[] neigh_eph2, double[] Select_Point, double dfo_err, double eph_pos_err, double eph_vel_err, double fu, double Pe,
- ref int LOP_Len);
- [DllImport(errorEllipseDll, CallingConvention = CallingConvention.Cdecl)]
- public static extern void freeBuff(IntPtr buf);
- public static ErrEllipseResDto ErrorEllipseLeoX2(ErrorEllipseX2Option opt, bool outputErrPoint)
- {
- int LOP_Len = 0;
- IntPtr LOP_ValuePtr = Error_Ellipse_DTFO(
- opt.MsEph,
- opt.NsEph,
- opt.RefGeod,
- opt.SelectPoint,
- opt.DtoErr,
- opt.DfoErr,
- opt.EphPosErr,
- opt.EphVelErr,
- opt.fu1, opt.fu2, opt.Pe, ref LOP_Len);
- return ParseResult(LOP_ValuePtr, LOP_Len, outputErrPoint);
- }
- public static ErrEllipseResDto ErrorEllipseLeoX3(ErrorEllipseX3Option opt, bool outputErrPoint)
- {
- #warning 未提供低轨三星误差椭圆算法
- int LOP_Len = 0;
- IntPtr LOP_ValuePtr = Error_Ellipse_DTFO(
- opt.MsEph,
- opt.NsEph1,
- opt.RefGeod,
- opt.SelectPoint,
- opt.DtoErr,
- opt.DfoErr,
- opt.EphPosErr,
- opt.EphVelErr,
- opt.fu1, opt.fu2, opt.Pe, ref LOP_Len);
- return ParseResult(LOP_ValuePtr, LOP_Len, outputErrPoint);
- }
- public static ErrEllipseResDto ErrorEllipse2X1D(ErrorEllipse2X1DOption opt, bool outputErrPoint)
- {
- int LOP_Len = 0;
- IntPtr LOP_ValuePtr = Error_Ellipse_2X1D(
- opt.MsEph,
- opt.NsEph,
- opt.CDBAnt,
- opt.RefGeod,
- opt.SelectPoint,
- opt.DtoErr,
- opt.EphErr,
- opt.Pe, ref LOP_Len);
- return ParseResult(LOP_ValuePtr, LOP_Len, outputErrPoint);
- }
- public static ErrEllipseResDto ErrorEllipseLeoX1(ErrorEllipseX1Option opt, bool outputErrPoint)
- {
- int LOP_Len = 0;
- IntPtr LOP_ValuePtr = Error_Ellipse_2DFO(
- opt.MsEph,
- opt.NsEph1,
- opt.NsEph2,
- opt.SelectPoint,
- opt.DfoErr,
- opt.EphPosErr,
- opt.EphVelErr,
- opt.fu, opt.Pe, ref LOP_Len);
- return ParseResult(LOP_ValuePtr, LOP_Len,outputErrPoint);
- }
- private static ErrEllipseResDto ParseResult(IntPtr LOP_ValuePtr, int LOP_Len, bool outputErrPoint)
- {
- double[] LOP_Value = new double[LOP_Len];
- if (LOP_Len > 0)
- {
- Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
- }
- #warning 低轨多星误差椭圆是否包含长轴、短轴、倾角
- 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)//13 ---01 23 45 67 89
- {
- res.GeoPoints.Add(new GeoPoint()
- {
- Lon = LOP_Value[i],
- Lat = LOP_Value[i + 1],
- });
- }
- }
- return res;
- }
- }
- }
|