Compare commits

..

No commits in common. "28286df81441c91b2964556988bf00f40a406c43" and "3a7a1f8c691baabcb71b0906891de7b2d3e7f209" have entirely different histories.

3 changed files with 8 additions and 19 deletions

View file

@ -3,8 +3,6 @@ package eu.m724.wtapi.provider;
import eu.m724.wtapi.provider.exception.NoSuchProviderException;
import eu.m724.wtapi.provider.thunder.ThunderProvider;
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.impl.openweathermap.OpenWeatherMapProvider;
@ -12,8 +10,8 @@ public class Providers {
public static ThunderProvider getThunderProvider(String name, String apiKey) throws NoSuchProviderException {
switch (name.toLowerCase()) {
case "blitzortung":
return new BlitzortungProvider();
case "blitzortung":
return new BlitzortungProvider();
}
throw new NoSuchProviderException();
@ -21,17 +19,8 @@ public class Providers {
public static WeatherProvider getWeatherProvider(String name, String apiKey) throws NoSuchProviderException {
switch (name.toLowerCase()) {
case "openweathermap":
return new OpenWeatherMapProvider(apiKey);
}
throw new NoSuchProviderException();
}
public static TwilightTimeProvider getTwilightTimeProvider(String name, String apiKey) throws NoSuchProviderException {
switch (name.toLowerCase()) {
case "approximate":
return new ApproximateTwilightTimeProvider();
case "openweathermap":
return new OpenWeatherMapProvider(apiKey);
}
throw new NoSuchProviderException();

View file

@ -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
* 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
public Twilight calculateTwilightTime(LocalDate date, Coordinates coordinates) {
int dayOfYear = date.getDayOfYear() - 1; // -1 because we have to start from zero

View file

@ -2,13 +2,13 @@ package eu.m724.wtapi.twilight;
import eu.m724.wtapi.object.Coordinates;
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 org.junit.Test;
import java.time.LocalDate;
public class ApproximateTwilightTimeTest {
public class SimpleTwilightTimeTest {
/**
* Acceptable discrepancy in minutes
*/
@ -16,7 +16,7 @@ public class ApproximateTwilightTimeTest {
@Test
public void approximateTest() {
TwilightTimeProvider provider = new ApproximateTwilightTimeProvider();
TwilightTimeProvider provider = new SimpleTwilightTimeProvider();
testLocation(provider, 26, 6, 2023, 53.123394, 23.0864867, 122, 1139);
testLocation(provider, 13, 11, 2040, 45.432427, -122.3899276, 907, 1481);