Skip to content
Snippets Groups Projects
Commit bc95bbbe authored by Maeva Pourpoint's avatar Maeva Pourpoint
Browse files

Move if statement in convert_coordinate() to avoid unnecessary division operation

parent 5e8cfbe4
No related branches found
No related tags found
1 merge request!3Util functions
......@@ -101,16 +101,16 @@ def check_serial_number(serial_number: str, equipment: str) -> bool:
def convert_coordinate(coordinate, hemisphere):
"""Convert coordinates outputted by LEMI to decimal degrees."""
if hemisphere not in ['N', 'S', 'E', 'W']:
logger.error("Unexpected hemisphere - {} - listed in data file!"
.format(hemisphere))
return None
try:
coordinate = float(coordinate) / 100
except ValueError:
logger.error("Failed to convert geographic coordinate - {} - to "
"decimal degrees!".format(coordinate))
return None
if hemisphere not in ['N', 'S', 'E', 'W']:
logger.error("Unexpected hemisphere - {} - listed in data file!"
.format(hemisphere))
return None
return -coordinate if hemisphere in ["S", "W"] else coordinate
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment