... | ... | @@ -155,9 +155,8 @@ static void askUser2() { |
|
|
|
|
|
|
|
|
|
|
|
## Conceptualisation
|
|
|
## Concept
|
|
|
|
|
|
### Concept
|
|
|
|
|
|
At the outset we began gathering ideas and drawing up concepts for our approach. We have visualised our concept below:
|
|
|
|
... | ... | @@ -226,7 +225,7 @@ public class GoogleEarthTweetMapper { |
|
|
|
|
|
</details>
|
|
|
|
|
|
## User Input
|
|
|
## 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.
|
|
|
|
... | ... | @@ -343,9 +342,7 @@ New directory set to: C:\Users\Christina\Documents\Test Folder |
|
|
</details>
|
|
|
|
|
|
|
|
|
## Web Map Service
|
|
|
|
|
|
### Connecting and Downloading WMS
|
|
|
## Connecting to WMS and Downloading Image
|
|
|
|
|
|
First, we created a [non-executable class "wms_GetMap"](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Previous%20Versions%20(working%20files)/Christina%2004_07_2021/wms_GetMap.java) that contains a method `getMap()` that:
|
|
|
> 1. creates a WebMapServer object
|
... | ... | @@ -489,7 +486,7 @@ The result is this image "boston.png": |
|
|
|
|
|

|
|
|
|
|
|
### Converting WMS Image into .KML
|
|
|
## Converting WMS Image into .KML
|
|
|
|
|
|
Here, we created a [non-executable class "wms_ImageToKML"](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Previous%20Versions%20(working%20files)/Christina%2004_07_2021/wms_ImageToKML.java) that contains a method `wmsTOkml()` that:
|
|
|
|
... | ... | @@ -584,9 +581,7 @@ Image converted to kml and stored at: C:\Users\Christina\Documents\Test Folder\b |
|
|
</details>
|
|
|
|
|
|
|
|
|
## Downloading and Converting Twitter.csv File
|
|
|
|
|
|
### Downloading
|
|
|
## 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 class "tweets_download"](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Previous%20Versions%20(working%20files)/Christina%2004_07_2021/tweets_download.java) that contains the methods `saveFileFromUrlWithCommonsIO()` and `downloadCSV()` that:
|
|
|
|
... | ... | @@ -652,7 +647,7 @@ CSV file downloaded and stored at :C:\Users\Christina\Documents\Test Folder\twee |
|
|
|
|
|
</details>
|
|
|
|
|
|
### Converting .csv into .kml
|
|
|
## Converting Tweets.csv into Tweets.kml
|
|
|
|
|
|
This step proved to be the most complex one. In the end we used two methods within the 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.
|
|
|
|
... | ... | @@ -661,7 +656,7 @@ In the process of creating this class we had to deal with a few challenges: |
|
|
**Time Stamp:** After some initial [research](https://developers.google.com/kml/documentation/kmlreference#timestamp) into typical kml-conform time stamps and comparing them to "created_at" column in the tweets.csv file, we chose to aim for a time stamp that was already mostly given in the .csv, but with a few differences:
|
|
|
|
|
|
> kml time stamp: 1997-07-16T10:30:15+03:00
|
|
|
|
|
|
>
|
|
|
> 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.
|
... | ... | @@ -1088,34 +1083,171 @@ KML Tour created and stored at C:\Users\Christina\Documents\Test Folder\A Little |
|
|
```
|
|
|
</details>
|
|
|
|
|
|
## User Input 2
|
|
|
|
|
|
## Launch Google Earth
|
|
|
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 user_Input.java class.
|
|
|
|
|
|
### 4.1: Ask User to Proceed and Launch
|
|
|
<details><summar>See the Code for the user_Input.java Class</summary>
|
|
|
|
|
|
In this final step, we merely used one [non-executable class "googleEarth_launch"](https://git.sbg.ac.at/s1080384/EoT/-/blob/main/Java%20Codes/Previous%20Versions%20(working%20files)/Christina%2004_07_2021/googleEarth_launch.java) with a method `launchGoogleEarth()` that:
|
|
|
```java
|
|
|
|
|
|
> - asks the user if they would like to proceed or else end the programme
|
|
|
> - launches google earth and opens the .kml files
|
|
|
package eot_Sahinovic_Woehs_Zorenboehmer;
|
|
|
|
|
|
Once again, we are keeping the user informed. The console will show the following:
|
|
|
import java.io.File;
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
<details><summary>See Console Output</summary>
|
|
|
public class User_input {
|
|
|
|
|
|
public static String directory;
|
|
|
|
|
|
static String askUser1() {
|
|
|
|
|
|
Scanner askUser = new Scanner(System.in); // warning coming from non-closed scanner. Note: if we close it, subsequent scanners fail to work.
|
|
|
String answer;
|
|
|
|
|
|
// welcome and information for user
|
|
|
System.out.println("Hello! Welcome to this Google Earth Tweet and WMS Mapper!\n\n"
|
|
|
+ "This programme will:\n"
|
|
|
+ "1: download an image of Boston from a WMS\n"
|
|
|
+ "2: convert it into a KML structure\n"
|
|
|
+ "3: download a tweets.csv file from the web\n"
|
|
|
+ "4: convert it into a KML structure\n"
|
|
|
+ "5: create a KML file for a tour in Google Earth\n"
|
|
|
+ "6: launch all kml files in Google Earth\n\n"
|
|
|
+ "By default, the downloaded files will be stored at: C:\\Users\\Public\\Documents"
|
|
|
+ "\nIf this is fine, please enter Y below and hit enter to continue! If not, enter anything else to set a new directory.");
|
|
|
|
|
|
answer = askUser.next();
|
|
|
String newDirectory = null;
|
|
|
|
|
|
// if yes, set directory to the default and return directory
|
|
|
if(answer.contains("Y") || answer.contains("y") || answer.contains("yes") || answer.contains("Yes")) {
|
|
|
System.out.println("Great! Lets get started!\n");
|
|
|
directory = "C:\\Users\\Public\\Documents";
|
|
|
return directory;
|
|
|
|
|
|
// else, allow user to enter directory and check if it exists. Otherwise keep asking for a valid directory.
|
|
|
} else {
|
|
|
System.out.println("Please enter a new directory below and hit enter: ");
|
|
|
Scanner askNewDirectory = new Scanner(System.in);
|
|
|
boolean exists = false; // by default, exists is set to "false"
|
|
|
while (exists != true) { // while-loop keeps asking for user input until exists is set to "true"
|
|
|
newDirectory = askNewDirectory.nextLine(); // use .nextLine() to make sure path-files with a space are read
|
|
|
File tempDir = new File(newDirectory);
|
|
|
boolean exists2 = tempDir.exists(); // check if entered directory exists
|
|
|
if (exists2 == true) { // if directory exists, set exists2 to "true"
|
|
|
exists = true; // if exists2 is "true", exists becomes "true" to exit the while loop
|
|
|
directory = newDirectory;
|
|
|
System.out.println("\nNew directory set to: " + directory + "\n");
|
|
|
} else {
|
|
|
System.out.println("\nWrong file path. Please try again.");
|
|
|
}
|
|
|
}
|
|
|
return directory;
|
|
|
}
|
|
|
} // askUser1()
|
|
|
|
|
|
|
|
|
static void askUser2() {
|
|
|
|
|
|
// ask user to proceed with google earth launch
|
|
|
Scanner askContinue = new Scanner(System.in);
|
|
|
String answer1;
|
|
|
|
|
|
System.out.println("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.\n"
|
|
|
+ "Would you like to proceed to launch Google Earth now? Type Y for yes or anything else for no and hit enter.");
|
|
|
|
|
|
answer1 = askContinue.next();
|
|
|
askContinue.close();
|
|
|
|
|
|
// if yes, proceed with programme execution. Else, exit programme.
|
|
|
if(answer1.contains("Y") || answer1.contains("y") || answer1.contains("yes") || answer1.contains("Yes")) {
|
|
|
System.out.println("Proceeding... ");
|
|
|
} else {
|
|
|
System.out.println("We've ended the programme for you. If you'd like to try again, run the programme again. :)"); // Inform
|
|
|
System.exit(0);
|
|
|
}
|
|
|
|
|
|
} // askUer2()
|
|
|
} // class
|
|
|
|
|
|
```
|
|
|
|
|
|
</details>
|
|
|
|
|
|
<details><summary>See the Concole Output</summary>
|
|
|
|
|
|
```
|
|
|
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/Previous%20Versions%20(working%20files)/Christina%2004_07_2021/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>
|
|
|
|
|
|
```java
|
|
|
|
|
|
package eot_Sahinovic_Woehs_Zorenboehmer;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
public class GoogleEarth_launch {
|
|
|
|
|
|
static void launchGoogleEarth() {
|
|
|
|
|
|
System.out.println("Launching Google Earth... "); // Inform
|
|
|
|
|
|
String command = GoogleEarthTweetMapper.google_earth_filepath;
|
|
|
String wms_kml = GoogleEarthTweetMapper.wms_kml;
|
|
|
String twitter_kml = GoogleEarthTweetMapper.twitter_kml;
|
|
|
String tour_kml = GoogleEarthTweetMapper.tour_kml;
|
|
|
|
|
|
// open googleearth.exe, both KML files, and the tour
|
|
|
try {
|
|
|
Runtime.getRuntime().exec(new String[] {
|
|
|
command,
|
|
|
wms_kml,
|
|
|
twitter_kml,
|
|
|
tour_kml
|
|
|
});
|
|
|
}
|
|
|
catch (IOException e2) {
|
|
|
e2.printStackTrace();
|
|
|
}
|
|
|
System.out.println("Launch complete.\n"); // Inform
|
|
|
|
|
|
} //launchGoogleEarth()
|
|
|
} // class
|
|
|
|
|
|
```
|
|
|
|
|
|
</details>
|
|
|
|
|
|
<details><summary>See the Console Output</summary>
|
|
|
|
|
|
```
|
|
|
Launching Google Earth...
|
|
|
Launch complete.
|
|
|
|
|
|
Step 5 completed.
|
|
|
--- Step 6 completed. ---
|
|
|
|
|
|
```
|
|
|
</details>
|
|
|
|
|
|
### Video Demos!
|
|
|
|
|
|
## Video Demos!
|
|
|
|
|
|
(1) Programme interaction
|
|
|

|
... | ... | |