Description
This application validates and normalizes a given decimal bearing.
A bearing, or navigational azimuth,
describes a direction or, the angular measurement, in a spherical coordinate system.
Bearings are used in many operations in KML Workbench, thus the need for functions
that normalize and validate user input.
Similar to latitude and
longitude,
the Bearing::isValid() function first calls
sanitizeGeo() for security.
Here, I call Bearing::normalize()
to convert the given input to a floating point decimal between 0 and 360.
- Trim whitespace; strip slashes; convert HTML special characters.
- Remove degree (°) sign.
- Trim leading zeros: "-005.5" --> "-5.5".
- Round to three places past the decimal
- Lead decimal with zero: ".6" --> "0.6".
- Normalize to a float >= 0 and < 360.
- Normalize negative zero: "-0" --> "0".
- Normalize 360 to zero: "360" --> "0".
Instructions
- Input a value into the Bearing field below.
- Click the [Validate] button.
- The result will be a valid, normalized bearing or "Invalid
bearing". If valid, KML will be generated displaying a 100 km path
from Null Island (0°,0°) in the direction of the bearing.
Inputs
Notes