StelCore.cpp   StelCore.cpp 
skipping to change at line 112 skipping to change at line 112
delete position; position=NULL; delete position; position=NULL;
} }
/************************************************************************* /*************************************************************************
Load core data and initialize with default values Load core data and initialize with default values
*************************************************************************/ *************************************************************************/
void StelCore::init() void StelCore::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
defaultLocationID = conf->value("init_location/location","error").to String(); defaultLocationID = conf->value("init_location/location", "auto").to String();
bool ok; bool ok;
StelLocationMgr* locationMgr = &StelApp::getInstance().getLocationMg r(); StelLocationMgr* locationMgr = &StelApp::getInstance().getLocationMg r();
StelLocation location = locationMgr->locationForString(defaultLocati StelLocation location;
onID); if (defaultLocationID == "auto")
{
locationMgr->locationFromIP();
}
else
{
location = locationMgr->locationForString(defaultLocationID)
;
}
if (!location.isValid()) if (!location.isValid())
{ {
qWarning() << "Warning: location" << defaultLocationID << "i s unknown."; qWarning() << "Warning: location" << defaultLocationID << "i s unknown.";
location = locationMgr->getLastResortLocation(); location = locationMgr->getLastResortLocation();
} }
position = new StelObserver(location); position = new StelObserver(location);
// Delta-T stuff // Delta-T stuff
// Define default algorithm for time correction (Delta T) // Define default algorithm for time correction (Delta T)
QString tmpDT = conf->value("navigation/time_correction_algorithm", "EspenakMeeus").toString(); QString tmpDT = conf->value("navigation/time_correction_algorithm", "EspenakMeeus").toString();
skipping to change at line 914 skipping to change at line 923
setJDay(JD+getDeltaT(JD)/86400); setJDay(JD+getDeltaT(JD)/86400);
} }
void StelCore::setTodayTime(const QTime& target) void StelCore::setTodayTime(const QTime& target)
{ {
QDateTime dt = QDateTime::currentDateTime(); QDateTime dt = QDateTime::currentDateTime();
if (target.isValid()) if (target.isValid())
{ {
dt.setTime(target); dt.setTime(target);
// don't forget to adjust for timezone / daylight savings. // don't forget to adjust for timezone / daylight savings.
setJDay(StelUtils::qDateTimeToJd(dt)-(StelUtils::getGMTShift double JD = StelUtils::qDateTimeToJd(dt)-(StelUtils::getGMTS
FromQT(StelUtils::getJDFromSystem()) * JD_HOUR)); hiftFromQT(StelUtils::getJDFromSystem()) * JD_HOUR);
setJDay(JD + getDeltaT(JD)/86400);
} }
else else
{ {
qWarning() << "WARNING - time passed to StelCore::setTodayTi me is not valid. The system time will be used." << target; qWarning() << "WARNING - time passed to StelCore::setTodayTi me is not valid. The system time will be used." << target;
setTimeNow(); setTimeNow();
} }
} }
//! Get whether the current stellarium time is the real world time //! Get whether the current stellarium time is the real world time
bool StelCore::getIsTimeNow(void) const bool StelCore::getIsTimeNow(void) const
skipping to change at line 1729 skipping to change at line 1739
else else
validRange = q_("Valid range of usage: between years %1 and %2.").arg(start).arg(finish); validRange = q_("Valid range of usage: between years %1 and %2.").arg(start).arg(finish);
if (start > year || year > finish) if (start > year || year > finish)
*marker = "*"; *marker = "*";
} }
else else
*marker = "?"; *marker = "?";
return QString(" %1").arg(validRange); return QString(" %1").arg(validRange);
} }
bool StelCore::isDay() const
{
const Vec3d& sunPos = GETSTELMODULE(SolarSystem)->getSun()->getAltAz
PosGeometric(this);
return sunPos[2] > -0.12; // Nautical twilight
}
double StelCore::getCurrentEpoch() const
{
int year, month, day;
StelUtils::getDateFromJulianDay(getJDay(), &year, &month, &day);
QDate date = QDate::fromString(QString("%1.%2.%3").arg(year, 4, 10,
QLatin1Char('0')).arg(month).arg(day), "yyyy.M.d");
return double(year) + double(date.dayOfYear())/double(date.daysInYea
r());
}
 End of changes. 4 change blocks. 
5 lines changed or deleted 15 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/