123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- using DPP_YH_Core.Extensions;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using XdCxRhDW.Dto;
- namespace XdCxRhDW.Api
- {
- /// <summary>
- /// 误差椭圆帮助类
- /// </summary>
- public static class ErrEllipseHepler
- {
- private const string ErrellipDll = @"AddIns\GDOP误差椭圆\DLL_GDOP_Analysis0623";
- /// <summary>
- /// 两星一地带参误差椭圆
- /// </summary>
- /// <param name="main_eph">主星星历 长度3</param>
- /// <param name="neigh_eph">邻星星历 长度3</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">星历误差(m)</param>
- /// <param name="Pe">概率,范围(0,1),默认0.5</param>
- /// <param name="LOP_Len">输出参数</param>
- /// <returns></returns>
- [DllImport(ErrellipDll, EntryPoint = "Error_Ellipse_2X1D", CallingConvention = CallingConvention.Cdecl)]
- private 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">主星位置 长度3</param>
- /// <param name="neigh_eph">邻星位置 长度3</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">星历误差(m)</param>
- /// <param name="Pe">0.5</param>
- /// <param name="LOP_Len"></param>
- /// <returns></returns>
- [DllImport(ErrellipDll, EntryPoint = "Error_Ellipse_2X1D_NoRef", CallingConvention = CallingConvention.Cdecl)]
- private extern static IntPtr Error_Ellipse_2X1D_NoRef(double[] main_eph, double[] neigh_eph, double[] cdbAnt, double[] Select_Point, double dto_err,
- double eph_err, double Pe, ref int LOP_Len);
- /// <summary>
- /// 三星带参误差椭圆(高轨和低轨是一样的)
- /// </summary>
- /// <param name="main_eph">主星位置 长度3</param>
- /// <param name="neigh_eph1">邻星1位置 长度3</param>
- /// <param name="neigh_eph2">邻星2位置 长度3</param>
- /// <param name="RefGeod">参考站 长度3</param>
- /// <param name="refStation">参考站 长度3</param>
- /// <param name="Select_Point">定位点 长度3</param>
- /// <param name="dto_err">时差误差(s)</param>
- /// <param name="eph_err">星历误差(m)</param>
- /// <param name="Pe">0.5</param>
- /// <param name="LOP_Len"></param>
- /// <returns></returns>
- [DllImport(ErrellipDll, EntryPoint = "Error_Ellipse_3X_2DTO", CallingConvention = CallingConvention.Cdecl)]
- private extern static IntPtr Error_Ellipse_3X_2DTO(double[] main_eph, double[] neigh_eph1, double[] neigh_eph2, double[] RefGeod, double[] Select_Point, double dto_err,
- double eph_err, double Pe, ref int LOP_Len);
- /// <summary>
- /// 三星无参误差椭圆(高轨和低轨是一样的)
- /// </summary>
- /// <param name="main_eph">主星位置 长度3</param>
- /// <param name="neigh_eph1">邻星1位置 长度3</param>
- /// <param name="neigh_eph2">邻星2位置 长度3</param>
- /// <param name="refStation">参考站 长度3</param>
- /// <param name="Select_Point">定位点 长度3</param>
- /// <param name="dto_err">时差误差(s)</param>
- /// <param name="eph_err">星历误差(m)</param>
- /// <param name="Pe">0.5</param>
- /// <param name="LOP_Len"></param>
- /// <returns></returns>
- [DllImport(ErrellipDll, EntryPoint = "Error_Ellipse_3X_NoRef", CallingConvention = CallingConvention.Cdecl)]
- private extern static IntPtr Error_Ellipse_3X_2DTONoRef(double[] main_eph, double[] neigh_eph1, double[] neigh_eph2, double[] Select_Point, double dto_err,
- double eph_err, double Pe, ref int LOP_Len);
- /// <summary>
- /// 两星一地带参误差椭圆
- /// </summary>
- /// <param name="posLon">定位点经度</param>
- /// <param name="posLat">定位点纬度</param>
- /// <param name="mainEph">主星xyz,长度=3</param>
- /// <param name="adjaEph">邻星xyz,长度=3</param>
- /// <param name="cdbPos">超短波位置(长度=2或3)</param>
- /// <param name="RefGeod">参考站位置(长度=2或3)</param>
- /// <param name="DtoErrus">时差误差(us)</param>
- /// <param name="EphErrm">星历误差(m)</param>
- /// <param name="outputErrPoint">是否输出椭圆Geo点</param>
- /// <param name="pe">概率(范围0-1,默认0.5)</param>
- /// <returns></returns>
- public static ErrEllipseResDto ErrorEllipse2X1D(double posLon, double posLat, double[] mainEph, double[] adjaEph, double[] cdbPos, double[] RefGeod, double DtoErrus, double EphErrm, bool outputErrPoint, double pe = 0.5)
- {
- if (cdbPos.Length == 2)
- {
- cdbPos = cdbPos.Concat(new double[1] { 0 }).ToArray();
- }
- if (RefGeod.Length == 2)
- {
- RefGeod = RefGeod.Concat(new double[1] { 0 }).ToArray();
- }
- int LOP_Len = 0;
- IntPtr LOP_ValuePtr = Error_Ellipse_2X1D(
- mainEph,
- adjaEph,
- cdbPos,
- RefGeod,
- new double[3] { posLon, posLat, 0 },
- DtoErrus * 1e-6,
- EphErrm,//单位m
- pe, ref LOP_Len);
- double[] LOP_Value = new double[LOP_Len];
- if (LOP_Len > 0)
- {
- Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
- }
- 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)
- {
- res.GeoPoints.Add(new GeoPoint()
- {
- Lon = LOP_Value[i],
- Lat = LOP_Value[i + 1],
- });
- }
- }
- return res;
- }
- /// <summary>
- /// 两星一地无参误差椭圆
- /// </summary>
- /// <param name="posLon">定位点经度</param>
- /// <param name="posLat">定位点纬度</param>
- /// <param name="mainEph">主星xyz,长度=3</param>
- /// <param name="adjaEph">邻星xyz,长度=3</param>
- /// <param name="cdbPos">超短波位置(长度=2或3)</param>
- /// <param name="DtoErrus">时差误差(us)</param>
- /// <param name="EphErrm">星历误差(m)</param>
- /// <param name="outputErrPoint">是否输出椭圆Geo点</param>
- /// <param name="pe">概率(范围0-1,默认0.5)</param>
- /// <returns></returns>
- public static ErrEllipseResDto ErrorEllipse2X1DNoRef(double posLon, double posLat, double[] mainEph, double[] adjaEph, double[] cdbPos, double DtoErrus, double EphErrm, bool outputErrPoint, double pe = 0.5)
- {
- if (cdbPos.Length == 2)
- {
- cdbPos = cdbPos.Concat(new double[1] { 0 }).ToArray();
- }
- int LOP_Len = 0;
- double Pe = 0.5;
- IntPtr LOP_ValuePtr = Error_Ellipse_2X1D_NoRef(
- mainEph,
- adjaEph,
- cdbPos,
- new double[3] { posLon, posLat, 0 },
- DtoErrus * 1e-6,
- EphErrm,//单位m
- Pe, ref LOP_Len);
- double[] LOP_Value = new double[LOP_Len];
- if (LOP_Len > 0)
- {
- Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
- }
- 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)
- {
- res.GeoPoints.Add(new GeoPoint()
- {
- Lon = LOP_Value[i],
- Lat = LOP_Value[i + 1],
- });
- }
- }
- return res;
- }
- /// <summary>
- /// 三星双时差带参误差椭圆(高轨和低轨是一样的)
- /// </summary>
- /// <param name="posLon">定位点经度</param>
- /// <param name="posLat">定位点纬度</param>
- /// <param name="mainEph">主星xyz,长度=3</param>
- /// <param name="adja1Eph">邻1星xyz,长度=3</param>
- /// <param name="adja2Eph">邻2星xyz,长度=3</param>
- /// <param name="RefGeod">参考站位置(长度=2或3)</param>
- /// <param name="dtoErrus">时差误差(us)</param>
- /// <param name="ephErrm">星历误差(m)</param>
- /// <param name="outputErrPoint">是否输出椭圆Geo点</param>
- /// <param name="pe">概率(范围0-1,默认0.5)</param>
- /// <returns></returns>
- public static ErrEllipseResDto ErrorEllipseX3(double posLon, double posLat, double[] mainEph, double[] adja1Eph, double[] adja2Eph,
- double[] RefGeod, double dtoErrus, double ephErrm, bool outputErrPoint, double pe = 0.5)
- {
- if (RefGeod.Length == 2)
- {
- RefGeod = RefGeod.Concat(new double[1] { 0 }).ToArray();
- }
- int LOP_Len = 0;
- IntPtr LOP_ValuePtr = Error_Ellipse_3X_2DTO(
- mainEph,
- adja1Eph,
- adja2Eph,
- RefGeod,
- new double[3] { posLon, posLat, 0 },
- dtoErrus * 1e-6,
- ephErrm,
- pe, ref LOP_Len);
- double[] LOP_Value = new double[LOP_Len];
- if (LOP_Len > 0)
- {
- Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
- }
- 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)
- {
- res.GeoPoints.Add(new GeoPoint()
- {
- Lon = LOP_Value[i],
- Lat = LOP_Value[i + 1],
- });
- }
- }
- return res;
- }
- public static ErrEllipseResDto ErrorEllipseX3NoRef(double posLon, double posLat, double[] mainEph, double[] adja1Eph, double[] adja2Eph,
- double dtoErrus, double ephErrm, bool outputErrPoint, double pe = 0.5)
- {
- int LOP_Len = 0;
- IntPtr LOP_ValuePtr = Error_Ellipse_3X_2DTONoRef(
- mainEph,
- adja1Eph,
- adja2Eph,
- new double[3] { posLon, posLat, 0 },
- dtoErrus * 1e-6,
- ephErrm,
- pe, ref LOP_Len);
- double[] LOP_Value = new double[LOP_Len];
- if (LOP_Len > 0)
- {
- Marshal.Copy(LOP_ValuePtr, LOP_Value, 0, LOP_Value.Length);
- }
- 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)
- {
- res.GeoPoints.Add(new GeoPoint()
- {
- Lon = LOP_Value[i],
- Lat = LOP_Value[i + 1],
- });
- }
- }
- return res;
- }
- }
- }
|