- Timestamp:
- Oct 6, 2006, 5:59:37 PM (18 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/RTCM/RTCM2.cpp
r216 r218 1075 1075 int refWeek; 1076 1076 double refSecs; 1077 gpsWeekAndSec(refWeek, refSecs);1077 currentGPSWeeks(refWeek, refSecs); 1078 1078 int epochWeek; 1079 1079 double epochSecs; -
trunk/BNC/bncutils.cpp
r214 r218 17 17 18 18 #include <iostream> 19 #include <ctime> 19 20 20 21 #include <QRegExp> … … 54 55 } 55 56 57 double 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 } 56 68 57 void gpsWeekAndSec(int& week, double& sec) { 69 void 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 } 58 74 59 QDate date = QDate::currentDate(); 60 QTime time = QTime::currentTime(); 75 void currentGPSWeeks(int& week, double& sec) { 61 76 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; 67 79 68 week = (int) floor(deltat/7.0); 69 sec = (deltat - (week)*7.0)*86400.0; 80 time(<ime); 81 gmt = gmtime(<ime); 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); 70 95 }
Note:
See TracChangeset
for help on using the changeset viewer.