Changeset 218 in ntrip for trunk/BNC


Ignore:
Timestamp:
Oct 6, 2006, 5:59:37 PM (18 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/RTCM/RTCM2.cpp

    r216 r218  
    10751075        int    refWeek;
    10761076        double refSecs;
    1077         gpsWeekAndSec(refWeek, refSecs);
     1077        currentGPSWeeks(refWeek, refSecs);
    10781078        int    epochWeek;
    10791079        double epochSecs;
  • trunk/BNC/bncutils.cpp

    r214 r218  
    1717
    1818#include <iostream>
     19#include <ctime>
    1920
    2021#include <QRegExp>
     
    5455}
    5556
     57double MJD(int year, int month, double day) {
     58  if( month <= 2 ) {
     59    year = year - 1;
     60    month = month + 12;
     61  } 
     62  int ii   = year/100;
     63  int kk   = 2 - ii + ii/4;
     64  double mjd = (365.25*year - fmod( 365.25*year, 1.0 )) - 679006.0
     65                + floor( 30.6001*(month + 1) ) + day + kk;
     66  return mjd;
     67}
    5668
    57 void gpsWeekAndSec(int& week, double& sec) {
     69void MJD_GPSWeeks(double mjd, int& week, double& sec) {
     70  double deltat = mjd - 44244.0 ;
     71  week = (long) floor(deltat/7.0);
     72  sec = (deltat - (week)*7.0)*86400.0;
     73}
    5874
    59   QDate date = QDate::currentDate();
    60   QTime time = QTime::currentTime();
     75void currentGPSWeeks(int& week, double& sec) {
    6176
    62   double deltat = double(date.toJulianDay()) - 2444244.0 +
    63            ((( time.msec() / 1000.0
    64              + time.second() ) / 60.0
    65              + time.minute()  ) / 60.0
    66              + time.hour()     ) / 24.0;
     77  time_t    ltime;
     78  struct tm *gmt;
    6779
    68   week = (int) floor(deltat/7.0);
    69   sec  = (deltat - (week)*7.0)*86400.0;
     80  time(&ltime);
     81  gmt = gmtime(&ltime);
     82
     83  double dayFrac = ((  gmt->tm_sec  / 60.0
     84                     + gmt->tm_min ) / 60.0
     85                     + gmt->tm_hour ) / 24.0;
     86
     87  double mjd = MJD(1900+gmt->tm_year, gmt->tm_mon+1, gmt->tm_mday+1+dayFrac);
     88
     89  cout << 1900+gmt->tm_year << " " << gmt->tm_mon+1 << " " << gmt->tm_mday+1
     90       << " " << gmt->tm_hour
     91       << " " << gmt->tm_min
     92       << " " << gmt->tm_sec << endl;
     93
     94  MJD_GPSWeeks(mjd, week, sec);
    7095}
Note: See TracChangeset for help on using the changeset viewer.