Search in sources :

Example 1 with Ecliptic

use of android.icu.impl.CalendarAstronomer.Ecliptic in project j2objc by google.

the class AstroTest method TestCoverage.

@Test
public void TestCoverage() {
    GregorianCalendar cal = new GregorianCalendar(1958, Calendar.AUGUST, 15);
    Date then = cal.getTime();
    CalendarAstronomer myastro = new CalendarAstronomer(then);
    // Latitude:  34 degrees 05' North
    // Longitude:  118 degrees 22' West
    double laLat = 34 + 5d / 60, laLong = 360 - (118 + 22d / 60);
    CalendarAstronomer myastro2 = new CalendarAstronomer(laLong, laLat);
    double eclLat = laLat * Math.PI / 360;
    double eclLong = laLong * Math.PI / 360;
    Ecliptic ecl = new Ecliptic(eclLat, eclLong);
    logln("ecliptic: " + ecl);
    CalendarAstronomer myastro3 = new CalendarAstronomer();
    myastro3.setJulianDay((4713 + 2000) * 365.25);
    CalendarAstronomer[] astronomers = { // check cache
    myastro, // check cache
    myastro2, // check cache
    myastro3, // check cache
    myastro2 };
    for (int i = 0; i < astronomers.length; ++i) {
        CalendarAstronomer astro = astronomers[i];
        logln("astro: " + astro);
        logln("   time: " + astro.getTime());
        logln("   date: " + astro.getDate());
        logln("   cent: " + astro.getJulianCentury());
        logln("   gw sidereal: " + astro.getGreenwichSidereal());
        logln("   loc sidereal: " + astro.getLocalSidereal());
        logln("   equ ecl: " + astro.eclipticToEquatorial(ecl));
        logln("   equ long: " + astro.eclipticToEquatorial(eclLong));
        logln("   horiz: " + astro.eclipticToHorizon(eclLong));
        logln("   sunrise: " + new Date(astro.getSunRiseSet(true)));
        logln("   sunset: " + new Date(astro.getSunRiseSet(false)));
        logln("   moon phase: " + astro.getMoonPhase());
        logln("   moonrise: " + new Date(astro.getMoonRiseSet(true)));
        logln("   moonset: " + new Date(astro.getMoonRiseSet(false)));
        logln("   prev summer solstice: " + new Date(astro.getSunTime(CalendarAstronomer.SUMMER_SOLSTICE, false)));
        logln("   next summer solstice: " + new Date(astro.getSunTime(CalendarAstronomer.SUMMER_SOLSTICE, true)));
        logln("   prev full moon: " + new Date(astro.getMoonTime(CalendarAstronomer.FULL_MOON, false)));
        logln("   next full moon: " + new Date(astro.getMoonTime(CalendarAstronomer.FULL_MOON, true)));
    }
}
Also used : GregorianCalendar(android.icu.util.GregorianCalendar) Ecliptic(android.icu.impl.CalendarAstronomer.Ecliptic) Date(java.util.Date) CalendarAstronomer(android.icu.impl.CalendarAstronomer) Test(org.junit.Test)

Aggregations

CalendarAstronomer (android.icu.impl.CalendarAstronomer)1 Ecliptic (android.icu.impl.CalendarAstronomer.Ecliptic)1 GregorianCalendar (android.icu.util.GregorianCalendar)1 Date (java.util.Date)1 Test (org.junit.Test)1