distance: Fix calculation of disntance
This commit is contained in:
11
classes.py
11
classes.py
@@ -75,11 +75,12 @@ class Location:
|
|||||||
Seitenkosinussatz
|
Seitenkosinussatz
|
||||||
"""
|
"""
|
||||||
rErde = 6378.388
|
rErde = 6378.388
|
||||||
lat1 = float(self.coord.lat)
|
lat1 = math.radians(float(self.coord.lat))
|
||||||
long1 = float(self.coord.long)
|
long1 = math.radians(float(self.coord.long))
|
||||||
lat2 = float(loc2.coord.lat)
|
lat2 = math.radians(float(loc2.coord.lat))
|
||||||
long2 = float(loc2.coord.long)
|
long2 = math.radians(float(loc2.coord.long))
|
||||||
inner = math.sin(lat1) * math.sin(lat2) + math.cos(lat1) * math.cos(lat2) * math.cos(long2 - long1)
|
inner = math.sin(lat1) * math.sin(lat2) + \
|
||||||
|
math.cos(lat1) * math.cos(lat2) * math.cos(long2 - long1)
|
||||||
return rErde * math.acos(inner)
|
return rErde * math.acos(inner)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
file.txt
2
file.txt
@@ -1,7 +1,7 @@
|
|||||||
Locations:
|
Locations:
|
||||||
csu_zen ; Location; 48.176971; 11.5895754; 1; CSU-Zentrale
|
csu_zen ; Location; 48.176971; 11.5895754; 1; CSU-Zentrale
|
||||||
mun_hbf ; PublicTransportStop; 48.140235; 11.559417; 1; Muenchen Hbf.
|
mun_hbf ; PublicTransportStop; 48.140235; 11.559417; 1; Muenchen Hbf.
|
||||||
mun_flugh; Airport; 48.140235; 11.770723; 1; Muenchen Flughafen
|
mun_flugh; Airport; 48.35333; 11.770723; 1; Muenchen Flughafen
|
||||||
reichstag; Location; 52.518191; 13.3751725; 1; Reichstags Gebaeude
|
reichstag; Location; 52.518191; 13.3751725; 1; Reichstags Gebaeude
|
||||||
ber_flugh; Airport; 52.553625; 13.2901544; 1; Berlin Flughafen Tegel
|
ber_flugh; Airport; 52.553625; 13.2901544; 1; Berlin Flughafen Tegel
|
||||||
ber_hbf ; PublicTransportStop; 52.524195; 13.3693013; 1; Berlin Hbf
|
ber_hbf ; PublicTransportStop; 52.524195; 13.3693013; 1; Berlin Hbf
|
||||||
|
|||||||
2
graph.py
2
graph.py
@@ -15,7 +15,7 @@ def calc_co2(distance: float, kind: TransportKind) -> float:
|
|||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
# TODO: CITY == AUTOBAHN
|
# TODO: CITY == AUTOBAHN
|
||||||
return distance * TransportMethod.CITY.value.co2
|
return (distance - 1) * TransportMethod.CITY.value.co2
|
||||||
case TransportKind.TRAIN:
|
case TransportKind.TRAIN:
|
||||||
# TODO: OPENV == ICE
|
# TODO: OPENV == ICE
|
||||||
return distance * TransportMethod.ICE.value.co2
|
return distance * TransportMethod.ICE.value.co2
|
||||||
|
|||||||
Reference in New Issue
Block a user