Throw an exception for invalid refraction option.

In JavaScript and Python, throw an exception if provided
an invalid refraction option. Especially in JavaScript,
it was too easy to pass in a value like 'true', which did
not calculate refraction as expected.
This commit is contained in:
Don Cross
2021-10-12 14:31:13 -04:00
parent 9c4b6e9f87
commit adf65e1f1f
16 changed files with 1655 additions and 1625 deletions

View File

@@ -1757,7 +1757,7 @@ due to lensing of the Earth's atmosphere.
| Type | Parameter | Description |
| --- | --- | --- |
| [`Refraction`](#Refraction) | `refraction` | The option for selecting whether to correct for atmospheric lensing. If `Refraction.Normal`, a well-behaved refraction model is used. If `Refraction.Airless`, no refraction correct is performed. `Refraction.JplHorizons` is used only for compatibility testing with the JPL Horizons online tool. |
| [`Refraction`](#Refraction) | `refraction` | The option for selecting whether to correct for atmospheric lensing. If `Refraction.Normal`, a well-behaved refraction model is used. If `Refraction.Airless`, no refraction correct is performed. `Refraction.JplHorizons` is used only for compatibility testing with the JPL Horizons online tool. Any other value raises an exception. |
| `float` | `altitude` | The number of degrees above (positive) or below (negative) the horizon an object is, before being corrected for refraction. |
### Returns: `float`

View File

@@ -4662,6 +4662,7 @@ def RefractionAngle(refraction, altitude):
If `Refraction.Airless`, no refraction correct is performed.
`Refraction.JplHorizons` is used only for compatibility testing
with the JPL Horizons online tool.
Any other value raises an exception.
altitude : float
The number of degrees above (positive) or below (negative) the
horizon an object is, before being corrected for refraction.
@@ -4694,9 +4695,11 @@ def RefractionAngle(refraction, altitude):
# When horizon angle is -1 degrees, the factor is exactly 1.
# As altitude approaches -90 (the nadir), the fraction approaches 0 linearly.
refr *= (altitude + 90.0) / 89.0
else:
# No refraction, or the refraction option is invalid.
elif refraction == Refraction.Airless:
# The caller does not want refraction correction.
refr = 0.0
else:
raise Error('Inalid refraction option')
return refr
def InverseRefractionAngle(refraction, bent_altitude):