VK1ET : Additions to check fflags

Implement changes suggested by John/VK1ET

Changes to cprNFunction to ensure fflag {was 'isodd'} is used as a flag.
Fix to decodeCPRrelative to pass 'surface' flag.
This commit is contained in:
Malcolm Robb 2013-04-26 09:49:53 +01:00
parent 2acb0947f0
commit f77a85e8b8

View file

@ -2338,14 +2338,14 @@ int cprNLFunction(double lat) {
else return 1; else return 1;
} }
int cprNFunction(double lat, int isodd) { int cprNFunction(double lat, int fflag) {
int nl = cprNLFunction(lat) - isodd; int nl = cprNLFunction(lat) - (fflag ? 1 : 0);
if (nl < 1) nl = 1; if (nl < 1) nl = 1;
return nl; return nl;
} }
double cprDlonFunction(double lat, int isodd, int surface) { double cprDlonFunction(double lat, int fflag, int surface) {
return (surface ? 90.0 : 360.0) / cprNFunction(lat, isodd); return (surface ? 90.0 : 360.0) / cprNFunction(lat, fflag);
} }
/* This algorithm comes from: /* This algorithm comes from:
@ -2444,7 +2444,7 @@ int decodeCPRrelative(struct aircraft *a, int fflag, int surface, double latr, d
} }
// Compute the Longitude Index "m" // Compute the Longitude Index "m"
AirDlon = cprDlonFunction(rlat, fflag, 0); AirDlon = cprDlonFunction(rlat, fflag, surface);
m = (int) (floor(lonr/AirDlon) + m = (int) (floor(lonr/AirDlon) +
trunc(0.5 + cprModFunction((int)lonr, (int)AirDlon)/AirDlon - lon/131072)); trunc(0.5 + cprModFunction((int)lonr, (int)AirDlon)/AirDlon - lon/131072));
rlon = AirDlon * (m + lon/131072); rlon = AirDlon * (m + lon/131072);