-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved dms_to_float conversion function to utils lib
- Loading branch information
1 parent
7b9b2a6
commit dcc7690
Showing
2 changed files
with
23 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,22 @@ | ||
def to_float(value): | ||
return float(value) if value is not None else None | ||
|
||
|
||
def dms_to_float(dms_value: str): | ||
""" | ||
Convert Degrees, Minutes, Seconds coordinate to float value | ||
:param dms_value: str Coordinate value sexpressed in Degrees, Minutes, Seconds | ||
:return: float Coordinate value converted to float | ||
""" | ||
dms_value = dms_value.strip() | ||
degrees, rest = dms_value.split("°") | ||
minutes, rest = rest.split("'") | ||
seconds, direction = rest.split('" ') | ||
degrees = float(degrees) | ||
minutes = float(minutes) | ||
seconds = float(seconds) | ||
float_value = degrees + minutes / 60 + seconds / 3600 | ||
if direction in ["S", "W"]: | ||
float_value = -float_value | ||
return float_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters