Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Address { private String streetNumber; private String streetName; private String streetType; private String streetOrientation; private String cityName; private String province; private String postCode;

public class Address { private String streetNumber; private String streetName; private String streetType; private String streetOrientation; private String cityName; private String province; private String postCode; public void setStreetNumber(String streetNumber) { if(streetNumber.contains("-")) this.streetNumber = streetNumber.split("-")[1]; else this.streetNumber = streetNumber; } public String getStreetNumber() { return streetNumber; } public void setStreetName(String streetName) { this.streetName = streetName; } public String getStreetName() { return streetName; } public void setStreetType(String streetType) { this.streetType = streetType; } public String getStreetType() { return streetType; } public void setStreetOrientation(String streetOrientation) { if (streetOrientation != null && streetOrientation.length() != 0) { this.streetOrientation = streetOrientation.substring(0, 1); } else { this.streetOrientation = ""; } } public String getStreetOrientation() { return streetOrientation; } public void setCityName(String cityName) { this.cityName = cityName; } public String getCityName() { return cityName; } public void setProvince(String province) { this.province = province; } public String getProvince() { return province; } public void setPostalCode(String postCode) { this.postCode = postCode; } public String getPostalCode() { return postCode; } }

 public class Person { private String firstName; private String lastName; private String spouseFirstName; private String spouseLastName; public void setFirstName(String firstName) { this.firstName = firstName; } public String getFirstName() { return firstName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getLastName() { return lastName; } public void setSpouseFirstName(String spouseFirstName) { if(spouseFirstName == null) { this.spouseFirstName = ""; } else { this.spouseFirstName = spouseFirstName; } } public String getSpouseFirstName() { return spouseFirstName; } public void setSpouseLastName(String spouseLastName) { if(spouseLastName == null){ this.spouseLastName = ""; } else { this.spouseLastName = spouseLastName; } } public String getSpouseLastName() { return spouseLastName; } }

package assignment.one; import java.io.IOException; import java.lang.IllegalStateException; import java.nio.file.Paths; import java.util.NoSuchElementException; import java.util.Scanner; import java.util.Formatter; public class PlotMyAddress { public static void main(String... args) { Person person = new Person(); Address address = new Address(); Scanner input = null; Formatter output = null; String[] records = null; String[] names = null; String[] streetInfo = null; String[] cityProv = null; String nextLine; try { input = new Scanner(Paths.get("C:\\CST8284\\input\\InputAddresses.txt")); output = new Formatter("C:\\CST8284\\input\\OutputAddresses.csv"); while(input.hasNext()) { nextLine = input.nextLine(); while (nextLine != null) { records = new String[4]; for (int i = 0; i 

image text in transcribed

Challenge At this point, you know by now how to construct the Google Maps Geocoding API request (Hybrid Activity 2) and you have produced a file that has a list of full records that you can process. It is time to put them together. You need to read the file generated through Assignment 1 (C:\CST8284loutputlOutputAddresses.csv), split every record on the comma, and use every field to build the URL request. In order to build your URL request, I want you to make use of classes from java.net package, like URL, HttpURLConnection, URLEnconder and any other one you find necessary. Based on topics covered in chapter 16, please feel free to use your collection of choice. We will keep the assumption for now that there should not be any names collision; i.e. no two distinct addresses with the same set of first and last names. Once you perform your requests on each address, you should receive the Latitude/Longitude (Lat/Long) set as part of the results returned. In order to figure out how to convert the results into a JSON object, you need to complete Hybrid Activity 3 which covers this part. Once you have extracted the Lat/Long set, you would need to create a csv file called LatLong.csv, located at C:\CST82841output, and save the following header and set of records in it Latitude,Longitude,Name,lcon,lconScale,lconAltitude and*,111,1,1 and* and*,111,1,1 and*

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

Students also viewed these Databases questions

Question

Understand why customers complain.

Answered: 1 week ago