@@ -330,6 +330,7 @@ static double varerr(int sat, int sys, double el, double snr_rover, int freq,
330330 switch (sys ) {
331331 case SYS_GPS : fact *= EFACT_GPS ; break ;
332332 case SYS_GLO : fact *= EFACT_GLO ; break ;
333+ case SYS_GAL : fact *= EFACT_GAL ; break ;
333334 case SYS_SBS : fact *= EFACT_SBS ; break ;
334335 default : fact *= EFACT_GPS ; break ;
335336 }
@@ -365,7 +366,8 @@ static void initx(rtk_t *rtk, double xi, double var, int i)
365366static double gfmeas (const obsd_t * obs , const nav_t * nav )
366367{
367368 const double * lam = nav -> lam [obs -> sat - 1 ];
368- int i = (satsys (obs -> sat ,NULL )& (SYS_GAL |SYS_SBS ))?2 :1 ;
369+ int i = (satsys (obs -> sat ,NULL )& (SYS_SBS ))?2 :1 ; /* always use L1/L5 for SBAS */
370+ if (NFREQ > 2 && obs -> P [1 ]== 0.0 ) i = 2 ; /* otherwise, if no L2, try L5 */
369371
370372 if (lam [0 ]== 0.0 || lam [i ]== 0.0 || obs -> L [0 ]== 0.0 || obs -> L [i ]== 0.0 ) return 0.0 ;
371373 return lam [0 ]* obs -> L [0 ]- lam [i ]* obs -> L [i ];
@@ -374,7 +376,8 @@ static double gfmeas(const obsd_t *obs, const nav_t *nav)
374376static double mwmeas (const obsd_t * obs , const nav_t * nav )
375377{
376378 const double * lam = nav -> lam [obs -> sat - 1 ];
377- int i = (satsys (obs -> sat ,NULL )& (SYS_GAL |SYS_SBS ))?2 :1 ;
379+ int i = (satsys (obs -> sat ,NULL )& (SYS_SBS ))?2 :1 ; /* always use L1/L5 for SBAS */
380+ if (NFREQ > 2 && obs -> P [1 ]== 0.0 ) i = 2 ; /* otherwise, if no L2, try L5 */
378381
379382 if (lam [0 ]== 0.0 || lam [i ]== 0.0 || obs -> L [0 ]== 0.0 || obs -> L [i ]== 0.0 ||
380383 obs -> P [0 ]== 0.0 || obs -> P [i ]== 0.0 ) return 0.0 ;
@@ -408,6 +411,8 @@ static void corr_meas(const obsd_t *obs, const nav_t *nav, const double *azel,
408411 ix = (i == 0 ?CODE_L1W - 1 :CODE_L2W - 1 );
409412 else if (sys == SYS_GLO )
410413 ix = (i == 0 ?CODE_L1P - 1 :CODE_L2P - 1 );
414+ else if (sys == SYS_GAL )
415+ ix = (i == 0 ?CODE_L1X - 1 :CODE_L7X - 1 );
411416 P [i ]+= (nav -> ssr [obs -> sat - 1 ].cbias [obs -> code [i ]- 1 ]- nav -> ssr [obs -> sat - 1 ].cbias [ix ]); /* ssr correction */
412417 }
413418 else {
@@ -426,7 +431,8 @@ static void corr_meas(const obsd_t *obs, const nav_t *nav, const double *azel,
426431 }
427432 /* iono-free LC */
428433 * Lc = * Pc = 0.0 ;
429- i = (sys & (SYS_GAL |SYS_SBS ))?2 :1 ; /* L1/L2 or L1/L5 */
434+ i = (sys & (SYS_SBS ))?2 :1 ; /* always use L1/L5 for SBAS */
435+ if (NFREQ > 2 && P [1 ]== 0.0 ) i = 2 ; /* otherwise, if no L2, try L5 */
430436 if (lam [0 ]== 0.0 || lam [i ]== 0.0 ) return ;
431437
432438 C1 = SQR (lam [i ])/(SQR (lam [i ])- SQR (lam [0 ]));
@@ -654,7 +660,8 @@ static void udiono_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav)
654660 for (i = 0 ;i < n ;i ++ ) {
655661 j = II (obs [i ].sat ,& rtk -> opt );
656662 if (rtk -> x [j ]== 0.0 ) {
657- k = satsys (obs [i ].sat ,NULL )== SYS_GAL ?2 :1 ;
663+ k = 1 ;
664+ if (NFREQ > 2 && obs [i ].P [1 ]== 0.0 ) k = 2 ; /* if no L2, try L5 */
658665 lam = nav -> lam [obs [i ].sat - 1 ];
659666 if (obs [i ].P [0 ]== 0.0 || obs [i ].P [k ]== 0.0 || lam [0 ]== 0.0 || lam [k ]== 0.0 ) {
660667 continue ;
@@ -733,7 +740,8 @@ static void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav)
733740 }
734741 else if (L [f ]!= 0.0 && P [f ]!= 0.0 ) {
735742 slip [i ]= rtk -> ssat [sat - 1 ].slip [f ];
736- l = satsys (sat ,NULL )== SYS_GAL ?2 :1 ;
743+ l = 1 ;
744+ if (NFREQ > 2 && obs [i ].P [l ]== 0.0 ) l = 2 ; /* if no L2, try L5 */
737745 lam = nav -> lam [sat - 1 ];
738746 if (obs [i ].P [0 ]== 0.0 || obs [i ].P [l ]== 0.0 || lam [0 ]== 0.0 || lam [l ]== 0.0 || lam [f ]== 0.0 )
739747 ion = 0 ;
0 commit comments