PtoLineUtils.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using CliWrap;
  2. using CliWrap.Buffered;
  3. using Ips.Library.Basic;
  4. using Ips.Library.Entity;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. namespace Ips.Pto
  11. {
  12. public static class PtoLineUtils
  13. {
  14. static readonly string CliPath = PathUtil.GetAssemblyPath("ipscli", "pto", "pto.exe");
  15. public static async Task<ExeResult<List<GeoLine>>> Get(GeoLLA recGeod, GeoXYZ msEph, GeoXYZ nsEph, double dtoTar, int timeout = 60, CancellationToken token = default)
  16. {
  17. const string cmd = "dtoline noref";
  18. var cli = Cli.Wrap(CliPath)
  19. .WithArguments(args =>
  20. {
  21. args.Add(cmd);
  22. args.Add("--recgeod").Add(recGeod.ToString());
  23. args.Add("--mseph").Add(msEph.ToString());
  24. args.Add("--nseph").Add(nsEph.ToString());
  25. args.Add("--dtotar").Add(dtoTar.ToString());
  26. });
  27. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  28. var dwResult = GeoLine.FromListString(res.StandardOutput);
  29. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  30. }
  31. public static async Task<ExeResult<List<GeoLine>>> GetRef(GeoLLA refGeod, GeoXYZ msEph, GeoXYZ nsEph, double dtoTar, double dtoRef, int timeout = 60, CancellationToken token = default)
  32. {
  33. const string cmd = "dtoline ref";
  34. var cli = Cli.Wrap(CliPath)
  35. .WithArguments(args =>
  36. {
  37. args.Add(cmd);
  38. args.Add("--refgeod").Add(refGeod.ToString());
  39. args.Add("--mseph").Add(msEph.ToString());
  40. args.Add("--nseph").Add(nsEph.ToString());
  41. args.Add("--dtotar").Add(dtoTar.ToString());
  42. args.Add("--dtoref").Add(dtoRef.ToString());
  43. });
  44. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  45. var dwResult = GeoLine.FromListString(res.StandardOutput);
  46. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  47. }
  48. public static async Task<ExeResult<List<GeoLine>>> GetLoc(GeoLLA recGeod, GeoXYZ msEph, GeoXYZ nsEph, GeoLLA pos, int timeout = 60, CancellationToken token = default)
  49. {
  50. const string cmd = "dtoline loc";
  51. var cli = Cli.Wrap(CliPath)
  52. .WithArguments(args =>
  53. {
  54. args.Add(cmd);
  55. args.Add("--recgeod").Add(recGeod.ToString());
  56. args.Add("--mseph").Add(msEph.ToString());
  57. args.Add("--nseph").Add(nsEph.ToString());
  58. args.Add("--pos").Add(pos.ToString());
  59. });
  60. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  61. var dwResult = GeoLine.FromListString(res.StandardOutput);
  62. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  63. }
  64. public static async Task<ExeResult<List<GeoLine>>> GetLocRef(GeoLLA refGeod, GeoXYZ msEph, GeoXYZ nsEph, GeoLLA pos, int timeout = 60, CancellationToken token = default)
  65. {
  66. const string cmd = "dtoline locref";
  67. var cli = Cli.Wrap(CliPath)
  68. .WithArguments(args =>
  69. {
  70. args.Add(cmd);
  71. args.Add("--refgeod").Add(refGeod.ToString());
  72. args.Add("--mseph").Add(msEph.ToString());
  73. args.Add("--nseph").Add(nsEph.ToString());
  74. args.Add("--pos").Add(pos.ToString());
  75. });
  76. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  77. var dwResult = GeoLine.FromListString(res.StandardOutput);
  78. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  79. }
  80. public static async Task<ExeResult<List<GeoLine>>> GetXdRef(GeoXYZ msEph, GeoLLA msAnt, GeoLLA nsAnt, double dtoTar, GeoLLA refGeod, double msDtoRef, int timeout = 60, CancellationToken token = default)
  81. {
  82. const string cmd = "dtoline xdref";
  83. var cli = Cli.Wrap(CliPath)
  84. .WithArguments(args =>
  85. {
  86. args.Add(cmd);
  87. args.Add("--mseph").Add(msEph.ToString());
  88. args.Add("--msant").Add(msAnt.ToString());
  89. args.Add("--nsant").Add(nsAnt.ToString());
  90. args.Add("--dtotar").Add(dtoTar.ToString());
  91. args.Add("--refgeod").Add(refGeod.ToString());
  92. args.Add("--msdtoref").Add(msDtoRef.ToString());
  93. });
  94. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  95. var dwResult = GeoLine.FromListString(res.StandardOutput);
  96. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  97. }
  98. public static async Task<ExeResult<List<GeoLine>>> GetYidi(GeoXYZ msEph, GeoXYZ nsEph, GeoLLA msAnt, GeoLLA nsAnt, double dtoTar, int timeout = 60, CancellationToken token = default)
  99. {
  100. const string cmd = "dtoline yidi";
  101. var cli = Cli.Wrap(CliPath)
  102. .WithArguments(args =>
  103. {
  104. args.Add(cmd);
  105. args.Add("--mseph").Add(msEph.ToString());
  106. args.Add("--nseph").Add(nsEph.ToString());
  107. args.Add("--msant").Add(msAnt.ToString());
  108. args.Add("--nsant").Add(nsAnt.ToString());
  109. args.Add("--dtotar").Add(dtoTar.ToString());
  110. });
  111. var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout));
  112. var dwResult = GeoLine.FromListString(res.StandardOutput);
  113. return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode);
  114. }
  115. }
  116. }