Click here to Skip to main content
12,452,015 members (25,806 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# .NET
I need help. Actually I do not know how to calculate a GPS time and GPS week, GPS day of the week.

I would like the current date calculated GPS date, GPS week and GPS time in seconds.

thanks for the help, if there is some sample code to help me out a lot.
Posted 30-Sep-12 22:20pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

See here[^].
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

// racunam gps nedelju
           // prvo racunam julijanski dan
           // koriscen algoritam "Practical Ephemeris Calculations" - oliver Montenbruck
           // Springer - Verlag, 1989)
           double yr = Convert.ToDouble(godina);
           double mn = Convert.ToDouble(mesec);
           double dy = Convert.ToDouble(datumUmesecu);
           double y = 0;
           double m = 0;
           double b = 0;
           double jd = 0;
 
           if (mn > 2)
           {
                y = yr;
                m = mn;
           }
           else
           {
                y = yr - 1;
                m = mn + 12;
           }
 
           double date0 = dy + 31 * (mn + 12 * yr);
           double date1 = 4 + 31 * (10 + 12 * 1582);
           double date2 = 15 + 31 * (10 + 12 * 1582);
 
           if (date0 < date1)
           {
                b = -2;
           }
           else
           {
                b = y / 400 - y / 100;
           }
 
           if ( y > 0)
           {
                jd = 365.25 * y + 30.6001 * (m + 1) + b + 1720996.5 + dy;// julijanski datum
           }
           else
           {
                jd = 365.25 * y - 0.75 + 30.6001 * (m + 1) + b + 1720996.5 + dy;// julijanski datum
           }
 
           double mjd = jd - 2400000.5;// modifikovvani julijanski datum

           // GPS nedelja racunam
           double jd1 = 0;
           yr = 1980;
           mn = 1;
           dy = 6;
           if (mn > 2)
           {
               y = yr;
               m = mn;
           }
           else
           {
               y = yr - 1;
               m = mn + 12;
           }
            date0 = dy + 31 * (mn + 12 * yr);
            date1 = 4 + 31 * (10 + 12 * 1582);
            date2 = 15 + 31 * (10 + 12 * 1582);
 
           if (date0 < date1)
           {
               b = -2;
           }
           else
           {
               b = y / 400 - y / 100;
           }
 
           if (y > 0)
           {
               jd1 = 365.25 * y + 30.6001 * (m + 1) + b + 1720996.5 + dy;// julijanski datum
           }
           else
           {
               jd1 = 365.25 * y - 0.75 + 30.6001 * (m + 1) + b + 1720996.5 + dy;// julijanski datum
           }
           double jdgps = jd1 - 2400000.5;// modifikovani julijanski datum
           double gpsWeek = (jd - jd1) / 7;// gps nedelja
           double sow = (jd - (jd1 + Convert.ToInt32(gpsWeek) * 7)) * 3600 * 24;// sekunda u nedelji
           // kraj racunanja gps nedelje
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 2 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100