Update End of Term Assignment authored by Zorenböhmer Christina's avatar Zorenböhmer Christina
......@@ -4,8 +4,14 @@
**.java Files:** All final .java files can be found in our ["Final Codes" folder](https://git.sbg.ac.at/s1080384/EoT/-/tree/main/Java%20Codes/Final%20Version).
**Code and Console Snippets:** Included in this wiki page in drop down boxes!
**Video Demo:** Scroll to the bottom of the page!
<!---blank line--->
<br>
<!---blank line--->
## Background and Aim
This End of Term (EoT) Project shall:
......@@ -35,7 +41,7 @@ Although it was not technically required by the assignment instructions, we want
Specifically, we wanted to allow user input for these decisions:
1\. Allow the user to either accept the default directory or set a new one.
<details><summary> 1. Allow the user to either accept the default directory or set a new one.</summary>
```java
Scanner askUser = new Scanner(System.in); // warning coming from non-closed scanner. Note: if we close it, subsequent scanners fail to work.
......@@ -84,8 +90,9 @@ Scanner askUser = new Scanner(System.in); // warning coming from non-closed sc
} // askUser1()
```
</details>
2\. Ask the user if they would like to see additional information on the WMS while the programme is running.
<details><summary> 2. Ask the user if they would like to see additional information on the WMS while the programme is running.</summary>
```java
......@@ -117,8 +124,9 @@ Scanner askUser = new Scanner(System.in); // warning coming from non-closed sc
System.out.println("Alright."); // lowkey annoyed answer hehe ;)
}
```
</details>
3\. Ask the user if they would like to proceed to launch Google Earth.
<details><summary> 3. Ask the user if they would like to proceed to launch Google Earth.</summary>
```java
......@@ -144,6 +152,8 @@ static void askUser2() {
} // askUer2()
```
</details>
## Concept
......@@ -151,13 +161,17 @@ At the outset we began gathering ideas and drawing up concepts for our approach.
![concept](/s1080384/EoT/-/wikis/uploads/7f8865dad611818e03f2f43a43598f76/concept.JPG)
<!---blank line--->
<br>
<!---blank line--->
## The Main Executable Class: GoogleEarthTweetMapper.java
Although this class could not be completed until we had created all other classes, we will begin with this class since it provides a neat summary of how all components for our project come together.
As stated above, we aimed to make the whole programme run smoothly without the user having to figure out which classes to execute and in which order. We hope that it may demonstrate how we applied our newly obtained knowledge about modularity, to make the whole programme run smoothly and without the user having to figure our which classes to execute and in which order. To see the main class [GoogleEarthTweetMapper.java](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Final%20Version/GoogleEarthTweetMapper.java) in the correct order.
See the Code for the GoogleEarthTweetMapper.java class here
<details><summary>See the Code for the GoogleEarthTweetMapper.java class here</summary>
```java
......@@ -210,15 +224,19 @@ public class GoogleEarthTweetMapper {
} // main()
} // class
```
</details>
## User Input 1
In this first step we ask the user to give us the "thumbs up" for downloading the required files onto their PC. We set the default directory to "C:/Users/Public/Documents", which is given on any PC. Nonetheless, we wanted to let the user specify a different directory if they prefer that. This was implemented in the non-executable [user_Input.java](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Final%20Version/User_input.java) class.
See the Code for the "userInput.java class here
<details><summary>See the Code for the userInput.java class here</summary>
```java
package eot_Sahinovic_Woehs_Zorenboehmer;
import java.io.File;
......@@ -298,11 +316,14 @@ public class User_input {
} // askUer2()
} // class
```
</details>
See the console output
<details><summary>See the console output</summary>
```plaintext
Hello! Welcome to this Google Earth Tweet and WMS Mapper!
This programme will:
......@@ -323,7 +344,10 @@ Wrong file path. Please try again.
C:\Users\Christina\Documents\Test Folder
New directory set to: C:\Users\Christina\Documents\Test Folder
```
</details>
## Connecting to WMS and Downloading Image
......@@ -335,7 +359,7 @@ First, we created a non-executable [wms_GetMap.java](https://git.sbg.ac.at/s1080
> 4. asks the user if they would like to see information on the service (and either prints infos to the console or moves on)
> 5. writes the image in .png to the local directory
See the Code for the "wms_GetMap.java" class here
<details><summary>See the Code for the "wms_GetMap.java" class here</summary>
```java
package eot_Sahinovic_Woehs_Zorenboehmer;
......@@ -436,11 +460,14 @@ public class WMS_GetMap {
} // getMap()
} // class
```
</details>
See Console Output
<details><summary>See Console Output</summary>
```plaintext
Testing Heigit's wms service URL... No errors in communicating with the server.
Would you like additional information on the WMS service while the programme runs? Type Y for yes or anything else for no and hit enter.
......@@ -456,7 +483,9 @@ ok
Image was successfully saved at: C:\Users\Christina\Documents\Test Folder\boston.png
--- Step 1 completed. ---
```
</details>
The result is this image "boston.png": <http://maps.heigit.org/osm-wms/service?REQUEST=GetMap&FORMAT=image%2Fpng&SRS=EPSG:4326&BBOX=-71.13,42.32,-71.03,42.42&VERSION=1.1.1&STYLES=default&SERVICE=WMS&WIDTH=1000&HEIGHT=1000&TRANSPARENT=TRUE&LAYERS=osm_auto%3Aall>
......@@ -467,7 +496,7 @@ Here, we created a non-executable [wms_ImageToKML](https://git.sbg.ac.at/s108038
> 1. finds the local boston.png image
> 2. writes a kml file (containing the image) to a local wms_kml_structure.kml
See Code for the "wms_ImageToKML.java" class here
<details><summary>See Code for the "wms_ImageToKML.java" class here</summary>
```java
......@@ -538,24 +567,31 @@ public class WMS_ImageToKML {
} // wmsTOkml()
} // class
```
</details>
See Console Output
<details><summary>See Console Output</summary>
```plaintext
Turning local .png of Boston into kml format ...
Image found...
Image converted to kml and stored at: C:\Users\Christina\Documents\Test Folder\boston.kml
--- Step 2 completed. ---
```
</details>
## Downloading Twitter.csv File
Although this step was not included in the assignment instructions, we decided it would be nice for the user to not worry about having to download the .csv file themselves. Therefore we created a non-executable [tweets_download.java](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Final%20Version/Tweets_download.java) class that contains the methods `saveFileFromUrlWithCommonsIO()` and `downloadCSV()` that access and download the .csv file from this web-URL: <http://www.berndresch.com/work/twitter.csv>
See the Code for the "tweets_download.java" Class
<details><summary>See the Code for the "tweets_download.java" Class</summary>
```java
package eot_Sahinovic_Woehs_Zorenboehmer;
import java.io.File;
......@@ -597,15 +633,21 @@ public class Tweets_download {
} // downloadCSV()
} // class
```
</details>
See Console Output
<details><summary>See Console Output</summary>
```plaintext
Downloading online tweets.csv and storing locally ...
CSV file downloaded and stored at :C:\Users\Christina\Documents\Test Folder\tweets.csv
--- Step 3 completed. ---
```
</details>
## Converting Tweets.csv into Tweets.kml
......@@ -625,7 +667,7 @@ We therefore concluded that we needed to add in the "T" where the blank space is
**Colouring the Polygons according to the Time of Tweet:** Here we decided to work with the difference between the first tweet’s time and every other tweet’s time to adjust the hexadecimal colour code for each placemark. We decided to work with a colour-ramp from yellow (=earliest) to red (=latest), which meant that we set opacity to full (FF), blue to zero (00), red to full (FF) and dynamically adjusted the value of green. The value for green was calculated with the two values “secondsFirstDate” (= the time of the first tweet in seconds) and “seconds” (= the time of the current tweet in seconds), which are given in milliseconds. We first divided both by 1000 to arrive at seconds, and then we divided them by 6 to ensure all values are within a range of 256, which is required for the colour values. We then simply calculated the difference between the first and the current tweet and used that difference to set the green colour value.
See the Code for the tweets_polygons.java Class
<details><summary>See the Code for the tweets_polygons.java Class</summary>
```java
......@@ -807,24 +849,31 @@ public class Tweets_polygons {
} // tweetsToPolygons()
} // class
```
</details>
See the Console Output
<details><summary>See the Console Output</summary>
```plaintext
Accessing local tweets.csv file and converting into kml file ...
1163 KML placemarks have been generated.
All 1163 placemarks have been integrated into a single KML file, which is saved at C:\Users\Christina\Documents\Test Folder\tweets_polygons.kml
--- Step 4 completed. ---
```
</details>
## Creating a KML Tour
Although not technically required, we though it would improve the user experience to be guided through the results in Google Earth. We therefore created our own KML tour and integrated it into a non-executable [googleEarth_Tour.java](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Final%20Version/GoogleEarth_tour.java) class that stores the tour.kml locally.
See the Code for the googleEarth_Tour.java Class
<details><summary>See the Code for the googleEarth_Tour.java Class</summary>
```java
package eot_Sahinovic_Woehs_Zorenboehmer;
import java.io.FileWriter;
......@@ -1023,20 +1072,26 @@ public class GoogleEarth_tour {
} // createTour()
} // class
```
</details>
See the Console Output
<details><summary>See the Console Output</summary>
```plaintext
KML Tour created and stored at C:\Users\Christina\Documents\Test Folder\A Little Tour of our Project.kml
--- Step 5 completed. ---
```
</details>
## User Input 2
Before launching the Google Earth application, we wanted to ask the user to confirm that they want to launch the programme. For this, we simply used a scanner to prompt the user to enter some form of "yes" to launch the programme. If something else is entered, we end the programme. We called the askUser2() method from the non-executable [user_Input.java](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Final%20Version/User_input.java) class.
See the Code for the user_Input.java Class
<details><summary>See the Code for the user_Input.java Class</summary>
```java
......@@ -1119,23 +1174,29 @@ public class User_input {
} // askUer2()
} // class
```
</details>
See the Concole Output
<details><summary>See the Concole Output</summary>
```plaintext
We have created a small tour to show you the WMS and Tweets in Google Earth. It will automatically begin when Google Earth is launched.
Would you like to proceed to launch Google Earth now? Type Y for yes or anything else for no and hit enter.
y
Proceeding...
Continued.
```
</details>
## Launch Google Earth
In this final step, we merely used one [non-executable class "googleEarth_launch"](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Final%20Version/GoogleEarth_launch.java) with a method `launchGoogleEarth()` that launches google earth and opens all .kml files, including the tour.
See the Code for the googleEarth_launch.java Class
<details><summary>See the Code for the googleEarth_launch.java Class</summary>
```java
......@@ -1170,16 +1231,27 @@ public class GoogleEarth_launch {
} //launchGoogleEarth()
} // class
```
</details>
See the Console Output
<details><summary>See the Console Output</summary>
```plaintext
Launching Google Earth...
Launch complete.
--- Step 6 completed. ---
```
</details>
<!---blank line--->
<br>
<!---blank line--->
## Video Demos!
......@@ -1191,6 +1263,10 @@ Launch complete.
[Google_Earth_Tour](/s1080384/EoT/-/wikis/uploads/255bb09b1b316dc47ed6bc780562c923/Google_Earth_Tour.mp4)
<!---blank line--->
<br>
<!---blank line--->
## Further Information
For further information on this project, or to offer feedback, please don't hesitate to contact the authors/ creators:
......
......