As part of my Computer Studies project, I have created an application which downloads in real-time, pollutant standard indexes and weather forecasts of different areas or sectors in Singapore from data.gov.sg. Afterwards, the data will be pre-processed and stored into files in readable format. The data will then be dissected and all of this information will be displayed onto google maps and also onto the side panel of the main scene. When the user clicks on the 1h PM2.5 option under the Statistics tab in the menu bar, my application will process the hourly PM2.5 data for the current day and display it in line charts in the statistics scene. In addition, it will also allow for the users to compare between the hourly PM2.5 readings for the current day and another day in the past of their preference.
In the program, there is code to set up a HttpURLConnection between the program and the data.gov.sg website. Query parameters can be added on to the back of the data-retrieving URL to specify the type of data that one wants. If no query parameters are specified, the data that is gathered from the get request will just be the data for the latest update to the system. I obtained a consumer key by creating an account on the data.gov.sg website, and utilised it to fill in the required api-key header parameter in order to fetch data. My program allows me to get the PM2.5 readings for the latest hour it was updated on, the PM2.5 readings for the entire of the current day, the PM2.5 readings for a specified day, and the weather forecasts for the latest half-hour it was updated on. In addition, I also used a pure JavaFX API, known as GMapsFX, to help with displaying Google maps in my application.
I have two main test scenarios in my application. The first occurs right at the start, whereby my program checks to see if there is internet connection. If there is, the program will just continue and proceed to download the relevant data. However, if there is no internet connection, my program will create an alert to notify the user of the failure to connect to the internet, and close the application. The second occurs during the initialisation of the trend chart. If there is data already present for the current day, the program will proceed to display the chart, but if it is just past midnight, there might not be any data uploaded yet. In that case, my application will alert the user that there is no data available yet and ask him/her to try again later.