'Validates that the input value can be converted to a Geometry
object (which is returned).  A ValidationError is raised if
the value cannot be instantiated as a Geometry.'

def clean(self, value):

    if (not value):
        if (self.null and (not self.required)):
            return None
        else:
            raise forms.ValidationError(self.error_messages['no_geom'])
    try:
        geom = GEOSGeometry(value)
    except:
        raise forms.ValidationError(self.error_messages['invalid_geom'])
    if ((str(geom.geom_type).upper() != self.geom_type) and (not (self.geom_type == 'GEOMETRY'))):
        raise forms.ValidationError(self.error_messages['invalid_geom_type'])
    if self.srid:
        if (not geom.srid):
            geom.srid = self.srid
        elif ((self.srid != (-1)) and (self.srid != geom.srid)):
            try:
                geom.transform(self.srid)
            except:
                raise forms.ValidationError(self.error_messages['transform_error'])
    return geom
