Example #1
0
   void processSubframes4and5(MDPNavSubframe& nav)
   {
         // For now, just look at L1 C/A navigation message
      if (nav.range != rcCA || nav.carrier != ccL1)
         return;
      
         // Pull the time from the subframe
      short week = static_cast<GPSWeekSecond>(nav.time).week;
      long sow = static_cast<GPSWeekSecond>(nav.getHOWTime()).sow;
      if ( sow >604800)
         return;
#pragma unused(week)
      NavIndex ni(RangeCarrierPair(nav.range, nav.carrier), nav.prn);
      
      AlmMap::iterator a;
      a = almData.find(ni);
      if (a==almData.end())
      {
         UniqueAlmStore init( ni, nav.nav );
         //pair<NavIndex,gpstk::UniqueAlmStore> = node(ni,init);
         almData.insert( make_pair(ni,init) );
         a = almData.find(ni);
         if (a==almData.end())
         {
            cerr << "Almanac map insertion failed in mdp2fic.processSubframes4and5." << endl;
            exit(1);
         }
         cout << "Inserted a new almanac map for PRN " << nav.prn << endl;
      }
      UniqueAlmStore uas = a->second;
      uas.newSubframe(nav);
      if (uas.readyToWrite()) uas.write( FICOutput );
   }
Example #2
0
   void EphReader::read_mdp_data(const string& fn)
   {
      GPSEphemerisStore* bce;

      if (eph == NULL)
      {
         bce = new(GPSEphemerisStore);
         eph = dynamic_cast<EphemerisStore*>(bce);
      }
      else
      {
         if (typeid(*eph) != typeid(GPSEphemerisStore))
            throw(FFStreamError("Don't mix nav data types..."));
         bce = dynamic_cast<GPSEphemerisStore*>(eph);
      }
      if (verboseLevel>2)
         cout << "Reading " << fn << " as MDP nav."<< endl;

      MDPStream mdps(fn.c_str(), ios::in);
      MDPHeader header;
      MDPNavSubframe nav;
      typedef pair<RangeCode, CarrierCode> RangeCarrierPair;
      typedef pair<RangeCarrierPair, short> NavIndex;
      typedef map<NavIndex, MDPNavSubframe> NavMap;
      NavMap ephData;
      map<NavIndex, EphemerisPages> ephPageStore;
      map<NavIndex, EngEphemeris> ephStore;
      bool firstEph=true;

      while (mdps >> header)
         if (header.id == MDPNavSubframe::myId)
         {
            mdps >> nav;
            if (!nav)
            {
               if (mdps && verboseLevel>2)
                  cout << "Error decoding nav " << endl;
            }
            else
            {
               MDPNavSubframe tmp = nav;

               // First try the data assuming it is already upright
               tmp.cooked = true;
               bool parityGood = tmp.checkParity();
               if (!parityGood)
               {
                  if (verboseLevel>3 && firstEph)
                     cout << "Raw subframe" << endl;
                  nav.cooked = false;
                  nav.cookSubframe();
                  parityGood = nav.checkParity();
               }
               else
               {
                  if (verboseLevel>3 && firstEph)
                     cout << "Cooked subframe" << endl;
               }

               firstEph = false;

               if (!parityGood)
               {
                  if (verboseLevel>2)
                     cout << "Parity error" << endl;
                  return;
               }

               short sfid = nav.getSFID();
               if (sfid > 3)
                  return;

               short week = static_cast<GPSWeekSecond>(nav.time).week;
#pragma unused(week)
               long sow = nav.getHOWTime();
               if (sow > FULLWEEK)
               {
                  if (verboseLevel>2)
                     cout << "Bad week" << endl;
                  return;
               }

               if (verboseLevel>3)
                  nav.dump(cout);

               if (nav.range != rcCA || nav.carrier != ccL1)
                  return;

               NavIndex ni(RangeCarrierPair(nav.range, nav.carrier), nav.prn);
               ephData[ni] = nav;

               ephPageStore[ni][sfid] = nav;
               EngEphemeris engEph;
               if (makeEngEphemeris(engEph, ephPageStore[ni]))
               {
                  bce->addEphemeris(RinexNavData(engEph));
                  ephPageStore[ni].clear();
               }
            }
         }