updated NOAAImporter to use IGRF model for pre-2024 dates

This commit is contained in:
Axel Uhl committed 2024-12-27 23:43:10 +01:00
1 parent ce9c814b6b
commit ad7c5e472f
1 file changed
+3 -1
@@ -56,8 +56,10 @@ public class NOAAImporter extends DeclinationImporter {
Date date = timePoint.asDate();
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
final int year = calendar.get(Calendar.YEAR);
URL url = new URL(QUERY_URL+"?key=zNEw7&lon1="+position.getLngDeg()+"&lat1="+position.getLatDeg()+"&startYear=" + calendar.get(Calendar.YEAR) + "&startMonth="
+ (calendar.get(Calendar.MONTH) + 1) + "&startDay=" + calendar.get(Calendar.DAY_OF_MONTH)+"&resultFormat=xml");
+ (calendar.get(Calendar.MONTH) + 1) + "&startDay=" + calendar.get(Calendar.DAY_OF_MONTH)+"&resultFormat=xml"
+(year < 2024 ? "&model=IGRF":"")); // WMM / WMMHR start only in 2024; earlier years need to be solved by the IGRF model
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
conn.setRequestProperty("Accept-Language", "en-US,en;q=0.8");