|
@@ -1,4 +1,5 @@
|
|
|
-using System;
|
|
|
+using DPP_YH_Core.Extensions;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Runtime.CompilerServices;
|
|
@@ -17,7 +18,7 @@ namespace XdCxRhDW.Api
|
|
|
public static class PosApi
|
|
|
{
|
|
|
//置信度统计次数
|
|
|
- private static int confidenceCount = 100;
|
|
|
+ private static int confidenceCount = 1000;
|
|
|
|
|
|
//置信度有效距离(m)
|
|
|
private static int confidenceDistance = 10000;
|
|
@@ -215,16 +216,16 @@ namespace XdCxRhDW.Api
|
|
|
var cgResNew = cgRes.Clone();
|
|
|
for (int i = 0; i < confidenceCount; i++)
|
|
|
{
|
|
|
- cgResNew.MainX = cgRes.MainX + RandomHelper.Normal(0, 500);
|
|
|
- cgResNew.MainY = cgRes.MainY + RandomHelper.Normal(0, 500);
|
|
|
- cgResNew.MainZ = cgRes.MainZ + RandomHelper.Normal(0, 500);
|
|
|
- cgResNew.Adja1X = cgRes.Adja1X + RandomHelper.Normal(0, 500);
|
|
|
- cgResNew.Adja1Y = cgRes.Adja1Y + RandomHelper.Normal(0, 500);
|
|
|
- cgResNew.Adja1Z = cgRes.Adja1Z + RandomHelper.Normal(0, 500);
|
|
|
- cgResNew.Dto1 = (cgRes.Dto1 * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
|
|
|
- cgResNew.DtoCdb = (cgRes.DtoCdb * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
|
|
|
- cgResNew.YbMainDto = (cgRes.YbMainDto * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
|
|
|
- cgResNew.YbAdja1Dto = (cgRes.YbAdja1Dto * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
|
|
|
+ cgResNew.MainX = cgRes.MainX + RandomHelper.Normal(0, 200);
|
|
|
+ cgResNew.MainY = cgRes.MainY + RandomHelper.Normal(0, 200);
|
|
|
+ cgResNew.MainZ = cgRes.MainZ + RandomHelper.Normal(0, 200);
|
|
|
+ cgResNew.Adja1X = cgRes.Adja1X + RandomHelper.Normal(0, 200);
|
|
|
+ cgResNew.Adja1Y = cgRes.Adja1Y + RandomHelper.Normal(0, 200);
|
|
|
+ cgResNew.Adja1Z = cgRes.Adja1Z + RandomHelper.Normal(0, 200);
|
|
|
+ cgResNew.Dto1 = (cgRes.Dto1 * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
|
|
|
+ cgResNew.DtoCdb = (cgRes.DtoCdb * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
|
|
|
+ cgResNew.YbMainDto = (cgRes.YbMainDto * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
|
|
|
+ cgResNew.YbAdja1Dto = (cgRes.YbAdja1Dto * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
|
|
|
res = X2D1_GzPos(cgResNew, sRes);
|
|
|
var posResNew = ConvertToGeoPoint(res);
|
|
|
if (IsGeoPoint2(posResNew))
|
|
@@ -311,13 +312,66 @@ namespace XdCxRhDW.Api
|
|
|
{
|
|
|
return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
|
|
|
}
|
|
|
- double startLon = (int)sRes.CdbTxLon.Value - 20;
|
|
|
- double endLon = (int)sRes.CdbTxLon.Value + 20;
|
|
|
- double startLat = (int)sRes.CdbTxLat.Value - 20;
|
|
|
- double endLat = (int)sRes.CdbTxLat.Value + 20;
|
|
|
+ var cdbStation = new double[2] { sRes.CdbTxLon.Value, sRes.CdbTxLat.Value };
|
|
|
+ var satStation = new double[2] { sRes.SatTxLon, sRes.SatTxLat };
|
|
|
+ var mainXYZ = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
|
|
|
+ var adjaXYZ = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
|
|
|
+ var dtoSxus = cgRes.Dto1.Value;
|
|
|
+ var dtoXdus = cgRes.DtoCdb.Value;
|
|
|
+ var posRes = X2D1_PosNoRefCore_Zl(cdbStation, satStation, mainXYZ, adjaXYZ, dtoSxus, dtoXdus);
|
|
|
+ posRes = ConvertToGeoPoint(posRes);
|
|
|
+ if (CalcConfidence && IsGeoPoint2(posRes))
|
|
|
+ {
|
|
|
+ int succeedCount = 0;
|
|
|
+ int totalCount = 100;
|
|
|
+ for (int i = 0; i < totalCount; i++)
|
|
|
+ {
|
|
|
+ var mainSatNew = new double[3]
|
|
|
+ {
|
|
|
+ cgRes.MainX.Value+RandomHelper.Normal(0,500),
|
|
|
+ cgRes.MainY.Value+RandomHelper.Normal(0,500),
|
|
|
+ cgRes.MainZ.Value+RandomHelper.Normal(0,500)
|
|
|
+
|
|
|
+ };
|
|
|
+ var adjaSatNew = new double[3]
|
|
|
+ {
|
|
|
+ cgRes.Adja1X.Value+RandomHelper.Normal(0,500),
|
|
|
+ cgRes.Adja1Y.Value+RandomHelper.Normal(0,500),
|
|
|
+ cgRes.Adja1Z.Value+RandomHelper.Normal(0,500)
|
|
|
+ };
|
|
|
+ var dtoSxusNew = dtoSxus + RandomHelper.Normal(0, 1);
|
|
|
+ var dtoXdusNew = dtoXdus + RandomHelper.Normal(0, 1);
|
|
|
+ var posResNew = X2D1_PosNoRefCore_Zl(cdbStation, satStation, mainSatNew, adjaSatNew, dtoSxusNew, dtoXdusNew);
|
|
|
+ posResNew = ConvertToGeoPoint(posResNew);
|
|
|
+ if (IsGeoPoint2(posResNew))
|
|
|
+ {
|
|
|
+ var distance = PhysicsHelper.DistanceGeo((posRes[0], posRes[1], 0), (posResNew[0], posResNew[1], 0));
|
|
|
+ if (distance <= confidenceDistance)
|
|
|
+ {
|
|
|
+ succeedCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var confidence = (int)(succeedCount / (double)totalCount * 100);
|
|
|
+ if (confidence == 0)
|
|
|
+ confidence = 1;
|
|
|
+ if (confidence == 100)
|
|
|
+ confidence = 99;
|
|
|
+ posRes[6] = confidence;
|
|
|
+ }
|
|
|
+ return posRes;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static double[] X2D1_PosNoRefCore_Zl(double[] cdbStation, double[] satStation, double[] mainXYZ, double[] adjaXYZ, double dtoSxus, double dtoXdus)
|
|
|
+ {
|
|
|
+
|
|
|
+ double startLon = (int)cdbStation[0] - 10;
|
|
|
+ double endLon = (int)cdbStation[0] + 10;
|
|
|
+ double startLat = (int)cdbStation[1] - 10;
|
|
|
+ double endLat = (int)cdbStation[1] + 10;
|
|
|
List<(double, double, double, double)> list = new List<(double, double, double, double)>();
|
|
|
- var recXYZ = PhysicsHelper.GeoToEcef((sRes.SatTxLon, sRes.SatTxLat, 0));
|
|
|
- var cdbXYZ = PhysicsHelper.GeoToEcef((sRes.CdbTxLon.Value, sRes.CdbTxLat.Value, 0));
|
|
|
+ var recXYZ = PhysicsHelper.GeoToEcef((satStation[0], satStation[1], 0));
|
|
|
+ var cdbXYZ = PhysicsHelper.GeoToEcef((cdbStation[0], cdbStation[1], 0));
|
|
|
for (double lon = startLon; lon < endLon; lon += 0.0001)
|
|
|
{
|
|
|
int flag = 0;
|
|
@@ -326,11 +380,11 @@ namespace XdCxRhDW.Api
|
|
|
var posXYZ = PhysicsHelper.GeoToEcef((lon, lat, 0));
|
|
|
|
|
|
//目标-主星-接收站的时间(us)
|
|
|
- var dt1 = PhysicsHelper.Dto(posXYZ, (cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value), recXYZ) * 1e6;
|
|
|
+ var dt1 = PhysicsHelper.Dto(posXYZ, (mainXYZ[0], mainXYZ[1], mainXYZ[2]), recXYZ) * 1e6;
|
|
|
|
|
|
//目标-超短站的时间(us)
|
|
|
var dt3 = PhysicsHelper.Dto(posXYZ, cdbXYZ) * 1e6;
|
|
|
- var dto2 = Math.Abs(dt1 - dt3 - cgRes.DtoCdb.Value);
|
|
|
+ var dto2 = Math.Abs(dt1 - dt3 - dtoXdus);
|
|
|
if (dto2 > 400)
|
|
|
{
|
|
|
lat += 1;
|
|
@@ -367,8 +421,8 @@ namespace XdCxRhDW.Api
|
|
|
// continue;
|
|
|
//}
|
|
|
//目标-邻星-接收站的时间(us)
|
|
|
- var dt2 = PhysicsHelper.Dto(posXYZ, (cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value), recXYZ) * 1e6;
|
|
|
- var dto1 = Math.Abs(dt1 - dt2 - cgRes.Dto1.Value);
|
|
|
+ var dt2 = PhysicsHelper.Dto(posXYZ, (adjaXYZ[0], adjaXYZ[1], adjaXYZ[2]), recXYZ) * 1e6;
|
|
|
+ var dto1 = Math.Abs(dt1 - dt2 - dtoSxus);
|
|
|
if (dto1 > 400)
|
|
|
{
|
|
|
lat += 1;
|
|
@@ -421,18 +475,18 @@ namespace XdCxRhDW.Api
|
|
|
var p1 = list.OrderBy(p => p.Item4 * p.Item4 + p.Item3 * p.Item3).FirstOrDefault();
|
|
|
if (p1 == default)
|
|
|
{
|
|
|
- posRes = new double[7] { 999, 999, 0, 999, 999, 0, -1 };
|
|
|
+ posRes = new double[6] { 999, 999, 0, 999, 999, 0 };
|
|
|
return posRes;
|
|
|
}
|
|
|
var p2 = list.Where(p => PhysicsHelper.DistanceGeo((p1.Item1, p1.Item2, 0), (p.Item1, p.Item2, 0)) > 10000).OrderBy(p => p.Item4 * p.Item4 + p.Item3 * p.Item3).FirstOrDefault();
|
|
|
if (p2 == default)
|
|
|
- posRes = new double[7] { p1.Item1, p1.Item2, 0, 999, 999, 0, -1 };
|
|
|
+ posRes = new double[6] { p1.Item1, p1.Item2, 0, 999, 999, 0 };
|
|
|
else
|
|
|
- posRes = new double[7] { p1.Item1, p1.Item2, 0, p2.Item1, p2.Item2, 0, -1 };
|
|
|
+ posRes = new double[6] { p1.Item1, p1.Item2, 0, p2.Item1, p2.Item2, 0 };
|
|
|
if (posRes[3] != 999)
|
|
|
{
|
|
|
- var dis1 = PhysicsHelper.DistanceArcGeo((posRes[3], posRes[4]), (sRes.CdbTxLon.Value, sRes.CdbTxLat.Value));
|
|
|
- var dis2 = PhysicsHelper.DistanceArcGeo((posRes[0], posRes[1]), (sRes.CdbTxLon.Value, sRes.CdbTxLat.Value));
|
|
|
+ var dis1 = PhysicsHelper.DistanceArcGeo((posRes[3], posRes[4]), (cdbStation[0], cdbStation[1]));
|
|
|
+ var dis2 = PhysicsHelper.DistanceArcGeo((posRes[0], posRes[1]), (cdbStation[0], cdbStation[1]));
|
|
|
if (dis1 < dis2)
|
|
|
{
|
|
|
var tmp1 = posRes[3];
|
|
@@ -443,48 +497,10 @@ namespace XdCxRhDW.Api
|
|
|
posRes[1] = tmp2;
|
|
|
}
|
|
|
}
|
|
|
- if (CalcConfidence && IsGeoPoint2(posRes))
|
|
|
- {
|
|
|
- double[] satStation = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
|
|
|
- double[] cdbStation = new double[3] { sRes.CdbTxLon.Value, sRes.CdbTxLat.Value, 0 };
|
|
|
- double dto1 = cgRes.Dto1.Value / 1e6;
|
|
|
- double dtoCdb = cgRes.DtoCdb.Value / 1e6;
|
|
|
- double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
|
|
|
- int succeedCount = 0;
|
|
|
- for (int i = 0; i < confidenceCount; i++)
|
|
|
- {
|
|
|
- var mainSatNew = new double[3]
|
|
|
- {
|
|
|
- cgRes.MainX.Value+RandomHelper.Normal(0,200),
|
|
|
- cgRes.MainY.Value+RandomHelper.Normal(0,200),
|
|
|
- cgRes.MainZ.Value+RandomHelper.Normal(0,200)
|
|
|
-
|
|
|
- };
|
|
|
- var adjaSatNew = new double[3]
|
|
|
- {
|
|
|
- cgRes.Adja1X.Value+RandomHelper.Normal(0,200),
|
|
|
- cgRes.Adja1Y.Value+RandomHelper.Normal(0,200),
|
|
|
- cgRes.Adja1Z.Value+RandomHelper.Normal(0,200)
|
|
|
- };
|
|
|
- var dto1New = (dto1 * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
|
|
|
- var dtoCdbNew = (dtoCdb * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
|
|
|
- double[] res = new double[6];
|
|
|
- X2D1_PosNoRef20240305_Core(mainSatNew, adjaSatNew, cdbStation, satStation, satStation, satStation, zone, dto1New, dtoCdbNew, res);
|
|
|
- var posResNew = ConvertToGeoPoint(res);
|
|
|
- if (IsGeoPoint2(posResNew))
|
|
|
- {
|
|
|
- var distance = PhysicsHelper.DistanceGeo((posRes[0], posRes[1], 0), (posResNew[0], posResNew[1], 0));
|
|
|
- if (distance <= confidenceDistance)
|
|
|
- {
|
|
|
- succeedCount++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
|
|
|
- }
|
|
|
return posRes;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 融合定位带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
|
|
|
/// </summary>
|