Exemple #1
0
  /** @param args */
  public static void main(String[] args) {

    try {

      // force dot as decimal separator
      Locale.setDefault(new Locale("en", "US"));

      // Get current time
      long start = System.currentTimeMillis();

      RinexNavigation navigationIn =
          new RinexNavigation(RinexNavigation.IGN_NAVIGATION_HOURLY_ZIM2);

      FileInputStream fis = new FileInputStream(".\\data\\aphemeris.dat");
      // FileInputStream fis = new FileInputStream(".\\data\\assistnow.dat");
      DataInputStream dis = new DataInputStream(fis);
      String msg = null;
      try {
        msg = dis.readUTF();
        while (msg != null) {
          System.out.println("Msg:[" + msg + "]");
          if (msg.equalsIgnoreCase(Streamable.MESSAGE_OBSERVATIONS)) {
            Observations o = new Observations(dis, false);

          } else if (msg.equalsIgnoreCase(Streamable.MESSAGE_EPHEMERIS)) {
            EphGps eph1 = new EphGps(dis, false);
            System.out.println(
                "found sat" + eph1.getSatID() + " time:" + eph1.getRefTime().getGpsTime());

            EphGps eph2 =
                navigationIn.findEph(
                    eph1.getRefTime().getMsec(), eph1.getSatID(), eph1.getSatType());

            // Compare
            if (eph2 != null) {
              double ms = eph1.getRefTime().getGpsTime() - eph2.getRefTime().getGpsTime();
              System.out.println(" time dif:" + (ms / 1000) + "s " + (ms % 1000) + "ms");
              ;
              equalDouble("Af0", eph1.getAf0(), eph2.getAf0());
              equalDouble("Af1", eph1.getAf1(), eph2.getAf1());
              equalDouble("Af2", eph1.getAf2(), eph2.getAf2());
              equalDouble("Cic", eph1.getCic(), eph2.getCic());
              equalDouble("Cis", eph1.getCis(), eph2.getCis());
              equalDouble("Crc", eph1.getCrc(), eph2.getCrc());
              equalDouble("Crs", eph1.getCrs(), eph2.getCrs());
              equalDouble("Cuc", eph1.getCuc(), eph2.getCuc());
              equalDouble("Cus", eph1.getCus(), eph2.getCus());
              equalDouble("DeltaN", eph1.getDeltaN(), eph2.getDeltaN());
              equalDouble("E", eph1.getE(), eph2.getE());
              equalDouble("FitInt", eph1.getFitInt(), eph2.getFitInt());
              equalDouble("I0", eph1.getI0(), eph2.getI0());
              equalDouble("iDot", eph1.getiDot(), eph2.getiDot());
              equalDouble("M0", eph1.getM0(), eph2.getM0());
              equalDouble("Omega", eph1.getOmega(), eph2.getOmega());
              equalDouble("Omega0", eph1.getOmega0(), eph2.getOmega0());
              equalDouble("OmegaDot", eph1.getOmegaDot(), eph2.getOmegaDot());
              equalDouble("RootA", eph1.getRootA(), eph2.getRootA());
              equalDouble("Tgd", eph1.getTgd(), eph2.getTgd());
              equalDouble("Toc", eph1.getToc(), eph2.getToc());
              equalDouble("Toe", eph1.getToe(), eph2.getToe());
              equalDouble("Iodc", eph1.getIodc(), eph2.getIodc());
              equalDouble("Iode", eph1.getIode(), eph2.getIode());
              equalDouble("L2Code", eph1.getL2Code(), eph2.getL2Code());
              equalDouble("L2Flag", eph1.getL2Flag(), eph2.getL2Flag());
              equalDouble("SvAccur", eph1.getSvAccur(), eph2.getSvAccur());
              equalDouble("SvHealth", eph1.getSvHealth(), eph2.getSvHealth());

            } else {
              System.out.println(
                  "EPH 2 not found for " + eph1.getSatID() + " at " + eph1.getRefTime());
            }

          } else if (msg.equalsIgnoreCase(Streamable.MESSAGE_OBSERVATIONS_SET)) {
            ObservationSet eps = new ObservationSet(dis, false);
            // nothing to do with ?
          } else if (msg.equalsIgnoreCase(Streamable.MESSAGE_IONO)) {
            IonoGps iono = new IonoGps(dis, false);
            // addIonospheric(iono);
          } else if (msg.equalsIgnoreCase(Streamable.MESSAGE_COORDINATES)) {
            Coordinates c = Coordinates.readFromStream(dis, false);
            // setDefinedPosition(c);

          } else {
            System.out.println("Unknow Msg:[" + msg + "]");
          }

          msg = dis.readUTF();
        }
      } catch (EOFException eof) {
        // ok
      }
      fis.close();

      try {
        navigationIn.release(true, 10000);
      } catch (InterruptedException ie) {
        ie.printStackTrace();
      }

      // Get and display elapsed time
      int elapsedTimeSec = (int) Math.floor((System.currentTimeMillis() - start) / 1000);
      int elapsedTimeMillisec =
          (int) ((System.currentTimeMillis() - start) - elapsedTimeSec * 1000);
      System.out.println(
          "\nElapsed time (read + proc + display + write): "
              + elapsedTimeSec
              + " seconds "
              + elapsedTimeMillisec
              + " milliseconds.");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }