System.out.println("Accessing WMS and downloading .png of Boston to local directory at: " + wms_png + "... ");
// Constructing a WebMapServer object:
URL url = null;
try {
System.out.println("Testing Heigit's wms service URL... ");
url = new URL(wms_url);
System.out.println("URL vaid.");
} catch (MalformedURLException e) {
System.out.println("Error related to URL.");
}
WebMapServer wms = null;
try {
wms = new WebMapServer(url);
} catch (IOException e) {
System.out.println("There was an error communicating with the server, e.g. the server is down.");
} catch (ServiceException e) {
System.out.println("The server returned a ServiceException (unusual in this case).");
}
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.
// 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;
Scanner askServiceInfo = new Scanner(System.in); //warning coming from non-closed scanner
String answer;
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("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");