using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; namespace XdCxRhDW.Api { public class DrawDfoLineHelper { private const string exeName = "locow.exe"; private static double[] zone = new double[] { -85, 85, -180, 180 }; //定位区域 /// /// 高轨双星频差线 /// /// /// /// public static IEnumerable<(double lon, double lat)> DfoLineTwoStart(DfoLineTwoStartOption opt) { List list = new List(); string exePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AddIns\\频差线"); if (string.IsNullOrWhiteSpace(exePath)) throw new Exception($"请先调用SetExePath指定{exeName}进程所在路径,支持相对路径"); if (!Directory.Exists(exePath)) throw new Exception($"路径[{exePath}]不存在"); var exeFile = Path.Combine(exePath, exeName); if (!File.Exists(exeFile)) throw new Exception($"文件[{exeFile}]不存在"); List arguments = new List { "dfoline", $"{opt.TargetDfo}", $"{opt.Freq * 1e-6}", $"{opt.Turn1 * 1e-6}", $"{opt.Turn2 * 1e-6}", $"--rec1 {opt.MsAnt[0]} {opt.MsAnt[1]} 0", $"--rec2 {opt.NsAnt[0]} {opt.NsAnt[1]} 0", $"--eph1 {opt.MsEph[0]} {opt.MsEph[1]} {opt.MsEph[2]} {opt.MsEph[3]} {opt.MsEph[4]} {opt.MsEph[5]}", $"--eph2 {opt.NsEph[0]} {opt.NsEph[1]} {opt.NsEph[2]} {opt.NsEph[3]} {opt.NsEph[4]} {opt.NsEph[5]}", $"--refdf {opt.RefDfo}", $"--reffreq {opt.RefFreq * 1e-6}", $"--reflla {opt.RefGeod[0]} {opt.RefGeod[1]} 0" }; Process p = new Process(); p.StartInfo.WorkingDirectory = exePath; p.StartInfo.FileName = exeFile; p.StartInfo.Arguments = string.Join(" ", arguments); p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.UseShellExecute = false; StringBuilder sb = new StringBuilder(); p.OutputDataReceived += (sender, e) => sb.Append(e.Data); p.Start(); p.BeginOutputReadLine(); p.WaitForExit(); if (string.IsNullOrWhiteSpace(sb.ToString())) { throw new Exception("计算频差线出现未知错误!"); } var array = sb.ToString().Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (var item in array) { var strs = item.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); DfoLinePoint point = new DfoLinePoint(); point.Lon = Convert.ToDouble(strs[0]); point.Lat = Convert.ToDouble(strs[1]); list.Add(point); } var Lines = list.Select(s => (s.Lon, s.Lat)); return Lines; } } }