mirror of
https://github.com/MistWeatherMedia/WeatherSTAR-3000-Java.git
synced 2026-11-28 14:38:08 -08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3e5e81500 | ||
|
|
a2791ddd91 | ||
|
|
dbe9b0964d | ||
|
|
742714fbac | ||
|
|
a29f4d0829 | ||
|
|
02e0a7cf1f | ||
|
|
5177d0fead | ||
|
|
1cc60fe38c | ||
|
|
ea86c54d5a | ||
|
|
35357d3082 | ||
|
|
a4f69d5b1b | ||
|
|
5cdc6af9dd |
No files matched your search
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>WS3000</groupId>
|
<groupId>WS3000</groupId>
|
||||||
<artifactId>weatherstar3000</artifactId>
|
<artifactId>weatherstar3000</artifactId>
|
||||||
<version>1.5.0</version>
|
<version>1.7.0</version>
|
||||||
|
|
||||||
<name>weatherstar3000</name>
|
<name>weatherstar3000</name>
|
||||||
<url>https://github.com/MistWeatherMedia/WeatherSTAR-3000-Java</url>
|
<url>https://github.com/MistWeatherMedia/WeatherSTAR-3000-Java</url>
|
||||||
@@ -586,6 +586,12 @@
|
|||||||
<artifactId>joml</artifactId>
|
<artifactId>joml</artifactId>
|
||||||
<version>${joml.version}</version>
|
<version>${joml.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.locationtech.jts</groupId>
|
||||||
|
<artifactId>jts-core</artifactId>
|
||||||
|
<version>1.19.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class Almanac extends Thread {
|
|||||||
String tomorrowLow;
|
String tomorrowLow;
|
||||||
String normalPrecip;
|
String normalPrecip;
|
||||||
String getDay(String icaoCode, String key, int dayNum) {
|
String getDay(String icaoCode, String key, int dayNum) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String getSunrise(String icaoCode, String key, int dayNum) {
|
String getSunrise(String icaoCode, String key, int dayNum) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String getSunset(String icaoCode, String key, int dayNum) {
|
String getSunset(String icaoCode, String key, int dayNum) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String getMonth(String icaoCode, String key) {
|
String getMonth(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "error";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String getDayDate(String icaoCode, String key) {
|
String getDayDate(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "error";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String getTempMax(String icaoCode, String key, int dayNum, String month, String day) {
|
String getTempMax(String icaoCode, String key, int dayNum, String month, String day) {
|
||||||
|
try {
|
||||||
if (Objects.equals(month, "error") || Objects.equals(day, "error")) {
|
if (Objects.equals(month, "error") || Objects.equals(day, "error")) {
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
@@ -180,8 +209,13 @@ public class Almanac extends Thread {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String getTempMin(String icaoCode, String key, int dayNum, String month, String day) {
|
String getTempMin(String icaoCode, String key, int dayNum, String month, String day) {
|
||||||
|
try {
|
||||||
if (Objects.equals(month, "error") || Objects.equals(day, "error")) {
|
if (Objects.equals(month, "error") || Objects.equals(day, "error")) {
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
@@ -206,10 +240,15 @@ public class Almanac extends Thread {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String getPrecip(String icaoCode, String key, String month, String day) {
|
String getPrecip(String icaoCode, String key, String month, String day) {
|
||||||
|
try {
|
||||||
if (Objects.equals(month, "error") || Objects.equals(day, "error")) {
|
if (Objects.equals(month, "error") || Objects.equals(day, "error")) {
|
||||||
return " ";
|
return utl.ljust("", 32, " ");
|
||||||
}
|
}
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
HttpRequest Request = HttpRequest.newBuilder()
|
||||||
@@ -221,27 +260,32 @@ public class Almanac extends Thread {
|
|||||||
try {
|
try {
|
||||||
HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());
|
HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());
|
||||||
if (Response.statusCode() != 200) {
|
if (Response.statusCode() != 200) {
|
||||||
return " ";
|
return utl.ljust("", 32, " ");
|
||||||
}
|
}
|
||||||
String ResponseBody = Response.body();
|
String ResponseBody = Response.body();
|
||||||
String[] monthNames = {"", "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"};
|
String[] monthNames = {"", "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"};
|
||||||
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
||||||
float precip = JSONResponse.getJSONArray("precipitationAverage").getFloat(0);
|
|
||||||
|
|
||||||
String precipString = utl.rjust(precip + " IN", 8, " ");
|
String precip = JSONResponse.getJSONArray("precipitationAverage").isNull(0) ? "NO REPORT" : String.valueOf(JSONResponse.getJSONArray("precipitationAverage").getFloat(0));
|
||||||
String cmonth = utl.ljust("NORMAL " + monthNames[Integer.parseInt(month)] + " PRECIP", 23, " ");
|
|
||||||
|
String precipString = precip.equals("NO REPORT") ? "NO REPORT" : utl.rjust(precip + " IN", 9, " ");
|
||||||
|
String cmonth = utl.ljust("NORMAL " + monthNames[Integer.parseInt(month)] + " PRECIP", 22, " ");
|
||||||
|
|
||||||
return utl.ljust(cmonth + precipString, 31, " ") + " ";
|
return utl.ljust(cmonth + precipString, 31, " ") + " ";
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return " ";
|
return utl.ljust("", 32, " ");
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return utl.ljust("", 32, " ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void run() {
|
public void run() {
|
||||||
String mainIcao = Main.mainIcao;
|
String mainIcao = Main.mainIcao;
|
||||||
String key = Main.key;
|
String key = Main.key;
|
||||||
String todayMonth = Main.todayMonth;
|
String todayMonth = getMonth(mainIcao, key);;
|
||||||
String todayDay = Main.todayDay;
|
String todayDay = getDayDate(mainIcao, key);;
|
||||||
Main.almanac.today = getDay(mainIcao, key, 0);
|
Main.almanac.today = getDay(mainIcao, key, 0);
|
||||||
Main.almanac.tomorrow = getDay(mainIcao, key, 1);
|
Main.almanac.tomorrow = getDay(mainIcao, key, 1);
|
||||||
Main.almanac.todaySunrise = getSunrise(mainIcao, key, 0);
|
Main.almanac.todaySunrise = getSunrise(mainIcao, key, 0);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.net.http.HttpResponse;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import util.Utilities;
|
import util.Utilities;
|
||||||
@@ -15,12 +14,10 @@ import util.Utilities;
|
|||||||
public class Bulletin extends Thread {
|
public class Bulletin extends Thread {
|
||||||
static Utilities utl = new Utilities();
|
static Utilities utl = new Utilities();
|
||||||
ArrayList<String> bulletinText = new ArrayList<>();
|
ArrayList<String> bulletinText = new ArrayList<>();
|
||||||
//String color;
|
|
||||||
//boolean severe;
|
|
||||||
//boolean crawl;
|
|
||||||
|
|
||||||
public ArrayList<String> getBulletin(String key, String lat, String lon) {
|
public ArrayList<String> getBulletin(String key, String lat, String lon) {
|
||||||
ArrayList<String> words = new ArrayList<>();
|
ArrayList<String> words = new ArrayList<>();
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
HttpRequest Request = HttpRequest.newBuilder()
|
||||||
.uri(URI.create("https://api.weather.com/v3/alerts/headlines?geocode=" + lat + "," + lon + "&format=json&language=en-US&apiKey=" + key))
|
.uri(URI.create("https://api.weather.com/v3/alerts/headlines?geocode=" + lat + "," + lon + "&format=json&language=en-US&apiKey=" + key))
|
||||||
@@ -61,11 +58,18 @@ public class Bulletin extends Thread {
|
|||||||
words.add("NOBULLETINCRAWL");
|
words.add("NOBULLETINCRAWL");
|
||||||
return words;
|
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) {
|
public ArrayList<String> eachAlert(String detailKey, String key) {
|
||||||
ArrayList<String> words = new ArrayList<>();
|
ArrayList<String> words = new ArrayList<>();
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
HttpRequest Request = HttpRequest.newBuilder()
|
||||||
.uri(URI.create("https://api.weather.com/v3/alerts/detail?alertId=" + detailKey + "&format=json&language=en-US&apiKey=" + key))
|
.uri(URI.create("https://api.weather.com/v3/alerts/detail?alertId=" + detailKey + "&format=json&language=en-US&apiKey=" + key))
|
||||||
@@ -139,6 +143,12 @@ public class Bulletin extends Thread {
|
|||||||
words.add("None");
|
words.add("None");
|
||||||
words.add("NOBULLETINCRAWL");
|
words.add("NOBULLETINCRAWL");
|
||||||
return words;
|
return words;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
words.clear();
|
||||||
|
words.add("None");
|
||||||
|
words.add("NOBULLETINCRAWL");
|
||||||
|
return words;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +156,7 @@ public class Bulletin extends Thread {
|
|||||||
String key = Main.key;
|
String key = Main.key;
|
||||||
String mainLat = Main.mainLat;
|
String mainLat = Main.mainLat;
|
||||||
String mainLon = Main.mainLon;
|
String mainLon = Main.mainLon;
|
||||||
|
Main.bulletin.bulletinText.clear();
|
||||||
Main.bulletin.bulletinText = getBulletin(key, mainLat, mainLon);
|
Main.bulletin.bulletinText = getBulletin(key, mainLat, mainLon);
|
||||||
//System.out.println(Main.bulletin.bulletinText);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ import java.net.http.HttpClient;
|
|||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
//import java.text.DecimalFormat;
|
//import java.text.DecimalFormat;
|
||||||
import java.time.LocalDate;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.Month;
|
import java.time.Month;
|
||||||
|
|
||||||
public class CurrentConditions extends Thread {
|
public class CurrentConditions extends Thread {
|
||||||
@@ -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 getLocName(String displayName) {return "CONDITIONS AT " + utl.ljust(displayName.toUpperCase(), 14, " ").substring(0, 14);}
|
||||||
static String getCondition(String icaoCode, String key) {
|
static String getCondition(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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 {
|
try {
|
||||||
HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());
|
HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());
|
||||||
if (Response.statusCode() != 200) {
|
if (Response.statusCode() != 200) {
|
||||||
return "NO REPORT";
|
return "NO CURRENT REPORT";
|
||||||
}
|
}
|
||||||
String ResponseBody = Response.body();
|
String ResponseBody = Response.body();
|
||||||
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
||||||
@@ -46,10 +47,15 @@ public class CurrentConditions extends Thread {
|
|||||||
return JSONResponse.getString("wxPhraseLong").toUpperCase();
|
return JSONResponse.getString("wxPhraseLong").toUpperCase();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
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) {
|
static String getTemperature(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static String getFeelsLike(String icaoCode, String key) {
|
static String getFeelsLike(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static String getHumidity(String icaoCode, String key) {
|
static String getHumidity(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static String getDewPoint(String icaoCode, String key) {
|
static String getDewPoint(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static String getPressure(String icaoCode, String key) {
|
static String getPressure(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static String getWind(String icaoCode, String key) {
|
static String getWind(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static String getGusts(String icaoCode, String key) {
|
static String getGusts(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static String getVisiblity(String icaoCode, String key) {
|
static String getVisiblity(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String getCeiling(String icaoCode, String key) {
|
String getCeiling(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String getPrecip(String key, String lat, String lon) {
|
String getPrecip(String key, String lat, String lon) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.uri(URI.create("https://api.weather.com/v1/geocode/" + lat + "/" + lon + "/observations/current.json?language=en-US&units=e&apiKey=" + key))
|
||||||
@@ -298,7 +349,7 @@ public class CurrentConditions extends Thread {
|
|||||||
String ResponseBody = Response.body();
|
String ResponseBody = Response.body();
|
||||||
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
||||||
|
|
||||||
LocalDate cdate = LocalDate.now();
|
ZonedDateTime cdate = ZonedDateTime.now(Main.timeZone);
|
||||||
Month cmonth = cdate.getMonth();
|
Month cmonth = cdate.getMonth();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -315,6 +366,10 @@ public class CurrentConditions extends Thread {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void run() {
|
public void run() {
|
||||||
String mainLocName = Main.mainLocName.getText();
|
String mainLocName = Main.mainLocName.getText();
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package WS3000.weatherstar3000;
|
|||||||
|
|
||||||
public class DataRunner extends Thread {
|
public class DataRunner extends Thread {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (Main.ztOption.equals("Location Time")) {
|
||||||
|
Main.timeZone = Main.getTimeZone(Main.mainIcao);
|
||||||
|
}
|
||||||
//System.out.println("Data collection");
|
//System.out.println("Data collection");
|
||||||
Main.currentConditions = new CurrentConditions();
|
Main.currentConditions = new CurrentConditions();
|
||||||
Main.hourlyObservations = new HourlyObservations();
|
Main.hourlyObservations = new HourlyObservations();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class ExtendedForecast extends Thread {
|
|||||||
String highThree;
|
String highThree;
|
||||||
Utilities utl = new Utilities();
|
Utilities utl = new Utilities();
|
||||||
String getDayName(String icaoCode, String key, int day) {
|
String getDayName(String icaoCode, String key, int day) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ArrayList<String> getCondition(String icaoCode, String key, int day) {
|
ArrayList<String> getCondition(String icaoCode, String key, int day) {
|
||||||
ArrayList<String> values = new ArrayList<>();
|
ArrayList<String> values = new ArrayList<>();
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||||
@@ -65,7 +71,7 @@ public class ExtendedForecast extends Thread {
|
|||||||
String ResponseBody = Response.body();
|
String ResponseBody = Response.body();
|
||||||
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
||||||
JSONObject dpData = JSONResponse.getJSONArray("daypart").getJSONObject(0);
|
JSONObject dpData = JSONResponse.getJSONArray("daypart").getJSONObject(0);
|
||||||
int bump = dpData.getJSONArray("dayOrNight").isNull(0) ? 5 : 4;
|
int bump = dpData.getJSONArray("dayOrNight").isNull(0) ? 6 : dpData.getJSONArray("dayOrNight").getString(0).equals("N") ? 6 : 4;
|
||||||
int ex = day*2;
|
int ex = day*2;
|
||||||
|
|
||||||
values.add(utl.getForecastEx(dpData.getJSONArray("iconCodeExtend").getInt(ex + bump), 0));
|
values.add(utl.getForecastEx(dpData.getJSONArray("iconCodeExtend").getInt(ex + bump), 0));
|
||||||
@@ -78,8 +84,15 @@ public class ExtendedForecast extends Thread {
|
|||||||
values.add(" ");
|
values.add(" ");
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
values.add(" ");
|
||||||
|
values.add(" ");
|
||||||
|
return values;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String getLow(String icaoCode, String key, int day) {
|
String getLow(String icaoCode, String key, int day) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String getHigh(String icaoCode, String key, int day) {
|
String getHigh(String icaoCode, String key, int day) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ public class HourlyObservations extends Thread {
|
|||||||
Utilities utl = new Utilities();
|
Utilities utl = new Utilities();
|
||||||
|
|
||||||
String getLocName(String displayName) {
|
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) {
|
String getTemperature(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String getCondition(String icaoCode, String key) {
|
String getCondition(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return "NO REPORT";
|
return "NO REPORT";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "NO REPORT";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String getWind(String icaoCode, String key) {
|
String getWind(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void run() {
|
public void run() {
|
||||||
ArrayList<String> nearNames = new ArrayList<>();
|
ArrayList<String> nearNames = new ArrayList<>();
|
||||||
@@ -92,6 +107,10 @@ public class HourlyObservations extends Thread {
|
|||||||
ArrayList<String> nearIcaos = new ArrayList<>();;
|
ArrayList<String> nearIcaos = new ArrayList<>();;
|
||||||
nearIcaos.addAll(Main.nearIcaos);
|
nearIcaos.addAll(Main.nearIcaos);
|
||||||
String key = Main.key;
|
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++) {
|
for (int i = 0; i < nearIcaos.size(); i++) {
|
||||||
Main.hourlyObservations.locName.add(getLocName(nearNames.get(i)));
|
Main.hourlyObservations.locName.add(getLocName(nearNames.get(i)));
|
||||||
Main.hourlyObservations.temperature.add(getTemperature(nearIcaos.get(i), key));
|
Main.hourlyObservations.temperature.add(getTemperature(nearIcaos.get(i), key));
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ public class LocalForecast extends Thread {
|
|||||||
Utilities utl = new Utilities();
|
Utilities utl = new Utilities();
|
||||||
|
|
||||||
ArrayList<String> getForecast(String icaoCode, String key, int forecastId) {
|
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();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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 {
|
try {
|
||||||
HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());
|
HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());
|
||||||
if (Response.statusCode() != 200) {
|
if (Response.statusCode() != 200) {
|
||||||
words.add("NO REPORT");
|
words.add("NO");
|
||||||
|
words.add("REPORT");
|
||||||
return words;
|
return words;
|
||||||
}
|
}
|
||||||
String ResponseBody = Response.body();
|
String ResponseBody = Response.body();
|
||||||
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
||||||
JSONObject dpData = JSONResponse.getJSONArray("daypart").getJSONObject(0);
|
JSONObject dpData = JSONResponse.getJSONArray("daypart").getJSONObject(0);
|
||||||
int bump = dpData.getJSONArray("dayOrNight").isNull(0) ? 1 : 0;
|
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(bump)).toUpperCase() +
|
String fullText = dpData.getJSONArray("daypartName").getString(forecastId + bump).replaceAll("Tomorrow", JSONResponse.getJSONArray("dayOfWeek").getString(1)).toUpperCase() +
|
||||||
"..." +
|
"..." +
|
||||||
dpData.getJSONArray("narrative").getString(forecastId + bump).toUpperCase();
|
dpData.getJSONArray("narrative").getString(forecastId + bump).toUpperCase();
|
||||||
String[] splitwords = fullText.split("\\s+");
|
String[] splitwords = fullText.split("\\s+");
|
||||||
@@ -48,13 +50,22 @@ public class LocalForecast extends Thread {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
words.clear();
|
words.clear();
|
||||||
words.add("NO REPORT");
|
words.add("NO");
|
||||||
|
words.add("REPORT");
|
||||||
return words;
|
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> getBulletin(String key, String lat, String lon) {
|
||||||
ArrayList<String> words = new ArrayList<>();
|
ArrayList<String> words = new ArrayList<>();
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
HttpRequest Request = HttpRequest.newBuilder()
|
||||||
.uri(URI.create("https://api.weather.com/v3/alerts/headlines?geocode=" + lat + "," + lon + "&format=json&language=en-US&apiKey=" + key))
|
.uri(URI.create("https://api.weather.com/v3/alerts/headlines?geocode=" + lat + "," + lon + "&format=json&language=en-US&apiKey=" + key))
|
||||||
@@ -99,6 +110,12 @@ public class LocalForecast extends Thread {
|
|||||||
words.add("NOBULLETIN");
|
words.add("NOBULLETIN");
|
||||||
return words;
|
return words;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
words.clear();
|
||||||
|
words.add("NOBULLETIN");
|
||||||
|
return words;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void run() {
|
public void run() {
|
||||||
String mainIcao = Main.mainIcao;
|
String mainIcao = Main.mainIcao;
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ import java.awt.*;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
static String selectedFlavor;
|
static String selectedFlavor;
|
||||||
@@ -41,8 +45,6 @@ public class Main {
|
|||||||
static String mainIcao;
|
static String mainIcao;
|
||||||
static String mainLon;
|
static String mainLon;
|
||||||
static String mainLat;
|
static String mainLat;
|
||||||
static String todayMonth;
|
|
||||||
static String todayDay;
|
|
||||||
static int simWidth;
|
static int simWidth;
|
||||||
static int simHeight;
|
static int simHeight;
|
||||||
static boolean fullscreen = false;
|
static boolean fullscreen = false;
|
||||||
@@ -60,6 +62,9 @@ public class Main {
|
|||||||
static Bulletin bulletin;
|
static Bulletin bulletin;
|
||||||
static Tides tides;
|
static Tides tides;
|
||||||
|
|
||||||
|
static String ztOption;
|
||||||
|
static ZoneId timeZone;
|
||||||
|
|
||||||
static JFrame settingsWindow;
|
static JFrame settingsWindow;
|
||||||
|
|
||||||
static ArrayList<String> nearNames = new ArrayList<>();
|
static ArrayList<String> nearNames = new ArrayList<>();
|
||||||
@@ -94,10 +99,9 @@ public class Main {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//things to add:
|
//things to add:
|
||||||
//airport conditions
|
//optimized LookAndFeels?
|
||||||
//air quality
|
//multiple ad crawls (up to 7)
|
||||||
//tides
|
System.out.println("WeatherSTAR 3000 Simulator Version 1.7.0");
|
||||||
System.out.println("WeatherSTAR 3000 Simulator Version 1.5.0");
|
|
||||||
|
|
||||||
String userDir = System.getProperty("user.dir");
|
String userDir = System.getProperty("user.dir");
|
||||||
if (userDir != null && !userDir.isEmpty()) {
|
if (userDir != null && !userDir.isEmpty()) {
|
||||||
@@ -382,7 +386,7 @@ public class Main {
|
|||||||
|
|
||||||
//tides
|
//tides
|
||||||
JPanel tPanel = new JPanel(new GridLayout(0, 1, 0, 0));
|
JPanel tPanel = new JPanel(new GridLayout(0, 1, 0, 0));
|
||||||
tPanel.setBorder(BorderFactory.createTitledBorder("Tides Locations"));
|
tPanel.setBorder(BorderFactory.createTitledBorder("Tides Locations (OPTIONAL)"));
|
||||||
|
|
||||||
JPanel t1Panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
JPanel t1Panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
t1Panel.add(new JLabel("Station ID"));
|
t1Panel.add(new JLabel("Station ID"));
|
||||||
@@ -447,6 +451,12 @@ public class Main {
|
|||||||
ldlDropdown.setSelectedIndex(0);
|
ldlDropdown.setSelectedIndex(0);
|
||||||
r2Panel.add(ldlDropdown);
|
r2Panel.add(ldlDropdown);
|
||||||
|
|
||||||
|
r2Panel.add(new JLabel("Time Zone"));
|
||||||
|
String[] timeZoneOptions = {"Location Time", "System Time", "US/Eastern", "US/Central", "US/Mountain", "US/Arizona", "US/Pacific", "US/Alaska", "US/Aleutian", "US/Hawaii", "US/Samoa"};
|
||||||
|
JComboBox timeZoneDropdown = new JComboBox(timeZoneOptions);
|
||||||
|
timeZoneDropdown.setSelectedIndex(0);
|
||||||
|
r2Panel.add(timeZoneDropdown);
|
||||||
|
|
||||||
rPanel.add(r2Panel);
|
rPanel.add(r2Panel);
|
||||||
|
|
||||||
JPanel r3Panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
JPanel r3Panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||||
@@ -871,6 +881,16 @@ public class Main {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ztOption = timeZoneDropdown.getSelectedItem().toString();
|
||||||
|
|
||||||
|
if (ztOption.equals("Location Time")) {
|
||||||
|
timeZone = getTimeZone(mainIcao);
|
||||||
|
} else if (ztOption.equals("System Time")) {
|
||||||
|
timeZone = ZoneId.systemDefault();
|
||||||
|
} else {
|
||||||
|
timeZone = ZoneId.of(timeZoneDropdown.getSelectedItem().toString());
|
||||||
|
}
|
||||||
|
|
||||||
selectedFlavor = (String) flavorDropdown.getSelectedItem();
|
selectedFlavor = (String) flavorDropdown.getSelectedItem();
|
||||||
|
|
||||||
simWidth = Integer.parseInt(widthField.getText());
|
simWidth = Integer.parseInt(widthField.getText());
|
||||||
@@ -879,10 +899,6 @@ public class Main {
|
|||||||
mainLat = icaoToLat(mainIcao, key);
|
mainLat = icaoToLat(mainIcao, key);
|
||||||
mainLon = icaoToLon(mainIcao, key);
|
mainLon = icaoToLon(mainIcao, key);
|
||||||
|
|
||||||
almanac = new Almanac();
|
|
||||||
todayMonth = almanac.getMonth(mainIcao, key);
|
|
||||||
todayDay = almanac.getDayDate(mainIcao, key);
|
|
||||||
|
|
||||||
wr.start();
|
wr.start();
|
||||||
|
|
||||||
settingsErrorThrown = false;
|
settingsErrorThrown = false;
|
||||||
@@ -894,27 +910,30 @@ public class Main {
|
|||||||
settingsWindow.setVisible(true);
|
settingsWindow.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String checkIcaoCode(String code, String key) {
|
static ZoneId getTimeZone(String icaoCode) {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
|
||||||
.uri(URI.create("https://api.weather.com/v3/location/point?icaoCode=" + code
|
|
||||||
+ "&language=en-US&format=json&apiKey=" + key))
|
|
||||||
.GET() // Or .POST(HttpRequest.BodyPublishers.ofString("your_json_body"))
|
|
||||||
.header("Accept", "application/json").build();
|
|
||||||
try {
|
try {
|
||||||
HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
if (Response.statusCode() != 200) {
|
HttpRequest Request = HttpRequest.newBuilder()
|
||||||
if (Response.statusCode() == 401) {
|
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||||
return "API Key error";
|
.GET()
|
||||||
} else {
|
.header("Accept", "application/json")
|
||||||
return "Invalid ICAO Code";
|
.build();
|
||||||
}
|
try {
|
||||||
}
|
HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());
|
||||||
|
if (Response.statusCode() != 200) {
|
||||||
|
return ZoneId.systemDefault();
|
||||||
|
}
|
||||||
|
String ResponseBody = Response.body();
|
||||||
|
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
||||||
|
String time = JSONResponse.getJSONArray("validTimeLocal").getString(0);
|
||||||
|
|
||||||
return "noerror";
|
return ZonedDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssZ")).getZone();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return ZoneId.systemDefault();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
return ZoneId.systemDefault();
|
||||||
return "Server Error";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,239 @@
|
|||||||
package WS3000.weatherstar3000;
|
package WS3000.weatherstar3000;
|
||||||
|
|
||||||
//import java.net.URI;
|
import org.locationtech.jts.geom.Coordinate;
|
||||||
//import java.net.http.HttpClient;
|
import org.locationtech.jts.geom.GeometryFactory;
|
||||||
//import java.net.http.HttpRequest;
|
import org.locationtech.jts.geom.Point;
|
||||||
//import java.net.http.HttpResponse;
|
import org.locationtech.jts.geom.Polygon;
|
||||||
import java.time.LocalDate;
|
import org.w3c.dom.Document;
|
||||||
import java.time.Month;
|
import org.w3c.dom.Element;
|
||||||
import java.util.ArrayList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.temporal.TemporalAdjusters;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
import util.Utilities;
|
import util.Utilities;
|
||||||
|
|
||||||
//import org.json.JSONObject;
|
|
||||||
|
|
||||||
public class Outlook extends Thread {
|
public class Outlook extends Thread {
|
||||||
static Utilities utl = new Utilities();
|
static Utilities utl = new Utilities();
|
||||||
String month;
|
String month;
|
||||||
ArrayList<String> outlook = new ArrayList<>();
|
String precipitation;
|
||||||
String getMonth() {
|
String temperature;
|
||||||
LocalDate cdate = LocalDate.now();
|
|
||||||
Month cmonth = cdate.getMonth();
|
|
||||||
|
|
||||||
return cmonth.name().toUpperCase();
|
private static final GeometryFactory geometryFactory = new GeometryFactory();
|
||||||
}
|
|
||||||
ArrayList<String> getOutlook() {
|
String getOutlook(String type, String lat, String lon) {//type prcp or temp
|
||||||
ArrayList<String> outlook = new ArrayList<>();
|
try {
|
||||||
outlook.add("NO");
|
String zipFile = "https://ftp.cpc.ncep.noaa.gov/GIS/us_tempprcpfcst/monthlyupdate/monthupd_" + type + "_latest.zip";
|
||||||
outlook.add("REPORT");
|
|
||||||
return outlook;
|
try {
|
||||||
|
InputStream kmlStream = getKmlStreamFromUrl(zipFile);
|
||||||
|
if (kmlStream == null) {
|
||||||
|
System.err.println("No .kml file found inside the ZIP archive.");
|
||||||
|
return utl.ljust("NO REPORT", 17, " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<NamedPolygon> polygons = parseKmlPolygons(kmlStream);
|
||||||
|
|
||||||
|
Point userPoint = geometryFactory.createPoint(new Coordinate(Double.parseDouble(lon), Double.parseDouble(lat)));
|
||||||
|
|
||||||
|
String matchedPolygonName = findContainingPolygon(polygons, userPoint);
|
||||||
|
|
||||||
|
if (matchedPolygonName != null) {
|
||||||
|
if (matchedPolygonName.contains("Above")) {
|
||||||
|
return utl.ljust("ABOVE NORMAL", 17, " ");
|
||||||
|
} else if (matchedPolygonName.contains("Below")) {
|
||||||
|
return utl.ljust("BELOW NORMAL", 17, " ");
|
||||||
|
} else {
|
||||||
|
return utl.ljust("NORMAL", 17, " ");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return utl.ljust("NO REPORT", 17, " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return utl.ljust("NO REPORT", 17, " ");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return utl.ljust("NO REPORT", 17, " ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private InputStream getKmlStreamFromUrl(String zipUrl) {
|
||||||
|
try {
|
||||||
|
URL url = URI.create(zipUrl).toURL();
|
||||||
|
|
||||||
|
ZipInputStream zis = new ZipInputStream(url.openStream());
|
||||||
|
ZipEntry entry;
|
||||||
|
|
||||||
|
while ((entry = zis.getNextEntry()) != null) {
|
||||||
|
if (!entry.isDirectory() && entry.getName().toLowerCase().endsWith(".kml")) {
|
||||||
|
return zis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<NamedPolygon> parseKmlPolygons(InputStream kmlStream) throws Exception {
|
||||||
|
List<NamedPolygon> result = new ArrayList<>();
|
||||||
|
|
||||||
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
|
Document doc = builder.parse(kmlStream);
|
||||||
|
|
||||||
|
NodeList placemarks = doc.getElementsByTagName("Placemark");
|
||||||
|
|
||||||
|
for (int i = 0; i < placemarks.getLength(); i++) {
|
||||||
|
Element placemark = (Element) placemarks.item(i);
|
||||||
|
|
||||||
|
NodeList nameNodes = placemark.getElementsByTagName("name");
|
||||||
|
String name = nameNodes.getLength() > 0 ? nameNodes.item(0).getTextContent().trim() : "Unnamed";
|
||||||
|
|
||||||
|
NodeList polygonNodes = placemark.getElementsByTagName("Polygon");
|
||||||
|
|
||||||
|
for (int j = 0; j < polygonNodes.getLength(); j++) {
|
||||||
|
Element polygonEl = (Element) polygonNodes.item(j);
|
||||||
|
NodeList coordsNodes = polygonEl.getElementsByTagName("coordinates");
|
||||||
|
|
||||||
|
if (coordsNodes.getLength() > 0) {
|
||||||
|
String rawCoords = coordsNodes.item(0).getTextContent();
|
||||||
|
Polygon polygon = buildJtsPolygon(rawCoords);
|
||||||
|
if (polygon != null) {
|
||||||
|
result.add(new NamedPolygon(name, polygon));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Polygon buildJtsPolygon(String rawCoords) {
|
||||||
|
String[] pointsStr = rawCoords.trim().split("\\s+");
|
||||||
|
List<Coordinate> coordsList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String p : pointsStr) {
|
||||||
|
p = p.trim();
|
||||||
|
if (p.isEmpty()) continue;
|
||||||
|
|
||||||
|
String[] parts = p.split(",");
|
||||||
|
if (parts.length >= 2) {
|
||||||
|
try {
|
||||||
|
double lon = Double.parseDouble(parts[0]);
|
||||||
|
double lat = Double.parseDouble(parts[1]);
|
||||||
|
coordsList.add(new Coordinate(lon, lat));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (coordsList.size() < 3) return null;
|
||||||
|
|
||||||
|
if (!coordsList.get(0).equals2D(coordsList.get(coordsList.size() - 1))) {
|
||||||
|
coordsList.add(coordsList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinate[] coordsArray = coordsList.toArray(new Coordinate[0]);
|
||||||
|
return geometryFactory.createPolygon(coordsArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String findContainingPolygon(List<NamedPolygon> polygons, Point point) {
|
||||||
|
for (NamedPolygon np : polygons) {
|
||||||
|
if (np.polygon.covers(point)) {
|
||||||
|
return np.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getOutlookTitle() {
|
||||||
|
try {
|
||||||
|
ZonedDateTime today = ZonedDateTime.now(Main.timeZone);
|
||||||
|
|
||||||
|
String[] monthsShorter = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC", "JAN"};
|
||||||
|
String[] monthsShort = {"JAN", "FEB", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUG", "SEPT", "OCT", "NOV", "DEC", "JAN"};
|
||||||
|
String[] monthsLong = {"JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER", "JANUARY"};
|
||||||
|
|
||||||
|
String zipFile = "https://ftp.cpc.ncep.noaa.gov/GIS/us_tempprcpfcst/monthlyupdate/monthupd_temp_latest.zip";
|
||||||
|
|
||||||
|
int cMonthVal = ZonedDateTime.now(Main.timeZone).getMonthValue()-1;
|
||||||
|
|
||||||
|
String currentMonth = monthsShorter[cMonthVal];
|
||||||
|
String dataMonth = "";
|
||||||
|
|
||||||
|
InputStream kmlStream = getKmlStreamFromUrl(zipFile);
|
||||||
|
if (kmlStream == null) {
|
||||||
|
System.err.println("No .kml file found inside the ZIP archive.");
|
||||||
|
return utl.ljust("", 32, " ");
|
||||||
|
}
|
||||||
|
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(kmlStream);
|
||||||
|
Element root = doc.getDocumentElement();
|
||||||
|
if (root.hasAttribute("id")) {
|
||||||
|
dataMonth = parseMonth(root.getAttribute("id").toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (today.isAfter(today.withDayOfMonth(1).with(TemporalAdjusters.dayOfWeekInMonth(3, DayOfWeek.THURSDAY)))) {
|
||||||
|
if (currentMonth.equals(dataMonth)) {
|
||||||
|
return utl.cjust("MID " + monthsShort[cMonthVal] + " - MID " + monthsShort[cMonthVal+1], 32, " ");
|
||||||
|
} else {
|
||||||
|
return utl.cjust(monthsLong[cMonthVal+1], 32, " ");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return utl.cjust(monthsLong[cMonthVal], 32, " ");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return utl.ljust("", 32, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String parseMonth(String text) {
|
||||||
|
if (text == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
Pattern pattern = Pattern.compile("Valid\\s+([A-Za-z]{3})", Pattern.CASE_INSENSITIVE);
|
||||||
|
Matcher matcher = pattern.matcher(text);
|
||||||
|
|
||||||
|
if (matcher.find()) {
|
||||||
|
return matcher.group(1).toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
Main.outlook.month = getMonth();
|
String mainLat = Main.mainLat;
|
||||||
Main.outlook.outlook = getOutlook();
|
String mainLon = Main.mainLon;
|
||||||
|
Main.outlook.month = getOutlookTitle();
|
||||||
|
Main.outlook.temperature = getOutlook("temp", mainLat, mainLon);
|
||||||
|
Main.outlook.precipitation = getOutlook("prcp", mainLat, mainLon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NamedPolygon {
|
||||||
|
String name;
|
||||||
|
Polygon polygon;
|
||||||
|
|
||||||
|
NamedPolygon(String name, Polygon polygon) {
|
||||||
|
this.name = name;
|
||||||
|
this.polygon = polygon;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,9 +17,10 @@ public class RegionalConditions extends Thread {
|
|||||||
Utilities utl = new Utilities();
|
Utilities utl = new Utilities();
|
||||||
|
|
||||||
String getLocName(String displayName){
|
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) {
|
String getCondition(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return "NO REPORT";
|
return "NO REPORT";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "NO REPORT";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String getTemperature(String icaoCode, String key) {
|
String getTemperature(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void run() {
|
public void run() {
|
||||||
ArrayList<String> regConNames = new ArrayList<>();
|
ArrayList<String> regConNames = new ArrayList<>();
|
||||||
@@ -67,6 +77,9 @@ public class RegionalConditions extends Thread {
|
|||||||
ArrayList<String> regConIcaos = new ArrayList<>();
|
ArrayList<String> regConIcaos = new ArrayList<>();
|
||||||
regConIcaos.addAll(Main.regConIcaos);
|
regConIcaos.addAll(Main.regConIcaos);
|
||||||
String key = Main.key;
|
String key = Main.key;
|
||||||
|
Main.regionalConditions.locName.clear();
|
||||||
|
Main.regionalConditions.temperature.clear();
|
||||||
|
Main.regionalConditions.condition.clear();
|
||||||
for (int i = 0; i < regConIcaos.size(); i++) {
|
for (int i = 0; i < regConIcaos.size(); i++) {
|
||||||
Main.regionalConditions.locName.add(getLocName(regConNames.get(i)));
|
Main.regionalConditions.locName.add(getLocName(regConNames.get(i)));
|
||||||
Main.regionalConditions.temperature.add(getTemperature(regConIcaos.get(i), key));
|
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.HttpClient;
|
||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class RegionalForecast extends Thread {
|
public class RegionalForecast extends Thread {
|
||||||
@@ -15,12 +16,14 @@ public class RegionalForecast extends Thread {
|
|||||||
ArrayList<String> condition = new ArrayList<>();
|
ArrayList<String> condition = new ArrayList<>();
|
||||||
ArrayList<String> low = new ArrayList<>();
|
ArrayList<String> low = new ArrayList<>();
|
||||||
ArrayList<String> high = new ArrayList<>();
|
ArrayList<String> high = new ArrayList<>();
|
||||||
|
String first;
|
||||||
Utilities utl = new Utilities();
|
Utilities utl = new Utilities();
|
||||||
|
|
||||||
String getLocName(String displayName){
|
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) {
|
String getCondition(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return "NO REPORT";
|
return "NO REPORT";
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "NO REPORT";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String getLow(String icaoCode, String key) {
|
String getLow(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String getHigh(String icaoCode, String key) {
|
String getHigh(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public void run() {
|
public void run() {
|
||||||
ArrayList<String> regForNames = new ArrayList<>();
|
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.low.add(getLow(regForIcaos.get(i), key));
|
||||||
Main.regionalForecast.high.add(getHigh(regForIcaos.get(i), key));
|
Main.regionalForecast.high.add(getHigh(regForIcaos.get(i), key));
|
||||||
}
|
}
|
||||||
|
int hr = ZonedDateTime.now(Main.timeZone).getHour();
|
||||||
|
Main.regionalForecast.first = hr >= 4 && hr < 16 ? "H" : "L";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,9 +60,8 @@ public class SlidesRunner extends Scene {
|
|||||||
GameObject cBumperTwo;
|
GameObject cBumperTwo;
|
||||||
Utilities utl = new Utilities();
|
Utilities utl = new Utilities();
|
||||||
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
ZonedDateTime now = ZonedDateTime.now(Main.timeZone);
|
||||||
ZonedDateTime today = ZonedDateTime.now();
|
final String prefix = now.format(DateTimeFormatter.ofPattern("E MMM"));
|
||||||
final String prefix = today.format(DateTimeFormatter.ofPattern("E MMM"));
|
|
||||||
|
|
||||||
//slide line variables
|
//slide line variables
|
||||||
ArrayList<String> ccMainLines = new ArrayList<>();
|
ArrayList<String> ccMainLines = new ArrayList<>();
|
||||||
@@ -547,8 +546,7 @@ public class SlidesRunner extends Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void dateTime() {
|
public void dateTime() {
|
||||||
now = LocalDateTime.now();
|
now = ZonedDateTime.now(Main.timeZone);
|
||||||
today = ZonedDateTime.now();
|
|
||||||
|
|
||||||
dateLine = utl.ljust(String.format("%s %2d", prefix, now.getDayOfMonth()).toUpperCase(), 10, " ") + utl.ljust(" ", 11, " ") + utl.rjust(now.format(formatter), 11, " ");
|
dateLine = utl.ljust(String.format("%s %2d", prefix, now.getDayOfMonth()).toUpperCase(), 10, " ") + utl.ljust(" ", 11, " ") + utl.rjust(now.format(formatter), 11, " ");
|
||||||
|
|
||||||
@@ -613,14 +611,20 @@ public class SlidesRunner extends Scene {
|
|||||||
CurrentConditions ctData = Main.currentConditions;
|
CurrentConditions ctData = Main.currentConditions;
|
||||||
|
|
||||||
tickerLines.clear();
|
tickerLines.clear();
|
||||||
tickerLines.add(utl.ljust(ctData.locName, 32, " "));
|
|
||||||
tickerLines.add(utl.ljust(ctData.condition, 32, " "));
|
if (ctData.condition.equals("NO CURRENT REPORT")) {
|
||||||
tickerLines.add(utl.ljust(ctData.temperature + " " + ctData.feelsLike, 32, " "));
|
tickerLines.add(utl.ljust(ctData.locName, 32, " "));
|
||||||
tickerLines.add(utl.ljust(ctData.humidity + " " + ctData.dewPoint, 32, " "));
|
tickerLines.add(utl.ljust(ctData.condition, 32, " "));
|
||||||
tickerLines.add(utl.ljust(ctData.pressure, 32, " "));
|
} else {
|
||||||
tickerLines.add(utl.ljust(ctData.wind + " " + ctData.gusts, 32, " "));
|
tickerLines.add(utl.ljust(ctData.locName, 32, " "));
|
||||||
tickerLines.add(utl.ljust(ctData.visibility + " " + ctData.ceiling, 32, " "));
|
tickerLines.add(utl.ljust(ctData.condition, 32, " "));
|
||||||
tickerLines.add(utl.ljust(ctData.precip, 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() {
|
public void currentConditions() {
|
||||||
slideRounds = 0;
|
slideRounds = 0;
|
||||||
@@ -1018,11 +1022,21 @@ public class SlidesRunner extends Scene {
|
|||||||
rfMainLines.clear();
|
rfMainLines.clear();
|
||||||
|
|
||||||
rfMainLines.add(" FORECAST ACROSS THE REGION ");
|
rfMainLines.add(" FORECAST ACROSS THE REGION ");
|
||||||
rfMainLines.add("CITY WEATHER LOW HI");
|
|
||||||
for (int i = 0; i < rfData.locName.size(); i++) {
|
if (rfData.first.equals("L")) {
|
||||||
rfMainLines.add(utl.ljust(rfData.locName.get(i), 14, " ") + " " + utl.ljust(rfData.condition.get(i), 10, " ") + rfData.low.get(i) + " " + rfData.high.get(i));
|
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;
|
slideInit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1117,24 +1131,14 @@ public class SlidesRunner extends Scene {
|
|||||||
|
|
||||||
olMainLines.clear();
|
olMainLines.clear();
|
||||||
|
|
||||||
olMainLines.add(" NAT'L WEATHER SERVICE OUTLOOK ");
|
|
||||||
olMainLines.add(utl.ljust(" ", 32, " "));//half space
|
|
||||||
olMainLines.add(utl.cjust(oData.month, 32, " "));
|
|
||||||
olMainLines.add(utl.ljust(" ", 32, " "));
|
olMainLines.add(utl.ljust(" ", 32, " "));
|
||||||
|
olMainLines.add(utl.ljust(" ", 32, " "));
|
||||||
StringBuilder sb = new StringBuilder();
|
olMainLines.add(" 30 DAY OUTLOOK ");
|
||||||
for (int i = 0; i <= oData.outlook.size()-1; i++) {
|
olMainLines.add(oData.month);
|
||||||
int cwordlength = oData.outlook.get(i).length();
|
olMainLines.add(utl.ljust(" ", 32, " "));
|
||||||
if (cwordlength + sb.length() + 1 <= 32) {
|
olMainLines.add("TEMPERATURES: " + oData.temperature);
|
||||||
if (!sb.isEmpty()) {sb.append(" ");}
|
olMainLines.add(utl.ljust(" ", 32, " "));
|
||||||
sb.append(oData.outlook.get(i));
|
olMainLines.add("PRECIPITATION: " + oData.precipitation);
|
||||||
} else {
|
|
||||||
i--;
|
|
||||||
olMainLines.add(utl.ljust(sb.toString(), 32, " "));
|
|
||||||
sb.setLength(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
olMainLines.add(utl.ljust(sb.toString(), 32, " "));
|
|
||||||
|
|
||||||
slideInit = true;
|
slideInit = true;
|
||||||
}
|
}
|
||||||
@@ -1144,7 +1148,7 @@ public class SlidesRunner extends Scene {
|
|||||||
int poolIdx = 0;
|
int poolIdx = 0;
|
||||||
|
|
||||||
for (int row = 0; row < olMainLines.size(); row++) {
|
for (int row = 0; row < olMainLines.size(); row++) {
|
||||||
int lineHeight = row == 1 ? 22 : 40;
|
int lineHeight = 40;
|
||||||
String line = olMainLines.get(row);
|
String line = olMainLines.get(row);
|
||||||
for (int i = 0; i < line.length(); i ++) {
|
for (int i = 0; i < line.length(); i ++) {
|
||||||
if (poolIdx >= olPool.length) break;
|
if (poolIdx >= olPool.length) break;
|
||||||
@@ -1232,15 +1236,6 @@ public class SlidesRunner extends Scene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void airportDelays() {
|
|
||||||
slideRounds = 0;
|
|
||||||
this.addGameObjectToScene(bg);
|
|
||||||
|
|
||||||
if (!slideInit) {
|
|
||||||
slideInit = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void travelForecast() {
|
public void travelForecast() {
|
||||||
travelForecastActive = true;
|
travelForecastActive = true;
|
||||||
this.addGameObjectToScene(travelBg);
|
this.addGameObjectToScene(travelBg);
|
||||||
@@ -1250,13 +1245,25 @@ public class SlidesRunner extends Scene {
|
|||||||
travelMainLines.clear();
|
travelMainLines.clear();
|
||||||
travelMainLines.add(" TRAVEL CITIES FORECAST ");
|
travelMainLines.add(" TRAVEL CITIES FORECAST ");
|
||||||
travelMainLines.add(utl.ljust(" ", 32, " "));
|
travelMainLines.add(utl.ljust(" ", 32, " "));
|
||||||
travelMainLines.add("CITY WEATHER LOW HI");
|
|
||||||
for (int i = 0; i < tfData.locName.size(); i++) {
|
if (tfData.first.equals("L")) {
|
||||||
travelMainLines.add(utl.ljust(tfData.locName.get(i), 15, " ") +
|
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.ljust(tfData.condition.get(i), 10, " ") +
|
||||||
utl.rjust(tfData.low.get(i), 3, " ") +
|
utl.rjust(tfData.low.get(i), 3, " ") +
|
||||||
utl.rjust(tfData.high.get(i), 4, " "));
|
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;
|
travelDataInit = true;
|
||||||
travelOffset = 0;
|
travelOffset = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.net.http.HttpRequest;
|
|||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -28,14 +28,14 @@ public class Tides extends Thread {
|
|||||||
DateTimeFormatter tideTimeFormatter = DateTimeFormatter.ofPattern("h:mma E", Locale.ENGLISH);
|
DateTimeFormatter tideTimeFormatter = DateTimeFormatter.ofPattern("h:mma E", Locale.ENGLISH);
|
||||||
|
|
||||||
String getLocName(String displayName) {
|
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) {
|
String getTides(String station, String tide) {
|
||||||
try {
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
HttpRequest Request = HttpRequest.newBuilder()
|
||||||
.uri(URI.create("https://api.tidesandcurrents.noaa.gov/api/prod/datagetter?begin_date=" + LocalDate.now().format(tideDateFormatter) + "&end_date=" + LocalDate.now().plusDays(1).format(tideDateFormatter) + "&station=" + station + "&product=predictions&datum=MLLW&time_zone=lst_ldt&interval=hilo&units=english&application=DataAPI_Sample&format=json"))
|
.uri(URI.create("https://api.tidesandcurrents.noaa.gov/api/prod/datagetter?begin_date=" + ZonedDateTime.now(Main.timeZone).format(tideDateFormatter) + "&end_date=" + ZonedDateTime.now(Main.timeZone).plusDays(1).format(tideDateFormatter) + "&station=" + station + "&product=predictions&datum=MLLW&time_zone=lst_ldt&interval=hilo&units=english&application=DataAPI_Sample&format=json"))
|
||||||
.GET()
|
.GET()
|
||||||
.header("Accept", "application/json")
|
.header("Accept", "application/json")
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.net.URI;
|
|||||||
import java.net.http.HttpClient;
|
import java.net.http.HttpClient;
|
||||||
import java.net.http.HttpRequest;
|
import java.net.http.HttpRequest;
|
||||||
import java.net.http.HttpResponse;
|
import java.net.http.HttpResponse;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@@ -17,14 +18,16 @@ public class TravelForecast extends Thread {
|
|||||||
ArrayList<String> low = new ArrayList<>();
|
ArrayList<String> low = new ArrayList<>();
|
||||||
ArrayList<String> high = new ArrayList<>();
|
ArrayList<String> high = new ArrayList<>();
|
||||||
Utilities utl = new Utilities();
|
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> 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"));
|
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){
|
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) {
|
String getCondition(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return "NO REPORT";
|
return "NO REPORT";
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "NO REPORT";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String getLow(String icaoCode, String key) {
|
String getLow(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String getHigh(String icaoCode, String key) {
|
String getHigh(String icaoCode, String key) {
|
||||||
|
try {
|
||||||
HttpClient Client = HttpClient.newBuilder().build();
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
HttpRequest Request = HttpRequest.newBuilder()
|
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))
|
.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) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return " ";
|
return " ";
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void run() {
|
public void run() {
|
||||||
String key = Main.key;
|
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++) {
|
for (int i = 0; i < tForIcaos.size(); i++) {
|
||||||
Main.travelForecast.locName.add(getLocName(tForNames.get(i)));
|
Main.travelForecast.locName.add(getLocName(tForNames.get(i)));
|
||||||
Main.travelForecast.condition.add(getCondition(tForIcaos.get(i), key));
|
Main.travelForecast.condition.add(getCondition(tForIcaos.get(i), key));
|
||||||
Main.travelForecast.low.add(getLow(tForIcaos.get(i), key));
|
Main.travelForecast.low.add(getLow(tForIcaos.get(i), key));
|
||||||
Main.travelForecast.high.add(getHigh(tForIcaos.get(i), key));
|
Main.travelForecast.high.add(getHigh(tForIcaos.get(i), key));
|
||||||
}
|
}
|
||||||
|
int hr = ZonedDateTime.now(Main.timeZone).getHour();
|
||||||
|
Main.travelForecast.first = hr >= 4 && hr < 16 ? "H" : "L";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,8 @@
|
|||||||
"Flash Flood Warning": { "headline": false, "scroll": true, "severity": "Warning" },
|
"Flash Flood Warning": { "headline": false, "scroll": true, "severity": "Warning" },
|
||||||
"Excessive Heat Watch": { "headline": true, "scroll": true, "severity": "Advisory" },
|
"Excessive Heat Watch": { "headline": true, "scroll": true, "severity": "Advisory" },
|
||||||
"Excessive Heat Warning": { "headline": true, "scroll": true, "severity": "Warning" },
|
"Excessive Heat Warning": { "headline": true, "scroll": true, "severity": "Warning" },
|
||||||
|
"Extreme Heat Watch": { "headline": true, "scroll": true, "severity": "Advisory" },
|
||||||
|
"Extreme Heat Warning": { "headline": true, "scroll": true, "severity": "Warning" },
|
||||||
"Heat Advisory": { "headline": true, "scroll": true, "severity": "Advisory" },
|
"Heat Advisory": { "headline": true, "scroll": true, "severity": "Advisory" },
|
||||||
"Tropical Storm Watch": { "headline": true, "scroll": true, "severity": "Advisory" },
|
"Tropical Storm Watch": { "headline": true, "scroll": true, "severity": "Advisory" },
|
||||||
"Tropical Storm Warning": { "headline": true, "scroll": true, "severity": "Warning" },
|
"Tropical Storm Warning": { "headline": true, "scroll": true, "severity": "Warning" },
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
{"segment":"localForecast", "duration": 600.0},
|
{"segment":"localForecast", "duration": 600.0},
|
||||||
{"segment":"regionalForecast", "duration": 600.0},
|
{"segment":"regionalForecast", "duration": 600.0},
|
||||||
{"segment":"almanac", "duration": 600.0},
|
{"segment":"almanac", "duration": 600.0},
|
||||||
{"segment":"regionalConditions", "duration": 600.0}
|
{"segment":"hourlyObservations", "duration": 600.0}
|
||||||
],
|
],
|
||||||
"I": [
|
"I": [
|
||||||
{"segment":"currentConditions", "duration": 600.0},
|
{"segment":"currentConditions", "duration": 600.0},
|
||||||
|
|||||||
Reference in new issue
Block a user