Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5440409

Browse files
committedNov 12, 2024
sbstropcorr: remove the static cache
not thread safe, and unlikely to be a bottleneck now.
1 parent aa79681 commit 5440409

File tree

1 file changed

+34
-38
lines changed

1 file changed

+34
-38
lines changed
 

‎src/sbas.c

+34-38
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static int decode_sbstype25(const sbsmsg_t *msg, sbssat_t *sbssat)
387387

388388
return decode_longcorrh(msg,14,sbssat)&&decode_longcorrh(msg,120,sbssat);
389389
}
390-
/* decode type 26: ionospheric deley corrections -----------------------------*/
390+
/* decode type 26: ionospheric delay corrections -----------------------------*/
391391
static int decode_sbstype26(const sbsmsg_t *msg, sbsion_t *sbsion)
392392
{
393393
int i,j,block,delay,give,band=getbitu(msg->msg,14,4);
@@ -743,43 +743,39 @@ static void getmet(double lat, double *met)
743743
for (i=0;i<10;i++) met[i]=(1.0-a)*metprm[j-1][i]+a*metprm[j][i];
744744
}
745745
}
746-
/* tropospheric delay correction -----------------------------------------------
747-
* compute sbas tropospheric delay correction (mops model)
748-
* args : gtime_t time I time
749-
* double *pos I receiver position {lat,lon,height} (rad/m)
750-
* double *azel I satellite azimuth/elavation (rad)
751-
* double *var O variance of troposphric error (m^2)
752-
* return : slant tropospheric delay (m)
753-
*-----------------------------------------------------------------------------*/
754-
extern double sbstropcorr(gtime_t time, const double *pos, const double *azel,
755-
double *var)
756-
{
757-
const double k1=77.604,k2=382000.0,rd=287.054,gm=9.784,g=9.80665;
758-
static double pos_[3]={0},zh=0.0,zw=0.0;
759-
int i;
760-
double c,met[10],sinel=sin(azel[1]),h=pos[2],m;
761-
762-
trace(4,"sbstropcorr: pos=%.3f %.3f azel=%.3f %.3f\n",pos[0]*R2D,pos[1]*R2D,
763-
azel[0]*R2D,azel[1]*R2D);
764-
765-
if (pos[2]<-100.0||10000.0<pos[2]||azel[1]<=0) {
766-
*var=0.0;
767-
return 0.0;
768-
}
769-
if (zh==0.0||fabs(pos[0]-pos_[0])>1E-7||fabs(pos[1]-pos_[1])>1E-7||
770-
fabs(pos[2]-pos_[2])>1.0) {
771-
getmet(pos[0]*R2D,met);
772-
c=cos(2.0*PI*(time2doy(time)-(pos[0]>=0.0?28.0:211.0))/365.25);
773-
for (i=0;i<5;i++) met[i]-=met[i+5]*c;
774-
zh=1E-6*k1*rd*met[0]/gm;
775-
zw=1E-6*k2*rd/(gm*(met[4]+1.0)-met[3]*rd)*met[2]/met[1];
776-
zh*=pow(1.0-met[3]*h/met[1],g/(rd*met[3]));
777-
zw*=pow(1.0-met[3]*h/met[1],(met[4]+1.0)*g/(rd*met[3])-1.0);
778-
for (i=0;i<3;i++) pos_[i]=pos[i];
779-
}
780-
m=1.001/sqrt(0.002001+sinel*sinel);
781-
*var=0.12*0.12*m*m;
782-
return (zh+zw)*m;
746+
/* Tropospheric delay correction -----------------------------------------------
747+
* Compute SBAS tropospheric delay correction (mops model)
748+
* Args : gtime_t time I time
749+
* double *pos I receiver position {lat,lon,height} (rad/m)
750+
* double *azel I satellite azimuth/elavation (rad)
751+
* double *var O variance of tropospheric error (m^2)
752+
* Return : slant tropospheric delay (m)
753+
*----------------------------------------------------------------------------*/
754+
extern double sbstropcorr(gtime_t time, const double *pos, const double *azel, double *var) {
755+
const double k1 = 77.604, k2 = 382000.0, rd = 287.054, gm = 9.784, g = 9.80665;
756+
757+
trace(4, "sbstropcorr: pos=%.3f %.3f azel=%.3f %.3f\n", pos[0] * R2D, pos[1] * R2D, azel[0] * R2D,
758+
azel[1] * R2D);
759+
760+
if (pos[2] < -100.0 || 10000.0 < pos[2] || azel[1] <= 0) {
761+
*var = 0.0;
762+
return 0.0;
763+
}
764+
765+
double met[10];
766+
getmet(pos[0] * R2D, met);
767+
double c = cos(2.0 * PI * (time2doy(time) - (pos[0] >= 0.0 ? 28.0 : 211.0)) / 365.25);
768+
for (int i = 0; i < 5; i++) met[i] -= met[i + 5] * c;
769+
double zh = 1E-6 * k1 * rd * met[0] / gm;
770+
double zw = 1E-6 * k2 * rd / (gm * (met[4] + 1.0) - met[3] * rd) * met[2] / met[1];
771+
double h = pos[2];
772+
zh *= pow(1.0 - met[3] * h / met[1], g / (rd * met[3]));
773+
zw *= pow(1.0 - met[3] * h / met[1], (met[4] + 1.0) * g / (rd * met[3]) - 1.0);
774+
775+
double sinel = sin(azel[1]);
776+
double m = 1.001 / sqrt(0.002001 + sinel * sinel);
777+
*var = 0.12 * 0.12 * m * m;
778+
return (zh + zw) * m;
783779
}
784780
/* long term correction ------------------------------------------------------*/
785781
static int sbslongcorr(gtime_t time, int sat, const sbssat_t *sbssat,

0 commit comments

Comments
 (0)
Please sign in to comment.