Beispiel #1
0
void modCalcDayLength::slotComputePosTime()
{
	long double jd0 = getDateTime().djd();
	getGeoLocation();

	KSNumbers * num = new KSNumbers(jd0);
	KSSun *Sun = new KSSun(((KStars*) parent()->parent()->parent())->data());
	Sun->findPosition(num);

	QTime setQtime = Sun->riseSetTime( jd0 , geoPlace, false );
	QTime riseQtime = Sun->riseSetTime( jd0 , geoPlace, true );
	QTime transitQtime = Sun->transitTime(jd0 , geoPlace);

	dms setAz = Sun->riseSetTimeAz(jd0, geoPlace, false);
	dms riseAz = Sun->riseSetTimeAz(jd0, geoPlace, true);
	dms transAlt = Sun->transitAltitude(jd0, geoPlace);

	if (setQtime.isValid() ) {
		azSetBox->show( setAz );
		elTransitBox->show( transAlt );
		azRiseBox->show( riseAz );

		setTimeBox->showTime( setQtime );
		riseTimeBox->showTime( riseQtime );
		transitTimeBox->showTime( transitQtime );

		QTime dayLQtime = lengthOfDay (setQtime,riseQtime);

		dayLBox->showTime( dayLQtime );
	} else if (transAlt.Degrees() > 0. ) {
		azSetBox->setDMS(i18n("Circumpolar"));
		elTransitBox->show( transAlt );
		azRiseBox->setDMS(i18n("Circumpolar"));

		setTimeBox->showTime( setQtime );
		riseTimeBox->showTime( riseQtime );
		transitTimeBox->showTime( transitQtime );

		dayLBox->setEntry("24:00:00");

	} else if (transAlt.Degrees() < 0. ) {
		azSetBox->setDMS("does not rise");
		elTransitBox->setDMS("does not rise");
		azRiseBox->setDMS("does not rise");

		setTimeBox->clearFields();
		riseTimeBox->clearFields();
		transitTimeBox->clearFields();

		dayLBox->showTime( QTime(0,0,0) );
	}

	delete num;
}
Beispiel #2
0
void modCalcDayLength::updateAlmanac( const QDate &d, GeoLocation *geo ) {
    //Determine values needed for the Almanac
    long double jd0 = KStarsDateTime(d, QTime(8,0,0)).djd();
    KSNumbers num(jd0);

    //Sun
    KSSun Sun;
    Sun.findPosition(&num);

    QTime ssTime = Sun.riseSetTime(jd0 , geo, false );
    QTime srTime = Sun.riseSetTime(jd0 , geo, true );
    QTime stTime = Sun.transitTime(jd0 , geo);

    dms ssAz  = Sun.riseSetTimeAz(jd0, geo, false);
    dms srAz  = Sun.riseSetTimeAz(jd0, geo, true);
    dms stAlt = Sun.transitAltitude(jd0, geo);

    //In most cases, the Sun will rise and set:
    if ( ssTime.isValid() ) {
        ssAzString = ssAz.toDMSString();
        stAltString = stAlt.toDMSString();
        srAzString = srAz.toDMSString();

        ssTimeString = QLocale().toString( ssTime );
        srTimeString = QLocale().toString( srTime );
        stTimeString = QLocale().toString( stTime );

        QTime daylength = lengthOfDay(ssTime,srTime);
        daylengthString = QLocale().toString( daylength);

        //...but not always!
    } else if ( stAlt.Degrees() > 0. ) {
        ssAzString = i18n("Circumpolar");
        stAltString = stAlt.toDMSString();
        srAzString = i18n("Circumpolar");

        ssTimeString = "--:--";
        srTimeString = "--:--";
        stTimeString = QLocale().toString( stTime );
        daylengthString = "24:00";

    } else if (stAlt.Degrees() < 0. ) {
        ssAzString = i18n("Does not rise");
        stAltString = stAlt.toDMSString();
        srAzString = i18n("Does not set");

        ssTimeString = "--:--";
        srTimeString = "--:--";
        stTimeString = QLocale().toString( stTime );
        daylengthString = "00:00";
    }

    //Moon
    KSMoon Moon;

    QTime msTime = Moon.riseSetTime( jd0 , geo, false );
    QTime mrTime = Moon.riseSetTime( jd0 , geo, true );
    QTime mtTime = Moon.transitTime(jd0 , geo);

    dms msAz  = Moon.riseSetTimeAz(jd0, geo, false);
    dms mrAz  = Moon.riseSetTimeAz(jd0, geo, true);
    dms mtAlt = Moon.transitAltitude(jd0, geo);

    //In most cases, the Moon will rise and set:
    if ( msTime.isValid() ) {
        msAzString = msAz.toDMSString();
        mtAltString = mtAlt.toDMSString();
        mrAzString = mrAz.toDMSString();

        msTimeString = QLocale().toString( msTime );
        mrTimeString = QLocale().toString( mrTime );
        mtTimeString = QLocale().toString( mtTime );

        //...but not always!
    } else if ( mtAlt.Degrees() > 0. ) {
        msAzString = i18n("Circumpolar");
        mtAltString = mtAlt.toDMSString();
        mrAzString = i18n("Circumpolar");

        msTimeString = "--:--";
        mrTimeString = "--:--";
        mtTimeString = QLocale().toString( mtTime );

    } else if ( mtAlt.Degrees() < 0. ) {
        msAzString = i18n("Does not rise");
        mtAltString = mtAlt.toDMSString();
        mrAzString = i18n("Does not rise");

        msTimeString = "--:--";
        mrTimeString = "--:--";
        mtTimeString = QLocale().toString( mtTime );
    }

    //after calling riseSetTime Phase needs to reset, setting it before causes Phase to set nan
    Moon.findPosition(&num);
    Moon.findPhase(0);
    lunarphaseString = Moon.phaseName()+" ("+QString::number( int( 100*Moon.illum() ) )+"%)";

    //Fix length of Az strings
    if ( srAz.Degrees() < 100.0 ) srAzString = ' '+srAzString;
    if ( ssAz.Degrees() < 100.0 ) ssAzString = ' '+ssAzString;
    if ( mrAz.Degrees() < 100.0 ) mrAzString = ' '+mrAzString;
    if ( msAz.Degrees() < 100.0 ) msAzString = ' '+msAzString;
}