+ public double getLng() {
+ return lng;
+ }
+
+ public void setFlag(String flag) {
+ this.flag = flag;
+ }
+
+ public String getFlag() {
+ return flag;
+ }
+
+ public int distanceTo(Country country) {
+ if ((this.getLat() == country.getLat()) && (this.getLng() == country.getLng())) {
+ return 0;
+ } else {
+ double theta = this.getLng() - country.getLng();
+ Double dist = Math.sin(Math.toRadians(this.getLat())) * Math.sin(Math.toRadians(country.getLat())) + Math.cos(Math.toRadians(this.getLat())) * Math.cos(Math.toRadians(country.getLat())) * Math.cos(Math.toRadians(theta));
+ dist = Math.acos(dist);
+ dist = Math.toDegrees(dist);
+ dist = dist * 60 * 1.1515;
+ // Kilometers
+ dist = dist * 1.609344;
+ return dist.intValue();
+ }
+ }
+
+ private void initCountryFromCSV(String name) {
+ Scanner scanner = null;
+ try {
+ scanner = new Scanner(new File(csvFile));
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ while (scanner.hasNext()) {
+ List<String> line = CSVUtils.parseLine(scanner.nextLine());
+ String countryList = line.get(0);
+ String[] countryArray = countryList.split(",");
+ String latLng = line.get(16);
+ String[] latLngArray = latLng.split(",");
+ if (countryArray[1].equals(name)) {
+ setRegion(line.get(12));
+ setLat(Double.parseDouble(latLngArray[0]));
+ setLng(Double.parseDouble(latLngArray[1]));
+ }
+ }
+ scanner.close();
+ }
+