| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007 |
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.IO;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- using System.Security.Policy;
- using System.Text;
- using System.Threading.Tasks;
- using XdCxRhDW.Entity;
- using XdCxRhDW.Framework;
- namespace XdCxRhDW.Api
- {
- /// <summary>
- ///TODO 定位算法接口.在这里调用罗博士的算法库
- /// </summary>
- public static class PosApi
- {
- //置信度统计次数
- private static int confidenceCount = 10000;
- //置信度有效距离(m)
- private static int confidenceDistance = 10000;
- #region cpp dll Interop
- //两星一地和三星解析定位算法(精度差、速度快,适用于置信度等统计时的多次调用)
- private const string gzPos = @"AddIns\定位\DLL_GZDW.dll";
- //一星一地测向带参定位
- private const string XDCX = @"AddIns\定位\DLL_DTO_DOA_DW.dll";
- //三星双时差带参、三星双时差无参、三星双频差带参、双星时频差带参、两星一地无参定位及时差线、一星两地
- private const string OtherPos = @"AddIns\定位\Position-New.dll";//DLL_11J_DW
- [DllImport(gzPos, EntryPoint = "DW_Analysis", CallingConvention = CallingConvention.Cdecl)]//两星一地和三星的解析定位算法(精度差、速度快)
- private extern static void DW_Analysis(double[] mainSatXYZ, double[] adja1XYZ, double[] adja2XYZ, double[] refStation, double tarDto1, double tarDto2, double refDto1, double refDto2, double[] posRes, int flag);
- [DllImport(XDCX, EntryPoint = "XD_CX_DW", CallingConvention = CallingConvention.Cdecl)]//一星一地测向带参
- private extern static void X1D1_Pos20240305_Core(double[] mainSat, double[] satStation, double[] cdbStation, double[] cxStation, double[] refStation, double[] zone, double theta, double tarDto, double refDto, double[] res);
- /// <summary>
- /// 两星一地
- /// </summary>
- /// <param name="mainSat">主星星历</param>
- /// <param name="adjaSat">邻星星历</param>
- /// <param name="cdbStation">超短波位置</param>
- /// <param name="satStation1">目标主星接收天线</param>
- /// <param name="satStation2">目标邻星接收天线</param>
- /// <param name="satStation3">参考主星接收天线</param>
- /// <param name="satStation4">参考邻星接收天线</param>
- /// <param name="satStation5">星地主星接收天线</param>
- /// <param name="refStation">参考站位置</param>
- /// <param name="zone"></param>
- /// <param name="tarSxDto"></param>
- /// <param name="tarXdDto"></param>
- /// <param name="samp_main_dto"></param>
- /// <param name="samp_neigh_dto"></param>
- /// <param name="res"></param>
- [DllImport(OtherPos, EntryPoint = "SC_2X1D_DW", CallingConvention = CallingConvention.Cdecl)]//两星一地带参
- private extern static void X2D1_Pos20240305_Core(double[] mainSat, double[] adjaSat, double[] cdbStation, double[] satStation1, double[] satStation2, double[] satStation3, double[] satStation4,
- double[] satStation5, double[] refStation, double[] zone, double tarSxDto, double tarXdDto, double samp_main_dto, double samp_neigh_dto, double[] res);
- [DllImport(OtherPos, EntryPoint = "XingDi_2X1D_DW_NoRef", CallingConvention = CallingConvention.Cdecl)]//两星一地无参
- private extern static void X2D1_PosNoRef20240305_Core(double[] mainSat, double[] adjaSat, double[] cdbStation, double[] mainSatTarStation, double[] adjaSat1TarStation, double[] adjaSat2TarStation
- , double[] zone, double tarSxDto, double tarXdDto, double[] res);
- [DllImport(OtherPos, EntryPoint = "SanXing_DW", CallingConvention = CallingConvention.Cdecl)]//三星双时差带参
- private extern static void X3_Pos20240305_Core(double[] mainSat, double[] adjaSat1, double[] adjaSat2, double[] mainSatTarStation, double[] adjaSat1TarStation, double[] adjaSat2TarStation
- , double[] mainSatRefStation, double[] adjaSat1RefStation, double[] adjaSat2RefStation, double[] refStation, double[] zone, double tarDto1, double tarDto2, double refDto1, double refDto2, double[] res);
- [DllImport(OtherPos, EntryPoint = "SanXing_DW_NoRef", CallingConvention = CallingConvention.Cdecl)]//三星双时差无参
- private extern static void X3_PosNoRef20240305_Core(double[] mainSat, double[] adjaSat1, double[] adjaSat2, double[] mainSatTarStation, double[] adjaSat1TarStation, double[] adjaSat2TarStation
- , double[] zone, double tarDto1, double tarDto2, double[] res);
- [DllImport(OtherPos, EntryPoint = "TriStar_2DFO_DW", CallingConvention = CallingConvention.Cdecl)]//三星双频差带参
- private extern static void X3_PosTwoDfo20240305_Core(double[] mainSat, double[] adjaSat1, double[] adjaSat2, double[] mainSatTarStation, double[] adjaSat1TarStation, double[] adjaSat2TarStation
- , double[] refStation, double[] zone, double tarDfo1, double tarDfo2, double refDfo1, double refDfo2, double fu1, double fd1, double fu2, double fd2, double[] res);
- [DllImport(OtherPos, EntryPoint = "TwoStar_DTFO_DW", CallingConvention = CallingConvention.Cdecl)]//双星时频差带参
- private extern static void X2_Pos20240305_Core(double[] mainSat, double[] adjaSat, double[] mainSatTarStation, double[] adjaSatTarStation, double[] refStation, double[] zone
- , double tarDto, double tarDfo, double refDto, double refDfo, double fu1, double fd1, double fu2, double fd2, double[] res);
- #endregion
- /// <summary>
- /// 一星一地带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
- /// </summary>
- /// <param name="cgRes">参估结果</param>
- /// <param name="sRes">站点信息</param>
- /// <param name="cxRes">测向结果</param>
- /// <param name="CalcConfidence">是否计算置信度</param>
- /// <returns></returns>
- public static double[] X1D1_Pos(CgRes cgRes, StationRes sRes, CxRes cxRes, bool CalcConfidence = false)
- {
- if (cgRes.DtoCdb.Value == 0) return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
- double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
- double[] satStation = new double[3] { sRes.MSatTxLon, sRes.MSatTxLat, 0 };
- double[] cdbStation = new double[3] { sRes.CdbTxLon.Value, sRes.CdbTxLat.Value, 0 };
- double[] cxStation = new double[3] { sRes.CxLon.Value, sRes.CxLat.Value, 0 };
- double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
- double dtoCdb = cgRes.DtoCdb.Value / 1e6;
- double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
- double theta = cxRes.Fx;//单位°
- double[] res = new double[6];
- var ybDto1 = cgRes.YbMainDto.Value / 1e6;
- X1D1_Pos20240305_Core(mainSat, satStation, cdbStation, cxStation, refStation, zone, theta, dtoCdb, ybDto1, res);
- var posRes = ConvertToGeoPoint(res);
- if (CalcConfidence && IsGeoPoint2(posRes))
- {
- 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 dtoCdbNew = (dtoCdb * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
- var ybDtoNew = (ybDto1 * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
- var thetaNew = theta + RandomHelper.Normal(0, 0.4);//单位°
- X1D1_Pos20240305_Core(mainSatNew, satStation, cdbStation, cxStation, refStation, zone, thetaNew, dtoCdbNew, ybDtoNew, 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>
- /// 两星一地带参解析定位(精度差速度快,主要用于置信度分析等需要多次调用的情况)
- /// </summary>
- /// <param name="cgRes"></param>
- /// <param name="sRes"></param>
- /// <returns></returns>
- public static double[] X2D1_GzPos(CgRes cgRes, StationRes sRes)
- {
- if (cgRes.Dto1.Value == 0 || cgRes.DtoCdb.Value == 0)
- {
- return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
- }
- double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
- double[] adjaSat = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
- double[] cdbStation = new double[3] { sRes.CdbTxLon.Value, sRes.CdbTxLat.Value, 0 };
- double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
- double dto1 = cgRes.Dto1.Value / 1e6;
- double dtoCdb = cgRes.DtoCdb.Value / 1e6;
- double ybDto1 = cgRes.YbMainDto.Value / 1e6;
- double ybDto2 = cgRes.YbAdja1Dto.Value / 1e6;
- double ybDto = ybDto1 - ybDto2;
- double[] posRes = new double[3];
- DW_Analysis(mainSat, adjaSat, cdbStation, refStation, dto1, -dtoCdb, ybDto, -ybDto1, posRes, 1);
- return posRes;
- }
- /// <summary>
- /// 三星双时差带参解析定位(精度差速度快,主要用于置信度分析等需要多次调用的情况)
- /// </summary>
- /// <param name="cgRes"></param>
- /// <param name="sRes"></param>
- /// <returns></returns>
- public static double[] X3Dto_GzPos(CgRes cgRes, StationRes sRes)
- {
- if (cgRes.Dto1.Value == 0 || cgRes.Dto2.Value == 0)
- {
- return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
- }
- double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
- double[] adja1Sat = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
- double[] adja2Sat = new double[3] { cgRes.Adja2X.Value, cgRes.Adja2Y.Value, cgRes.Adja2Z.Value };
- double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
- double dto1 = cgRes.Dto1.Value / 1e6;
- double dto2 = cgRes.Dto2.Value / 1e6;
- double ybDto1 = cgRes.YbMainDto.Value / 1e6;
- double ybDto2 = cgRes.YbAdja1Dto.Value / 1e6;
- double ybDto3 = cgRes.YbAdja2Dto.Value / 1e6;
- double refDto1 = ybDto1 - ybDto2;
- double refDto2 = ybDto1 - ybDto3;
- double[] posRes = new double[3];
- DW_Analysis(mainSat, adja1Sat, adja2Sat, refStation, dto1, dto2, refDto1, refDto2, posRes, 0);
- return posRes;
- }
- /// <summary>
- /// 两星一地带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
- /// </summary>
- /// <param name="cgRes">参估结果</param>
- /// <param name="sRes">站点信息</param>
- /// <param name="CalcConfidence">是否计算置信度</param>
- /// <returns></returns>
- public static double[] X2D1_Pos(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
- {
- if (cgRes.Dto1.Value == 0 || cgRes.DtoCdb.Value == 0)
- {
- return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
- }
- double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
- double[] adjaSat = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
- double[] msatStation = new double[3] { sRes.MSatTxLon, sRes.MSatTxLat, 0 };
- double[] nsatStation = new double[3] { sRes.N1SatTxLat.Value, sRes.N1SatTxLat.Value, 0 };
- double[] cdbStation = new double[3] { sRes.CdbTxLon.Value, sRes.CdbTxLat.Value, 0 };
- double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
- double dto1 = cgRes.Dto1.Value / 1e6;
- double dtoCdb = cgRes.DtoCdb.Value / 1e6;
- double ybDto1 = cgRes.YbMainDto.Value / 1e6;
- double ybDto2 = cgRes.YbAdja1Dto.Value / 1e6;
- double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
- double[] res = new double[6];
- X2D1_Pos20240305_Core(mainSat, adjaSat, cdbStation, msatStation, nsatStation, msatStation, nsatStation, msatStation, refStation, zone, -dto1, -dtoCdb, -ybDto1, -ybDto2, res);
- var posRes = ConvertToGeoPoint(res);//精确搜索值
- if (HasMirror(res))
- {
- var d1 = PhysicsHelper.DistanceArcGeo((cdbStation[0], cdbStation[1]), (posRes[0], posRes[1]));
- var d2 = PhysicsHelper.DistanceArcGeo((cdbStation[0], cdbStation[1]), (posRes[3], posRes[4]));
- if (d2 < 500000 && d1 > 500000)
- {
- var p0 = posRes[0];
- var p1 = posRes[1];
- var p2 = posRes[2];
- posRes[0] = posRes[3];
- posRes[1] = posRes[4];
- posRes[2] = posRes[5];
- posRes[3] = p0;
- posRes[4] = p1;
- posRes[5] = p2;
- }
- else if (d1 > 200000 && d2 > 200000)
- {
- if (posRes[1] < 5 && posRes[4] > 10 && posRes[4] < 30)
- {
- var p0 = posRes[0];
- var p1 = posRes[1];
- var p2 = posRes[2];
- posRes[0] = posRes[3];
- posRes[1] = posRes[4];
- posRes[2] = posRes[5];
- posRes[3] = p0;
- posRes[4] = p1;
- posRes[5] = p2;
- }
- }
- }
- if (CalcConfidence && IsGeoPoint2(posRes))
- {
- var posResGz = X2D1_GzPos(cgRes, sRes);
- if (IsGeoPoint2(posResGz))
- {
- int succeedCount = 0;
- 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;
- res = X2D1_GzPos(cgResNew, sRes);
- var posResNew = ConvertToGeoPoint(res);
- if (IsGeoPoint2(posResNew))
- {
- var distance = PhysicsHelper.DistanceGeo((posResGz[0], posResGz[1], 0), (posResNew[0], posResNew[1], 0));
- if (distance <= confidenceDistance)
- {
- succeedCount++;
- }
- }
- }
- posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
- }
- else
- {
- posRes[6] = 0;
- }
- }
- return posRes;
- }
- /// <summary>
- /// 两星一地无参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
- /// </summary>
- /// <param name="cgRes">参估结果</param>
- /// <param name="sRes">站点信息</param>
- /// <param name="CalcConfidence">是否计算置信度</param>
- /// <returns></returns>
- public static double[] X2D1_PosNoRef(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
- {
- if (cgRes.Dto1.Value == 0 || cgRes.DtoCdb.Value == 0)
- {
- return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
- }
- double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
- double[] adjaSat = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
- double[] satStation = new double[3] { sRes.MSatTxLon, sRes.MSatTxLat, 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 }; //定位区域
- double[] res = new double[6];
- X2D1_PosNoRef20240305_Core(mainSat, adjaSat, cdbStation, satStation, satStation, satStation, zone, dto1, dtoCdb, res);
- var posRes = ConvertToGeoPoint(res);
- if (HasMirror(res))
- {
- var d1 = PhysicsHelper.DistanceArcGeo((cdbStation[0], cdbStation[1]), (posRes[0], posRes[1]));
- var d2 = PhysicsHelper.DistanceArcGeo((cdbStation[0], cdbStation[1]), (posRes[3], posRes[4]));
- if (d2 < 500000 && d1 > 500000)
- {
- var p0 = posRes[0];
- var p1 = posRes[1];
- var p2 = posRes[2];
- posRes[0] = posRes[3];
- posRes[1] = posRes[4];
- posRes[2] = posRes[5];
- posRes[3] = p0;
- posRes[4] = p1;
- posRes[5] = p2;
- }
- if (d1 > 200000 && d2 > 200000)
- {
- if (posRes[1] < 5 && posRes[4] > 10 && posRes[4] < 30)
- {
- var p0 = posRes[0];
- var p1 = posRes[1];
- var p2 = posRes[2];
- posRes[0] = posRes[3];
- posRes[1] = posRes[4];
- posRes[2] = posRes[5];
- posRes[3] = p0;
- posRes[4] = p1;
- posRes[5] = p2;
- }
- }
- }
- if (CalcConfidence && IsGeoPoint2(posRes))
- {
- 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;
- 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;
- }
- public static double[] X2D1_PosNoRef_ZL(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
- {
- if (cgRes.Dto1.Value == 0 || cgRes.DtoCdb.Value == 0)
- {
- 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;
- List<(double, double, double, double)> list = new List<(double, double, double, double)>();
- var recXYZ = PhysicsHelper.GeoToEcef((sRes.MSatTxLon, sRes.MSatTxLat, 0));
- var cdbXYZ = PhysicsHelper.GeoToEcef((sRes.CdbTxLon.Value, sRes.CdbTxLat.Value, 0));
- for (double lon = startLon; lon < endLon; lon += 0.0001)
- {
- int flag = 0;
- for (double lat = startLat; lat < endLat; lat += 0.0001)
- {
- var posXYZ = PhysicsHelper.GeoToEcef((lon, lat, 0));
- //目标-主星-接收站的时间(us)
- var dt1 = PhysicsHelper.Dto(posXYZ, (cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value), recXYZ) * 1e6;
- //目标-超短站的时间(us)
- var dt3 = PhysicsHelper.Dto(posXYZ, cdbXYZ) * 1e6;
- var dto2 = Math.Abs(dt1 - dt3 - cgRes.DtoCdb.Value);
- if (dto2 > 100)
- {
- lat += 1;
- if (flag < 1)
- flag = 1;
- continue;
- }
- else if (dto2 > 50)
- {
- lat += 0.5;
- if (flag < 2)
- flag = 2;
- continue;
- }
- else if (dto2 > 20)
- {
- lat += 0.2;
- if (flag < 3)
- flag = 3;
- continue;
- }
- else if (dto2 > 5)
- {
- lat += 0.1;
- if (flag < 4)
- flag = 4;
- continue;
- }
- else if (dto2 > 2)
- {
- lat += 0.02;
- if (flag < 5)
- flag = 5;
- 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);
- if (dto1 > 100)
- {
- lat += 1;
- if (flag < 1)
- flag = 1;
- continue;
- }
- if (dto1 > 50)
- {
- lat += 0.5;
- if (flag < 2)
- flag = 2;
- continue;
- }
- else if (dto1 > 20)
- {
- lat += 0.2;
- if (flag < 3)
- flag = 3;
- continue;
- }
- else if (dto1 > 5)
- {
- lat += 0.1;
- if (flag < 4)
- flag = 4;
- continue;
- }
- else if (dto1 > 2)
- {
- lat += 0.02;
- if (flag < 5)
- flag = 5;
- continue;
- }
- list.Add((lon, lat, dto1, dto2));
- }
- if (flag == 1)
- lon += 1;
- else if (flag == 2)
- lon += 0.5;
- else if (flag == 3)
- lon += 0.2;
- else if (flag == 4)
- lon += 0.1;
- else if (flag == 5)
- lon += 0.02;
- }
- double[] res;
- var p1 = list.OrderBy(p => p.Item3 + p.Item4).FirstOrDefault();
- if (p1 == default)
- {
- res = new double[7] { 999, 999, 0, 999, 999, 0, -1 };
- return res;
- }
- var p2 = list.Where(p => PhysicsHelper.DistanceGeo((p1.Item1, p1.Item2, 0), (p.Item1, p.Item2, 0)) > 10000).OrderBy(p => p.Item3 + p.Item4).FirstOrDefault();
- if (p2 == default)
- res = new double[7] { p1.Item1, p1.Item2, 0, 999, 999, 0, -1 };
- else
- res = new double[7] { p1.Item1, p1.Item2, 0, p2.Item1, p2.Item2, 0, -1 };
- return res;
- }
- /// <summary>
- /// 融合定位带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
- /// </summary>
- /// <param name="cgRes">参估结果</param>
- /// <param name="sRes">站点信息</param>
- /// <param name="cxRes">测向结果</param>
- /// <param name="CalcConfidence">是否计算置信度</param>
- /// <returns></returns>
- public static double[] RH_Pos(CgRes cgRes, StationRes sRes, CxRes cxRes, bool CalcConfidence = false)
- {
- var res1 = X1D1_Pos(cgRes, sRes, cxRes, CalcConfidence);
- var res2 = X2D1_Pos(cgRes, sRes, CalcConfidence);
- double[] res = new double[] { 999, 999, 0, 999, 999, 0, 100 };
- var p1 = res1.Take(3).ToArray();
- var p2 = res1.Skip(3).ToArray();
- var p3 = res2.Take(3).ToArray();
- var p4 = res2.Skip(3).ToArray();
- if (IsGeoPoint(p1) && IsGeoPoint(p2) && IsGeoPoint(p3) && IsGeoPoint(p4))
- {
- res = new double[7] {
- (p1[0] + p3[0]) / 2 + 0.003,
- (p1[1] + p3[1]) / 2 - 0.002,
- 0,
- (p2[0] + p4[0]) / 2 + 0.003,
- (p2[1] + p4[1]) / 2 - 0.002,
- 0,
- (res1[6]+res2[6])/2
- };
- }
- else if (IsGeoPoint(p1) && IsGeoPoint(p3))
- {
- res = new double[7] {
- (p1[0] + p3[0]) / 2 + 0.003,
- (p1[1] + p3[1]) / 2 - 0.002,
- 0,
- 999,
- 999,
- 0,
- (res1[6]+res2[6])/2
- };
- }
- else if (IsGeoPoint(p1) && IsGeoPoint(p2))
- {
- res = new double[7]
- {
- p1[0] + 0.003,
- p1[1] - 0.002,
- 0,
- p2[0] + 0.003,
- p2[1] - 0.002,
- 0,
- (res1[6]+res2[6])/2
- };
- }
- else if (IsGeoPoint(p3) && IsGeoPoint(p4))
- {
- res = new double[7]
- {
- p3[0] + 0.003,
- p3[1] - 0.002,
- 0,
- p4[0] + 0.003,
- p4[1] - 0.002,
- 0,
- (res1[6]+res2[6])/2
- };
- }
- return res;
- }
- /// <summary>
- /// 三星双时差带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
- /// </summary>
- /// <param name="cgRes">参估结果</param>
- /// <param name="sRes">站点信息</param>
- /// <param name="CalcConfidence">是否计算置信度</param>
- /// <returns></returns>
- public static double[] X3_Pos(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
- {
- if (cgRes.Dto1.Value == 0 || cgRes.Dto2.Value == 0)
- {
- return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
- }
- if (cgRes.Dto1.Value == 0 || cgRes.Dto2.Value == 0) return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
- double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
- double[] adjaSat1 = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
- double[] adjaSat2 = new double[3] { cgRes.Adja2X.Value, cgRes.Adja2Y.Value, cgRes.Adja2Z.Value };
- double[] msatStation = new double[3] { sRes.MSatTxLon, sRes.MSatTxLat, 0 };
- double[] n1satStation = new double[3] { sRes.N1SatTxLon.Value, sRes.N1SatTxLat.Value, 0 };
- double[] n2satStation = new double[3] { sRes.N2SatTxLon.Value, sRes.N2SatTxLat.Value, 0 };
- double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
- double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
- var tarDto1 = cgRes.Dto1.Value / 1e6;
- var tarDto2 = cgRes.Dto2.Value / 1e6;
- var refDto1 = (cgRes.YbMainDto.Value - cgRes.YbAdja1Dto.Value) / 1e6;
- var refDto2 = (cgRes.YbMainDto.Value - cgRes.YbAdja2Dto.Value) / 1e6;
- double[] res = new double[6];
- X3_Pos20240305_Core(mainSat, adjaSat1, adjaSat2, msatStation, n1satStation, n2satStation, msatStation, n1satStation, n2satStation, refStation, zone, -tarDto1, -tarDto2, -refDto1, -refDto2, res);
- var posRes = ConvertToGeoPoint(res);//精确搜索值
- if (CalcConfidence && IsGeoPoint2(posRes))
- {
- var posResGz = X3Dto_GzPos(cgRes, sRes);
- if (IsGeoPoint2(posResGz))
- {
- int succeedCount = 0;
- 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.Adja2X = cgRes.Adja2X + RandomHelper.Normal(0, 500);
- cgResNew.Adja2Y = cgRes.Adja2Y + RandomHelper.Normal(0, 500);
- cgResNew.Adja2Z = cgRes.Adja2Z + RandomHelper.Normal(0, 500);
- cgResNew.Dto1 = (cgRes.Dto1 * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
- cgResNew.Dto2 = (cgRes.Dto2 * 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.YbAdja2Dto = (cgRes.YbAdja2Dto * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
- res = X3Dto_GzPos(cgResNew, sRes);
- var posResNew = ConvertToGeoPoint(res);
- if (IsGeoPoint2(posResNew))
- {
- var distance = PhysicsHelper.DistanceGeo((posResGz[0], posResGz[1], 0), (posResNew[0], posResNew[1], 0));
- if (distance <= confidenceDistance)
- {
- succeedCount++;
- }
- }
- }
- posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
- }
- else
- {
- posRes[6] = 0;
- }
- }
- var latRange = 0;
- if (posRes[0] != 999 && posRes[1] < latRange && posRes[3] != 999 && posRes[4] > latRange)
- {
- var p0 = posRes[0];
- var p1 = posRes[1];
- var p2 = posRes[2];
- posRes[0] = posRes[3];
- posRes[1] = posRes[4];
- posRes[2] = posRes[5];
- posRes[3] = p0;
- posRes[4] = p1;
- posRes[5] = p2;
- }
- return posRes;
- }
- /// <summary>
- /// 三星双时差无参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
- /// </summary>
- /// <param name="cgRes">参估结果</param>
- /// <param name="sRes">站点信息</param>
- /// <param name="CalcConfidence">是否计算置信度</param>
- /// <returns></returns>
- public static double[] X3_PosNoRef(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
- {
- if (cgRes.Dto1.Value == 0 || cgRes.Dto2.Value == 0)
- {
- return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
- }
- double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
- double[] adjaSat1 = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
- double[] adjaSat2 = new double[3] { cgRes.Adja2X.Value, cgRes.Adja2Y.Value, cgRes.Adja2Z.Value };
- double[] msatStation = new double[3] { sRes.MSatTxLon, sRes.MSatTxLat, 0 };
- double[] n1satStation = new double[3] { sRes.N1SatTxLon.Value, sRes.N1SatTxLat.Value, 0 };
- double[] n2satStation = new double[3] { sRes.N2SatTxLon.Value, sRes.N2SatTxLat.Value, 0 };
- double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
- var tarDto1 = cgRes.Dto1.Value / 1e6;
- var tarDto2 = cgRes.Dto2.Value / 1e6;
- double[] res = new double[6];
- X3_PosNoRef20240305_Core(mainSat, adjaSat1, adjaSat2, msatStation, n1satStation, n2satStation, zone, -tarDto1, -tarDto2, res);
- ConvertToGeoPoint(res);
- var posRes = ConvertToGeoPoint(res);
- if (CalcConfidence && IsGeoPoint2(posRes))
- {
- 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 adjaSat1New = 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 adjaSat2New = new double[3]
- {
- cgRes.Adja2X.Value+RandomHelper.Normal(0,200),
- cgRes.Adja2Y.Value+RandomHelper.Normal(0,200),
- cgRes.Adja2Z.Value+RandomHelper.Normal(0,200)
- };
- var tarDto1New = (tarDto1 * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
- var tarDto2New = (tarDto2 * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
- X3_PosNoRef20240305_Core(mainSatNew, adjaSat1New, adjaSat2New, msatStation, n1satStation, n2satStation, zone, tarDto1New, tarDto2New, 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>
- /// <param name="cgRes">参估结果</param>
- /// <param name="sRes">站点信息</param>
- /// <param name="CalcConfidence">是否计算置信度</param>
- /// <returns></returns>
- public static double[] X3_PosTwoDfo(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
- {
- if (cgRes.Dfo1.Value == 0 || cgRes.Dfo2.Value == 0) return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
- double[] mainSat = new double[6] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value, cgRes.MainVx.Value, cgRes.MainVy.Value, cgRes.MainVz.Value };
- double[] adjaSat1 = new double[6] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value, cgRes.Adja1Vx.Value, cgRes.Adja1Vy.Value, cgRes.Adja1Vz.Value };
- double[] adjaSat2 = new double[6] { cgRes.Adja2X.Value, cgRes.Adja2Y.Value, cgRes.Adja2Z.Value, cgRes.Adja2Vx.Value, cgRes.Adja2Vy.Value, cgRes.Adja2Vz.Value };
- double[] satStation = new double[3] { sRes.MSatTxLon, sRes.MSatTxLat, 0 };
- double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
- double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
- var tarDfo1 = cgRes.Dfo1.Value;
- var tarDfo2 = cgRes.Dfo2.Value;
- var refDfo1 = cgRes.YbMainDfo.Value - cgRes.YbAdja1Dfo.Value;
- var refDfo2 = cgRes.YbMainDfo.Value - cgRes.YbAdja2Dfo.Value;
- double fu1 = cgRes.TarFreqUp.Value;
- double fd1 = cgRes.TarFreqDown.Value;
- double fu2 = cgRes.RefFreqUp.Value;
- double fd2 = cgRes.RefFreqDown.Value;
- double[] res = new double[6];
- X3_PosTwoDfo20240305_Core(mainSat, adjaSat1, adjaSat2, satStation, satStation, satStation,
- refStation, zone, tarDfo1, tarDfo2, refDfo1, refDfo2, fu1, fd1, fu2, fd2, res);
- ConvertToGeoPoint(res);
- var posRes = ConvertToGeoPoint(res);
- if (CalcConfidence && IsGeoPoint2(posRes))
- {
- 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 adjaSat1New = 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 adjaSat2New = new double[3]
- {
- cgRes.Adja2X.Value+RandomHelper.Normal(0,200),
- cgRes.Adja2Y.Value+RandomHelper.Normal(0,200),
- cgRes.Adja2Z.Value+RandomHelper.Normal(0,200)
- };
- var tarDfo1New = (tarDfo1 * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
- var tarDfo2New = (tarDfo2 * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
- var refDfo1New = (refDfo1 * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
- var refDfo2New = (refDfo2 * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
- X3_PosTwoDfo20240305_Core(mainSatNew, adjaSat1New, adjaSat2New, satStation, satStation, satStation, refStation, zone, tarDfo1New, tarDfo2New, refDfo1New, refDfo2New, fu1, fd1, fu2, fd2, 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>
- /// <param name="cgRes">参估结果</param>
- /// <param name="sRes">站点信息</param>
- /// <param name="CalcConfidence">是否计算置信度</param>
- /// <returns></returns>
- public static double[] X2_PosDtoDfo(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
- {
- if (cgRes.Dto1.Value == 0) return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
- double[] mainSat = new double[6] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value, cgRes.MainVx.Value, cgRes.MainVy.Value, cgRes.MainVz.Value };
- double[] adjaSat = new double[6] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value, cgRes.Adja1Vx.Value, cgRes.Adja1Vy.Value, cgRes.Adja1Vz.Value };
- double[] satStation = new double[3] { sRes.MSatTxLon, sRes.MSatTxLat, 0 };
- double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
- double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
- var tarDto = cgRes.Dto1.Value / 1e6;
- var tarDfo = cgRes.Dfo1.Value;
- var refDto = (cgRes.YbMainDto.Value - cgRes.YbAdja1Dto.Value) / 1e6;
- var refDfo = cgRes.YbMainDfo.Value - cgRes.YbAdja1Dfo.Value;
- double fu1 = cgRes.TarFreqUp.Value;
- double fd1 = cgRes.TarFreqDown.Value;
- double fu2 = cgRes.RefFreqUp.Value;
- double fd2 = cgRes.RefFreqDown.Value;
- double[] res = new double[6];
- X2_Pos20240305_Core(mainSat, adjaSat, satStation, satStation, refStation, zone, tarDto, tarDfo, refDto, refDfo, fu1, fd1, fu2, fd2, res);
- ConvertToGeoPoint(res);
- var posRes = ConvertToGeoPoint(res);
- if (CalcConfidence && IsGeoPoint2(posRes))
- {
- 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 tarDtoNew = (tarDto * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
- var refDtoNew = (refDto * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
- var tarDfoNew = (tarDfo * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
- var refDfoNew = (refDfo * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
- X2_Pos20240305_Core(mainSatNew, adjaSatNew, satStation, satStation, refStation, zone, tarDtoNew, tarDfoNew, refDtoNew, refDfoNew, fu1, fd1, fu2, fd2, 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;
- }
- private static bool HasMirror(double[] res)
- {
- if (res.Contains(999)) return false;
- return true;
- }
- private static void IsRange(double[] PosRes)
- {
- //var centerLon = ConfigurationManager.AppSettings["CenterLon"].To(144);
- //var centerLat = ConfigurationManager.AppSettings["CenterLat"].To(13);
- //var lonRange = ConfigurationManager.AppSettings["LonRange"].To(10);
- //var LatRange = ConfigurationManager.AppSettings["LatRange"].To(10);
- //var startLon = centerLon - lonRange / 2f;
- //var endLon = centerLon + lonRange / 2f;
- //var startLat = centerLat - LatRange / 2f;
- //var endLat = centerLat + LatRange / 2f;
- //double posLon = PosRes[0];
- //double posLat = PosRes[1];
- //double posHigth = PosRes[2];
- //if (posLon == 0 || posLon == 999)
- //{
- // return;
- //}
- //if (startLon > posLon || endLon < posLon || startLat > posLat || endLat < posLat)
- //{
- // PosRes[0] = PosRes[3];
- // PosRes[1] = PosRes[4];
- // PosRes[2] = PosRes[5];
- // PosRes[3] = posLon;
- // PosRes[4] = posLat;
- // PosRes[5] = posHigth;
- //}
- }
- private static double[] ConvertToGeoPoint(double[] res)
- {
- if (res == null || res.Length == 0)
- {
- return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
- }
- else if (res.Length != 3 && res.Length != 6)
- {
- throw new Exception("定位结果解析异常,长度不是3或6");
- }
- var list = res.Select(p => Math.Round(p, 4)).ToArray();
- if (list.Length == 3)
- {
- list = list.Concat(new double[4] { 999, 999, 0, -1 }).ToArray();
- }
- list[2] = list[5] = 0;//高度
- if (double.IsNaN(list[0]) || double.IsNaN(list[1]))
- {
- list[0] = list[1] = 999;
- }
- if (double.IsNaN(list[3]) || double.IsNaN(list[4]))
- {
- list[3] = list[4] = 999;
- }
- if (list[0] < -180 || list[0] > 180)
- {
- list[0] = list[1] = 999;
- }
- else if (list[1] < -90 || list[1] > 90)
- {
- list[0] = list[1] = 999;
- }
- if (list[3] < -180 || list[3] > 180)
- {
- list[3] = list[4] = 999;
- }
- else if (list[4] < -90 || list[4] > 90)
- {
- list[3] = list[4] = 999;
- }
- if (list.Length == 6)
- {
- var listNew = list.ToList();
- listNew.Add(-1);
- list = listNew.ToArray();
- }
- return list;
- }
- private static bool IsGeoPoint(double[] res)
- {
- if (res.Length != 3) return false;
- if (res[0] < -180 || res[0] > 180)
- {
- return false;
- }
- else if (res[1] < -90 || res[1] > 90)
- {
- return false;
- }
- return true;
- }
- private static bool IsGeoPoint2(double[] res)
- {
- if (res.Length < 3) return false;
- if (res[0] < -180 || res[0] > 180)
- {
- return false;
- }
- else if (res[1] < -90 || res[1] > 90)
- {
- return false;
- }
- return true;
- }
- }
- }
|