Latitude Validator

Validate a coordinate latitude

Description

This application normalizes and validates a given decimal latitude. A latitude, specifies the north–south position of a point on Earth's surface. Latitudes are used in many operations in KML Workbench, thus the need for functions that normalize and validate user input. Similar to bearing and longitude, the Latitude::isValid() function first calls KMLWB::sanitizeGeo() for security. Here, I call Latitude::normalize() to convert the given input to a floating point decimal between -90 and 90.

  • Trim whitespace; Strip slashes; Convert html.
  • Remove degree (°) sign.
  • Round to 6 digits past the decimal.
  • Trim leading zeros: "-005.5" --> "-5.5".
  • Lead decimal with zero: ".6" --> "0.6".
  • Correct negative zero: "-0" --> "0".
  • Accept all floats from -90 to 90.

Input

Output

The result will be a valid, normalized latitude or "Invalid latitude". If valid, KML will be generated displaying the latitude.