PosApi.cs 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  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. res = new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  394. 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();
  395. if (p2 == default)
  396. res = new double[7] { p1.Item1, p1.Item2, 0, 999, 999, 0, -1 };
  397. else
  398. res = new double[7] { p1.Item1, p1.Item2, 0, p2.Item1, p2.Item2, 0, -1 };
  399. return res;
  400. }
  401. /// <summary>
  402. /// 融合定位带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  403. /// </summary>
  404. /// <param name="cgRes">参估结果</param>
  405. /// <param name="sRes">站点信息</param>
  406. /// <param name="cxRes">测向结果</param>
  407. /// <param name="CalcConfidence">是否计算置信度</param>
  408. /// <returns></returns>
  409. public static double[] RH_Pos(CgRes cgRes, StationRes sRes, CxRes cxRes, bool CalcConfidence = false)
  410. {
  411. var res1 = X1D1_Pos(cgRes, sRes, cxRes, CalcConfidence);
  412. var res2 = X2D1_Pos(cgRes, sRes, CalcConfidence);
  413. double[] res = new double[] { 999, 999, 0, 999, 999, 0, 100 };
  414. var p1 = res1.Take(3).ToArray();
  415. var p2 = res1.Skip(3).ToArray();
  416. var p3 = res2.Take(3).ToArray();
  417. var p4 = res2.Skip(3).ToArray();
  418. if (IsGeoPoint(p1) && IsGeoPoint(p2) && IsGeoPoint(p3) && IsGeoPoint(p4))
  419. {
  420. res = new double[7] {
  421. (p1[0] + p3[0]) / 2 + 0.003,
  422. (p1[1] + p3[1]) / 2 - 0.002,
  423. 0,
  424. (p2[0] + p4[0]) / 2 + 0.003,
  425. (p2[1] + p4[1]) / 2 - 0.002,
  426. 0,
  427. (res1[6]+res2[6])/2
  428. };
  429. }
  430. else if (IsGeoPoint(p1) && IsGeoPoint(p3))
  431. {
  432. res = new double[7] {
  433. (p1[0] + p3[0]) / 2 + 0.003,
  434. (p1[1] + p3[1]) / 2 - 0.002,
  435. 0,
  436. 999,
  437. 999,
  438. 0,
  439. (res1[6]+res2[6])/2
  440. };
  441. }
  442. else if (IsGeoPoint(p1) && IsGeoPoint(p2))
  443. {
  444. res = new double[7]
  445. {
  446. p1[0] + 0.003,
  447. p1[1] - 0.002,
  448. 0,
  449. p2[0] + 0.003,
  450. p2[1] - 0.002,
  451. 0,
  452. (res1[6]+res2[6])/2
  453. };
  454. }
  455. else if (IsGeoPoint(p3) && IsGeoPoint(p4))
  456. {
  457. res = new double[7]
  458. {
  459. p3[0] + 0.003,
  460. p3[1] - 0.002,
  461. 0,
  462. p4[0] + 0.003,
  463. p4[1] - 0.002,
  464. 0,
  465. (res1[6]+res2[6])/2
  466. };
  467. }
  468. return res;
  469. }
  470. /// <summary>
  471. /// 三星双时差带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  472. /// </summary>
  473. /// <param name="cgRes">参估结果</param>
  474. /// <param name="sRes">站点信息</param>
  475. /// <param name="CalcConfidence">是否计算置信度</param>
  476. /// <returns></returns>
  477. public static double[] X3_Pos(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
  478. {
  479. if (cgRes.Dto1.Value == 0 || cgRes.Dto2.Value == 0)
  480. {
  481. return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  482. }
  483. if (cgRes.Dto1.Value == 0 || cgRes.Dto2.Value == 0) return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  484. double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
  485. double[] adjaSat1 = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
  486. double[] adjaSat2 = new double[3] { cgRes.Adja2X.Value, cgRes.Adja2Y.Value, cgRes.Adja2Z.Value };
  487. double[] satStation = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
  488. double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
  489. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  490. var tarDto1 = cgRes.Dto1.Value / 1e6;
  491. var tarDto2 = cgRes.Dto2.Value / 1e6;
  492. var refDto1 = (cgRes.YbMainDto.Value - cgRes.YbAdja1Dto.Value) / 1e6;
  493. var refDto2 = (cgRes.YbMainDto.Value - cgRes.YbAdja2Dto.Value) / 1e6;
  494. double[] res = new double[6];
  495. X3_Pos20240305_Core(mainSat, adjaSat1, adjaSat2, satStation, satStation, satStation, satStation,
  496. satStation, satStation, refStation, zone, tarDto1, tarDto2, refDto1, refDto2, res);
  497. var posRes = ConvertToGeoPoint(res);//精确搜索值
  498. if (CalcConfidence && IsGeoPoint2(posRes))
  499. {
  500. var posResGz = X3Dto_GzPos(cgRes, sRes);
  501. if (IsGeoPoint2(posResGz))
  502. {
  503. int succeedCount = 0;
  504. var cgResNew = cgRes.Clone();
  505. for (int i = 0; i < confidenceCount; i++)
  506. {
  507. cgResNew.MainX = cgRes.MainX + RandomHelper.Normal(0, 500);
  508. cgResNew.MainY = cgRes.MainY + RandomHelper.Normal(0, 500);
  509. cgResNew.MainZ = cgRes.MainZ + RandomHelper.Normal(0, 500);
  510. cgResNew.Adja1X = cgRes.Adja1X + RandomHelper.Normal(0, 500);
  511. cgResNew.Adja1Y = cgRes.Adja1Y + RandomHelper.Normal(0, 500);
  512. cgResNew.Adja1Z = cgRes.Adja1Z + RandomHelper.Normal(0, 500);
  513. cgResNew.Adja2X = cgRes.Adja2X + RandomHelper.Normal(0, 500);
  514. cgResNew.Adja2Y = cgRes.Adja2Y + RandomHelper.Normal(0, 500);
  515. cgResNew.Adja2Z = cgRes.Adja2Z + RandomHelper.Normal(0, 500);
  516. cgResNew.Dto1 = (cgRes.Dto1 * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  517. cgResNew.Dto2 = (cgRes.Dto2 * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  518. cgResNew.YbMainDto = (cgRes.YbMainDto * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  519. cgResNew.YbAdja1Dto = (cgRes.YbAdja1Dto * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  520. cgResNew.YbAdja2Dto = (cgRes.YbAdja2Dto * 1e6 + RandomHelper.Normal(0, 4)) / 1e6;
  521. res = X3Dto_GzPos(cgResNew, sRes);
  522. var posResNew = ConvertToGeoPoint(res);
  523. if (IsGeoPoint2(posResNew))
  524. {
  525. var distance = PhysicsHelper.DistanceGeo((posResGz[0], posResGz[1], 0), (posResNew[0], posResNew[1], 0));
  526. if (distance <= confidenceDistance)
  527. {
  528. succeedCount++;
  529. }
  530. }
  531. }
  532. posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
  533. }
  534. else
  535. {
  536. posRes[6] = 0;
  537. }
  538. }
  539. return posRes;
  540. }
  541. /// <summary>
  542. /// 三星双时差无参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  543. /// </summary>
  544. /// <param name="cgRes">参估结果</param>
  545. /// <param name="sRes">站点信息</param>
  546. /// <param name="CalcConfidence">是否计算置信度</param>
  547. /// <returns></returns>
  548. public static double[] X3_PosNoRef(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
  549. {
  550. if (cgRes.Dto1.Value == 0 || cgRes.Dto2.Value == 0)
  551. {
  552. return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  553. }
  554. double[] mainSat = new double[3] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value };
  555. double[] adjaSat1 = new double[3] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value };
  556. double[] adjaSat2 = new double[3] { cgRes.Adja2X.Value, cgRes.Adja2Y.Value, cgRes.Adja2Z.Value };
  557. double[] satStation = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
  558. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  559. var tarDto1 = cgRes.Dto1.Value / 1e6;
  560. var tarDto2 = cgRes.Dto2.Value / 1e6;
  561. double[] res = new double[6];
  562. X3_PosNoRef20240305_Core(mainSat, adjaSat1, adjaSat2, satStation, satStation, satStation, zone, tarDto1, tarDto2, res);
  563. ConvertToGeoPoint(res);
  564. var posRes = ConvertToGeoPoint(res);
  565. if (CalcConfidence && IsGeoPoint2(posRes))
  566. {
  567. int succeedCount = 0;
  568. for (int i = 0; i < confidenceCount; i++)
  569. {
  570. var mainSatNew = new double[3]
  571. {
  572. cgRes.MainX.Value+RandomHelper.Normal(0,200),
  573. cgRes.MainY.Value+RandomHelper.Normal(0,200),
  574. cgRes.MainZ.Value+RandomHelper.Normal(0,200)
  575. };
  576. var adjaSat1New = new double[3]
  577. {
  578. cgRes.Adja1X.Value+RandomHelper.Normal(0,200),
  579. cgRes.Adja1Y.Value+RandomHelper.Normal(0,200),
  580. cgRes.Adja1Z.Value+RandomHelper.Normal(0,200)
  581. };
  582. var adjaSat2New = new double[3]
  583. {
  584. cgRes.Adja2X.Value+RandomHelper.Normal(0,200),
  585. cgRes.Adja2Y.Value+RandomHelper.Normal(0,200),
  586. cgRes.Adja2Z.Value+RandomHelper.Normal(0,200)
  587. };
  588. var tarDto1New = (tarDto1 * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
  589. var tarDto2New = (tarDto2 * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
  590. X3_PosNoRef20240305_Core(mainSatNew, adjaSat1New, adjaSat2New, satStation, satStation, satStation, zone, tarDto1New, tarDto2New, res);
  591. var posResNew = ConvertToGeoPoint(res);
  592. if (IsGeoPoint2(posResNew))
  593. {
  594. var distance = PhysicsHelper.DistanceGeo((posRes[0], posRes[1], 0), (posResNew[0], posResNew[1], 0));
  595. if (distance <= confidenceDistance)
  596. {
  597. succeedCount++;
  598. }
  599. }
  600. }
  601. posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
  602. }
  603. return posRes;
  604. }
  605. /// <summary>
  606. /// 三星双频差带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  607. /// </summary>
  608. /// <param name="cgRes">参估结果</param>
  609. /// <param name="sRes">站点信息</param>
  610. /// <param name="CalcConfidence">是否计算置信度</param>
  611. /// <returns></returns>
  612. public static double[] X3_PosTwoDfo(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
  613. {
  614. if (cgRes.Dfo1.Value == 0 || cgRes.Dfo2.Value == 0) return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  615. double[] mainSat = new double[6] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value, cgRes.MainVx.Value, cgRes.MainVy.Value, cgRes.MainVz.Value };
  616. double[] adjaSat1 = new double[6] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value, cgRes.Adja1Vx.Value, cgRes.Adja1Vy.Value, cgRes.Adja1Vz.Value };
  617. double[] adjaSat2 = new double[6] { cgRes.Adja2X.Value, cgRes.Adja2Y.Value, cgRes.Adja2Z.Value, cgRes.Adja2Vx.Value, cgRes.Adja2Vy.Value, cgRes.Adja2Vz.Value };
  618. double[] satStation = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
  619. double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
  620. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  621. var tarDfo1 = cgRes.Dfo1.Value;
  622. var tarDfo2 = cgRes.Dfo2.Value;
  623. var refDfo1 = cgRes.YbMainDfo.Value - cgRes.YbAdja1Dfo.Value;
  624. var refDfo2 = cgRes.YbMainDfo.Value - cgRes.YbAdja2Dfo.Value;
  625. double fu1 = cgRes.TarFreqUp.Value;
  626. double fd1 = cgRes.TarFreqDown.Value;
  627. double fu2 = cgRes.RefFreqUp.Value;
  628. double fd2 = cgRes.RefFreqDown.Value;
  629. double[] res = new double[6];
  630. X3_PosTwoDfo20240305_Core(mainSat, adjaSat1, adjaSat2, satStation, satStation, satStation,
  631. refStation, zone, tarDfo1, tarDfo2, refDfo1, refDfo2, fu1, fd1, fu2, fd2, res);
  632. ConvertToGeoPoint(res);
  633. var posRes = ConvertToGeoPoint(res);
  634. if (CalcConfidence && IsGeoPoint2(posRes))
  635. {
  636. int succeedCount = 0;
  637. for (int i = 0; i < confidenceCount; i++)
  638. {
  639. var mainSatNew = new double[3]
  640. {
  641. cgRes.MainX.Value+RandomHelper.Normal(0,200),
  642. cgRes.MainY.Value+RandomHelper.Normal(0,200),
  643. cgRes.MainZ.Value+RandomHelper.Normal(0,200)
  644. };
  645. var adjaSat1New = new double[3]
  646. {
  647. cgRes.Adja1X.Value+RandomHelper.Normal(0,200),
  648. cgRes.Adja1Y.Value+RandomHelper.Normal(0,200),
  649. cgRes.Adja1Z.Value+RandomHelper.Normal(0,200)
  650. };
  651. var adjaSat2New = new double[3]
  652. {
  653. cgRes.Adja2X.Value+RandomHelper.Normal(0,200),
  654. cgRes.Adja2Y.Value+RandomHelper.Normal(0,200),
  655. cgRes.Adja2Z.Value+RandomHelper.Normal(0,200)
  656. };
  657. var tarDfo1New = (tarDfo1 * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
  658. var tarDfo2New = (tarDfo2 * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
  659. var refDfo1New = (refDfo1 * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
  660. var refDfo2New = (refDfo2 * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
  661. X3_PosTwoDfo20240305_Core(mainSatNew, adjaSat1New, adjaSat2New, satStation, satStation, satStation, refStation, zone, tarDfo1New, tarDfo2New, refDfo1New, refDfo2New, fu1, fd1, fu2, fd2, res);
  662. var posResNew = ConvertToGeoPoint(res);
  663. if (IsGeoPoint2(posResNew))
  664. {
  665. var distance = PhysicsHelper.DistanceGeo((posRes[0], posRes[1], 0), (posResNew[0], posResNew[1], 0));
  666. if (distance <= confidenceDistance)
  667. {
  668. succeedCount++;
  669. }
  670. }
  671. }
  672. posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
  673. }
  674. return posRes;
  675. }
  676. /// <summary>
  677. /// 双星时频差带参,返回经度、纬度、高度、镜像点、置信度,数组长度为7
  678. /// </summary>
  679. /// <param name="cgRes">参估结果</param>
  680. /// <param name="sRes">站点信息</param>
  681. /// <param name="CalcConfidence">是否计算置信度</param>
  682. /// <returns></returns>
  683. public static double[] X2_PosDtoDfo(CgRes cgRes, StationRes sRes, bool CalcConfidence = false)
  684. {
  685. if (cgRes.Dto1.Value == 0) return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  686. double[] mainSat = new double[6] { cgRes.MainX.Value, cgRes.MainY.Value, cgRes.MainZ.Value, cgRes.MainVx.Value, cgRes.MainVy.Value, cgRes.MainVz.Value };
  687. double[] adjaSat = new double[6] { cgRes.Adja1X.Value, cgRes.Adja1Y.Value, cgRes.Adja1Z.Value, cgRes.Adja1Vx.Value, cgRes.Adja1Vy.Value, cgRes.Adja1Vz.Value };
  688. double[] satStation = new double[3] { sRes.SatTxLon, sRes.SatTxLat, 0 };
  689. double[] refStation = new double[3] { sRes.RefLon.Value, sRes.RefLat.Value, 0 };
  690. double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域
  691. var tarDto = cgRes.Dto1.Value / 1e6;
  692. var tarDfo = cgRes.Dfo1.Value;
  693. var refDto = (cgRes.YbMainDto.Value - cgRes.YbAdja1Dto.Value) / 1e6;
  694. var refDfo = cgRes.YbMainDfo.Value - cgRes.YbAdja1Dfo.Value;
  695. double fu1 = cgRes.TarFreqUp.Value;
  696. double fd1 = cgRes.TarFreqDown.Value;
  697. double fu2 = cgRes.RefFreqUp.Value;
  698. double fd2 = cgRes.RefFreqDown.Value;
  699. double[] res = new double[6];
  700. X2_Pos20240305_Core(mainSat, adjaSat, satStation, satStation, refStation, zone, tarDto, tarDfo, refDto, refDfo, fu1, fd1, fu2, fd2, res);
  701. ConvertToGeoPoint(res);
  702. var posRes = ConvertToGeoPoint(res);
  703. if (CalcConfidence && IsGeoPoint2(posRes))
  704. {
  705. int succeedCount = 0;
  706. for (int i = 0; i < confidenceCount; i++)
  707. {
  708. var mainSatNew = new double[3]
  709. {
  710. cgRes.MainX.Value+RandomHelper.Normal(0,200),
  711. cgRes.MainY.Value+RandomHelper.Normal(0,200),
  712. cgRes.MainZ.Value+RandomHelper.Normal(0,200)
  713. };
  714. var adjaSatNew = new double[3]
  715. {
  716. cgRes.Adja1X.Value+RandomHelper.Normal(0,200),
  717. cgRes.Adja1Y.Value+RandomHelper.Normal(0,200),
  718. cgRes.Adja1Z.Value+RandomHelper.Normal(0,200)
  719. };
  720. var tarDtoNew = (tarDto * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
  721. var refDtoNew = (refDto * 1e6 + RandomHelper.Normal(0, 1)) / 1e6;
  722. var tarDfoNew = (tarDfo * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
  723. var refDfoNew = (refDfo * 1e6 + RandomHelper.Normal(0, 5)) / 1e6;
  724. X2_Pos20240305_Core(mainSatNew, adjaSatNew, satStation, satStation, refStation, zone, tarDtoNew, tarDfoNew, refDtoNew, refDfoNew, fu1, fd1, fu2, fd2, res);
  725. var posResNew = ConvertToGeoPoint(res);
  726. if (IsGeoPoint2(posResNew))
  727. {
  728. var distance = PhysicsHelper.DistanceGeo((posRes[0], posRes[1], 0), (posResNew[0], posResNew[1], 0));
  729. if (distance <= confidenceDistance)
  730. {
  731. succeedCount++;
  732. }
  733. }
  734. }
  735. posRes[6] = (int)(succeedCount / (double)confidenceCount * 100);
  736. }
  737. return posRes;
  738. }
  739. private static double[] ConvertToGeoPoint(double[] res)
  740. {
  741. if (res == null || res.Length == 0)
  742. {
  743. return new double[7] { 999, 999, 0, 999, 999, 0, -1 };
  744. }
  745. else if (res.Length != 3 && res.Length != 6)
  746. {
  747. throw new Exception("定位结果解析异常,长度不是3或6");
  748. }
  749. var list = res.Select(p => Math.Round(p, 4)).ToArray();
  750. if (list.Length == 3)
  751. {
  752. list = list.Concat(new double[4] { 999, 999, 0, -1 }).ToArray();
  753. }
  754. list[2] = list[5] = 0;//高度
  755. if (double.IsNaN(list[0]) || double.IsNaN(list[1]))
  756. {
  757. list[0] = list[1] = 999;
  758. }
  759. if (double.IsNaN(list[3]) || double.IsNaN(list[4]))
  760. {
  761. list[3] = list[4] = 999;
  762. }
  763. if (list[0] < -180 || list[0] > 180)
  764. {
  765. list[0] = list[1] = 999;
  766. }
  767. else if (list[1] < -90 || list[1] > 90)
  768. {
  769. list[0] = list[1] = 999;
  770. }
  771. if (list[3] < -180 || list[3] > 180)
  772. {
  773. list[3] = list[4] = 999;
  774. }
  775. else if (list[4] < -90 || list[4] > 90)
  776. {
  777. list[3] = list[4] = 999;
  778. }
  779. if (list.Length == 6)
  780. {
  781. var listNew = list.ToList();
  782. listNew.Add(-1);
  783. list = listNew.ToArray();
  784. }
  785. return list;
  786. }
  787. private static bool IsGeoPoint(double[] res)
  788. {
  789. if (res.Length != 3) return false;
  790. if (res[0] < -180 || res[0] > 180)
  791. {
  792. return false;
  793. }
  794. else if (res[1] < -90 || res[1] > 90)
  795. {
  796. return false;
  797. }
  798. return true;
  799. }
  800. private static bool IsGeoPoint2(double[] res)
  801. {
  802. if (res.Length < 3) return false;
  803. if (res[0] < -180 || res[0] > 180)
  804. {
  805. return false;
  806. }
  807. else if (res[1] < -90 || res[1] > 90)
  808. {
  809. return false;
  810. }
  811. return true;
  812. }
  813. }
  814. }