From Fran. validators for LATITUDE and LONGITUDE
class IS_LAT(object):
"""
example:
INPUT(_type='text',_name='name',requires=IS_LAT())
latitude has to be in degrees between -90 & 90
"""
def __init__(self, error_message='Latitude/Northing should be between -90 & 90!'):
self.minimum=-90
self.maximum=90
self.error_message = error_message
def __call__(self, value):
try:
value = float(value)
if self.minimum <= value <= self.maximum: return (value,None)
except ValueError: pass
return (value, self.error_message)
class IS_LON(object):
"""
example:
INPUT(_type='text',_name='name',requires=IS_LON())
longitude has to be in degrees between -180 & 180
"""
def __init__(self, error_message='Longitude/Easting should be between -180 & 180!'):
self.minimum=-180
self.maximum=180
self.error_message = error_message
def __call__(self, value):
try:
value = float(value)
if self.minimum <= value <= self.maximum: return (value,None)
except ValueError: pass
return (value, self.error_message)