From 39cfdc4d438d8e0b3ae522c9749a138d3eb5789e Mon Sep 17 00:00:00 2001 From: Selim Eser <2211482@stud.hs-mannheim.de> Date: Sun, 9 Jun 2024 17:01:39 +0200 Subject: [PATCH] Fixed second if statement and corrected return formula --- src/main/java/de/hs_mannheim/domain/System.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/hs_mannheim/domain/System.java b/src/main/java/de/hs_mannheim/domain/System.java index ae22776..5d8c180 100644 --- a/src/main/java/de/hs_mannheim/domain/System.java +++ b/src/main/java/de/hs_mannheim/domain/System.java @@ -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){