-void SGTime::updateLocal( double lon, double lat, const string& root )
-{
- time_t currGMT;
- time_t aircraftLocalTime;
- GeoCoord location( RAD_TO_DEG * lat, RAD_TO_DEG * lon );
- GeoCoord* nearestTz = tzContainer->getNearest(location);
- FGPath zone( root );
- zone.append ("Timezone" );
- zone.append ( nearestTz->getDescription() );
- if ( zonename ) {
- delete zonename;
- }
- zonename = strdup( zone.c_str() );
- currGMT = get_gmt( gmtime(&cur_time) );
- aircraftLocalTime = get_gmt( (fgLocaltime(&cur_time, zone.c_str())) );
- local_offset = aircraftLocalTime - currGMT;
- // cout << "Using " << local_offset << " as local time offset Timezone is "
- // << zonename << endl;
-}
-
-
-// given Julian Date and Longitude (decimal degrees West) compute
-// Local Sidereal Time, in decimal hours.
-//
-// Provided courtesy of ecdowney@noao.edu (Elwood Downey)
-double SGTime::sidereal_precise( double lng )
-{
- double lstTmp;
-
- /* printf ("Current Lst on JD %13.5f at %8.4f degrees West: ",
- mjd + MJD0, lng); */
-
- // convert to required internal units
- lng *= DEG_TO_RAD;
-
- // compute LST and print
- gst = sgTimeCalcGST( mjd );
- lstTmp = gst - RADHR (lng);
- lstTmp -= 24.0*floor(lstTmp/24.0);
- // printf ("%7.4f\n", lstTmp);
-
- // that's all
- return (lstTmp);
-}
-
-
-// return a courser but cheaper estimate of sidereal time
-double SGTime::sidereal_course( double lng )
-{
- time_t start_gmt, now;
- double diff, part, days, hours, lstTmp;
- char tbuf[64];
-
- now = cur_time;
- start_gmt = get_gmt(gmt->tm_year, 2, 21, 12, 0, 0);
-
- FG_LOG( FG_EVENT, FG_DEBUG, " COURSE: GMT = "
- << sgTimeFormatTime(gmt, tbuf) );
- FG_LOG( FG_EVENT, FG_DEBUG, " March 21 noon (GMT) = " << start_gmt );
-
- diff = (now - start_gmt) / (3600.0 * 24.0);
-
- FG_LOG( FG_EVENT, FG_DEBUG,
- " Time since 3/21/" << gmt->tm_year << " GMT = " << diff );
-
- part = fmod(diff, 1.0);
- days = diff - part;
- hours = gmt->tm_hour + gmt->tm_min/60.0 + gmt->tm_sec/3600.0;
-
- lstTmp = (days - lng)/15.0 + hours - 12;
-
- while ( lstTmp < 0.0 ) {
- lstTmp += 24.0;