title: Variable already define in scope?
body: <p>Hi I am having issues implementing a method I made to calculate distance in Java using the Haversine formula. </p>
  
  <p>The section that I am trying to implement it in is:</p>
  
  <pre><code>            if(gps.canGetLocation()){
  
                  double latitude1 = gps.getLatitude();
                  double longitude1 = gps.getLongitude();
  
                  double atrium_longitude = -122.6078622;
                  double atrium_latitude = 49.170241;
  
                  //double latitude = 49.1702665;
                  //double longitude = -122.6078454;
                  String atriumString = "Atrium";
                  double distanceMeters = (latitude1, longitude1, atrium_latitude, atrium_longitude, atriumString);
  
                  TextView distanceToText;
                  distanceToText = (TextView) findViewById(R.id.distanceTo);
  
                  distanceToText.setText("" + distanceMeters);
                  // \n is for new line
                  Toast.makeText(getApplicationContext(), "Your Location is - \nLat: " + latitude1 + "\nLong: " + longitude1 + "\n", Toast.LENGTH_LONG).show();
              }else{
                  // can't get location
                  // GPS or Network is not enabled
                  // Ask user to enable GPS/network in settings
                  gps.showSettingsAlert();
              }
  </code></pre>
  
  <p>And the Haversine method is:</p>
  
  <pre><code>public static double calculateDistance(double latitude1, double longitude1, double latitude2, double longitude2, String buildingName) {
      double toRad = (Math.PI/180);
  //double latitude = gps.getLatitude();
  //double longitude = gps.getLongitude();
  
  //double latitude = 49.1702665;
  //double longitude = -122.6078454;
  
  double radius = 6371000;
  double lat1 = latitude1 * toRad;
  double lon1 = longitude1 * toRad;
  
  double lat2 = latitude2 * toRad;
  double lon2 = longitude2 * toRad;
  
  double deltaLat = (latitude2 - latitude1) * toRad;
  double deltaLon = (longitude2 - longitude1) * toRad;
  
  double aHaversine = Math.sin(deltaLat/2) * Math.sin(deltaLat/2) +
          Math.cos(lat1) * Math.cos(lat2) *
                  Math.sin(deltaLon/2) * Math.sin(deltaLon/2);
  
  double cHaversine = 2 * Math.atan2(Math.sqrt(aHaversine), Math.sqrt(1-aHaversine));
  
  double distanceHaversine = radius * cHaversine;
  
  return distanceHaversine;
  </code></pre>
  
  <p>}</p>
  
  <p>I believe that I made the method correctly but I may be wrong as I am just an amateur programming in my first year at University. Also, if there is a more efficient way of implementing this formula, please by all means let me know.</p>