Fixed second if statement and corrected return formula

distance_method
Selim Eser 2024-06-09 17:01:39 +02:00
parent 14f8c38a70
commit 39cfdc4d43
1 changed files with 4 additions and 3 deletions

View File

@ -226,14 +226,15 @@ public class System {
lat2 = Double.parseDouble(line.split(";")[3]);
}
if(line.split(";")[0].equals(current_user.getZip())){
if(line.split(";")[0].equals(""+current_user.getZip())){
lon1 = Double.parseDouble(line.split(";")[2]);
lat1 = Double.parseDouble(line.split(";")[3]);
}
}
} catch (Exception e) {}
return "" + 6378.388 * Math.acos(Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1));
return "" + (Math.acos(Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1)) * 111.324) + " km";
}
public String[] travel_time(String destination_zip){