EquationHelper.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. using BHJD.DEMdll.Entity;
  2. using BHJD.DEMdll.Public;
  3. using System.Diagnostics;
  4. using static BHJD.DEMdll.Public.IHttpHelper;
  5. using Unity.Mathematics;
  6. using Newtonsoft.Json;
  7. using Newtonsoft.Json.Linq;
  8. using SJ;
  9. using Model;
  10. using MathNet.Numerics;
  11. namespace MuShiApp
  12. {
  13. public class EquationHelper
  14. {
  15. //数据库访问类,dll有
  16. //IDbHelper _db = null;
  17. //http请求类,dll有
  18. IHttpHelper m_HttpHelper = null;
  19. public string baseUrl;
  20. public double x;
  21. public EquationHelper(string baseUrl)
  22. {
  23. this.baseUrl = baseUrl;
  24. m_HttpHelper = new HttpHelper();
  25. //this._db = db;
  26. //m_HttpHelper = Factory.Load();
  27. }
  28. //a、b、c、d、r、e均为修正系数
  29. double[] a = { 9.5128, 1.3738, 0.0875 };
  30. double[] b = { -49.6937, -13.2945, -2.5112 };
  31. double[] c = { 31.6031, 13.1456, 6.1604 };
  32. double[] d = { 95.0664, 97.0952, 94.9145 };
  33. double[][] r = new double[3][];
  34. double[][] e = new double[3][];
  35. double[] posibility = { 0, 0, 0 };
  36. public double GetMushiSeaProbability(double3 aircraftPoint, double visibility, double wavehigh, TargetPoint targetPoint)
  37. {
  38. r[0] = new double[] { 4.375, 1.18, 1.01, 1 };
  39. r[1] = new double[] { 2.85, 1.51, 1.18, 1 };
  40. r[2] = new double[] { 2.75, 2.1, 1.2, 1 };
  41. e[0] = new double[] { -10, -30, -50, -65, -80, -90 };
  42. e[1] = new double[] { -2, -15, -30, -50, -70, -80 };
  43. e[2] = new double[] { 0, 0, -10, -20, -30, -40 };
  44. double[] posibility = { 0, 0, 0 };
  45. var distance = GetDistance(aircraftPoint.x, targetPoint.TargetPointLongitude,aircraftPoint.y,targetPoint.TargetPointLatitude);
  46. if (distance >= 0 && distance < 2)
  47. {
  48. posibility = MuShiModel.GetPosibilityClear(distance, a, b, c, d, r, e, visibility, wavehigh);
  49. while (posibility[0] <= 0 || posibility[1] <= 0 || posibility[2] <= 0)
  50. {
  51. distance += 0.1;
  52. posibility = MuShiModel.GetPosibilityClear(distance, a, b, c, d, r, e, visibility, wavehigh);
  53. }
  54. }
  55. if (distance >= 2)
  56. {
  57. posibility = MuShiModel.GetPosibilityFar(distance, a, b, c, d);
  58. while (posibility[0] <= 0 || posibility[1] <= 0 || posibility[2] <= 0)
  59. {
  60. distance += 0.5;
  61. posibility = MuShiModel.GetPosibilityFar(distance, a, b, c, d);
  62. }
  63. if (distance > 3.5)
  64. {
  65. posibility[0] = 0;
  66. }
  67. if (distance > 5)
  68. {
  69. posibility[1] = 0;
  70. }
  71. if (distance > 10)
  72. {
  73. posibility[2] = 0;
  74. }
  75. }
  76. return posibility[GetType(targetPoint.TargetType.Type)];
  77. }
  78. public double GetMushiLandProbability(double3 aircraftPoint, double visibility, TargetPoint targetPoint)
  79. {
  80. r[0] = new double[] { 4.375, 1.18, 1.01, 1 };
  81. r[1] = new double[] { 2.85, 1.51, 1.18, 1 };
  82. r[2] = new double[] { 2.75, 2.1, 1.2, 1 };
  83. e[0] = new double[] { 0, -30, -50, -65, -80, -90 };
  84. e[1] = new double[] { 0, -15, -30, -50, -70, -80 };
  85. e[2] = new double[] { 0, 0, -10, -20, -30, -40 };
  86. double[] posibility = { 0, 0, 0 };
  87. var distance = GetDistance(aircraftPoint.x, targetPoint.TargetPointLongitude,aircraftPoint.y,targetPoint.TargetPointLatitude);
  88. if (distance >= 0 && distance < 2)
  89. {
  90. posibility = MuShiModel.GetPosibilityClear(distance, a, b, c, d, r, e, visibility, 0);
  91. while (posibility[0] <= 0 || posibility[1] <= 0 || posibility[2] <= 0)
  92. {
  93. distance += 0.1;
  94. posibility = MuShiModel.GetPosibilityClear(distance, a, b, c, d, r, e, visibility, 0);
  95. }
  96. }
  97. if (distance >= 2)
  98. {
  99. posibility = MuShiModel.GetPosibilityFar(distance, a, b, c, d);
  100. while (posibility[0] <= 0 || posibility[1] <= 0 || posibility[2] <= 0)
  101. {
  102. distance += 0.5;
  103. posibility = MuShiModel.GetPosibilityFar(distance, a, b, c, d);
  104. }
  105. if (distance > 3.5)
  106. {
  107. posibility[0] = 0;
  108. }
  109. if (distance > 5)
  110. {
  111. posibility[1] = 0;
  112. }
  113. if (distance > 10)
  114. {
  115. posibility[2] = 0;
  116. }
  117. }
  118. return posibility[GetType(targetPoint.TargetType.Type)];
  119. }
  120. // Pd0 = 0.5 / Pf0 = Math.Pow(10,-6) / Pf = Math.Pow(10,-6) / R0 = 23645 / sigma0 = 5000 / sigma = Editor雷达截面面积 // R 单位m
  121. public double GetRadarPossibility(double Pd0, double Pf0, double Pf, double R0, double3 aircraftPoint , TargetPoint targetPoint, double sigma, double sigma0, double visibility)
  122. {
  123. var distance = GetDistance(aircraftPoint.x, targetPoint.TargetPointLongitude, aircraftPoint.y, targetPoint.TargetPointLatitude);
  124. double R = 1000 * distance;
  125. //修正系数
  126. double RadarC = 1;
  127. //能见度单位:km
  128. if (visibility >= 1)
  129. {
  130. RadarC = 1;
  131. }
  132. else if (visibility >= 0.3 && visibility < 1)
  133. {
  134. RadarC = 0.8;
  135. }
  136. else if (visibility >= 0.09 && visibility < 0.3)
  137. {
  138. RadarC = 0.6;
  139. }
  140. else
  141. {
  142. RadarC = 0.2;
  143. }
  144. double Possibility0 = 0;
  145. double SNR = 1;
  146. //SNR为信噪比;sigma为实际目标雷达截面积,单位:平方米;sigma0为理论目标雷达截面积,单位:平方米
  147. SNR = sigma * Math.Pow(R0, 4) / (sigma0 * Math.Pow(R, 4));
  148. Possibility0 = Math.Pow(Math.E, Math.Log(Pd0, Math.E) * Math.Log(Pf, Math.E) / (SNR * Math.Log(Pf0, Math.E) + Math.Log(Pd0, Math.E)));
  149. double Possibility = RadarC * Possibility0;
  150. return Possibility;
  151. }
  152. // Lt = 探测目标亮度 Editor / At = 探测目标面积 Editor / τa = 1 / Lb = 3 / A0 = 1 / D0 = 0.075 / Dstar = 3 / τo = 0.8 / Ad = 0.0073728 / Δf = 0.125 / δ = 0.5 / Pf0 = Math.Pow(10, -6);
  153. public double GetInfraredDetectionProbability(double Lt, double At, double τa, double Lb, double A0, double3 aircraftPoint, TargetPoint targetPoint, double D0, double Dstar, double τo, double Ad, double Δf, double δ, double Pf0)
  154. {
  155. var distance = GetDistance(aircraftPoint.x, targetPoint.TargetPointLongitude, aircraftPoint.y, targetPoint.TargetPointLatitude);
  156. double R = 1000 * distance;
  157. //确定由Pfa确定的最小信噪比
  158. double minSNR = Math.Sqrt(-2 * Math.Log(Pf0, Math.E));
  159. // 计算信噪比
  160. double a = (Lt * At * τa - Lb * A0) * Math.PI * Math.Pow(D0, 2) * Dstar * δ * τo;
  161. double b = 4 * Math.Sqrt(Ad * Δf) * Math.Pow(R, 2);
  162. double SNR = a / b;
  163. // 使用 Math.NET Numerics 库计算高斯积分
  164. double Pd = GaussianIntegral(SNR - minSNR);
  165. return Pd;
  166. }
  167. public static double GaussianIntegral(double x)
  168. {
  169. double integral = 1;
  170. if (x < 0)
  171. {
  172. integral = 0.5 - Math.Pow(Math.Sqrt(2 * Math.PI), -1) * Integrate.OnClosedInterval(t => Math.Exp(-Math.Pow(t, 2) / 2), 0, -x, 1e-2);
  173. }
  174. else
  175. {
  176. integral = 0.5 + Math.Pow(Math.Sqrt(2 * Math.PI), -1) * Integrate.OnClosedInterval(t => Math.Exp(-Math.Pow(t, 2) / 2), 0, x, 1e-2);
  177. }
  178. return integral;
  179. }
  180. public int GetType(string type)
  181. {
  182. switch (type)
  183. {
  184. case "遇险人员":
  185. case "落水人员":
  186. return 0;
  187. case "车辆":
  188. case "救生筏":
  189. case "小于5700kg航空器":
  190. case "小于20m船舶":
  191. return 1;
  192. case "大于20m船舶":
  193. case "大于5700kg航空器":
  194. return 2;
  195. }
  196. return -1;
  197. }
  198. public static double GetDistance(double lon1, double lon2, double lat1, double lat2)
  199. {
  200. double R = 6371; // 地球的半径(公里)
  201. double dLat = (lat2 - lat1) * Math.PI / 180.0;
  202. double dLon = (lon2 - lon1) * Math.PI / 180.0;
  203. double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
  204. Math.Cos(lat1 * Math.PI / 180.0) * Math.Cos(lat2 * Math.PI / 180.0) *
  205. Math.Sin(dLon / 2) * Math.Sin(dLon / 2);
  206. double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
  207. double distance = R * c;
  208. return distance;
  209. }
  210. /// <summary>
  211. ///
  212. /// </summary>
  213. /// <param name="aircraftPoint">飞机坐标</param>
  214. /// <param name="targetPoint">目标点坐标</param>
  215. /// <param name="course">航向(度数)</param>
  216. /// <param name="currentDate">(当前日期)</param>
  217. /// <param name="windspeed">风速(km/h)</param>
  218. /// <param name="wavehigh">浪高(m)</param>
  219. /// <param name="targetpye">遇险目标类型</param>
  220. /// <param name="typee">救援场景类型</param>
  221. /// <returns></returns>
  222. public double getProbability(double3 aircraftPoint, double3 targetPoint, double pb, double course, double windspeed, double wavehigh, string targetpye, string type)
  223. {
  224. try
  225. {
  226. double Cw = 1;
  227. if (windspeed > 46 && wavehigh > 1.5)
  228. {
  229. if (targetpye == "落水人员")
  230. {
  231. Cw = 0.25;
  232. }
  233. else
  234. {
  235. Cw = 0.6;
  236. }
  237. }
  238. else if (28 < windspeed && windspeed < 46 && 1 < wavehigh && wavehigh < 1.5)
  239. {
  240. if (targetpye == "船")
  241. {
  242. Cw = 0.5;
  243. }
  244. else
  245. {
  246. Cw = 0.9;
  247. }
  248. }
  249. else if (0 < windspeed && windspeed < 28 && 0 < wavehigh && wavehigh < 1)
  250. {
  251. Cw = 1;
  252. }
  253. double Cv = 1;
  254. System.Random ran = new System.Random();
  255. double x = getx(aircraftPoint, targetPoint, course);
  256. double V = 15;//getVisibility(getCityName(targetPoint.x, targetPoint.y), DateTime.Now.ToString("yyyy-MM-dd HH"));
  257. if (V < 6)
  258. {
  259. Cv = 0.4;
  260. }
  261. else if (6 < V && V < 9)
  262. {
  263. Cv = 0.6;
  264. }
  265. else if (9 < V && V < 19)
  266. {
  267. Cv = 0.8;
  268. }
  269. else if (19 < V && V < 28)
  270. {
  271. Cv = 0.9;
  272. }
  273. else if (37 < V)
  274. {
  275. Cv = 1;
  276. }
  277. double pt = this.nextDouble(ran, 0.800, 0.999, 8);
  278. //double pb = targetPoint;//getPb(targetPoint.x, targetPoint.y);
  279. double D = 0;
  280. double C = Math.Round((double)((pt - pb) / pt), 8);
  281. if (type == "陆地")
  282. {
  283. D = (V / 3.912) * Math.Log10(C / 0.02);
  284. }
  285. else if (type == "海上")
  286. {
  287. if (targetpye == "船")
  288. { D = 31 * Cv * Cw; }
  289. else if (targetpye == "落水人员")
  290. { D = 0.2 * Cv * Cw; }
  291. }
  292. double px = 1 - Math.Exp((-1 * D * D) / (4 * Math.PI * x * x));
  293. return px;
  294. }
  295. catch (Exception ex)
  296. {
  297. Debug.Print("error!!!!!getProbability:" + ex.ToString());
  298. return -1;
  299. }
  300. }
  301. /// <summary>
  302. ///
  303. /// </summary>
  304. /// <param name="aircraftPoint">飞机坐标</param>
  305. /// <param name="targetPoint">目标点坐标</param>
  306. /// <param name="course">航向(度数)</param>
  307. /// <param name="currentDate">(当前日期)</param>
  308. /// <returns></returns>
  309. public double getProbability(double3 aircraftPoint, double3 targetPoint, double course)
  310. {
  311. try
  312. {
  313. x = getx(aircraftPoint, targetPoint, course);
  314. double V = getVisibility(getCityName(targetPoint.x, targetPoint.y), DateTime.Now.ToString("yyyy-MM-dd HH"));
  315. System.Random ran = new System.Random();
  316. double pt = this.nextDouble(ran, 0.800, 0.999, 8);
  317. double pb = getPb(targetPoint.x, targetPoint.y);
  318. double C = Math.Round((double)((pt - pb) / pt), 8);
  319. double D = (V / 3.912) * Math.Log10(C / 0.02);
  320. double px = 1 - Math.Exp((-1 * D * D) / (4 * Math.PI * x * x));
  321. return px;
  322. }
  323. catch (Exception ex)
  324. {
  325. Console.WriteLine("error!!!!!getProbability:" + ex.ToString());
  326. return -1;
  327. }
  328. }
  329. public double getX(double3 targetPoint)
  330. {
  331. try
  332. {
  333. double result = -1;
  334. double V = getVisibility(getCityName(targetPoint.x, targetPoint.y), DateTime.Now.ToString("yyyy-MM-dd HH"));
  335. double pt = 0.85;
  336. double pb = getPb(targetPoint.x, targetPoint.y);
  337. double C = Math.Round((double)((pt - pb) / pt), 3);
  338. double D = (V / 3.912) * Math.Log10(C / 0.02);
  339. double x = Math.Sqrt(-1 * D * D / Math.Log(1 - 0.85) / 4 / Math.PI);
  340. return x;
  341. }
  342. catch (Exception ex)
  343. {
  344. Debug.Print("error!!!!!getX:" + ex.ToString());
  345. return -1;
  346. }
  347. }
  348. private double nextDouble(System.Random ran, double minValue, double maxValue, int decimalPlace)
  349. {
  350. double randNum = ran.NextDouble() * (maxValue - minValue) + minValue;
  351. return Convert.ToDouble(randNum.ToString("f" + decimalPlace));
  352. }
  353. public double getVisibility(string city_name, string weather_date)
  354. {
  355. try
  356. {
  357. //调在线气象接口,封装到服务中了
  358. HttpCmd cmd = new HttpCmd
  359. {
  360. m_RequestType = HttpRequestType.GET,
  361. m_Addr = $"{baseUrl}rescue-platform-service/api/v1/tbMeteorology/getInfosByNowApi",
  362. m_Args = new List<string> { "city_name", "weather_date" }
  363. };
  364. string response = m_HttpHelper.Request(cmd, new List<string> { city_name, weather_date });
  365. R data = JsonConvert.DeserializeObject<R>(response);
  366. if (data != null && data.code == 200)
  367. {
  368. NAdtListDto rt = JsonConvert.DeserializeObject<NAdtListDto>(data.data.ToString());
  369. double fl = Convert.ToDouble(rt.wtVisibility);
  370. if (fl.Equals(0))
  371. {
  372. fl = 15;
  373. }
  374. return fl;
  375. }
  376. return 15;
  377. }
  378. catch (Exception ex)
  379. {
  380. Debug.Print("error!!!!!getVisibility");
  381. Debug.Print(ex.ToString());
  382. return 15;
  383. }
  384. }
  385. public double getVisibilityByDb(double centerLon, double centerLat, string visibility_date)
  386. {
  387. try
  388. {
  389. HttpCmd cmd = new HttpCmd
  390. {
  391. m_RequestType = HttpRequestType.GET,
  392. m_Addr = "http://10.130.100.5:7785//rescue-platform-service/api/v1/attribute/getVisibility", //10.130.100.5 127.0.0.1
  393. m_Args = new List<string> { "centerLon", "centerLat", "visibility_date" }
  394. };
  395. string response = m_HttpHelper.Request(cmd, new List<string> { centerLon.ToString(), centerLat.ToString(), visibility_date });
  396. //Console.WriteLine(" centerLon:" + centerLon + " " + "centerLat:" + centerLat + " " + "visibility_date:" + visibility_date);
  397. //Console.WriteLine("response:" + response);
  398. R data = JsonConvert.DeserializeObject<R>(response);
  399. if (data != null && data.code == 200)
  400. {
  401. string vi = data.data.ToString();
  402. double fl = Convert.ToDouble(vi);
  403. if (fl.Equals(0))
  404. {
  405. fl = 15;
  406. //Console.WriteLine("1:" + fl);
  407. }
  408. //Console.WriteLine("2:" + fl);
  409. return fl;
  410. }
  411. //Console.WriteLine("3:" + 15);
  412. return 15;
  413. }
  414. catch (Exception ex)
  415. {
  416. //Console.WriteLine("4:" + 15);
  417. Debug.Print("error!!!!!getVisibility");
  418. Debug.Print(ex.ToString());
  419. return 15;
  420. }
  421. }
  422. //rescue-platform-service/api/v1/dem/getCityName
  423. // {
  424. // "msg": "success",
  425. // "code": 200,
  426. // "cityName": "承德市"
  427. // }
  428. public string getCityName(double lon, double lat)
  429. {
  430. string cityName = "北京";
  431. // try
  432. // {
  433. // string sql = string.Format("select a.f_xzqdm cityCode, a.f_xzqmc cityName from xzq_ds a where ST_Contains(shape,st_geomfromtext('POINT({0} {1})',4326)) limit 1", lon, lat);
  434. // DataTable dt = this._db.DoQueryEx(sql);
  435. // if (dt != null && dt.Rows.Count > 0)
  436. // {
  437. // cityName = dt.Rows[0][1].ToString().Replace("市", "").Replace("自治区", "");
  438. // }
  439. // }
  440. // catch (Exception ex)
  441. // {
  442. // Debug.Print("error!!!!!getCityName");
  443. // Debug.Print(ex.ToString());
  444. // }
  445. try
  446. {
  447. //调在线气象接口,封装到服务中了
  448. HttpCmd cmd = new HttpCmd
  449. {
  450. m_RequestType = HttpRequestType.GET,
  451. m_Addr = $"{baseUrl}rescue-platform-service/api/v1/dem/getCityName",
  452. m_Args = new List<string> { "lon", "lat" }
  453. };
  454. string response = m_HttpHelper.Request(cmd, new List<string> { lon.ToString(), lat.ToString() });
  455. JObject jObject = JObject.Parse(response);
  456. cityName = jObject["cityName"].ToString().Replace("市", "").Replace("自治区", "");
  457. }
  458. catch (Exception ex)
  459. {
  460. Debug.Print("error!!!!!getVisibility");
  461. Debug.Print(ex.ToString());
  462. }
  463. return cityName;
  464. }
  465. //rescue-platform-service/api/v1/dem/getCategory
  466. // {
  467. // "msg": "success",
  468. // "code": 200,
  469. // "category": "7 草丛"
  470. // }
  471. public double getPb(double lon, double lat)
  472. {
  473. double pb = 0.13;
  474. try
  475. {
  476. // string sql_zb = string.Format("select f_category from ly_vegetation where ST_Contains(st_geomfromtext(st_astext(shape) ),st_geomfromtext('POINT({0} {1})'))", lon, lat);
  477. // DataTable dt_zb = _db.DoQueryEx(sql_zb);
  478. //调在线气象接口,封装到服务中了
  479. HttpCmd cmd = new HttpCmd
  480. {
  481. m_RequestType = HttpRequestType.GET,
  482. m_Addr = $"{baseUrl}rescue-platform-service/api/v1/dem/getCategory",
  483. m_Args = new List<string> { "lon", "lat" }
  484. };
  485. string response = m_HttpHelper.Request(cmd, new List<string> { lon.ToString(), lat.ToString() });
  486. JObject jObject = JObject.Parse(response);
  487. string fcategory = jObject["category"].ToString();
  488. switch (fcategory)
  489. {
  490. case "1 针叶林":
  491. pb = 0.13;
  492. break;
  493. case "10 高山植被":
  494. pb = 0.13;
  495. break;
  496. case "11 栽培植被":
  497. pb = 0.13;
  498. break;
  499. case "2 针阔叶混交林":
  500. pb = 0.13;
  501. break;
  502. case "3 阔叶林":
  503. pb = 0.13;
  504. break;
  505. case "4 灌丛":
  506. pb = 0.13;
  507. break;
  508. case "5 荒漠":
  509. pb = 0.13;
  510. break;
  511. case "6 草原":
  512. pb = 0.13;
  513. break;
  514. case "7 草丛":
  515. pb = 0.13;
  516. break;
  517. case "8 草甸":
  518. pb = 0.13;
  519. break;
  520. case "9 沼泽":
  521. pb = 0.13;
  522. break;
  523. default:
  524. pb = 0.13;
  525. break;
  526. }
  527. }
  528. catch (Exception ex)
  529. {
  530. Debug.Print("error!!!!!getPb");
  531. Debug.Print(ex.ToString());
  532. }
  533. return pb;
  534. }
  535. //rescue-platform-service/api/v1/dem/getDistance
  536. // {
  537. // "msg": "success",
  538. // "code": 200,
  539. // "data": {
  540. // "differ": 328.31408076,
  541. // "azimuth": 2.400469679065642
  542. // }
  543. // }
  544. private double getx(double3 aircraftPoint, double3 targetPoint, double course)
  545. {
  546. double result = -1;
  547. // string sql = string.Format("select ST_Distance( ST_SetSRID(ST_MakePoint({0},{1}),4326)::geography, ST_SetSRID(ST_MakePoint({2},{3}),4326)::geography) as differ,ST_azimuth(st_geomfromtext('POINT({0} {1})'),st_geomfromtext('POINT({2} {3})')) as azimuth", aircraftPoint.x, aircraftPoint.y, targetPoint.x, targetPoint.y);
  548. // DataTable dt = _db.DoQueryEx(sql);
  549. HttpCmd cmd = new HttpCmd
  550. {
  551. m_RequestType = HttpRequestType.GET,
  552. m_Addr = $"{baseUrl}rescue-platform-service/api/v1/dem/getDistance",
  553. m_Args = new List<string> { "lon_air", "lat_air", "lon_target", "lat_target" }
  554. };
  555. string response = m_HttpHelper.Request(cmd, new List<string> { aircraftPoint.x.ToString(), aircraftPoint.y.ToString(), targetPoint.x.ToString(), targetPoint.y.ToString() });
  556. JObject jObject = JObject.Parse(response);
  557. double differ = double.Parse(jObject["data"]["differ"].ToString());
  558. double azimuth = double.Parse(jObject["data"]["azimuth"].ToString());
  559. // differ = Convert.ToDouble(dt.Rows[0][0].ToString());
  560. azimuth = 180 / Math.PI * azimuth;//Convert.ToDouble(dt.Rows[0][1].ToString());
  561. double angle = course - azimuth;
  562. if (angle < 0)
  563. {
  564. angle = -1 * angle;
  565. }
  566. double x = differ * Math.Sin(angle * Math.PI / 180) / 1000;
  567. return x;
  568. }
  569. }
  570. }