Pages, some stolen, some original

Thursday, October 1, 2009

Calculating Local Time from Raw GPS Data

Here is an example of the kind of math I had to deal with at work several years ago. I wrote the explanation up for my kids. As expected, they showed no interest.

Calculating the timezone offset from the Longitude that we get from the GPS.

(GPS - Global Positioning System). We have a GPS module we use in our radio to get the current time. But the current time is GMT (Greenwich Mean Time), which doesn't mean much to someone in Timbuktu. We also can get our longitude from the GPS. So from the Longitude and the GMT, we can calculate what timezone we are in, and with that we can figure out what the local time is.
  • Longitude is given in milli-arc-seconds (mas).
  • There are 3,600,000 mas in one degree (60 minutes * 60 seconds * 1000)
  • There are 15 degrees per time zone (360 degrees divided by 24 hours per day).
  1. Divide Longitude by 3,600,000 gives longitude in degrees.
  2. Divide result by 15 gives timezone, which is the same as the hourly difference.
  3. Multiply result by 3600 to get timezone in seconds
  4. Multiply result by -1 to get the direction to agree with Microsoft's timezone variable.
Combined, we have:
Longitude * 3,600 * -1
-------------------------
15 * 3,600,000

Reduced we get:
Timezone = Longitude / -15,000

2 comments:

  1. Wrong. There are not 15 degrees per time zone. There are time zones offset by 30 minutes in some parts of the world.

    Plus the international Date Line is not a straight meridian.

    Microschrott merely provides an approximation to the truch (as usual).

    ReplyDelete
  2. Wrong? Truth? It's all politics. Local time is a fable, as are all time zones. True, this formula only approximates the local time, but without access to an extensive database that is continuously updated with the latest politcal vagaries, you would have a hard time deducing the local time from your GPS coordinates.

    When I become time czar, the day will start at 6AM at sunrise, and the length of each minute will be adjusted to match the length of the day. There will be twelve hours of light and twelve hours of dark.

    ReplyDelete