Skip to content

Commit 033c642

Browse files
committed
Fix code smells
1 parent 87f7687 commit 033c642

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

src/python_opensky/opensky.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -232,28 +232,28 @@ def calculate_point(
232232
"""Calculate a point from an origin point, direction in degrees and distance."""
233233
# ruff: noqa: N806
234234
# pylint: disable=invalid-name
235-
piD4 = math.atan(1.0)
236-
two_pi = piD4 * 8.0
237-
latitude = latitude * piD4 / 45.0
238-
longitude = longitude * piD4 / 45.0
239-
degrees = degrees * piD4 / 45.0
235+
pi_d4 = math.atan(1.0)
236+
two_pi = pi_d4 * 8.0
237+
latitude = latitude * pi_d4 / 45.0
238+
longitude = longitude * pi_d4 / 45.0
239+
degrees = degrees * pi_d4 / 45.0
240240
if degrees < 0.0:
241241
degrees = degrees + two_pi
242242
if degrees > two_pi:
243243
degrees = degrees - two_pi
244-
AXIS_A = 6378137
245-
FLATTENING = 1 / 298.257223563
246-
AXIS_B = AXIS_A * (1.0 - FLATTENING)
247-
TanU1 = (1 - FLATTENING) * math.tan(latitude)
248-
U1 = math.atan(TanU1)
249-
sigma1 = math.atan2(TanU1, math.cos(degrees))
250-
Sinalpha = math.cos(U1) * math.sin(degrees)
251-
cosalpha_sq = 1.0 - Sinalpha * Sinalpha
252-
u2 = cosalpha_sq * (AXIS_A * AXIS_A - AXIS_B * AXIS_B) / (AXIS_B * AXIS_B)
244+
axis_a = 6378137
245+
flattening = 1 / 298.257223563
246+
axis_b = axis_a * (1.0 - flattening)
247+
tan_u1 = (1 - flattening) * math.tan(latitude)
248+
u1 = math.atan(tan_u1)
249+
sigma1 = math.atan2(tan_u1, math.cos(degrees))
250+
sinalpha = math.cos(u1) * math.sin(degrees)
251+
cosalpha_sq = 1.0 - sinalpha * sinalpha
252+
u2 = cosalpha_sq * (axis_a * axis_a - axis_b * axis_b) / (axis_b * axis_b)
253253
A = 1.0 + (u2 / 16384) * (4096 + u2 * (-768 + u2 * (320 - 175 * u2)))
254254
B = (u2 / 1024) * (256 + u2 * (-128 + u2 * (74 - 47 * u2)))
255255
# Starting with the approx
256-
sigma = distance / (AXIS_B * A)
256+
sigma = distance / (axis_b * A)
257257
last_sigma = 2.0 * sigma + 2.0 # something impossible
258258

259259
# Iterate the following 3 eqs until no sig change in sigma
@@ -280,19 +280,19 @@ def calculate_point(
280280
)
281281
)
282282
last_sigma = sigma
283-
sigma = (distance / (AXIS_B * A)) + delta_sigma
283+
sigma = (distance / (axis_b * A)) + delta_sigma
284284
phi2 = math.atan2(
285285
(
286-
math.sin(U1) * math.cos(sigma)
287-
+ math.cos(U1) * math.sin(sigma) * math.cos(degrees)
286+
math.sin(u1) * math.cos(sigma)
287+
+ math.cos(u1) * math.sin(sigma) * math.cos(degrees)
288288
),
289289
(
290-
(1 - FLATTENING)
290+
(1 - flattening)
291291
* math.sqrt(
292-
math.pow(Sinalpha, 2)
292+
math.pow(sinalpha, 2)
293293
+ pow(
294-
math.sin(U1) * math.sin(sigma)
295-
- math.cos(U1) * math.cos(sigma) * math.cos(degrees),
294+
math.sin(u1) * math.sin(sigma)
295+
- math.cos(u1) * math.cos(sigma) * math.cos(degrees),
296296
2,
297297
),
298298
)
@@ -301,12 +301,12 @@ def calculate_point(
301301
lembda = math.atan2(
302302
(math.sin(sigma) * math.sin(degrees)),
303303
(
304-
math.cos(U1) * math.cos(sigma)
305-
- math.sin(U1) * math.sin(sigma) * math.cos(degrees)
304+
math.cos(u1) * math.cos(sigma)
305+
- math.sin(u1) * math.sin(sigma) * math.cos(degrees)
306306
),
307307
)
308-
C = (FLATTENING / 16) * cosalpha_sq * (4 + FLATTENING * (4 - 3 * cosalpha_sq))
309-
omega = lembda - (1 - C) * FLATTENING * Sinalpha * (
308+
C = (flattening / 16) * cosalpha_sq * (4 + flattening * (4 - 3 * cosalpha_sq))
309+
omega = lembda - (1 - C) * flattening * sinalpha * (
310310
sigma
311311
+ C
312312
* math.sin(sigma)
@@ -317,14 +317,14 @@ def calculate_point(
317317
)
318318
lembda2 = longitude + omega
319319
math.atan2(
320-
Sinalpha,
320+
sinalpha,
321321
(
322-
-math.sin(U1) * math.sin(sigma)
323-
+ math.cos(U1) * math.cos(sigma) * math.cos(degrees)
322+
-math.sin(u1) * math.sin(sigma)
323+
+ math.cos(u1) * math.cos(sigma) * math.cos(degrees)
324324
),
325325
)
326-
phi2 = phi2 * 45.0 / piD4
327-
lembda2 = lembda2 * 45.0 / piD4
326+
phi2 = phi2 * 45.0 / pi_d4
327+
lembda2 = lembda2 * 45.0 / pi_d4
328328
return phi2, lembda2
329329

330330
@staticmethod

0 commit comments

Comments
 (0)