PosApi.cs 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.CompilerServices;
  5. using System.Runtime.InteropServices;
  6. using System.Security.Policy;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using XdCxRhDW.Entity;
  10. using XdCxRhDW.Framework;
  11. namespace XdCxRhDW.Api
  12. {
  13. /// <summary>
  14. ///TODO 定位算法接口.在这里调用罗博士的算法库
  15. /// </summary>
  16. public static class PosApi
  17. {
  18. //置信度统计次数
  19. private static int confidenceCount = 10000;
  20. //置信度有效距离(m)
  21. private static int confidenceDistance = 10000;
  22. #region cpp dll Interop
  23. //两星一地和三星解析定位算法(精度差、速度快,适用于置信度等统计时的多次调用)
  24. private const string gzPos = @"AddIns\定位\DLL_GZDW.dll";
  25. //一星一地测向带参定位
  26. private const string XDCX = @"AddIns\定位\DLL_DTO_DOA_DW.dll";
  27. //三星双时差带参、三星双时差无参、三星双频差带参、双星时频差带参、两星一地无参定位及时差线、一星两地
  28. private const string OtherPos = @"AddIns\定位\Position-New.dll";//DLL_11J_DW
  29. [DllImport(gzPos, EntryPoint = "DW_Analysis", CallingConvention = CallingConvention.Cdecl)]//两星一地和三星的解析定位算法(精度差、速度快)
  30. 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);
  31. [DllImport(XDCX, EntryPoint = "XD_CX_DW", CallingConvention = CallingConvention.Cdecl)]//一星一地测向带参
  32. 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);
  33. [DllImport(OtherPos, EntryPoint = "SC_2X1D_DW", CallingConvention = CallingConvention.Cdecl)]//两星一地带参
  34. private extern static void X2D1_Pos20240305_Core(double[] mainSat, double[] adjaSat, double[] cdbStation, double[] satStation1, double[] satStation2, double[] satStation3, double[] satStation4,
  35. double[] satStation5, double[] refStation, double[] zone, double tarSxDto, double tarXdDto, double samp_main_dto, double samp_neigh_dto, double[] res);
  36. [DllImport(OtherPos, EntryPoint = "XingDi_2X1D_DW_NoRef", CallingConvention = CallingConvention.Cdecl)]//两星一地无参
  37. private extern static void X2D1_PosNoRef20240305_Core(double[] mainSat, double[] adjaSat, double[] cdbStation, double[] mainSatTarStation, double[] adjaSat1TarStation, double[] adjaSat2TarStation
  38. , double[] zone, double tarSxDto, double tarXdDto, double[] res);
  39. [DllImport(OtherPos, EntryPoint = "SanXing_DW", CallingConvention = CallingConvention.Cdecl)]//三星双时差带参
  40. private extern static void X3_Pos20240305_Core(double[] mainSat, double[] adjaSat1, double[] adjaSat2, double[] mainSatTarStation, double[] adjaSat1TarStation, double[] adjaSat2TarStation
  41. , double[] mainSatRefStation, double[] adjaSat1RefStation, double[] adjaSat2RefStation, double[] refStation, double[] zone, double tarDto1, double tarDto2, double refDto1, double refDto2, double[] res);
  42. [DllImport(OtherPos, EntryPoint = "SanXing_DW_NoRef", CallingConvention = CallingConvention.Cdecl)]//三星双时差无参
  43. private extern static void X3_PosNoRef20240305_Core(double[] mainSat, double[] adjaSat1, double[] adjaSat2, double[] mainSatTarStation, double[] adjaSat1TarStation, double[] adjaSat2TarStation
  44. , double[] zone, double tarDto1, double tarDto2, double[] res);
  45. [DllImport(OtherPos, EntryPoint = "TriStar_2DFO_DW", CallingConvention = CallingConvention.Cdecl)]//三星双频差带参
  46. private extern static void X3_PosTwoDfo20240305_Core(double[] mainSat, double[] adjaSat1, double[] adjaSat2, double[] mainSatTarStation, double[] adjaSat1TarStation, double[] adjaSat2TarStation
  47. , double[] refStation, double[] zone, double tarDfo1, double tarDfo2, double refDfo1, double refDfo2, double fu1, double fd1, double fu2, double fd2, double[] res);
  48. [DllImport(OtherPos, EntryPoint = "TwoStar_DTFO_DW", CallingConvention = CallingConvention.Cdecl)]//双星时频差带参
  49. private extern static void X2_Pos20240305_Core(double[] mainSat, double[] adjaSat, double[] mainSatTarStation, double[] adjaSatTarStation, double[] refStation, double[] zone
  50. , double tarDto, double tarDfo, double refDto, double refDfo, double fu1, double fd1, double fu2, double fd2, double[] res);
  51. #endregion
  52. /// <summary>
  53. /// 一星一地带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  54. /// </summary>
  55. /// <param name="cgRes">参估结果</param>
  56. /// <param name="sRes">站点信息</param>
  57. /// <param name="cxRes">测向结果</param>
  58. /// <param name="CalcConfidence">是否计算置信度</param>
  59. /// <returns></returns>
  60. public static double[] X1D1_Pos(CgRes cgRes, StationRes sRes, CxRes cxRes, bool CalcConfidence = false)
  61. {
  62. if (cgRes.DtoCdb.Value == 0) return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  63. double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
  64. double[] satStation = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
  65. double[] cdbStation = new double[3] { sRes.CdbTxLon.Value, sRes.CdbTxLat.Value, 0 };
  66. double[] cxStation = new double[3] { sRes.CxLon.Value, sRes.CxLat.Value, 0 };
  67. double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
  68. double dtoCdb = cgRes.DtoCdb.Value / 1e6;
  69. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  70. double theta = cxRes.Fx;//单位°
  71. double[] res = new double[6];
  72. var ybDto1 = cgRes.YbMainDto.Value / 1e6;
  73. X1D1_Pos20240305_Core(mainSat, satStation, cdbStation, cxStation, refStation, zone, theta, dtoCdb, ybDto1, res);
  74. var posRes = ConvertToGeoPoint(res);
  75. if (CalcConfidence && IsGeoPoint2(posRes))
  76. {
  77. int succeedCount = 0;
  78. for (int i = 0; i < confidenceCount; i++)
  79. {
  80. var mainSatNew = new double[3]
  81. {
  82. cgRes.MainX.Value+RandomHelper.Normal(0,200),
  83. cgRes.MainY.Value+RandomHelper.Normal(0,200),
  84. cgRes.MainZ.Value+RandomHelper.Normal(0,200)
  85. };
  86. var dtoCdbNew = (dtoCdb * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
  87. var ybDtoNew = (ybDto1 * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
  88. var thetaNew = theta + RandomHelper.Normal(0, 0.4);//单位°
  89. X1D1_Pos20240305_Core(mainSatNew, satStation, cdbStation, cxStation, refStation, zone, thetaNew, dtoCdbNew, ybDtoNew, res);
  90. var posResNew = ConvertToGeoPoint(res);
  91. if (IsGeoPoint2(posResNew))
  92. {
  93. var distance = PhysicsHelper.DistanceGeo((posRes[0], posRes[1], 0), (posResNew[0], posResNew[1], 0));
  94. if (distance <= confidenceDistance)
  95. {
  96. succeedCount++;
  97. }
  98. }
  99. }
  100. posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
  101. }
  102. return posRes;
  103. }
  104. /// <summary>
  105. /// 两星一地带参解析定位(精度差速度快,主要用于置信度分析等需要多次调用的情况)
  106. /// </summary>
  107. /// <param name="cgRes"></param>
  108. /// <param name="sRes"></param>
  109. /// <returns></returns>
  110. public static double[] X2D1_GzPos(CgRes cgRes, StationRes sRes)
  111. {
  112. if (cgRes.Dto1.Value == 0 || cgRes.DtoCdb.Value == 0)
  113. {
  114. return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  115. }
  116. double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
  117. double[] adjaSat = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
  118. double[] cdbStation = new double[3] { sRes.CdbTxLon.Value, sRes.CdbTxLat.Value, 0 };
  119. double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
  120. double dto1 = cgRes.Dto1.Value / 1e6;
  121. double dtoCdb = cgRes.DtoCdb.Value / 1e6;
  122. double ybDto1 = cgRes.YbMainDto.Value / 1e6;
  123. double ybDto2 = cgRes.YbAdja1Dto.Value / 1e6;
  124. double ybDto = ybDto1 - ybDto2;
  125. double[] posRes = new double[3];
  126. DW_Analysis(mainSat, adjaSat, cdbStation, refStation, dto1, -dtoCdb, ybDto, -ybDto1, posRes, 1);
  127. return posRes;
  128. }
  129. /// <summary>
  130. /// 三星双时差带参解析定位(精度差速度快,主要用于置信度分析等需要多次调用的情况)
  131. /// </summary>
  132. /// <param name="cgRes"></param>
  133. /// <param name="sRes"></param>
  134. /// <returns></returns>
  135. public static double[] X3Dto_GzPos(CgRes cgRes, StationRes sRes)
  136. {
  137. if (cgRes.Dto1.Value == 0 || cgRes.Dto2.Value == 0)
  138. {
  139. return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  140. }
  141. double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
  142. double[] adja1Sat = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
  143. double[] adja2Sat = new double[3] { cgRes.Adja2X.Value, cgRes.Adja2Y.Value, cgRes.Adja2Z.Value };
  144. double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
  145. double dto1 = cgRes.Dto1.Value / 1e6;
  146. double dto2 = cgRes.Dto2.Value / 1e6;
  147. double ybDto1 = cgRes.YbMainDto.Value / 1e6;
  148. double ybDto2 = cgRes.YbAdja1Dto.Value / 1e6;
  149. double ybDto3 = cgRes.YbAdja2Dto.Value / 1e6;
  150. double refDto1 = ybDto1 - ybDto2;
  151. double refDto2 = ybDto1 - ybDto3;
  152. double[] posRes = new double[3];
  153. DW_Analysis(mainSat, adja1Sat, adja2Sat, refStation, dto1, dto2, refDto1, refDto2, posRes, 0);
  154. return posRes;
  155. }
  156. /// <summary>
  157. /// 两星一地带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  158. /// </summary>
  159. /// <param name="cgRes">参估结果</param>
  160. /// <param name="sRes">站点信息</param>
  161. /// <param name="CalcConfidence">是否计算置信度</param>
  162. /// <returns></returns>
  163. public static double[] X2D1_Pos(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
  164. {
  165. if (cgRes.Dto1.Value == 0 || cgRes.DtoCdb.Value == 0)
  166. {
  167. return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  168. }
  169. double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
  170. double[] adjaSat = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
  171. double[] satStation = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
  172. double[] cdbStation = new double[3] { sRes.CdbTxLon.Value, sRes.CdbTxLat.Value, 0 };
  173. double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
  174. double dto1 = cgRes.Dto1.Value / 1e6;
  175. double dtoCdb = cgRes.DtoCdb.Value / 1e6;
  176. double ybDto1 = cgRes.YbMainDto.Value / 1e6;
  177. double ybDto2 = cgRes.YbAdja1Dto.Value / 1e6;
  178. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  179. double[] res = new double[6];
  180. X2D1_Pos20240305_Core(mainSat, adjaSat, cdbStation, satStation, satStation, satStation, satStation, satStation, refStation, zone, dto1, dtoCdb, ybDto1, ybDto2, res);
  181. ConvertToGeoPoint(res);
  182. var posRes = ConvertToGeoPoint(res);//精确搜索值
  183. if (CalcConfidence && IsGeoPoint2(posRes))
  184. {
  185. var posResGz = X2D1_GzPos(cgRes, sRes);
  186. if (IsGeoPoint2(posResGz))
  187. {
  188. int succeedCount = 0;
  189. var cgResNew = cgRes.Clone();
  190. for (int i = 0; i < confidenceCount; i++)
  191. {
  192. cgResNew.MainX = cgRes.MainX + RandomHelper.Normal(0, 500);
  193. cgResNew.MainY = cgRes.MainY + RandomHelper.Normal(0, 500);
  194. cgResNew.MainZ = cgRes.MainZ + RandomHelper.Normal(0, 500);
  195. cgResNew.Adja1X = cgRes.Adja1X + RandomHelper.Normal(0, 500);
  196. cgResNew.Adja1Y = cgRes.Adja1Y + RandomHelper.Normal(0, 500);
  197. cgResNew.Adja1Z = cgRes.Adja1Z + RandomHelper.Normal(0, 500);
  198. cgResNew.Dto1 = (cgRes.Dto1 * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  199. cgResNew.DtoCdb = (cgRes.DtoCdb * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  200. cgResNew.YbMainDto = (cgRes.YbMainDto * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  201. cgResNew.YbAdja1Dto = (cgRes.YbAdja1Dto * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  202. res = X2D1_GzPos(cgResNew, sRes);
  203. var posResNew = ConvertToGeoPoint(res);
  204. if (IsGeoPoint2(posResNew))
  205. {
  206. var distance = PhysicsHelper.DistanceGeo((posResGz[0], posResGz[1], 0), (posResNew[0], posResNew[1], 0));
  207. if (distance <= confidenceDistance)
  208. {
  209. succeedCount++;
  210. }
  211. }
  212. }
  213. posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
  214. }
  215. else
  216. {
  217. posRes[6] = 0;
  218. }
  219. }
  220. return posRes;
  221. }
  222. /// <summary>
  223. /// 两星一地无参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  224. /// </summary>
  225. /// <param name="cgRes">参估结果</param>
  226. /// <param name="sRes">站点信息</param>
  227. /// <param name="CalcConfidence">是否计算置信度</param>
  228. /// <returns></returns>
  229. public static double[] X2D1_PosNoRef(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
  230. {
  231. if (cgRes.Dto1.Value == 0 || cgRes.DtoCdb.Value == 0)
  232. {
  233. return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  234. }
  235. double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
  236. double[] adjaSat = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
  237. double[] satStation = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
  238. double[] cdbStation = new double[3] { sRes.CdbTxLon.Value, sRes.CdbTxLat.Value, 0 };
  239. double dto1 = cgRes.Dto1.Value / 1e6;
  240. double dtoCdb = cgRes.DtoCdb.Value / 1e6;
  241. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  242. double[] res = new double[6];
  243. X2D1_PosNoRef20240305_Core(mainSat, adjaSat, cdbStation, satStation, satStation, satStation, zone, dto1, dtoCdb, res);
  244. ConvertToGeoPoint(res);
  245. var posRes = ConvertToGeoPoint(res);
  246. if (CalcConfidence && IsGeoPoint2(posRes))
  247. {
  248. int succeedCount = 0;
  249. for (int i = 0; i < confidenceCount; i++)
  250. {
  251. var mainSatNew = new double[3]
  252. {
  253. cgRes.MainX.Value+RandomHelper.Normal(0,200),
  254. cgRes.MainY.Value+RandomHelper.Normal(0,200),
  255. cgRes.MainZ.Value+RandomHelper.Normal(0,200)
  256. };
  257. var adjaSatNew = new double[3]
  258. {
  259. cgRes.Adja1X.Value+RandomHelper.Normal(0,200),
  260. cgRes.Adja1Y.Value+RandomHelper.Normal(0,200),
  261. cgRes.Adja1Z.Value+RandomHelper.Normal(0,200)
  262. };
  263. var dto1New = (dto1 * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
  264. var dtoCdbNew = (dtoCdb * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
  265. X2D1_PosNoRef20240305_Core(mainSatNew, adjaSatNew, cdbStation, satStation, satStation, satStation, zone, dto1New, dtoCdbNew, res);
  266. var posResNew = ConvertToGeoPoint(res);
  267. if (IsGeoPoint2(posResNew))
  268. {
  269. var distance = PhysicsHelper.DistanceGeo((posRes[0], posRes[1], 0), (posResNew[0], posResNew[1], 0));
  270. if (distance <= confidenceDistance)
  271. {
  272. succeedCount++;
  273. }
  274. }
  275. }
  276. posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
  277. }
  278. return posRes;
  279. }
  280. public static double[] X2D1_PosNoRef_ZL(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
  281. {
  282. if (cgRes.Dto1.Value == 0 || cgRes.DtoCdb.Value == 0)
  283. {
  284. return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  285. }
  286. double startLon = (int)sRes.CdbTxLon.Value - 20;
  287. double endLon = (int)sRes.CdbTxLon.Value + 20;
  288. double startLat = (int)sRes.CdbTxLat.Value - 20;
  289. double endLat = (int)sRes.CdbTxLat.Value + 20;
  290. List<(double, double, double, double)> list = new List<(double, double, double, double)>();
  291. var recXYZ = PhysicsHelper.GeoToEcef((sRes.SatTxLon, sRes.SatTxLat, 0));
  292. var cdbXYZ = PhysicsHelper.GeoToEcef((sRes.CdbTxLon.Value, sRes.CdbTxLat.Value, 0));
  293. for (double lon = startLon; lon < endLon; lon += 0.0001)
  294. {
  295. int flag = 0;
  296. for (double lat = startLat; lat < endLat; lat += 0.0001)
  297. {
  298. var posXYZ = PhysicsHelper.GeoToEcef((lon, lat, 0));
  299. //目标-主星-接收站的时间(us)
  300. var dt1 = PhysicsHelper.Dto(posXYZ, (cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value), recXYZ) * 1e6;
  301. //目标-超短站的时间(us)
  302. var dt3 = PhysicsHelper.Dto(posXYZ, cdbXYZ) * 1e6;
  303. var dto2 = Math.Abs(dt1 - dt3 - cgRes.DtoCdb.Value);
  304. if (dto2 > 100)
  305. {
  306. lat += 1;
  307. if (flag < 1)
  308. flag = 1;
  309. continue;
  310. }
  311. else if (dto2 > 50)
  312. {
  313. lat += 0.5;
  314. if (flag < 2)
  315. flag = 2;
  316. continue;
  317. }
  318. else if (dto2 > 20)
  319. {
  320. lat += 0.2;
  321. if (flag < 3)
  322. flag = 3;
  323. continue;
  324. }
  325. else if (dto2 > 5)
  326. {
  327. lat += 0.1;
  328. if (flag < 4)
  329. flag = 4;
  330. continue;
  331. }
  332. else if (dto2 > 2)
  333. {
  334. lat += 0.02;
  335. if (flag < 5)
  336. flag = 5;
  337. continue;
  338. }
  339. //目标-邻星-接收站的时间(us)
  340. var dt2 = PhysicsHelper.Dto(posXYZ, (cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value), recXYZ) * 1e6;
  341. var dto1 = Math.Abs(dt1 - dt2 - cgRes.Dto1.Value);
  342. if (dto1 > 100)
  343. {
  344. lat += 1;
  345. if (flag < 1)
  346. flag = 1;
  347. continue;
  348. }
  349. if (dto1 > 50)
  350. {
  351. lat += 0.5;
  352. if (flag < 2)
  353. flag = 2;
  354. continue;
  355. }
  356. else if (dto1 > 20)
  357. {
  358. lat += 0.2;
  359. if (flag < 3)
  360. flag = 3;
  361. continue;
  362. }
  363. else if (dto1 > 5)
  364. {
  365. lat += 0.1;
  366. if (flag < 4)
  367. flag = 4;
  368. continue;
  369. }
  370. else if (dto1 > 2)
  371. {
  372. lat += 0.02;
  373. if (flag < 5)
  374. flag = 5;
  375. continue;
  376. }
  377. list.Add((lon, lat, dto1, dto2));
  378. }
  379. if (flag == 1)
  380. lon += 1;
  381. else if (flag == 2)
  382. lon += 0.5;
  383. else if (flag == 3)
  384. lon += 0.2;
  385. else if (flag == 4)
  386. lon += 0.1;
  387. else if (flag == 5)
  388. lon += 0.02;
  389. }
  390. double[] res;
  391. var p1 = list.OrderBy(p => p.Item3 + p.Item4).FirstOrDefault();
  392. if (p1 == default)
  393. {
  394. res = new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  395. return res;
  396. }
  397. 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();
  398. if (p2 == default)
  399. res = new double[7] { p1.Item1, p1.Item2, 0, 999, 999, 0, -1 };
  400. else
  401. res = new double[7] { p1.Item1, p1.Item2, 0, p2.Item1, p2.Item2, 0, -1 };
  402. return res;
  403. }
  404. /// <summary>
  405. /// 融合定位带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  406. /// </summary>
  407. /// <param name="cgRes">参估结果</param>
  408. /// <param name="sRes">站点信息</param>
  409. /// <param name="cxRes">测向结果</param>
  410. /// <param name="CalcConfidence">是否计算置信度</param>
  411. /// <returns></returns>
  412. public static double[] RH_Pos(CgRes cgRes, StationRes sRes, CxRes cxRes, bool CalcConfidence = false)
  413. {
  414. var res1 = X1D1_Pos(cgRes, sRes, cxRes, CalcConfidence);
  415. var res2 = X2D1_Pos(cgRes, sRes, CalcConfidence);
  416. double[] res = new double[] { 999, 999, 0, 999, 999, 0, 100 };
  417. var p1 = res1.Take(3).ToArray();
  418. var p2 = res1.Skip(3).ToArray();
  419. var p3 = res2.Take(3).ToArray();
  420. var p4 = res2.Skip(3).ToArray();
  421. if (IsGeoPoint(p1) && IsGeoPoint(p2) && IsGeoPoint(p3) && IsGeoPoint(p4))
  422. {
  423. res = new double[7] {
  424. (p1[0] + p3[0]) / 2 + 0.003,
  425. (p1[1] + p3[1]) / 2 - 0.002,
  426. 0,
  427. (p2[0] + p4[0]) / 2 + 0.003,
  428. (p2[1] + p4[1]) / 2 - 0.002,
  429. 0,
  430. (res1[6]+res2[6])/2
  431. };
  432. }
  433. else if (IsGeoPoint(p1) && IsGeoPoint(p3))
  434. {
  435. res = new double[7] {
  436. (p1[0] + p3[0]) / 2 + 0.003,
  437. (p1[1] + p3[1]) / 2 - 0.002,
  438. 0,
  439. 999,
  440. 999,
  441. 0,
  442. (res1[6]+res2[6])/2
  443. };
  444. }
  445. else if (IsGeoPoint(p1) && IsGeoPoint(p2))
  446. {
  447. res = new double[7]
  448. {
  449. p1[0] + 0.003,
  450. p1[1] - 0.002,
  451. 0,
  452. p2[0] + 0.003,
  453. p2[1] - 0.002,
  454. 0,
  455. (res1[6]+res2[6])/2
  456. };
  457. }
  458. else if (IsGeoPoint(p3) && IsGeoPoint(p4))
  459. {
  460. res = new double[7]
  461. {
  462. p3[0] + 0.003,
  463. p3[1] - 0.002,
  464. 0,
  465. p4[0] + 0.003,
  466. p4[1] - 0.002,
  467. 0,
  468. (res1[6]+res2[6])/2
  469. };
  470. }
  471. return res;
  472. }
  473. /// <summary>
  474. /// 三星双时差带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  475. /// </summary>
  476. /// <param name="cgRes">参估结果</param>
  477. /// <param name="sRes">站点信息</param>
  478. /// <param name="CalcConfidence">是否计算置信度</param>
  479. /// <returns></returns>
  480. public static double[] X3_Pos(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
  481. {
  482. if (cgRes.Dto1.Value == 0 || cgRes.Dto2.Value == 0)
  483. {
  484. return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  485. }
  486. if (cgRes.Dto1.Value == 0 || cgRes.Dto2.Value == 0) return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  487. double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
  488. double[] adjaSat1 = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
  489. double[] adjaSat2 = new double[3] { cgRes.Adja2X.Value, cgRes.Adja2Y.Value, cgRes.Adja2Z.Value };
  490. double[] satStation = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
  491. double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
  492. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  493. var tarDto1 = cgRes.Dto1.Value / 1e6;
  494. var tarDto2 = cgRes.Dto2.Value / 1e6;
  495. var refDto1 = (cgRes.YbMainDto.Value - cgRes.YbAdja1Dto.Value) / 1e6;
  496. var refDto2 = (cgRes.YbMainDto.Value - cgRes.YbAdja2Dto.Value) / 1e6;
  497. double[] res = new double[6];
  498. X3_Pos20240305_Core(mainSat, adjaSat1, adjaSat2, satStation, satStation, satStation, satStation,
  499. satStation, satStation, refStation, zone, tarDto1, tarDto2, refDto1, refDto2, res);
  500. var posRes = ConvertToGeoPoint(res);//精确搜索值
  501. if (CalcConfidence && IsGeoPoint2(posRes))
  502. {
  503. var posResGz = X3Dto_GzPos(cgRes, sRes);
  504. if (IsGeoPoint2(posResGz))
  505. {
  506. int succeedCount = 0;
  507. var cgResNew = cgRes.Clone();
  508. for (int i = 0; i < confidenceCount; i++)
  509. {
  510. cgResNew.MainX = cgRes.MainX + RandomHelper.Normal(0, 500);
  511. cgResNew.MainY = cgRes.MainY + RandomHelper.Normal(0, 500);
  512. cgResNew.MainZ = cgRes.MainZ + RandomHelper.Normal(0, 500);
  513. cgResNew.Adja1X = cgRes.Adja1X + RandomHelper.Normal(0, 500);
  514. cgResNew.Adja1Y = cgRes.Adja1Y + RandomHelper.Normal(0, 500);
  515. cgResNew.Adja1Z = cgRes.Adja1Z + RandomHelper.Normal(0, 500);
  516. cgResNew.Adja2X = cgRes.Adja2X + RandomHelper.Normal(0, 500);
  517. cgResNew.Adja2Y = cgRes.Adja2Y + RandomHelper.Normal(0, 500);
  518. cgResNew.Adja2Z = cgRes.Adja2Z + RandomHelper.Normal(0, 500);
  519. cgResNew.Dto1 = (cgRes.Dto1 * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  520. cgResNew.Dto2 = (cgRes.Dto2 * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  521. cgResNew.YbMainDto = (cgRes.YbMainDto * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  522. cgResNew.YbAdja1Dto = (cgRes.YbAdja1Dto * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  523. cgResNew.YbAdja2Dto = (cgRes.YbAdja2Dto * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  524. res = X3Dto_GzPos(cgResNew, sRes);
  525. var posResNew = ConvertToGeoPoint(res);
  526. if (IsGeoPoint2(posResNew))
  527. {
  528. var distance = PhysicsHelper.DistanceGeo((posResGz[0], posResGz[1], 0), (posResNew[0], posResNew[1], 0));
  529. if (distance <= confidenceDistance)
  530. {
  531. succeedCount++;
  532. }
  533. }
  534. }
  535. posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
  536. }
  537. else
  538. {
  539. posRes[6] = 0;
  540. }
  541. }
  542. return posRes;
  543. }
  544. /// <summary>
  545. /// 三星双时差无参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  546. /// </summary>
  547. /// <param name="cgRes">参估结果</param>
  548. /// <param name="sRes">站点信息</param>
  549. /// <param name="CalcConfidence">是否计算置信度</param>
  550. /// <returns></returns>
  551. public static double[] X3_PosNoRef(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
  552. {
  553. if (cgRes.Dto1.Value == 0 || cgRes.Dto2.Value == 0)
  554. {
  555. return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  556. }
  557. double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
  558. double[] adjaSat1 = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
  559. double[] adjaSat2 = new double[3] { cgRes.Adja2X.Value, cgRes.Adja2Y.Value, cgRes.Adja2Z.Value };
  560. double[] satStation = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
  561. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  562. var tarDto1 = cgRes.Dto1.Value / 1e6;
  563. var tarDto2 = cgRes.Dto2.Value / 1e6;
  564. double[] res = new double[6];
  565. X3_PosNoRef20240305_Core(mainSat, adjaSat1, adjaSat2, satStation, satStation, satStation, zone, tarDto1, tarDto2, res);
  566. ConvertToGeoPoint(res);
  567. var posRes = ConvertToGeoPoint(res);
  568. if (CalcConfidence && IsGeoPoint2(posRes))
  569. {
  570. int succeedCount = 0;
  571. for (int i = 0; i < confidenceCount; i++)
  572. {
  573. var mainSatNew = new double[3]
  574. {
  575. cgRes.MainX.Value+RandomHelper.Normal(0,200),
  576. cgRes.MainY.Value+RandomHelper.Normal(0,200),
  577. cgRes.MainZ.Value+RandomHelper.Normal(0,200)
  578. };
  579. var adjaSat1New = new double[3]
  580. {
  581. cgRes.Adja1X.Value+RandomHelper.Normal(0,200),
  582. cgRes.Adja1Y.Value+RandomHelper.Normal(0,200),
  583. cgRes.Adja1Z.Value+RandomHelper.Normal(0,200)
  584. };
  585. var adjaSat2New = new double[3]
  586. {
  587. cgRes.Adja2X.Value+RandomHelper.Normal(0,200),
  588. cgRes.Adja2Y.Value+RandomHelper.Normal(0,200),
  589. cgRes.Adja2Z.Value+RandomHelper.Normal(0,200)
  590. };
  591. var tarDto1New = (tarDto1 * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
  592. var tarDto2New = (tarDto2 * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
  593. X3_PosNoRef20240305_Core(mainSatNew, adjaSat1New, adjaSat2New, satStation, satStation, satStation, zone, tarDto1New, tarDto2New, res);
  594. var posResNew = ConvertToGeoPoint(res);
  595. if (IsGeoPoint2(posResNew))
  596. {
  597. var distance = PhysicsHelper.DistanceGeo((posRes[0], posRes[1], 0), (posResNew[0], posResNew[1], 0));
  598. if (distance <= confidenceDistance)
  599. {
  600. succeedCount++;
  601. }
  602. }
  603. }
  604. posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
  605. }
  606. return posRes;
  607. }
  608. /// <summary>
  609. /// 三星双频差带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  610. /// </summary>
  611. /// <param name="cgRes">参估结果</param>
  612. /// <param name="sRes">站点信息</param>
  613. /// <param name="CalcConfidence">是否计算置信度</param>
  614. /// <returns></returns>
  615. public static double[] X3_PosTwoDfo(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
  616. {
  617. if (cgRes.Dfo1.Value == 0 || cgRes.Dfo2.Value == 0) return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  618. double[] mainSat = new double[6] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value, cgRes.MainVx.Value, cgRes.MainVy.Value, cgRes.MainVz.Value };
  619. double[] adjaSat1 = new double[6] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value, cgRes.Adja1Vx.Value, cgRes.Adja1Vy.Value, cgRes.Adja1Vz.Value };
  620. double[] adjaSat2 = new double[6] { cgRes.Adja2X.Value, cgRes.Adja2Y.Value, cgRes.Adja2Z.Value, cgRes.Adja2Vx.Value, cgRes.Adja2Vy.Value, cgRes.Adja2Vz.Value };
  621. double[] satStation = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
  622. double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
  623. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  624. var tarDfo1 = cgRes.Dfo1.Value;
  625. var tarDfo2 = cgRes.Dfo2.Value;
  626. var refDfo1 = cgRes.YbMainDfo.Value - cgRes.YbAdja1Dfo.Value;
  627. var refDfo2 = cgRes.YbMainDfo.Value - cgRes.YbAdja2Dfo.Value;
  628. double fu1 = cgRes.TarFreqUp.Value;
  629. double fd1 = cgRes.TarFreqDown.Value;
  630. double fu2 = cgRes.RefFreqUp.Value;
  631. double fd2 = cgRes.RefFreqDown.Value;
  632. double[] res = new double[6];
  633. X3_PosTwoDfo20240305_Core(mainSat, adjaSat1, adjaSat2, satStation, satStation, satStation,
  634. refStation, zone, tarDfo1, tarDfo2, refDfo1, refDfo2, fu1, fd1, fu2, fd2, res);
  635. ConvertToGeoPoint(res);
  636. var posRes = ConvertToGeoPoint(res);
  637. if (CalcConfidence && IsGeoPoint2(posRes))
  638. {
  639. int succeedCount = 0;
  640. for (int i = 0; i < confidenceCount; i++)
  641. {
  642. var mainSatNew = new double[3]
  643. {
  644. cgRes.MainX.Value+RandomHelper.Normal(0,200),
  645. cgRes.MainY.Value+RandomHelper.Normal(0,200),
  646. cgRes.MainZ.Value+RandomHelper.Normal(0,200)
  647. };
  648. var adjaSat1New = new double[3]
  649. {
  650. cgRes.Adja1X.Value+RandomHelper.Normal(0,200),
  651. cgRes.Adja1Y.Value+RandomHelper.Normal(0,200),
  652. cgRes.Adja1Z.Value+RandomHelper.Normal(0,200)
  653. };
  654. var adjaSat2New = new double[3]
  655. {
  656. cgRes.Adja2X.Value+RandomHelper.Normal(0,200),
  657. cgRes.Adja2Y.Value+RandomHelper.Normal(0,200),
  658. cgRes.Adja2Z.Value+RandomHelper.Normal(0,200)
  659. };
  660. var tarDfo1New = (tarDfo1 * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
  661. var tarDfo2New = (tarDfo2 * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
  662. var refDfo1New = (refDfo1 * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
  663. var refDfo2New = (refDfo2 * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
  664. X3_PosTwoDfo20240305_Core(mainSatNew, adjaSat1New, adjaSat2New, satStation, satStation, satStation, refStation, zone, tarDfo1New, tarDfo2New, refDfo1New, refDfo2New, fu1, fd1, fu2, fd2, res);
  665. var posResNew = ConvertToGeoPoint(res);
  666. if (IsGeoPoint2(posResNew))
  667. {
  668. var distance = PhysicsHelper.DistanceGeo((posRes[0], posRes[1], 0), (posResNew[0], posResNew[1], 0));
  669. if (distance <= confidenceDistance)
  670. {
  671. succeedCount++;
  672. }
  673. }
  674. }
  675. posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
  676. }
  677. return posRes;
  678. }
  679. /// <summary>
  680. /// 双星时频差带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  681. /// </summary>
  682. /// <param name="cgRes">参估结果</param>
  683. /// <param name="sRes">站点信息</param>
  684. /// <param name="CalcConfidence">是否计算置信度</param>
  685. /// <returns></returns>
  686. public static double[] X2_PosDtoDfo(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
  687. {
  688. if (cgRes.Dto1.Value == 0) return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  689. double[] mainSat = new double[6] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value, cgRes.MainVx.Value, cgRes.MainVy.Value, cgRes.MainVz.Value };
  690. double[] adjaSat = new double[6] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value, cgRes.Adja1Vx.Value, cgRes.Adja1Vy.Value, cgRes.Adja1Vz.Value };
  691. double[] satStation = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
  692. double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
  693. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  694. var tarDto = cgRes.Dto1.Value / 1e6;
  695. var tarDfo = cgRes.Dfo1.Value;
  696. var refDto = (cgRes.YbMainDto.Value - cgRes.YbAdja1Dto.Value) / 1e6;
  697. var refDfo = cgRes.YbMainDfo.Value - cgRes.YbAdja1Dfo.Value;
  698. double fu1 = cgRes.TarFreqUp.Value;
  699. double fd1 = cgRes.TarFreqDown.Value;
  700. double fu2 = cgRes.RefFreqUp.Value;
  701. double fd2 = cgRes.RefFreqDown.Value;
  702. double[] res = new double[6];
  703. X2_Pos20240305_Core(mainSat, adjaSat, satStation, satStation, refStation, zone, tarDto, tarDfo, refDto, refDfo, fu1, fd1, fu2, fd2, res);
  704. ConvertToGeoPoint(res);
  705. var posRes = ConvertToGeoPoint(res);
  706. if (CalcConfidence && IsGeoPoint2(posRes))
  707. {
  708. int succeedCount = 0;
  709. for (int i = 0; i < confidenceCount; i++)
  710. {
  711. var mainSatNew = new double[3]
  712. {
  713. cgRes.MainX.Value+RandomHelper.Normal(0,200),
  714. cgRes.MainY.Value+RandomHelper.Normal(0,200),
  715. cgRes.MainZ.Value+RandomHelper.Normal(0,200)
  716. };
  717. var adjaSatNew = new double[3]
  718. {
  719. cgRes.Adja1X.Value+RandomHelper.Normal(0,200),
  720. cgRes.Adja1Y.Value+RandomHelper.Normal(0,200),
  721. cgRes.Adja1Z.Value+RandomHelper.Normal(0,200)
  722. };
  723. var tarDtoNew = (tarDto * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
  724. var refDtoNew = (refDto * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
  725. var tarDfoNew = (tarDfo * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
  726. var refDfoNew = (refDfo * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
  727. X2_Pos20240305_Core(mainSatNew, adjaSatNew, satStation, satStation, refStation, zone, tarDtoNew, tarDfoNew, refDtoNew, refDfoNew, fu1, fd1, fu2, fd2, res);
  728. var posResNew = ConvertToGeoPoint(res);
  729. if (IsGeoPoint2(posResNew))
  730. {
  731. var distance = PhysicsHelper.DistanceGeo((posRes[0], posRes[1], 0), (posResNew[0], posResNew[1], 0));
  732. if (distance <= confidenceDistance)
  733. {
  734. succeedCount++;
  735. }
  736. }
  737. }
  738. posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
  739. }
  740. return posRes;
  741. }
  742. private static double[] ConvertToGeoPoint(double[] res)
  743. {
  744. if (res == null || res.Length == 0)
  745. {
  746. return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  747. }
  748. else if (res.Length != 3 && res.Length != 6)
  749. {
  750. throw new Exception("定位结果解析异常,长度不是3或6");
  751. }
  752. var list = res.Select(p => Math.Round(p, 4)).ToArray();
  753. if (list.Length == 3)
  754. {
  755. list = list.Concat(new double[4] { 999, 999, 0, -1 }).ToArray();
  756. }
  757. list[2] = list[5] = 0;//高度
  758. if (double.IsNaN(list[0]) || double.IsNaN(list[1]))
  759. {
  760. list[0] = list[1] = 999;
  761. }
  762. if (double.IsNaN(list[3]) || double.IsNaN(list[4]))
  763. {
  764. list[3] = list[4] = 999;
  765. }
  766. if (list[0] < -180 || list[0] > 180)
  767. {
  768. list[0] = list[1] = 999;
  769. }
  770. else if (list[1] < -90 || list[1] > 90)
  771. {
  772. list[0] = list[1] = 999;
  773. }
  774. if (list[3] < -180 || list[3] > 180)
  775. {
  776. list[3] = list[4] = 999;
  777. }
  778. else if (list[4] < -90 || list[4] > 90)
  779. {
  780. list[3] = list[4] = 999;
  781. }
  782. if (list.Length == 6)
  783. {
  784. var listNew = list.ToList();
  785. listNew.Add(-1);
  786. list = listNew.ToArray();
  787. }
  788. return list;
  789. }
  790. private static bool IsGeoPoint(double[] res)
  791. {
  792. if (res.Length != 3) return false;
  793. if (res[0] < -180 || res[0] > 180)
  794. {
  795. return false;
  796. }
  797. else if (res[1] < -90 || res[1] > 90)
  798. {
  799. return false;
  800. }
  801. return true;
  802. }
  803. private static bool IsGeoPoint2(double[] res)
  804. {
  805. if (res.Length < 3) return false;
  806. if (res[0] < -180 || res[0] > 180)
  807. {
  808. return false;
  809. }
  810. else if (res[1] < -90 || res[1] > 90)
  811. {
  812. return false;
  813. }
  814. return true;
  815. }
  816. }
  817. }