|
|

|
|
|

|
|
|
|
|
|
**Contributors:** Edah Sahinovic, Katharina Wöhs, Christina Zorenböhmer
|
|
|
|
... | ... | @@ -6,26 +6,22 @@ |
|
|
|
|
|
**Video Demo:** Scroll to the bottom of the page!
|
|
|
|
|
|
<!-- blank line -->
|
|
|
<br>
|
|
|
<!-- blank line -->
|
|
|
|
|
|
## Background and Aim
|
|
|
|
|
|
This End of Term (EoT) Project shall:
|
|
|
|
|
|
> - Welcome the user and ask the user to either accept a default directory or set a new one
|
|
|
> - Establish a WMS connection and download an image of Boston as .png and store it locally
|
|
|
> - Integrate the WMS Image into a kml structure
|
|
|
> - Download Tweets text file from the web and store locally
|
|
|
> - Integrate information about the Tweets to a kml and
|
|
|
> - visualises the tweets as 3D polygons
|
|
|
> - colours the polygons according to the time of the tweets
|
|
|
> - includes time stamps
|
|
|
> - includes pop-up boxes
|
|
|
> - Create and store a kml tour file
|
|
|
> - Launch Google Earth and all .kml files
|
|
|
> - Properly document all steps in a final submission .pdf and in this wiki repository
|
|
|
> * Welcome the user and ask the user to either accept a default directory or set a new one
|
|
|
> * Establish a WMS connection and download an image of Boston as .png and store it locally
|
|
|
> * Integrate the WMS Image into a kml structure
|
|
|
> * Download Tweets text file from the web and store locally
|
|
|
> * Integrate information about the Tweets to a kml and
|
|
|
> * visualises the tweets as 3D polygons
|
|
|
> * colours the polygons according to the time of the tweets
|
|
|
> * includes time stamps
|
|
|
> * includes pop-up boxes
|
|
|
> * Create and store a kml tour file
|
|
|
> * Launch Google Earth and all .kml files
|
|
|
> * Properly document all steps in a final submission .pdf and in this wiki repository
|
|
|
|
|
|
Before launching into a detailed description of our code and result, we first want to discuss a few key aspects that we kept in mind for this assignment:
|
|
|
|
... | ... | @@ -37,11 +33,9 @@ Since this assignment contains a variety of steps, it would lead to an extremely |
|
|
|
|
|
Although it was not technically required by the assignment instructions, we wanted to allow the user to interact with the programme in a few key steps. With this, we also had the aim of enhancing the user experience. We tried to come up with simple and friendly texts that would inform the user of what is happening. For example, the programme starts with a greeting and an explanation of what will happen.
|
|
|
|
|
|
|
|
|
Specifically, we wanted to allow user input for these decisions:
|
|
|
|
|
|
<details><summary> 1. Allow the user to either accept the default directory or set a new one.
|
|
|
</summary>
|
|
|
1\. Allow the user to either accept the default directory or set a new one.
|
|
|
|
|
|
```java
|
|
|
Scanner askUser = new Scanner(System.in); // warning coming from non-closed scanner. Note: if we close it, subsequent scanners fail to work.
|
... | ... | @@ -89,12 +83,9 @@ Scanner askUser = new Scanner(System.in); // warning coming from non-closed sc |
|
|
}
|
|
|
} // askUser1()
|
|
|
|
|
|
```
|
|
|
</details>
|
|
|
|
|
|
```
|
|
|
|
|
|
<details><summary> 2. Ask the user if they would like to see additional information on the WMS while the programme is running.
|
|
|
</summary>
|
|
|
2\. Ask the user if they would like to see additional information on the WMS while the programme is running.
|
|
|
|
|
|
```java
|
|
|
|
... | ... | @@ -125,14 +116,9 @@ Scanner askUser = new Scanner(System.in); // warning coming from non-closed sc |
|
|
} else {
|
|
|
System.out.println("Alright."); // lowkey annoyed answer hehe ;)
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
|
<details><summary> 3. Ask the user if they would like to proceed to launch Google Earth.
|
|
|
</summary>
|
|
|
3\. Ask the user if they would like to proceed to launch Google Earth.
|
|
|
|
|
|
```java
|
|
|
|
... | ... | @@ -157,31 +143,21 @@ static void askUser2() { |
|
|
}
|
|
|
|
|
|
} // askUer2()
|
|
|
|
|
|
```
|
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
|
|
|
|
## Concept
|
|
|
|
|
|
|
|
|
At the outset we began gathering ideas and drawing up concepts for our approach. We have visualised our concept below:
|
|
|
|
|
|

|
|
|
|
|
|
<!--blank link --->
|
|
|
<br>
|
|
|
<!---blank link--->
|
|
|

|
|
|
|
|
|
## 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.
|
|
|
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.
|
|
|
|
|
|
<details><summary> See the Code for the GoogleEarthTweetMapper.java class here</summary>
|
|
|
See the Code for the GoogleEarthTweetMapper.java class here
|
|
|
|
|
|
```java
|
|
|
|
... | ... | @@ -236,13 +212,11 @@ public class GoogleEarthTweetMapper { |
|
|
} // 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.
|
|
|
|
|
|
<details><summary> See the Code for the "userInput.java class here</summary>
|
|
|
See the Code for the "userInput.java class here
|
|
|
|
|
|
```java
|
|
|
package eot_Sahinovic_Woehs_Zorenboehmer;
|
... | ... | @@ -325,12 +299,10 @@ public class User_input { |
|
|
} // askUer2()
|
|
|
} // class
|
|
|
```
|
|
|
</details>
|
|
|
|
|
|
|
|
|
<details><summary> See the console output </summary>
|
|
|
See the console output
|
|
|
|
|
|
```
|
|
|
```plaintext
|
|
|
Hello! Welcome to this Google Earth Tweet and WMS Mapper!
|
|
|
|
|
|
This programme will:
|
... | ... | @@ -352,20 +324,18 @@ C:\Users\Christina\Documents\Test Folder |
|
|
|
|
|
New directory set to: C:\Users\Christina\Documents\Test Folder
|
|
|
```
|
|
|
</details>
|
|
|
|
|
|
|
|
|
## Connecting to WMS and Downloading Image
|
|
|
|
|
|
First, we created a non-executable [wms_GetMap.java](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Final%20Version/WMS_GetMap.java) class which contains a method `getMap()` that:
|
|
|
|
|
|
> 1. creates a WebMapServer object
|
|
|
> 2. tests the URL
|
|
|
> 3. retrieves the WMSCapabilities and information about the service
|
|
|
> 4. sends a fully configured GetMapRequest
|
|
|
> 5. asks the user if they would like to see information on the service (and either shows it or moves on)
|
|
|
> 6. writes the image in .png to the local directory
|
|
|
> 2. tests the URL
|
|
|
> 3. sends a fully configured GetMapRequest
|
|
|
> 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
|
|
|
|
|
|
<details><summary> See the Code for the "wms_GetMap.java" class here </summary>
|
|
|
See the Code for the "wms_GetMap.java" class here
|
|
|
|
|
|
```java
|
|
|
package eot_Sahinovic_Woehs_Zorenboehmer;
|
... | ... | @@ -468,12 +438,9 @@ public class WMS_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.
|
... | ... | @@ -489,22 +456,18 @@ 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
|
|
|
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>
|
|
|
|
|
|
## Converting WMS Image into .KML
|
|
|
|
|
|
Here, we created a non-executable [wms_ImageToKML"](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Final%20Version/WMS_ImageToKML.java) class which contains a method `wmsTOkml()` that:
|
|
|
Here, we created a non-executable [wms_ImageToKML](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Final%20Version/WMS_ImageToKML.java) class which contains a method `wmsTOkml()` that:
|
|
|
|
|
|
> finds the local boston.png image
|
|
|
> writes a kml file (containing the image) to a local wms_kml_structure.kml
|
|
|
> 1. finds the local boston.png image
|
|
|
> 2. writes a kml file (containing the image) to a local wms_kml_structure.kml
|
|
|
|
|
|
<details><summary>See Code for the "wms_ImageToKML.java" class here</summary>
|
|
|
See Code for the "wms_ImageToKML.java" class here
|
|
|
|
|
|
```java
|
|
|
|
... | ... | @@ -575,29 +538,22 @@ 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
|
|
|
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>
|
|
|
|
|
|
|
|
|
<details><summary>See the Code for the "tweets_download.java" Class</summary>
|
|
|
See the Code for the "tweets_download.java" Class
|
|
|
|
|
|
```java
|
|
|
package eot_Sahinovic_Woehs_Zorenboehmer;
|
... | ... | @@ -643,22 +599,17 @@ public class Tweets_download { |
|
|
} // 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
|
|
|
|
|
|
This step proved to be the most complex one. In the end we used two methods within the non-executable [tweets_polygons.java](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Final%20Version/Tweets_polygons.java) class. The first method dynamically determines a colour-code for the placemarks depending on the time of the tweet. The second method creates a kml file that contains 3D polygons for the point locations, with pop-up boxes, time-stamps, and a colour-coded visualisation of the time of the tweet.
|
|
|
This step proved to be the most complex one. In the end we used two methods within the non-executable [tweets_polygons.java](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Final%20Version/Tweets_polygons.java) class. The first method dynamically determines a colour-code for the placemarks depending on the time of the tweet. The second method creates a kml file that contains 3D polygons for the point locations, with pop-up boxes, time-stamps, and a colour-coded visualisation of the time of the tweet.
|
|
|
|
|
|
In the process of creating this class we had to deal with a few challenges:
|
|
|
|
... | ... | @@ -668,14 +619,13 @@ In the process of creating this class we had to deal with a few challenges: |
|
|
>
|
|
|
> tweets.csv time format: 2012-11-05 15:47:16+01
|
|
|
|
|
|
We therefore concluded that we needed to add in the "T" where the blank space is and add ":00" at the end.
|
|
|
|
|
|
**Creating Polygons from Points:** To solve this, we perfomed some simple math calculations on the lat and lng coordinates of the point locations. This required a few conversions of String to Double and then back into String, to insert the new coordinates into the kml body.
|
|
|
We therefore concluded that we needed to add in the "T" where the blank space is and add ":00" at the end. We split the content of “column\[6\]” of the String array, which is the “created_at” column by “ “ (a blank space) and inserted a “T” in its place, and added the ending “:00”.
|
|
|
|
|
|
**Colouring the Polygons according to the Time of Tweet:** ....
|
|
|
**Creating Polygons from Points:** To solve this, we perfomed some simple math calculations on the lat and lng coordinates of the point locations. This required a few conversions of String to Double and then back into String, to insert the new coordinates into the kml body.
|
|
|
|
|
|
**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.
|
|
|
|
|
|
<details><summary>See the Code for the tweets_polygons.java Class</summary>
|
|
|
See the Code for the tweets_polygons.java Class
|
|
|
|
|
|
```java
|
|
|
|
... | ... | @@ -857,28 +807,22 @@ public class Tweets_polygons { |
|
|
|
|
|
} // tweetsToPolygons()
|
|
|
} // class
|
|
|
```
|
|
|
|
|
|
```
|
|
|
|
|
|
</details>
|
|
|
|
|
|
<details><summary>See the Console Output</summary>
|
|
|
See the Console Output
|
|
|
|
|
|
```
|
|
|
```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.
|
|
|
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.
|
|
|
|
|
|
<details><summary>See the Code for the googleEarth_Tour.java Class</summary>
|
|
|
See the Code for the googleEarth_Tour.java Class
|
|
|
|
|
|
```java
|
|
|
package eot_Sahinovic_Woehs_Zorenboehmer;
|
... | ... | @@ -1079,24 +1023,20 @@ public class GoogleEarth_tour { |
|
|
|
|
|
} // createTour()
|
|
|
} // class
|
|
|
|
|
|
```
|
|
|
</details>
|
|
|
|
|
|
<details><summary>See the Console Output</summary>
|
|
|
See the Console Output
|
|
|
|
|
|
```
|
|
|
```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.
|
|
|
|
|
|
<details><summary>See the Code for the user_Input.java Class</summary>
|
|
|
See the Code for the user_Input.java Class
|
|
|
|
|
|
```java
|
|
|
|
... | ... | @@ -1179,32 +1119,25 @@ public class User_input { |
|
|
|
|
|
} // askUer2()
|
|
|
} // class
|
|
|
|
|
|
```
|
|
|
|
|
|
</details>
|
|
|
|
|
|
<details><summary>See the Concole Output</summary>
|
|
|
See the Concole Output
|
|
|
|
|
|
```
|
|
|
```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.
|
|
|
|
|
|
<details><summary>See the Code for the googleEarth_launch.java Class</summary>
|
|
|
See the Code for the googleEarth_launch.java Class
|
|
|
|
|
|
```java
|
|
|
```java
|
|
|
|
|
|
package eot_Sahinovic_Woehs_Zorenboehmer;
|
|
|
|
... | ... | @@ -1237,54 +1170,40 @@ public class GoogleEarth_launch { |
|
|
|
|
|
} //launchGoogleEarth()
|
|
|
} // class
|
|
|
|
|
|
```
|
|
|
|
|
|
</details>
|
|
|
|
|
|
<details><summary>See the Console Output</summary>
|
|
|
See the Console Output
|
|
|
|
|
|
```
|
|
|
```plaintext
|
|
|
Launching Google Earth...
|
|
|
Launch complete.
|
|
|
|
|
|
--- Step 6 completed. ---
|
|
|
|
|
|
```
|
|
|
</details>
|
|
|
|
|
|
<!-- blank line -->
|
|
|
<br>
|
|
|
<!-- blank line -->
|
|
|
|
|
|
## Video Demos!
|
|
|
|
|
|
(1) Programme interaction
|
|
|

|
|
|
|
|
|
[Programme](/s1080384/EoT/-/wikis/uploads/aa9d681078730f5eeeeda441304c1b78/Programme.mp4)
|
|
|
|
|
|
(2) Google Earth Tour
|
|
|

|
|
|
|
|
|
<!-- blank line -->
|
|
|
<br>
|
|
|
<!-- blank line -->
|
|
|
|
|
|
[Google_Earth_Tour](/s1080384/EoT/-/wikis/uploads/255bb09b1b316dc47ed6bc780562c923/Google_Earth_Tour.mp4)
|
|
|
|
|
|
## Further Information
|
|
|
|
|
|
For further information on this project, or to offer feedback, please don't hesitate to contact the authors/ creators:
|
|
|
|
|
|
> katharina.woehs@stud.sbg.ac.at
|
|
|
>
|
|
|
> edah.sahinovic@stud.sbg.ac.at
|
|
|
> [katharina.woehs@stud.sbg.ac.at](mailto:katharina.woehs@stud.sbg.ac.at)
|
|
|
>
|
|
|
> [edah.sahinovic@stud.sbg.ac.at](mailto:edah.sahinovic@stud.sbg.ac.at)
|
|
|
>
|
|
|
> christina.zorenboehmer@stud.sbg.ac.at
|
|
|
> [christina.zorenboehmer@stud.sbg.ac.at](mailto:christina.zorenboehmer@stud.sbg.ac.at)
|
|
|
|
|
|
This project was carried out in the context of a practical course at the University of Salzburg. For more information on the course visit:
|
|
|
|
|
|
This project was carried out in the context of a practical course at the University of Salzburg. For more information on the course visit:
|
|
|
<https://online.uni-salzburg.at/plus_online/wbLv.wbShowLVDetail?pStpSpNr=524338>
|
|
|
|
|
|
https://online.uni-salzburg.at/plus_online/wbLv.wbShowLVDetail?pStpSpNr=524338
|
|
|
<!-- blank line -->
|
|
|
<br>
|
|
|
<!-- blank line -->
|
|
|
 |
|
|
\
|
|
|
 |
|
|
\ No newline at end of file |