Bearing

Validate and normalize a navigational bearing

Description

This application validates a given bearing, an angle, in degrees, clockwise from north.

Instructions

  1. Input a value into the Bearing field below.
  2. Select if to format to 3 digits with a degree sign (000°).
  3. Select if to wrap to a value between 0 and 360.
  4. Click the [Validate] button.
  5. The result will be a valid, displayed, along with a map and kml to illustrate.

Inputs

Notes

Here we mean the Absolute Bearing, the angle, in degrees, clockwise from north.

This application demonstrates the Bearing class an its functions validates a given Absolute Bearing, the angle, in degrees, clockwise from north. decimal bearing. A bearing, or navigational bearing, 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 wrap and validate user input. Similar to latitude and longitude, the Bearing::isValid() function first calls sanitizeGeo() for security. Here, I call Bearing::wrap() 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".

References