mirror of
https://github.com/MistWeatherMedia/WeatherSTAR-3000-Java.git
synced 2026-11-28 14:38:08 -08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea86c54d5a | ||
|
|
35357d3082 | ||
|
|
a4f69d5b1b | ||
|
|
5cdc6af9dd |
No files matched your search
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>WS3000</groupId>
|
||||
<artifactId>weatherstar3000</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.5.3</version>
|
||||
|
||||
<name>weatherstar3000</name>
|
||||
<url>https://github.com/MistWeatherMedia/WeatherSTAR-3000-Java</url>
|
||||
|
||||
@@ -25,6 +25,7 @@ public class Almanac extends Thread {
|
||||
String tomorrowLow;
|
||||
String normalPrecip;
|
||||
String getDay(String icaoCode, String key, int dayNum) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -56,8 +57,13 @@ public class Almanac extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
String getSunrise(String icaoCode, String key, int dayNum) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -84,8 +90,13 @@ public class Almanac extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
String getSunset(String icaoCode, String key, int dayNum) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -112,8 +123,14 @@ public class Almanac extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
|
||||
String getMonth(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -133,8 +150,14 @@ public class Almanac extends Thread {
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
String getDayDate(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -154,8 +177,14 @@ public class Almanac extends Thread {
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
String getTempMax(String icaoCode, String key, int dayNum, String month, String day) {
|
||||
try {
|
||||
if (Objects.equals(month, "error") || Objects.equals(day, "error")) {
|
||||
return " ";
|
||||
}
|
||||
@@ -180,8 +209,13 @@ public class Almanac extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
String getTempMin(String icaoCode, String key, int dayNum, String month, String day) {
|
||||
try {
|
||||
if (Objects.equals(month, "error") || Objects.equals(day, "error")) {
|
||||
return " ";
|
||||
}
|
||||
@@ -206,8 +240,13 @@ public class Almanac extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
String getPrecip(String icaoCode, String key, String month, String day) {
|
||||
try {
|
||||
if (Objects.equals(month, "error") || Objects.equals(day, "error")) {
|
||||
return " ";
|
||||
}
|
||||
@@ -236,12 +275,16 @@ public class Almanac extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
public void run() {
|
||||
String mainIcao = Main.mainIcao;
|
||||
String key = Main.key;
|
||||
String todayMonth = Main.todayMonth;
|
||||
String todayDay = Main.todayDay;
|
||||
String todayMonth = getMonth(mainIcao, key);;
|
||||
String todayDay = getDayDate(mainIcao, key);;
|
||||
Main.almanac.today = getDay(mainIcao, key, 0);
|
||||
Main.almanac.tomorrow = getDay(mainIcao, key, 1);
|
||||
Main.almanac.todaySunrise = getSunrise(mainIcao, key, 0);
|
||||
|
||||
@@ -15,12 +15,10 @@ import util.Utilities;
|
||||
public class Bulletin extends Thread {
|
||||
static Utilities utl = new Utilities();
|
||||
ArrayList<String> bulletinText = new ArrayList<>();
|
||||
//String color;
|
||||
//boolean severe;
|
||||
//boolean crawl;
|
||||
|
||||
public ArrayList<String> getBulletin(String key, String lat, String lon) {
|
||||
ArrayList<String> words = new ArrayList<>();
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/alerts/headlines?geocode=" + lat + "," + lon + "&format=json&language=en-US&apiKey=" + key))
|
||||
@@ -61,11 +59,18 @@ public class Bulletin extends Thread {
|
||||
words.add("NOBULLETINCRAWL");
|
||||
return words;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
words.clear();
|
||||
words.add("None");
|
||||
words.add("NOBULLETINCRAWL");
|
||||
return words;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> eachAlert(String detailKey, String key) {
|
||||
ArrayList<String> words = new ArrayList<>();
|
||||
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/alerts/detail?alertId=" + detailKey + "&format=json&language=en-US&apiKey=" + key))
|
||||
@@ -139,6 +144,12 @@ public class Bulletin extends Thread {
|
||||
words.add("None");
|
||||
words.add("NOBULLETINCRAWL");
|
||||
return words;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
words.clear();
|
||||
words.add("None");
|
||||
words.add("NOBULLETINCRAWL");
|
||||
return words;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +157,7 @@ public class Bulletin extends Thread {
|
||||
String key = Main.key;
|
||||
String mainLat = Main.mainLat;
|
||||
String mainLon = Main.mainLon;
|
||||
Main.bulletin.bulletinText.clear();
|
||||
Main.bulletin.bulletinText = getBulletin(key, mainLat, mainLon);
|
||||
//System.out.println(Main.bulletin.bulletinText);
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ public class CurrentConditions extends Thread {
|
||||
|
||||
static String getLocName(String displayName) {return "CONDITIONS AT " + utl.ljust(displayName.toUpperCase(), 14, " ").substring(0, 14);}
|
||||
static String getCondition(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -38,7 +39,7 @@ public class CurrentConditions extends Thread {
|
||||
try {
|
||||
HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());
|
||||
if (Response.statusCode() != 200) {
|
||||
return "NO REPORT";
|
||||
return "NO CURRENT REPORT";
|
||||
}
|
||||
String ResponseBody = Response.body();
|
||||
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
||||
@@ -46,10 +47,15 @@ public class CurrentConditions extends Thread {
|
||||
return JSONResponse.getString("wxPhraseLong").toUpperCase();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "NO REPORT";
|
||||
return "NO CURRENT REPORT";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "NO CURRENT REPORT";
|
||||
}
|
||||
}
|
||||
static String getTemperature(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -71,8 +77,13 @@ public class CurrentConditions extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
static String getFeelsLike(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -103,8 +114,13 @@ public class CurrentConditions extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
static String getHumidity(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -126,8 +142,13 @@ public class CurrentConditions extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
static String getDewPoint(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -149,8 +170,13 @@ public class CurrentConditions extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
static String getPressure(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -184,8 +210,13 @@ public class CurrentConditions extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
static String getWind(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -212,8 +243,13 @@ public class CurrentConditions extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
static String getGusts(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -236,8 +272,13 @@ public class CurrentConditions extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
static String getVisiblity(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -259,8 +300,13 @@ public class CurrentConditions extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
String getCeiling(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -282,8 +328,13 @@ public class CurrentConditions extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
String getPrecip(String key, String lat, String lon) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v1/geocode/" + lat + "/" + lon + "/observations/current.json?language=en-US&units=e&apiKey=" + key))
|
||||
@@ -315,6 +366,10 @@ public class CurrentConditions extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
public void run() {
|
||||
String mainLocName = Main.mainLocName.getText();
|
||||
|
||||
@@ -25,6 +25,7 @@ public class ExtendedForecast extends Thread {
|
||||
String highThree;
|
||||
Utilities utl = new Utilities();
|
||||
String getDayName(String icaoCode, String key, int day) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -46,9 +47,14 @@ public class ExtendedForecast extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
ArrayList<String> getCondition(String icaoCode, String key, int day) {
|
||||
ArrayList<String> values = new ArrayList<>();
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -78,8 +84,15 @@ public class ExtendedForecast extends Thread {
|
||||
values.add(" ");
|
||||
return values;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
values.add(" ");
|
||||
values.add(" ");
|
||||
return values;
|
||||
}
|
||||
}
|
||||
String getLow(String icaoCode, String key, int day) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -102,8 +115,13 @@ public class ExtendedForecast extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
String getHigh(String icaoCode, String key, int day) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -125,6 +143,10 @@ public class ExtendedForecast extends Thread {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
public void run() {
|
||||
|
||||
@@ -18,9 +18,10 @@ public class HourlyObservations extends Thread {
|
||||
Utilities utl = new Utilities();
|
||||
|
||||
String getLocName(String displayName) {
|
||||
return utl.ljust(displayName, 14, " ").substring(0, 14);
|
||||
return utl.ljust(displayName, 14, " ").toUpperCase().substring(0, 14);
|
||||
}
|
||||
String getTemperature(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -40,8 +41,13 @@ public class HourlyObservations extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
String getCondition(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -61,8 +67,13 @@ public class HourlyObservations extends Thread {
|
||||
e.printStackTrace();
|
||||
return "NO REPORT";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "NO REPORT";
|
||||
}
|
||||
}
|
||||
String getWind(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -85,6 +96,10 @@ public class HourlyObservations extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
public void run() {
|
||||
ArrayList<String> nearNames = new ArrayList<>();
|
||||
@@ -92,6 +107,10 @@ public class HourlyObservations extends Thread {
|
||||
ArrayList<String> nearIcaos = new ArrayList<>();;
|
||||
nearIcaos.addAll(Main.nearIcaos);
|
||||
String key = Main.key;
|
||||
Main.hourlyObservations.locName.clear();
|
||||
Main.hourlyObservations.temperature.clear();
|
||||
Main.hourlyObservations.condition.clear();
|
||||
Main.hourlyObservations.wind.clear();
|
||||
for (int i = 0; i < nearIcaos.size(); i++) {
|
||||
Main.hourlyObservations.locName.add(getLocName(nearNames.get(i)));
|
||||
Main.hourlyObservations.temperature.add(getTemperature(nearIcaos.get(i), key));
|
||||
|
||||
@@ -20,7 +20,8 @@ public class LocalForecast extends Thread {
|
||||
Utilities utl = new Utilities();
|
||||
|
||||
ArrayList<String> getForecast(String icaoCode, String key, int forecastId) {
|
||||
ArrayList<String> words = new ArrayList<>();
|
||||
ArrayList<String> words = new ArrayList<>();
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -30,14 +31,15 @@ public class LocalForecast extends Thread {
|
||||
try {
|
||||
HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());
|
||||
if (Response.statusCode() != 200) {
|
||||
words.add("NO REPORT");
|
||||
words.add("NO");
|
||||
words.add("REPORT");
|
||||
return words;
|
||||
}
|
||||
String ResponseBody = Response.body();
|
||||
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
||||
JSONObject dpData = JSONResponse.getJSONArray("daypart").getJSONObject(0);
|
||||
int bump = dpData.getJSONArray("dayOrNight").isNull(0) ? 1 : 0;
|
||||
String fullText = dpData.getJSONArray("daypartName").getString(forecastId + bump).replaceAll("Tomorrow", JSONResponse.getJSONArray("dayOfWeek").getString(bump)).toUpperCase() +
|
||||
int bump = dpData.getJSONArray("dayOrNight").isNull(0) ? 1 : dpData.getJSONArray("dayOrNight").getString(0).equals("N") ? 1 : 0;
|
||||
String fullText = dpData.getJSONArray("daypartName").getString(forecastId + bump).replaceAll("Tomorrow", JSONResponse.getJSONArray("dayOfWeek").getString(1)).toUpperCase() +
|
||||
"..." +
|
||||
dpData.getJSONArray("narrative").getString(forecastId + bump).toUpperCase();
|
||||
String[] splitwords = fullText.split("\\s+");
|
||||
@@ -48,13 +50,22 @@ public class LocalForecast extends Thread {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
words.clear();
|
||||
words.add("NO REPORT");
|
||||
words.add("NO");
|
||||
words.add("REPORT");
|
||||
return words;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
words.clear();
|
||||
words.add("NO");
|
||||
words.add("REPORT");
|
||||
return words;
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<String> getBulletin(String key, String lat, String lon) {
|
||||
ArrayList<String> words = new ArrayList<>();
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/alerts/headlines?geocode=" + lat + "," + lon + "&format=json&language=en-US&apiKey=" + key))
|
||||
@@ -98,6 +109,12 @@ public class LocalForecast extends Thread {
|
||||
words.clear();
|
||||
words.add("NOBULLETIN");
|
||||
return words;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
words.clear();
|
||||
words.add("NOBULLETIN");
|
||||
return words;
|
||||
}
|
||||
}
|
||||
public void run() {
|
||||
|
||||
@@ -41,8 +41,6 @@ public class Main {
|
||||
static String mainIcao;
|
||||
static String mainLon;
|
||||
static String mainLat;
|
||||
static String todayMonth;
|
||||
static String todayDay;
|
||||
static int simWidth;
|
||||
static int simHeight;
|
||||
static boolean fullscreen = false;
|
||||
@@ -96,8 +94,8 @@ public class Main {
|
||||
//things to add:
|
||||
//airport conditions
|
||||
//air quality
|
||||
//tides
|
||||
System.out.println("WeatherSTAR 3000 Simulator Version 1.5.0");
|
||||
//timezone switch?
|
||||
System.out.println("WeatherSTAR 3000 Simulator Version 1.5.2");
|
||||
|
||||
String userDir = System.getProperty("user.dir");
|
||||
if (userDir != null && !userDir.isEmpty()) {
|
||||
@@ -879,10 +877,6 @@ public class Main {
|
||||
mainLat = icaoToLat(mainIcao, key);
|
||||
mainLon = icaoToLon(mainIcao, key);
|
||||
|
||||
almanac = new Almanac();
|
||||
todayMonth = almanac.getMonth(mainIcao, key);
|
||||
todayDay = almanac.getDayDate(mainIcao, key);
|
||||
|
||||
wr.start();
|
||||
|
||||
settingsErrorThrown = false;
|
||||
|
||||
@@ -17,16 +17,28 @@ public class Outlook extends Thread {
|
||||
String month;
|
||||
ArrayList<String> outlook = new ArrayList<>();
|
||||
String getMonth() {
|
||||
try {
|
||||
LocalDate cdate = LocalDate.now();
|
||||
Month cmonth = cdate.getMonth();
|
||||
|
||||
return cmonth.name().toUpperCase();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
ArrayList<String> getOutlook() {
|
||||
ArrayList<String> outlook = new ArrayList<>();
|
||||
try {
|
||||
outlook.add("NO");
|
||||
outlook.add("REPORT");
|
||||
return outlook;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
outlook.add("NO");
|
||||
outlook.add("REPORT");
|
||||
return outlook;
|
||||
}
|
||||
}
|
||||
public void run() {
|
||||
Main.outlook.month = getMonth();
|
||||
|
||||
@@ -17,9 +17,10 @@ public class RegionalConditions extends Thread {
|
||||
Utilities utl = new Utilities();
|
||||
|
||||
String getLocName(String displayName){
|
||||
return utl.ljust(displayName, 19, " ").substring(0, 19);
|
||||
return utl.ljust(displayName, 19, " ").toUpperCase().substring(0, 19);
|
||||
}
|
||||
String getCondition(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -39,8 +40,13 @@ public class RegionalConditions extends Thread {
|
||||
e.printStackTrace();
|
||||
return "NO REPORT";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "NO REPORT";
|
||||
}
|
||||
}
|
||||
String getTemperature(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/observations/current?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -60,6 +66,10 @@ public class RegionalConditions extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
public void run() {
|
||||
ArrayList<String> regConNames = new ArrayList<>();
|
||||
@@ -67,6 +77,9 @@ public class RegionalConditions extends Thread {
|
||||
ArrayList<String> regConIcaos = new ArrayList<>();
|
||||
regConIcaos.addAll(Main.regConIcaos);
|
||||
String key = Main.key;
|
||||
Main.regionalConditions.locName.clear();
|
||||
Main.regionalConditions.temperature.clear();
|
||||
Main.regionalConditions.condition.clear();
|
||||
for (int i = 0; i < regConIcaos.size(); i++) {
|
||||
Main.regionalConditions.locName.add(getLocName(regConNames.get(i)));
|
||||
Main.regionalConditions.temperature.add(getTemperature(regConIcaos.get(i), key));
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RegionalForecast extends Thread {
|
||||
@@ -15,12 +16,14 @@ public class RegionalForecast extends Thread {
|
||||
ArrayList<String> condition = new ArrayList<>();
|
||||
ArrayList<String> low = new ArrayList<>();
|
||||
ArrayList<String> high = new ArrayList<>();
|
||||
String first;
|
||||
Utilities utl = new Utilities();
|
||||
|
||||
String getLocName(String displayName){
|
||||
return utl.ljust(displayName, 14, " ").substring(0, 14);
|
||||
return utl.ljust(displayName, 14, " ").toUpperCase().substring(0, 14);
|
||||
}
|
||||
String getCondition(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -41,9 +44,14 @@ public class RegionalForecast extends Thread {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "NO REPORT";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "NO REPORT";
|
||||
}
|
||||
}
|
||||
String getLow(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -64,8 +72,13 @@ public class RegionalForecast extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
String getHigh(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -87,6 +100,10 @@ public class RegionalForecast extends Thread {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
public void run() {
|
||||
ArrayList<String> regForNames = new ArrayList<>();
|
||||
@@ -104,5 +121,7 @@ public class RegionalForecast extends Thread {
|
||||
Main.regionalForecast.low.add(getLow(regForIcaos.get(i), key));
|
||||
Main.regionalForecast.high.add(getHigh(regForIcaos.get(i), key));
|
||||
}
|
||||
int hr = LocalTime.now().getHour();
|
||||
Main.regionalForecast.first = hr >= 4 && hr < 16 ? "H" : "L";
|
||||
}
|
||||
}
|
||||
@@ -613,14 +613,20 @@ public class SlidesRunner extends Scene {
|
||||
CurrentConditions ctData = Main.currentConditions;
|
||||
|
||||
tickerLines.clear();
|
||||
tickerLines.add(utl.ljust(ctData.locName, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.condition, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.temperature + " " + ctData.feelsLike, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.humidity + " " + ctData.dewPoint, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.pressure, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.wind + " " + ctData.gusts, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.visibility + " " + ctData.ceiling, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.precip, 32, " "));
|
||||
|
||||
if (ctData.condition.equals("NO CURRENT REPORT")) {
|
||||
tickerLines.add(utl.ljust(ctData.locName, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.condition, 32, " "));
|
||||
} else {
|
||||
tickerLines.add(utl.ljust(ctData.locName, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.condition, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.temperature + " " + ctData.feelsLike, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.humidity + " " + ctData.dewPoint, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.pressure, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.wind + " " + ctData.gusts, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.visibility + " " + ctData.ceiling, 32, " "));
|
||||
tickerLines.add(utl.ljust(ctData.precip, 32, " "));
|
||||
}
|
||||
}
|
||||
public void currentConditions() {
|
||||
slideRounds = 0;
|
||||
@@ -1018,11 +1024,21 @@ public class SlidesRunner extends Scene {
|
||||
rfMainLines.clear();
|
||||
|
||||
rfMainLines.add(" FORECAST ACROSS THE REGION ");
|
||||
rfMainLines.add("CITY WEATHER LOW HI");
|
||||
for (int i = 0; i < rfData.locName.size(); i++) {
|
||||
rfMainLines.add(utl.ljust(rfData.locName.get(i), 14, " ") + " " + utl.ljust(rfData.condition.get(i), 10, " ") + rfData.low.get(i) + " " + rfData.high.get(i));
|
||||
|
||||
if (rfData.first.equals("L")) {
|
||||
rfMainLines.add("CITY WEATHER LOW HI");
|
||||
for (int i = 0; i < rfData.locName.size(); i++) {
|
||||
rfMainLines.add(utl.ljust(rfData.locName.get(i), 14, " ") + " " + utl.ljust(rfData.condition.get(i), 10, " ") + rfData.low.get(i) + " " + rfData.high.get(i));
|
||||
}
|
||||
} else if (rfData.first.equals("H")) {
|
||||
rfMainLines.add("CITY WEATHER HI LOW");
|
||||
for (int i = 0; i < rfData.locName.size(); i++) {
|
||||
rfMainLines.add(utl.ljust(rfData.locName.get(i), 14, " ") + " " + utl.ljust(rfData.condition.get(i), 10, " ") + rfData.high.get(i) + " " + rfData.low.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
slideInit = true;
|
||||
}
|
||||
|
||||
@@ -1250,13 +1266,25 @@ public class SlidesRunner extends Scene {
|
||||
travelMainLines.clear();
|
||||
travelMainLines.add(" TRAVEL CITIES FORECAST ");
|
||||
travelMainLines.add(utl.ljust(" ", 32, " "));
|
||||
travelMainLines.add("CITY WEATHER LOW HI");
|
||||
for (int i = 0; i < tfData.locName.size(); i++) {
|
||||
travelMainLines.add(utl.ljust(tfData.locName.get(i), 15, " ") +
|
||||
|
||||
if (tfData.first.equals("L")) {
|
||||
travelMainLines.add("CITY WEATHER LOW HI");
|
||||
for (int i = 0; i < tfData.locName.size(); i++) {
|
||||
travelMainLines.add(utl.ljust(tfData.locName.get(i), 15, " ") +
|
||||
utl.ljust(tfData.condition.get(i), 10, " ") +
|
||||
utl.rjust(tfData.low.get(i), 3, " ") +
|
||||
utl.rjust(tfData.high.get(i), 4, " "));
|
||||
}
|
||||
} else if ((tfData.first.equals("H"))) {
|
||||
travelMainLines.add("CITY WEATHER HI LOW");
|
||||
for (int i = 0; i < tfData.locName.size(); i++) {
|
||||
travelMainLines.add(utl.ljust(tfData.locName.get(i), 15, " ") +
|
||||
utl.ljust(tfData.condition.get(i), 10, " ") +
|
||||
utl.rjust(tfData.high.get(i), 3, " ") +
|
||||
utl.rjust(tfData.low.get(i), 4, " "));
|
||||
}
|
||||
}
|
||||
|
||||
travelDataInit = true;
|
||||
travelOffset = 0;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Tides extends Thread {
|
||||
DateTimeFormatter tideTimeFormatter = DateTimeFormatter.ofPattern("h:mma E", Locale.ENGLISH);
|
||||
|
||||
String getLocName(String displayName) {
|
||||
return utl.cjust(displayName, 32, " ").substring(0, 32);
|
||||
return utl.cjust(displayName, 32, " ").toUpperCase().substring(0, 32);
|
||||
}
|
||||
|
||||
String getTides(String station, String tide) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -17,14 +18,16 @@ public class TravelForecast extends Thread {
|
||||
ArrayList<String> low = new ArrayList<>();
|
||||
ArrayList<String> high = new ArrayList<>();
|
||||
Utilities utl = new Utilities();
|
||||
String first;
|
||||
|
||||
ArrayList<String> tForNames = new ArrayList<>(Arrays.asList("ATLANTA", "BISMARCK", "BOISE", "BOSTON", "BUFFALO", "CHICAGO", "CINCINNATI", "DALLAS", "DENVER", "DETROIT", "KANSAS CITY", "LOS ANGELES", "MINNEAPOLIS", "NASHVILLE", "NEW ORLEANS", "NEW YORK CITY", "PHOENIX", "PORTLAND", "RALEIGH", "RAPID CITY", "SACRAMENTO", "SALT LAKE CITY", "TAMPA", "WASHINGTON, DC"));
|
||||
ArrayList<String> tForIcaos = new ArrayList<>(Arrays.asList("KATL", "KBIS", "KBOI", "KBOS", "KBUF", "KORD", "KCVG", "KDAL", "KDEN", "KDTW", "KMCI", "KLAX", "KMSP", "KDNA", "KMSY", "KLGA", "KPHX", "KPDX", "KRDU", "KRAP", "KSMF", "KSLC", "KTPA", "KDCA"));
|
||||
|
||||
String getLocName(String displayName){
|
||||
return utl.ljust(displayName, 14, " ").substring(0, 14);
|
||||
return utl.ljust(displayName, 14, " ").toUpperCase().substring(0, 14);
|
||||
}
|
||||
String getCondition(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -45,9 +48,14 @@ public class TravelForecast extends Thread {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "NO REPORT";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "NO REPORT";
|
||||
}
|
||||
}
|
||||
String getLow(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -67,9 +75,14 @@ public class TravelForecast extends Thread {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
String getHigh(String icaoCode, String key) {
|
||||
try {
|
||||
HttpClient Client = HttpClient.newBuilder().build();
|
||||
HttpRequest Request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||
@@ -90,15 +103,25 @@ public class TravelForecast extends Thread {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
public void run() {
|
||||
String key = Main.key;
|
||||
Main.travelForecast.locName.clear();
|
||||
Main.travelForecast.condition.clear();
|
||||
Main.travelForecast.high.clear();
|
||||
Main.travelForecast.low.clear();
|
||||
for (int i = 0; i < tForIcaos.size(); i++) {
|
||||
Main.travelForecast.locName.add(getLocName(tForNames.get(i)));
|
||||
Main.travelForecast.condition.add(getCondition(tForIcaos.get(i), key));
|
||||
Main.travelForecast.low.add(getLow(tForIcaos.get(i), key));
|
||||
Main.travelForecast.high.add(getHigh(tForIcaos.get(i), key));
|
||||
}
|
||||
int hr = LocalTime.now().getHour();
|
||||
Main.travelForecast.first = hr >= 4 && hr < 16 ? "H" : "L";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user