Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

validate longitude and latitude in python

def validate_longitude(longitude):
    if re.fullmatch("^(+|-)?(?:180(?:(?:.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:.[0-9]{1,6})?))$", longitude):
        return True
    else:
        raise False

def validate_latitude(latitude):
    if re.fullmatch("^(+|-)?(?:90(?:(?:.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:.[0-9]{1,6})?))$", latitude):
        return True
    else:
        raise False
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #validate #longitude #latitude #python
ADD COMMENT
Topic
Name
2+8 =