Changeset 6799 in ntrip for trunk/BNC/src/bncutils.cpp


Ignore:
Timestamp:
Apr 28, 2015, 4:17:15 PM (9 years ago)
Author:
stuerze
Message:

simplification and harmonization of the conversion from accuracy indices into metric values and vice versa

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bncutils.cpp

    r6786 r6799  
    644644}
    645645
     646double accuracyFromIndex(int index, t_eph::e_type type) {
     647
     648  if (type == t_eph::GPS || type == t_eph::BDS || type == t_eph::SBAS
     649      || type == t_eph::QZSS) {
     650
     651    if ((index >= 0) && (index <= 6)) {
     652      if (index == 3) {
     653        return ceil(10.0 * pow(2.0, (double(index) / 2.0) + 1.0)) / 10.0;
     654      }
     655      else {
     656        return floor(10.0 * pow(2.0, (double(index) / 2.0) + 1.0)) / 10.0;
     657      }
     658    }
     659    else if ((index > 6) && (index <= 15)) {
     660      return (10.0 * pow(2.0, (double(index) - 2.0))) / 10.0;
     661    }
     662    else {
     663      return 8192.0;
     664    }
     665  }
     666
     667  if (type == t_eph::Galileo) {
     668
     669    if ((index >= 0) && (index <= 49)) {
     670      return (double(index) / 100.0);
     671    }
     672    else if ((index > 49) && (index <= 74)) {
     673      return (50.0 + (double(index) - 50.0) * 2.0) / 100.0;
     674    }
     675    else if ((index > 74) && (index <= 99)) {
     676      return 1.0 + (double(index) - 75.0) * 0.04;
     677    }
     678    else if ((index > 99) && (index <= 125)) {
     679      return 2.0 + (double(index) - 100.0) * 0.16;
     680    }
     681    else {
     682      return -1.0;
     683    }
     684  }
     685
     686  return double(index);
     687}
     688
     689int indexFromAccuracy(double accuracy, t_eph::e_type type) {
     690
     691  if (type == t_eph::GPS || type == t_eph::BDS || type == t_eph::SBAS
     692      || type == t_eph::QZSS) {
     693
     694    if (accuracy <= 2.40) {
     695      return 0;
     696    }
     697    else if (accuracy <= 3.40) {
     698      return 1;
     699    }
     700    else if (accuracy <= 4.85) {
     701      return 2;
     702    }
     703    else if (accuracy <= 6.85) {
     704      return 3;
     705    }
     706    else if (accuracy <= 9.65) {
     707      return 4;
     708    }
     709    else if (accuracy <= 13.65) {
     710      return 5;
     711    }
     712    else if (accuracy <= 24.00) {
     713      return 6;
     714    }
     715    else if (accuracy <= 48.00) {
     716      return 7;
     717    }
     718    else if (accuracy <= 96.00) {
     719      return 8;
     720    }
     721    else if (accuracy <= 192.00) {
     722      return 9;
     723    }
     724    else if (accuracy <= 384.00) {
     725      return 10;
     726    }
     727    else if (accuracy <= 768.00) {
     728      return 11;
     729    }
     730    else if (accuracy <= 1536.00) {
     731      return 12;
     732    }
     733    else if (accuracy <= 3072.00) {
     734      return 13;
     735    }
     736    else if (accuracy <= 6144.00) {
     737      return 14;
     738    }
     739    else {
     740      return 15;
     741    }
     742  }
     743
     744  if (type == t_eph::Galileo) {
     745    //TODO: implement conversion
     746  }
     747
     748  return (type == t_eph::Galileo) ? 255 : 15;
     749}
Note: See TracChangeset for help on using the changeset viewer.