/*读取观测值头文件*/ public static int readobsh(StreamReader sr, obs_t obs, station sta) { int flag = 0; string line = ""; while (!sr.EndOfStream) { line = sr.ReadLine(); if (line.Contains("RINEX VERSION / TYPE")) { sta.ver = double.Parse(line.Substring(0, 9)); } if (line.Contains("MARKER NAME")) { sta.name = line.Substring(0, 59).Trim(); } if (line.Contains("ANT # / TYPE"))//接收机天线类型 { sta.anxtype = line.Substring(20, 20); } if (line.Contains("ANTENNA: DELTA H/E/N")) { string[] ss = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); sta.atxdel[2] = double.Parse(ss[0]); //ss: H E N sta.atxdel[0] = double.Parse(ss[1]); //atxdel: E N U sta.atxdel[1] = double.Parse(ss[2]); } if (line.Contains("APPROX POSITION XYZ")) { for (int i = 0, j = 0; i < 3; i++, j += 14) { sta.xyz[i] = double.Parse(line.Substring(j, 14)); } } if (line.Contains("# / TYPES OF OBSERV")) { obs.ntype = int.Parse(line.Substring(0, 6)); for (int i = 0, j = 10; i < obs.ntype; i++, j += 6) { if (j > 58) { line = sr.ReadLine(); j = 10; } obs.obstype[i] = line.Substring(j, 2); } } if (line.Contains("END OF HEADER")) { return(1); } } return(flag); }
public static void propos(obs_t obss, dcb_t dcb, pcv_t pcv, station sta, nav_t nav, erp_t erp, List <result> res, RichTextBox text) { int nobs = 0; rtktime solt = new rtktime(); string timestr = null; obs_t obs = new obs_t(); ppp_t p3 = new ppp_t(); spp_t spp = new spp_t(); while ((nobs = inputobs(obs, obss)) > 0) { result re = new result(); solt = spp.tcur; if (pntpos(obs.obs_b, nav, spp, dcb) == 0) { continue; } p3.spp = spp; p3.soltime = spp.tcur; if (solt.time_int != 0) { p3.tt = rtklibcmn.timediff(p3.soltime, solt); } if (pppos(p3, obs.obs_b, nav, dcb, sta, erp) != 1) { continue; } for (int j = 0; j < 3; j++) { spp.rr[j] = p3.x[j]; } spp.dtr = p3.x[4]; re.time = obs.obs_b[0].t.calend; re.X = p3.x[0]; re.Y = p3.x[1]; re.Z = p3.x[2]; timestr = re.time[0] + "/" + re.time[1] + "/" + re.time[2] + " " + re.time[3] + ":" + re.time[4] + ":" + re.time[5]; text.AppendText(string.Format("{0,-20}", timestr) + string.Format("{0,-20}", re.X) + string.Format("{0,-20}", re.Y) + string.Format("{0,-20}", re.Z) + "\r\n"); res.Add(re); } }
public static int inputobs(obs_t obs, obs_t obss) { int n = 0, sat; time t = new time(); List <obs_s> obs_ = new List <obs_s>(); for (int i = 0; i < 32; i++) { obs_.Add(null); } obs.obs_b = new List <obs_s>(); if (0 <= iobss && iobss < obss.n) { t = obss.obs_b[iobss].t; } for (int i = 0; i < obss.obs_b.Count; i++) { if ((iobss + i) >= obss.obs_b.Count) { n = i; break; } if ((obss.obs_b[iobss + i].t.gpsec - t.gpsec) > DT) { n = i; break; } } for (int i = 0; i < n; i++) { sat = int.Parse(obss.obs_b[iobss + i].sprn.Substring(1, 2)); obs_[sat - 1] = obss.obs_b[iobss + i]; } foreach (var v in obs_) { if (v != null) { obs.obs_b.Add(v); } } iobss += n; return(n);//n为当前历元观测的卫星数 }
const double CLIGHT = 299792458.0; /* speed of light (m/s) */ /*读取观测值文件 支持ver 2.11*/ public static int readobs(string path, obs_t obs, station sta) { using (StreamReader sr = new StreamReader(path)) { if (readobsh(sr, obs, sta) == 1 && (sta.ver < 3 && sta.ver > 0)) { string line = ""; while (!sr.EndOfStream) { time tcurrent = new time(); string[] sprn = new string[64]; rtktime rtktcur = new rtktime(); int ns = 0; //每个历元观测到的卫星数 line = sr.ReadLine(); if (line != null) //读取含历元时间信息和卫星数的一行 { tcurrent = new time(line.Substring(0, 26), "o"); //读取时间信息 rtklibcmn.str2time(line.Substring(0, 26), rtktcur); ns = int.Parse(line.Substring(29, 3)); //读取当前历元观测到的卫星数 sprn = new string[ns]; //卫星prn for (int i = 0, j = 32; i < ns; i++, j += 3) { if (j >= 68) { line = sr.ReadLine(); j = 32; } sprn[i] = line.Substring(j, 3); } } for (int i = 0; i < ns; i++)//读取每个卫星相应的观测值 { obs_s sat = new obs_s(); sat.t = tcurrent; sat.rtkt = rtktcur; sat.sprn = sprn[i]; line = sr.ReadLine(); for (int k = 0, j = 0; k < obs.ntype; k++, j += 16)//读取一颗卫星的所有观测值信息 { obssat obsat = new obssat(); if (j >= 80) { line = sr.ReadLine(); j = 0; } obsat.type = obs.obstype[k]; if (j >= line.Length) { obsat.value = 0; } else { if (line.Substring(j, 14).Trim() == "") { obsat.value = 0; } else { obsat.value = double.Parse(line.Substring(j, 14)); } } sat.type_value.Add(obsat); } obs.obs_b.Add(sat); } obs.n += ns; } return(1); } else { return(0); } } }