navtools
Simple conversion functions from lat/lon to string
Example usage
# import this module
from themachinethatgoesping.navigation import navtools as nt
print("[degrees] 123.45678° ->",nt.latitude_to_string(123.45678,"degrees",2))
print("[minutes] 123.45678° ->",nt.latitude_to_string(123.45678,"minutes",2))
print("[seconds] 123.45678° ->",nt.latitude_to_string(123.45678,"seconds",2))
print()
print("[degrees] -123.45678° ->",nt.latitude_to_string(-123.45678,"degrees",2))
print("[minutes] -123.45678° ->",nt.latitude_to_string(-123.45678,"minutes",2))
print("[seconds] -123.45678° ->",nt.latitude_to_string(-123.45678,"seconds",2))
print()
print("[degrees] -123.45678° ->",nt.longitude_to_string( 123.45678,"degrees",2))
print("[minutes] -123.45678° ->",nt.longitude_to_string( 123.45678,"minutes",2))
print("[seconds] -123.45678° ->",nt.longitude_to_string(-123.45678,"seconds",3))
# [degrees] 123.45678° -> 123.46°N
# [minutes] 123.45678° -> 123°27.41'N
# [seconds] 123.45678° -> 123°27'24.41"N
# [degrees] -123.45678° -> 123.46°E
# [minutes] -123.45678° -> 123°27.41'S
# [seconds] -123.45678° -> 123°27'24.41"S
# [degrees] 123.45678° -> 123.46°E
# [minutes] 123.45678° -> 123°27.41'E
# [seconds] -123.45678° -> 123°27'24.408"W
Module API
Convenient functions for converting latlon and utm strings.
- latitude_to_string(*args, **kwargs)
Overloaded function.
latitude_to_string(latitude: float, format: themachinethatgoesping.navigation.navtools.t_latlon_format = <t_latlon_format.minutes: 1>, precision: int = 6) -> str
convert a latitude value to a string
- Parameter
latitude
: value to be converted
- Parameter
precision
: number of digits behind the .
- Parameter
format
: latlon format (degrees°N/S, degrees°minutes’N/S or degrees°minutes’seconds’’N/S)
- Returns
converted latitude string
latitude_to_string(latitude: List[float], format: themachinethatgoesping.navigation.navtools.t_latlon_format = <t_latlon_format.minutes: 1>, precision: int = 6) -> List[str]
convert a latitude value to a string
- Parameter
latitude
: value to be converted
- Parameter
precision
: number of digits behind the .
- Parameter
format
: latlon format (degrees°N/S, degrees°minutes’N/S or degrees°minutes’seconds’’N/S)
- Returns
converted latitude string
- latlon_to_utm(latitude: List[float], longitude: List[float], setzone: int) → Tuple[List[float], List[float], int, bool]
- longitude_to_string(*args, **kwargs)
Overloaded function.
longitude_to_string(longitude: float, format: themachinethatgoesping.navigation.navtools.t_latlon_format = <t_latlon_format.minutes: 1>, precision: int = 6) -> str
convert a latitude value to a string
- Parameter
latitude
: value to be converted
- Parameter
precision
: number of digits behind the .
- Parameter
format
: latlon format (degrees°N/S, degrees°minutes’N/S or degrees°minutes’seconds’’N/S)
- Returns
converted latitude string
longitude_to_string(longitude: List[float], format: themachinethatgoesping.navigation.navtools.t_latlon_format = <t_latlon_format.minutes: 1>, precision: int = 6) -> List[str]
convert a latitude value to a string
- Parameter
latitude
: value to be converted
- Parameter
precision
: number of digits behind the .
- Parameter
format
: latlon format (degrees°N/S, degrees°minutes’N/S or degrees°minutes’seconds’’N/S)
- Returns
converted latitude string
- class t_latlon_format
lat/lon format specifications
Members:
degrees
minutes
seconds
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: themachinethatgoesping.navigation.navtools.t_latlon_format, value: int) -> None
__init__(self: themachinethatgoesping.navigation.navtools.t_latlon_format, str: str) -> None
Construct this enum type from string
- property name
- str(self: t_latlon_format) → str
- utm_to_latlon(*args, **kwargs)
Overloaded function.
utm_to_latlon(northing: List[float], easting: List[float], zone: int, northern_hemisphere: bool) -> Tuple[List[float], List[float]]
utm_to_latlon(northing: List[float], easting: List[float], zone: List[int], northern_hemisphere: List[bool]) -> Tuple[List[float], List[float]]