mirror of
https://github.com/danieldemus/openhab-addons
synced 2026-07-29 12:34:21 +02:00
[astro] Restore lost 180° on azimuth (#20187)
Signed-off-by: gael@lhopital.org <gael@lhopital.org>
This commit is contained in:
+1
-1
@@ -98,7 +98,7 @@ public class SunCalc {
|
||||
double a = getRightAscension(lsun);
|
||||
double th = getSiderealTime(j, lw);
|
||||
|
||||
double azimuth = Math.toDegrees(getAzimuth(th, a, phi, d));
|
||||
double azimuth = Math.toDegrees(getAzimuth(th, a, phi, d)) + 180;
|
||||
double elevation = Math.toDegrees(getElevation(th, a, phi, d));
|
||||
return new Position(azimuth, elevation);
|
||||
}
|
||||
|
||||
+12
@@ -27,6 +27,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.astro.internal.model.Position;
|
||||
import org.openhab.binding.astro.internal.model.Range;
|
||||
import org.openhab.binding.astro.internal.model.Sun;
|
||||
import org.openhab.binding.astro.internal.model.SunPhase;
|
||||
@@ -429,6 +430,17 @@ public class SunCalcTest {
|
||||
assertEquals(SunPhase.DAYLIGHT, sun.getSunPhase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAzimuthRange() {
|
||||
for (int hour = 0; hour < 23; hour++) {
|
||||
Calendar noonCalendar = SunCalcTest.newCalendar(2019, Calendar.FEBRUARY, 27, hour, 0, AMSTERDAM_TIME_ZONE);
|
||||
Position position = Objects.requireNonNull(sunCalc).getPosition(noonCalendar, AMSTERDAM_LATITUDE,
|
||||
AMSTERDAM_LONGITUDE);
|
||||
double azimuth = position.getAzimuthAsDouble();
|
||||
assertTrue(azimuth >= 0 && azimuth < 360, "Azimuth should be >=0 and <360");
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Constructs a <code>GregorianCalendar</code> with the given date and time set
|
||||
* for the provided time zone.
|
||||
|
||||
Reference in New Issue
Block a user