Compare commits
No commits in common. "28286df81441c91b2964556988bf00f40a406c43" and "3a7a1f8c691baabcb71b0906891de7b2d3e7f209" have entirely different histories.
28286df814
...
3a7a1f8c69
3 changed files with 8 additions and 19 deletions
|
@ -3,8 +3,6 @@ package eu.m724.wtapi.provider;
|
||||||
import eu.m724.wtapi.provider.exception.NoSuchProviderException;
|
import eu.m724.wtapi.provider.exception.NoSuchProviderException;
|
||||||
import eu.m724.wtapi.provider.thunder.ThunderProvider;
|
import eu.m724.wtapi.provider.thunder.ThunderProvider;
|
||||||
import eu.m724.wtapi.provider.thunder.impl.blitzortung.BlitzortungProvider;
|
import eu.m724.wtapi.provider.thunder.impl.blitzortung.BlitzortungProvider;
|
||||||
import eu.m724.wtapi.provider.twilight.ApproximateTwilightTimeProvider;
|
|
||||||
import eu.m724.wtapi.provider.twilight.TwilightTimeProvider;
|
|
||||||
import eu.m724.wtapi.provider.weather.WeatherProvider;
|
import eu.m724.wtapi.provider.weather.WeatherProvider;
|
||||||
import eu.m724.wtapi.provider.weather.impl.openweathermap.OpenWeatherMapProvider;
|
import eu.m724.wtapi.provider.weather.impl.openweathermap.OpenWeatherMapProvider;
|
||||||
|
|
||||||
|
@ -28,13 +26,4 @@ public class Providers {
|
||||||
throw new NoSuchProviderException();
|
throw new NoSuchProviderException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TwilightTimeProvider getTwilightTimeProvider(String name, String apiKey) throws NoSuchProviderException {
|
|
||||||
switch (name.toLowerCase()) {
|
|
||||||
case "approximate":
|
|
||||||
return new ApproximateTwilightTimeProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new NoSuchProviderException();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import static java.lang.Math.*;
|
||||||
* Usually off by a few minutes, except the Poles which, during polar days, are up to few hours inaccurate
|
* Usually off by a few minutes, except the Poles which, during polar days, are up to few hours inaccurate
|
||||||
* Adapted from: <a href="https://gml.noaa.gov/grad/solcalc/solareqns.PDF">https://gml.noaa.gov/grad/solcalc/solareqns.PDF</a>
|
* Adapted from: <a href="https://gml.noaa.gov/grad/solcalc/solareqns.PDF">https://gml.noaa.gov/grad/solcalc/solareqns.PDF</a>
|
||||||
*/
|
*/
|
||||||
public class ApproximateTwilightTimeProvider extends TwilightTimeProvider {
|
public class SimpleTwilightTimeProvider extends TwilightTimeProvider {
|
||||||
@Override
|
@Override
|
||||||
public Twilight calculateTwilightTime(LocalDate date, Coordinates coordinates) {
|
public Twilight calculateTwilightTime(LocalDate date, Coordinates coordinates) {
|
||||||
int dayOfYear = date.getDayOfYear() - 1; // -1 because we have to start from zero
|
int dayOfYear = date.getDayOfYear() - 1; // -1 because we have to start from zero
|
|
@ -2,13 +2,13 @@ package eu.m724.wtapi.twilight;
|
||||||
|
|
||||||
import eu.m724.wtapi.object.Coordinates;
|
import eu.m724.wtapi.object.Coordinates;
|
||||||
import eu.m724.wtapi.object.Twilight;
|
import eu.m724.wtapi.object.Twilight;
|
||||||
import eu.m724.wtapi.provider.twilight.ApproximateTwilightTimeProvider;
|
import eu.m724.wtapi.provider.twilight.SimpleTwilightTimeProvider;
|
||||||
import eu.m724.wtapi.provider.twilight.TwilightTimeProvider;
|
import eu.m724.wtapi.provider.twilight.TwilightTimeProvider;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
|
||||||
public class ApproximateTwilightTimeTest {
|
public class SimpleTwilightTimeTest {
|
||||||
/**
|
/**
|
||||||
* Acceptable discrepancy in minutes
|
* Acceptable discrepancy in minutes
|
||||||
*/
|
*/
|
||||||
|
@ -16,7 +16,7 @@ public class ApproximateTwilightTimeTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void approximateTest() {
|
public void approximateTest() {
|
||||||
TwilightTimeProvider provider = new ApproximateTwilightTimeProvider();
|
TwilightTimeProvider provider = new SimpleTwilightTimeProvider();
|
||||||
|
|
||||||
testLocation(provider, 26, 6, 2023, 53.123394, 23.0864867, 122, 1139);
|
testLocation(provider, 26, 6, 2023, 53.123394, 23.0864867, 122, 1139);
|
||||||
testLocation(provider, 13, 11, 2040, 45.432427, -122.3899276, 907, 1481);
|
testLocation(provider, 13, 11, 2040, 45.432427, -122.3899276, 907, 1481);
|
Loading…
Reference in a new issue