Validate latitude & longitude with regex

Latitude:

/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,12})?))$/

Longitude:

/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,12})?))$/

Example:

$lat_pattern = '/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,12})?))$/';
$lng_pattern = '/^(\+|-)?(?:180(?:(?:\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\.[0-9]{1,12})?))$/';

if (!preg_match($lat_pattern, $latitude) || !preg_match($lng_pattern, $longitude)) {
    echo "Latitude or longitude is not correctly formatted";
}