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.
...
...
@@ -120,17 +120,16 @@ As stated above, we aimed to make the whole programme run smoothly without the u
```java
packageTest2;
packageeot_Sahinovic_Woehs_Zorenboehmer;
publicclassexecute_programme{
publicclassGoogleEarthTweetMapper{
publicstaticStringdirectory="C:\\Users\\Christina\\Documents\\EoT";//ADAPT NAME
// public static String directory = setDirectories.directory;
publicstaticStringgoogle_earth_filepath="C:\\Program Files\\Google\\Google Earth Pro\\client\\googleearth.exe";// ADAPT to where Google Earth is
@@ -171,6 +172,66 @@ public class execute_programme {
</details>
## Step 1: Inform User, Ask for Permission to Store Files Locally
In this first step we ask the user to give us the "thumbs up" for downloading the required files onto their PC. We specify the location, which is set to "C:/Users/Public/Documents", which is a default file path that can apply to any PC.
<details><summary> See the Code for the "userInput1.java class here</summary>
```java
packageeot_Sahinovic_Woehs_Zorenboehmer;
importjava.util.Scanner;
publicclassuserInput1{
Stringdirectory=GoogleEarthTweetMapper.directory;
staticvoidaskUser(){
ScanneraskUser=newScanner(System.in);// warning coming from non-closed scanner. Note: if we close it, subsequent scanners fail to work.
Stringanswer;
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: launch both kml files in Google Earth\n\n"
+"The downloaded files will be stored at C:\\Users\\Public\\Documents\n"
+"If this is fine, please enter Y below and hit enter to continue! If not, we will stop the programme and you can manually change the directory at the very top of this class's code.");
@@ -187,8 +248,7 @@ First, we created a [non-executable class "wms_GetMap"](https://git.sbg.ac.at/s1
<details><summary> See the Code for the "wms_GetMap.java" class here</summary>
```java
packageTest2;
packageeot_Sahinovic_Woehs_Zorenboehmer;
importjava.awt.image.BufferedImage;
importjava.io.File;
...
...
@@ -209,22 +269,19 @@ public class wms_GetMap {
staticvoidgetMap(){
Stringwms_url=execute_programme.wms_url;
Stringdirectory=execute_programme.directory;
Stringwms_png=execute_programme.wms_png;
System.out.println("Accessing WMS and downloading .png of Boston to local directory at: "+wms_png+"... ");
// Constructing a WebMapServer object:
Stringwms_url=GoogleEarthTweetMapper.wms_url;
Stringwms_png=GoogleEarthTweetMapper.wms_png;
// Check if WMS URL is valid
URLurl=null;
try{
System.out.println("Testing Heigit's wms service URL... ");
System.out.print("Testing Heigit's wms service URL... ");
url=newURL(wms_url);
System.out.println("URL vaid.");
}catch(MalformedURLExceptione){
System.out.println("Error related to URL.");
}
}
// Construct WMS object
WebMapServerwms=null;
try{
wms=newWebMapServer(url);
...
...
@@ -235,17 +292,17 @@ public class wms_GetMap {
}
System.out.println("No errors in communicating with the server.");
// You can retrieve a WMSCapabilities directly from your WebMapService. This capabilities bean is split into three sections: Service, Request, and Layer.
// Access WMSCapabilities directly from the WMS. This capabilities bean is split into three sections: Service, Request, and Layer.
// Get Map Request: ask the client to create a GetMapRequest object. MAKE SURE TO IMPORT THE CORRECT GETMAPREQUEST: import org.geotools.ows.wms.request.GetMapRequest;
// Get Map Request: ask client to create a GetMapRequest object
GetMapRequestrequest=wms.createGetMapRequest();
// Configure the request object:
// Configure the request object
request.addLayer("osm_auto:all","default");
request.setFormat("image/png");
request.setDimensions("1000","1000");
...
...
@@ -254,39 +311,37 @@ public class wms_GetMap {
request.setVersion("1.1.1");
request.setBBox("-71.13,42.32,-71.03,42.42");
ScanneraskServiceInfo=newScanner(System.in);//warning coming from non-closed scanner
// user interaction: offer additional information
ScanneraskServiceInfo=newScanner(System.in);//warning coming from non-closed scanner. Note: if scanner is closed subsequent scanners fail to work.
Stringanswer;
System.out.println("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.");
System.out.println("\nWould you like additional information on the WMS service while the programme runs? Type Y for yes or anything else for no and hit enter.");
System.out.println("The WMS capabilities are being retreived from a server called: "+serverName+"\nAnd the server's title is :"+serverTitle+".\n\n"+
"The requested image will be stored as a .png with dimensions of 1000 x 1000 pixels."+
"The coordinate reference system is set to ESPG:4326");
System.out.println("\tThe WMS capabilities are being retreived from a server called: "+serverName+"\n\tAnd the server's title is: "+serverTitle+"\n\t"+
"The requested image will be stored as a .png with dimensions of 1000 x 1000 pixels.\n\t"+
"The coordinate reference system is set to ESPG:4326.");