mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
refactor: Move constants outside of variable scope (#7262)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com> Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
from math import asin, atan, cos, radians, sin, sqrt, tan
|
||||
|
||||
AXIS_A = 6378137.0
|
||||
AXIS_B = 6356752.314245
|
||||
RADIUS = 6378137
|
||||
|
||||
|
||||
def haversine_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> float:
|
||||
"""
|
||||
@ -30,9 +34,6 @@ def haversine_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> fl
|
||||
"""
|
||||
# CONSTANTS per WGS84 https://en.wikipedia.org/wiki/World_Geodetic_System
|
||||
# Distance in metres(m)
|
||||
AXIS_A = 6378137.0 # noqa: N806
|
||||
AXIS_B = 6356752.314245 # noqa: N806
|
||||
RADIUS = 6378137 # noqa: N806
|
||||
# Equation parameters
|
||||
# Equation https://en.wikipedia.org/wiki/Haversine_formula#Formulation
|
||||
flattening = (AXIS_A - AXIS_B) / AXIS_A
|
||||
|
@ -2,6 +2,10 @@ from math import atan, cos, radians, sin, tan
|
||||
|
||||
from .haversine_distance import haversine_distance
|
||||
|
||||
AXIS_A = 6378137.0
|
||||
AXIS_B = 6356752.314245
|
||||
EQUATORIAL_RADIUS = 6378137
|
||||
|
||||
|
||||
def lamberts_ellipsoidal_distance(
|
||||
lat1: float, lon1: float, lat2: float, lon2: float
|
||||
@ -45,10 +49,6 @@ def lamberts_ellipsoidal_distance(
|
||||
|
||||
# CONSTANTS per WGS84 https://en.wikipedia.org/wiki/World_Geodetic_System
|
||||
# Distance in metres(m)
|
||||
AXIS_A = 6378137.0 # noqa: N806
|
||||
AXIS_B = 6356752.314245 # noqa: N806
|
||||
EQUATORIAL_RADIUS = 6378137 # noqa: N806
|
||||
|
||||
# Equation Parameters
|
||||
# https://en.wikipedia.org/wiki/Geographical_distance#Lambert's_formula_for_long_lines
|
||||
flattening = (AXIS_A - AXIS_B) / AXIS_A
|
||||
|
Reference in New Issue
Block a user