PosEsUtil.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. using CliWrap;
  2. using CliWrap.Buffered;
  3. using Ips.Library.Basic;
  4. using Ips.Library.CliLib;
  5. using Ips.Library.Entity;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace Ips.PosAlgorithm
  12. {
  13. public class PosEsUtil
  14. {
  15. static readonly string CliPath = PathUtil.GetAssemblyPath("ipscli", "poses", "poses.exe");
  16. public static async Task<ExeResult<PosResult>> X3(
  17. double dtotar1,
  18. double dtotar2,
  19. double[] msant1,
  20. double[] nsant1,
  21. double[] msant2,
  22. double[] nsant2,
  23. double[] mseph1,
  24. double[] nseph1,
  25. double[] mseph2,
  26. double[] nseph2,
  27. int timeout = 60,
  28. CancellationToken token = default
  29. )
  30. {
  31. const string cmd = "x3";
  32. var cli = Cli.Wrap(CliPath)
  33. .WithArguments(args =>
  34. {
  35. args.Add(cmd);
  36. args.IpsAdd(nameof(dtotar1), dtotar1);
  37. args.IpsAdd(nameof(dtotar2), dtotar2);
  38. args.IpsAdd(nameof(msant1), msant1);
  39. args.IpsAdd(nameof(nsant1), nsant1);
  40. args.IpsAdd(nameof(msant2), msant2);
  41. args.IpsAdd(nameof(nsant2), nsant2);
  42. args.IpsAdd(nameof(mseph1), mseph1);
  43. args.IpsAdd(nameof(nseph1), nseph1);
  44. args.IpsAdd(nameof(mseph2), mseph2);
  45. args.IpsAdd(nameof(nseph2), nseph2);
  46. });
  47. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  48. var dwResult = PosResult.FromString(PosType.X3, false, res.StandardOutput);
  49. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode, res.StandardError);
  50. }
  51. public static async Task<ExeResult<PosResult>> X3Ref(
  52. double dtotar1,
  53. double dtotar2,
  54. double dtoref1,
  55. double dtoref2,
  56. double[] refgeod1,
  57. double[] refgeod2,
  58. double[] msant1,
  59. double[] nsant1,
  60. double[] msant2,
  61. double[] nsant2,
  62. double[] mseph1,
  63. double[] nseph1,
  64. double[] mseph2,
  65. double[] nseph2,
  66. int timeout = 60,
  67. CancellationToken token = default
  68. )
  69. {
  70. const string cmd = "x3ref";
  71. var cli = Cli.Wrap(CliPath)
  72. .WithArguments(args =>
  73. {
  74. args.Add(cmd);
  75. args.IpsAdd(nameof(dtotar1), dtotar1);
  76. args.IpsAdd(nameof(dtotar2), dtotar2);
  77. args.IpsAdd(nameof(dtoref1), dtoref1);
  78. args.IpsAdd(nameof(dtoref2), dtoref2);
  79. args.IpsAdd(nameof(refgeod1), refgeod1);
  80. args.IpsAdd(nameof(refgeod2), refgeod2);
  81. args.IpsAdd(nameof(msant1), msant1);
  82. args.IpsAdd(nameof(nsant1), nsant1);
  83. args.IpsAdd(nameof(msant2), msant2);
  84. args.IpsAdd(nameof(nsant2), nsant2);
  85. args.IpsAdd(nameof(mseph1), mseph1);
  86. args.IpsAdd(nameof(nseph1), nseph1);
  87. args.IpsAdd(nameof(mseph2), mseph2);
  88. args.IpsAdd(nameof(nseph2), nseph2);
  89. });
  90. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  91. var dwResult = PosResult.FromString(PosType.X3Ref, true, res.StandardOutput);
  92. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode, res.StandardError);
  93. }
  94. public static Task<ExeResult<PosResult>> X4(
  95. double dtotar1,
  96. double dtotar2,
  97. double dtotar3,
  98. double[] nsant1,
  99. double[] nsant2,
  100. double[] nsant3,
  101. double[] nseph1,
  102. double[] nseph2,
  103. double[] nseph3,
  104. int timeout = 60,
  105. CancellationToken token = default
  106. )
  107. {
  108. var dt1 = dtotar2 - dtotar1;
  109. var dt2 = dtotar3 - dtotar1;
  110. return X3(dt1, dt2, nsant1, nsant2, nsant1, nsant3, nseph1, nseph2, nseph1, nseph3, timeout, token);
  111. }
  112. public static Task<ExeResult<PosResult>> X4Ref(
  113. double dtotar1,
  114. double dtotar2,
  115. double dtotar3,
  116. double dtoref1,
  117. double dtoref2,
  118. double dtoref3,
  119. double[] refgeod,
  120. double[] nsant1,
  121. double[] nsant2,
  122. double[] nsant3,
  123. double[] nseph1,
  124. double[] nseph2,
  125. double[] nseph3,
  126. int timeout = 60,
  127. CancellationToken token = default
  128. )
  129. {
  130. var dt1 = dtotar2 - dtotar1;
  131. var dt2 = dtotar3 - dtotar1;
  132. var refdt1 = dtoref2 - dtoref1;
  133. var refdt2 = dtoref3 - dtoref1;
  134. return X3Ref(dt1, dt2, refdt1, refdt2, refgeod, refgeod, nsant1, nsant2, nsant1, nsant3, nseph1, nseph2, nseph1, nseph3, timeout, token);
  135. }
  136. public static async Task<ExeResult<List<GeoLine>>> DtoLineSx(double dtotar, double[] recgeod, double[] mseph, double[] nseph, int timeout = 60, CancellationToken token = default)
  137. {
  138. const string cmd = "dtolinesx";
  139. var cli = Cli.Wrap(CliPath)
  140. .WithArguments(args =>
  141. {
  142. args.Add(cmd);
  143. args.IpsAdd(nameof(dtotar), dtotar);
  144. args.IpsAdd(nameof(recgeod), recgeod);
  145. args.IpsAdd(nameof(mseph), mseph);
  146. args.IpsAdd(nameof(nseph), nseph);
  147. });
  148. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  149. var dwResult = GeoLine.FromListString(res.StandardOutput);
  150. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  151. }
  152. public static async Task<ExeResult<List<GeoLine>>> DtoLineSxRef(double dtotar, double dtoref, double[] refgeod, double[] mseph, double[] nseph, double[] msant, double[] nsaant, int timeout = 60, CancellationToken token = default)
  153. {
  154. const string cmd = "dtolinesxref";
  155. var cli = Cli.Wrap(CliPath)
  156. .WithArguments(args =>
  157. {
  158. args.Add(cmd);
  159. args.IpsAdd(nameof(dtotar), dtotar);
  160. args.IpsAdd(nameof(dtoref), dtoref);
  161. args.IpsAdd(nameof(refgeod), refgeod);
  162. args.IpsAdd(nameof(mseph), mseph);
  163. args.IpsAdd(nameof(nseph), nseph);
  164. });
  165. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  166. var dwResult = GeoLine.FromListString(res.StandardOutput);
  167. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  168. }
  169. public static async Task<ExeResult<List<GeoLine>>> DtoLineLoc(double[] pos, GeoXYZ recgeod, GeoXYZ mseph, GeoLLA nseph, int timeout = 60, CancellationToken token = default)
  170. {
  171. const string cmd = "dtolineloc";
  172. var cli = Cli.Wrap(CliPath)
  173. .WithArguments(args =>
  174. {
  175. args.Add(cmd);
  176. args.IpsAdd(nameof(pos), pos);
  177. args.IpsAdd(nameof(recgeod), recgeod);
  178. args.IpsAdd(nameof(mseph), mseph);
  179. args.IpsAdd(nameof(nseph), nseph);
  180. });
  181. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  182. var dwResult = GeoLine.FromListString(res.StandardOutput);
  183. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  184. }
  185. public static async Task<ExeResult<List<GeoLine>>> DtoLineLocRef(double[] pos, double[] refgeod, double[] mseph, double[] nseph, int timeout = 60, CancellationToken token = default)
  186. {
  187. const string cmd = "dtolinelocref";
  188. var cli = Cli.Wrap(CliPath)
  189. .WithArguments(args =>
  190. {
  191. args.Add(cmd);
  192. args.IpsAdd(nameof(pos), pos);
  193. args.IpsAdd(nameof(refgeod), refgeod);
  194. args.IpsAdd(nameof(mseph), mseph);
  195. args.IpsAdd(nameof(nseph), nseph);
  196. });
  197. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  198. var dwResult = GeoLine.FromListString(res.StandardOutput);
  199. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  200. }
  201. public static async Task<ExeResult<List<GeoLine>>> DtoLineYiDi(double dtotar, double[] mseph, double[] nseph, double[] msant, double[] nsant, int timeout = 60, CancellationToken token = default)
  202. {
  203. const string cmd = "dtolineyidi";
  204. var cli = Cli.Wrap(CliPath)
  205. .WithArguments(args =>
  206. {
  207. args.Add(cmd);
  208. args.IpsAdd(nameof(dtotar), dtotar);
  209. args.IpsAdd(nameof(mseph), mseph);
  210. args.IpsAdd(nameof(nseph), nseph);
  211. args.IpsAdd(nameof(msant), msant);
  212. args.IpsAdd(nameof(nsant), nsant);
  213. });
  214. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  215. var dwResult = GeoLine.FromListString(res.StandardOutput);
  216. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  217. }
  218. public static async Task<ExeResult<GdopResult>> Gdop(double[] recgeod, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default)
  219. {
  220. const string cmd = "gdop";
  221. var cli = Cli.Wrap(CliPath)
  222. .WithArguments(args =>
  223. {
  224. args.Add(cmd);
  225. args.IpsAdd(nameof(recgeod), recgeod);
  226. args.IpsAdd(nameof(mseph1), mseph1);
  227. args.IpsAdd(nameof(nseph1), nseph1);
  228. args.IpsAdd(nameof(mseph2), mseph2);
  229. args.IpsAdd(nameof(nseph2), nseph2);
  230. });
  231. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  232. var result = new GdopResult(res.StandardOutput);
  233. return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  234. }
  235. public static async Task<ExeResult<GdopResult>> GdopRef(double[] refgeod, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default)
  236. {
  237. const string cmd = "gdopref";
  238. var cli = Cli.Wrap(CliPath)
  239. .WithArguments(args =>
  240. {
  241. args.Add(cmd);
  242. args.IpsAdd(nameof(refgeod), refgeod);
  243. args.IpsAdd(nameof(mseph1), mseph1);
  244. args.IpsAdd(nameof(nseph1), nseph1);
  245. args.IpsAdd(nameof(mseph2), mseph2);
  246. args.IpsAdd(nameof(nseph2), nseph2);
  247. });
  248. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  249. var result = new GdopResult(res.StandardOutput);
  250. return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  251. }
  252. public static async Task<ExeResult<LocErrResult>> LocErr(double[] pos, double[] recgeod, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default)
  253. {
  254. const string cmd = "locerr";
  255. var cli = Cli.Wrap(CliPath)
  256. .WithArguments(args =>
  257. {
  258. args.Add(cmd);
  259. args.IpsAdd(nameof(pos), pos);
  260. args.IpsAdd(nameof(recgeod), recgeod);
  261. args.IpsAdd(nameof(mseph1), mseph1);
  262. args.IpsAdd(nameof(nseph1), nseph1);
  263. args.IpsAdd(nameof(mseph2), mseph2);
  264. args.IpsAdd(nameof(nseph2), nseph2);
  265. });
  266. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  267. var result = new LocErrResult(res.StandardOutput);
  268. return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  269. }
  270. public static async Task<ExeResult<LocErrResult>> LocErrRef(double[] pos, double[] refgeod, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default)
  271. {
  272. const string cmd = "locerrref";
  273. var cli = Cli.Wrap(CliPath)
  274. .WithArguments(args =>
  275. {
  276. args.Add(cmd);
  277. args.IpsAdd(nameof(pos), pos);
  278. args.IpsAdd(nameof(refgeod), refgeod);
  279. args.IpsAdd(nameof(mseph1), mseph1);
  280. args.IpsAdd(nameof(nseph1), nseph1);
  281. args.IpsAdd(nameof(mseph2), mseph2);
  282. args.IpsAdd(nameof(nseph2), nseph2);
  283. });
  284. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  285. var result = new LocErrResult(res.StandardOutput);
  286. return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  287. }
  288. public static async Task<ExeResult<double>> RefCalc(DateTime[] intimes, double[] inmsephs, double[] innsephs, double[] indtorefs, double[] refgeod, double[] recgeod, DateTime time, double[] mseph, double[] nseph, int timeout = 60, CancellationToken token = default)
  289. {
  290. const string cmd = "refcalc";
  291. var cli = Cli.Wrap(CliPath)
  292. .WithArguments(args =>
  293. {
  294. args.Add(cmd);
  295. args.IpsAdd(nameof(intimes), intimes);
  296. args.IpsAdd(nameof(inmsephs), inmsephs);
  297. args.IpsAdd(nameof(innsephs), innsephs);
  298. args.IpsAdd(nameof(indtorefs), indtorefs);
  299. args.IpsAdd(nameof(refgeod), refgeod);
  300. args.IpsAdd(nameof(recgeod), recgeod);
  301. args.IpsAdd(nameof(time), time);
  302. args.IpsAdd(nameof(mseph), mseph);
  303. args.IpsAdd(nameof(nseph), nseph);
  304. });
  305. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  306. var dtoRefOut = double.Parse(res.StandardOutput);
  307. return ExeResult.Create(dtoRefOut, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  308. }
  309. }
  310. }