entfernungsberechnung
parent
0a4faef3d2
commit
4c96ee8075
|
@ -1,5 +1,30 @@
|
||||||
package domain;
|
package domain;
|
||||||
|
|
||||||
|
import java.lang.Math;
|
||||||
public class Reiseplanung {
|
public class Reiseplanung {
|
||||||
|
|
||||||
|
private Ort standort;
|
||||||
|
private Ort zielort;
|
||||||
|
private double entfernung;
|
||||||
|
private double dauerPKW;
|
||||||
|
private double dauerFahrrad;
|
||||||
|
private double co2AusstoßPKW;
|
||||||
|
|
||||||
|
public Reiseplanung(Ort zielort) {
|
||||||
|
this.standort = standort;
|
||||||
|
this.zielort = zielort;
|
||||||
|
this.entfernung = entfernung;
|
||||||
|
this.dauerPKW = dauerPKW;
|
||||||
|
this.dauerFahrrad = dauerFahrrad;
|
||||||
|
this.co2AusstoßPKW =co2AusstoßPKW;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double berechneEntfernung(Ort standort, Ort zielort) {
|
||||||
|
double b1 = Math.toRadians(standort.getBreitengrad());
|
||||||
|
double b2 = Math.toRadians(zielort.getBreitengrad());
|
||||||
|
double l1 = Math.toRadians(standort.getLängengrad());
|
||||||
|
double l2 = Math.toRadians(zielort.getLängengrad());
|
||||||
|
|
||||||
|
return 6378.388 * Math.acos(Math.sin(b1) * Math.sin(b2) + Math.cos(b1) * Math.cos(b2) * Math.cos(l2 - l1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue