Changeset 6799 in ntrip


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

Location:
trunk/BNC/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/RTCM3/ephEncoder.cpp

    r6635 r6799  
    4545  int numbits = 0;
    4646  unsigned long long bitbuffer = 0;
    47   if (eph._ura <= 2.40){
    48     eph._ura = 0;
    49   }
    50   else if (eph._ura <= 3.40){
    51     eph._ura = 1;
    52   }
    53   else if (eph._ura <= 6.85){
    54     eph._ura = 2;
    55   }
    56   else if (eph._ura <= 9.65){
    57     eph._ura = 3;
    58   }
    59   else if (eph._ura <= 13.65){
    60     eph._ura = 4;
    61   }
    62   else if (eph._ura <= 24.00){
    63     eph._ura = 5;
    64   }
    65   else if (eph._ura <= 48.00){
    66     eph._ura = 6;
    67   }
    68   else if (eph._ura <= 96.00){
    69     eph._ura = 7;
    70   }
    71   else if (eph._ura <= 192.00){
    72     eph._ura = 8;
    73   }
    74   else if (eph._ura <= 384.00){
    75     eph._ura = 9;
    76   }
    77   else if (eph._ura <= 768.00){
    78     eph._ura = 10;
    79   }
    80   else if (eph._ura <= 1536.00){
    81     eph._ura = 11;
    82   }
    83   else if (eph._ura <= 1536.00){
    84     eph._ura = 12;
    85   }
    86   else if (eph._ura <= 2072.00){
    87     eph._ura = 13;
    88   }
    89   else if (eph._ura <= 6144.00){
    90     eph._ura = 14;
    91   }
    92   else{
    93     eph._ura = 15;
    94   }
    95 
     47  eph._ura = indexFromAccuracy(eph._ura, eph.type());
    9648  GPSADDBITS(12, 1019)
    9749  if (eph._prn.system() == 'J') {
     
    256208  buffer= buffer+3;
    257209
     210  eph._SISA = indexFromAccuracy(eph._SISA, eph.type());
     211
    258212  bool inav = ( (eph._flags & GALEPHF_INAV) == GALEPHF_INAV );
    259 
    260213  GALILEOADDBITS(12, inav ? 1046 : 1045)
    261214  GALILEOADDBITS(6, eph._prn.number())
     
    340293  buffer= buffer+3;
    341294
     295  eph._ura = indexFromAccuracy(eph._ura, eph.type());
    342296  SBASADDBITS(12, 1043)
    343297  SBASADDBITS(6, eph._prn.number()-20)
     
    388342  buffer= buffer+3;
    389343
     344  eph._URA = indexFromAccuracy(eph._URA, eph.type());
    390345  BDSADDBITS(12, RTCM3ID_BDS)
    391346  BDSADDBITS(6, eph._prn.number())
    392347  BDSADDBITS(13, eph._TOC_bdt.gpsw() - 1356.0)
    393   BDSADDBITS(4, eph._URAI);
     348  BDSADDBITS(4, eph._URA);
    394349  BDSADDBITSFLOAT(14, eph._IDOT, M_PI/static_cast<double>(1<<30)/static_cast<double>(1<<13))
    395350  BDSADDBITS(5, eph._AODE)
  • trunk/BNC/src/RTCM3/ephEncoder.h

    r6600 r6799  
    33
    44#include "ephemeris.h"
     5#include "bncutils.h"
    56
    67class t_ephEncoder {
  • 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}
  • trunk/BNC/src/bncutils.h

    r6786 r6799  
    3333#include <newmat.h>
    3434#include <bncconst.h>
     35#include <ephemeris.h>
    3536
    3637void         expandEnvVar(QString& str);
     
    109110void         stripWhiteSpace(std::string& str);
    110111
     112double       accuracyFromIndex(int index, t_eph::e_type type);
     113
     114int          indexFromAccuracy(double accuracy, t_eph::e_type type);
     115
    111116#endif
  • trunk/BNC/src/ephemeris.cpp

    r6798 r6799  
    135135  _L2PFlag  = 0.0;
    136136
    137   if (ee->URAindex <= 6) {
    138     _ura = ceil(10.0*pow(2.0, 1.0+((double)ee->URAindex)/2.0))/10.0;
    139   }
    140   else {
    141     _ura = ceil(10.0*pow(2.0, ((double)ee->URAindex)/2.0))/10.0;
    142   }
     137  _ura = accuracyFromIndex(ee->URAindex, type());
     138
    143139  _health   = ee->SVhealth;
    144140  _TGD      = ee->TGD;
     
    461457  _TOEweek  = ee->Week;
    462458 
    463   if ((ee->SISA >= 0) && (ee->SISA <= 49)) {
    464     _SISA = ee->SISA / 100.0;
    465   }
    466   else if((ee->SISA >= 50) && (ee->SISA <= 74)) {
    467     _SISA = (50 + (ee->SISA - 50.0) * 2.0) / 100.0;
    468   }
    469   else if((ee->SISA >= 75) && (ee->SISA <= 99)) {
    470     _SISA = 1.0 + (ee->SISA - 75.0) * 0.04;
    471   }
    472   else if((ee->SISA >= 100) && (ee->SISA <= 125)) {
    473     _SISA = 2.0 + (ee->SISA - 100.0) * 0.16;
    474   }
    475   else if (ee->SISA >= 126 ) {
    476     _SISA = -1.0;
    477   }
     459  _SISA = accuracyFromIndex(ee->SISA, type());
    478460  _E5aHS    = ee->E5aHS;
    479461  _E5bHS    = ee->E5bHS;
     
    13521334  _z_acceleration = ee->z_acceleration;
    13531335
    1354   _ura            = ee->URA;
     1336  _ura            = accuracyFromIndex(ee->URA, type());
    13551337
    13561338  _health = 0;
     
    16081590  _omega    = ee->omega;
    16091591  _OMEGADOT = ee->OMEGADOT;
     1592
    16101593  _IDOT     = ee->IDOT;
    16111594
     1595  _URA      = accuracyFromIndex(ee->URAI, type());
     1596  _SatH1    = (ee->flags & BDSEPHF_SATH1) ? 1: 0;
    16121597  _TGD1     = ee->TGD_B1_B3;
    16131598  _TGD2     = ee->TGD_B2_B3;
    16141599
    1615   if ((ee->URAI <  6) && (ee->URAI >= 0)) {
    1616     _URA = ceil(10.0 * pow(2.0, ((double)ee->URAI/2.0) + 1.0)) / 10.0;
    1617   }
    1618   if ((ee->URAI >= 6) && (ee->URAI < 15)) {
    1619     _URA = ceil(10.0 * pow(2.0, ((double)ee->URAI/2.0)      )) / 10.0;
    1620   }
    1621   _SatH1    = (ee->flags & BDSEPHF_SATH1) ? 1: 0;
    16221600
    16231601}
Note: See TracChangeset for help on using the changeset viewer.