distance: Fix calculation of disntance

This commit is contained in:
Marco Thomas
2022-07-27 14:48:58 +02:00
parent d6a8689175
commit 57d977d4e6
3 changed files with 8 additions and 7 deletions

View File

@@ -75,11 +75,12 @@ class Location:
Seitenkosinussatz
"""
rErde = 6378.388
lat1 = float(self.coord.lat)
long1 = float(self.coord.long)
lat2 = float(loc2.coord.lat)
long2 = float(loc2.coord.long)
inner = math.sin(lat1) * math.sin(lat2) + math.cos(lat1) * math.cos(lat2) * math.cos(long2 - long1)
lat1 = math.radians(float(self.coord.lat))
long1 = math.radians(float(self.coord.long))
lat2 = math.radians(float(loc2.coord.lat))
long2 = math.radians(float(loc2.coord.long))
inner = math.sin(lat1) * math.sin(lat2) + \
math.cos(lat1) * math.cos(lat2) * math.cos(long2 - long1)
return rErde * math.acos(inner)

View File

@@ -1,7 +1,7 @@
Locations:
csu_zen ; Location; 48.176971; 11.5895754; 1; CSU-Zentrale
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
ber_flugh; Airport; 52.553625; 13.2901544; 1; Berlin Flughafen Tegel
ber_hbf ; PublicTransportStop; 52.524195; 13.3693013; 1; Berlin Hbf

View File

@@ -15,7 +15,7 @@ def calc_co2(distance: float, kind: TransportKind) -> float:
return 0
else:
# TODO: CITY == AUTOBAHN
return distance * TransportMethod.CITY.value.co2
return (distance - 1) * TransportMethod.CITY.value.co2
case TransportKind.TRAIN:
# TODO: OPENV == ICE
return distance * TransportMethod.ICE.value.co2