using CliWrap; using CliWrap.Buffered; using Ips.Library.Basic; using Ips.Library.CliLib; using Ips.Library.Entity; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Ips.PosAlgorithm { public class PosLyUtil { static readonly string CliPath = PathUtil.GetAssemblyPath("ipscli", "posly", "posly.exe"); public static async Task> X3( double dtotar1, double dtotar2, double[] msant1, double[] nsant1, double[] msant2, double[] nsant2, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default ) { const string cmd = "x3"; var cli = Cli.Wrap(CliPath) .WithArguments(args => { args.Add(cmd); args.IpsAdd(nameof(dtotar1), dtotar1); args.IpsAdd(nameof(dtotar2), dtotar2); args.IpsAdd(nameof(msant1), msant1); args.IpsAdd(nameof(nsant1), nsant1); args.IpsAdd(nameof(msant2), msant2); args.IpsAdd(nameof(nsant2), nsant2); args.IpsAdd(nameof(mseph1), mseph1); args.IpsAdd(nameof(nseph1), nseph1); args.IpsAdd(nameof(mseph2), mseph2); args.IpsAdd(nameof(nseph2), nseph2); }); var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout)); var dwResult = PosResult.FromString(PosType.X3, false, res.StandardOutput); return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode, res.StandardError); } public static async Task> X3Ref( double dtotar1, double dtotar2, double dtoref1, double dtoref2, double[] refgeod1, double[] refgeod2, double[] msant1, double[] nsant1, double[] msant2, double[] nsant2, double[] mseph1, double[] nseph1, double[] mseph2, double[] nseph2, int timeout = 60, CancellationToken token = default ) { const string cmd = "x3ref"; var cli = Cli.Wrap(CliPath) .WithArguments(args => { args.Add(cmd); args.IpsAdd(nameof(dtotar1), dtotar1); args.IpsAdd(nameof(dtotar2), dtotar2); args.IpsAdd(nameof(dtoref1), dtoref1); args.IpsAdd(nameof(dtoref2), dtoref2); args.IpsAdd(nameof(refgeod1), refgeod1); args.IpsAdd(nameof(refgeod2), refgeod2); args.IpsAdd(nameof(msant1), msant1); args.IpsAdd(nameof(nsant1), nsant1); args.IpsAdd(nameof(msant2), msant2); args.IpsAdd(nameof(nsant2), nsant2); args.IpsAdd(nameof(mseph1), mseph1); args.IpsAdd(nameof(nseph1), nseph1); args.IpsAdd(nameof(mseph2), mseph2); args.IpsAdd(nameof(nseph2), nseph2); }); var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout)); var dwResult = PosResult.FromString(PosType.X3Ref, true, res.StandardOutput); return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode, res.StandardError); } public static Task> X4( double dtotar1, double dtotar2, double dtotar3, double[] nsant1, double[] nsant2, double[] nsant3, double[] nseph1, double[] nseph2, double[] nseph3, int timeout = 60, CancellationToken token = default ) { var dt1 = dtotar2 - dtotar1; var dt2 = dtotar3 - dtotar1; return X3(dt1, dt2, nsant1, nsant2, nsant1, nsant3, nseph1, nseph2, nseph1, nseph3, timeout, token); } public static Task> X4Ref( double dtotar1, double dtotar2, double dtotar3, double dtoref1, double dtoref2, double dtoref3, double[] refgeod, double[] nsant1, double[] nsant2, double[] nsant3, double[] nseph1, double[] nseph2, double[] nseph3, int timeout = 60, CancellationToken token = default ) { var dt1 = dtotar2 - dtotar1; var dt2 = dtotar3 - dtotar1; var refdt1 = dtoref2 - dtoref1; var refdt2 = dtoref3 - dtoref1; return X3Ref(dt1, dt2, refdt1, refdt2, refgeod, refgeod, nsant1, nsant2, nsant1, nsant3, nseph1, nseph2, nseph1, nseph3, timeout, token); } public static async Task>> DtoLineSx(double dtotar, double[] msant, double[] nsant, double[] mseph, double[] nseph, int timeout = 60, CancellationToken token = default) { const string cmd = "dtolinesx"; var cli = Cli.Wrap(CliPath) .WithArguments(args => { args.Add(cmd); args.IpsAdd(nameof(dtotar), dtotar); args.IpsAdd(nameof(msant), msant); args.IpsAdd(nameof(nsant), nsant); args.IpsAdd(nameof(mseph), mseph); args.IpsAdd(nameof(nseph), nseph); }); var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout)); var dwResult = GeoLine.FromListString(res.StandardOutput); return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode); } public static async Task>> DtoLineSxRef(double dtotar, double dtoref, double[] refgeod, double[] mseph, double[] nseph, double[] msant, double[] nsant, int timeout = 60, CancellationToken token = default) { const string cmd = "dtolinesxref"; var cli = Cli.Wrap(CliPath) .WithArguments(args => { args.Add(cmd); args.IpsAdd(nameof(dtotar), dtotar); args.IpsAdd(nameof(dtoref), dtoref); args.IpsAdd(nameof(refgeod), refgeod); args.IpsAdd(nameof(mseph), mseph); args.IpsAdd(nameof(nseph), nseph); args.IpsAdd(nameof(msant), msant); args.IpsAdd(nameof(nsant), nsant); }); var res = await cli.ExecuteBufferedAsync(token.LinkTimeout(timeout)); var dwResult = GeoLine.FromListString(res.StandardOutput); return ExeResult.Create(dwResult, cli.Arguments, res.StartTime, res.ExitTime, res.ExitCode); } } }