LocRhUtil.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.LocAlgorithm
  12. {
  13. public static class LocRhUtil
  14. {
  15. static readonly string CliPath = Path.Combine(IpsPath.CliRootDir, "locrh", "locrh.exe");
  16. public static async Task<ExeResult<GdopErrResult>> GdopErr(double[] pos, double[] recgeod, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default)
  17. {
  18. const string cmd = "gdoperr";
  19. var cli = Cli.Wrap(CliPath)
  20. .WithArguments(args =>
  21. {
  22. args.Add(cmd);
  23. args.IpsAdd(nameof(pos), pos);
  24. args.IpsAdd(nameof(recgeod), recgeod);
  25. args.IpsAdd(nameof(mseph1), mseph1);
  26. args.IpsAdd(nameof(nseph1), nseph1);
  27. args.IpsAdd(nameof(mseph2), mseph2);
  28. args.IpsAdd(nameof(nseph2), nseph2);
  29. });
  30. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  31. var result = GdopErrResult.FromString(res.StandardOutput);
  32. return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  33. }
  34. public static async Task<ExeResult<GdopErrResult>> GdopErrRef(double[] pos, double[] refgeod, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default)
  35. {
  36. const string cmd = "gdoperrref";
  37. var cli = Cli.Wrap(CliPath)
  38. .WithArguments(args =>
  39. {
  40. args.Add(cmd);
  41. args.IpsAdd(nameof(pos), pos);
  42. args.IpsAdd(nameof(refgeod), refgeod);
  43. args.IpsAdd(nameof(mseph1), mseph1);
  44. args.IpsAdd(nameof(nseph1), nseph1);
  45. args.IpsAdd(nameof(mseph2), mseph2);
  46. args.IpsAdd(nameof(nseph2), nseph2);
  47. });
  48. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  49. var result = GdopErrResult.FromString(res.StandardOutput);
  50. return ExeResult.Create(result, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  51. }
  52. }
  53. }