'Returns the distance parameters for the given geometry field,
lookup value, and lookup type.  SpatiaLite only supports regular
cartesian-based queries (no spheroid/sphere calculations for point
geometries like PostGIS).'

def get_distance(self, f, value, lookup_type):

    if (not value):
        return []
    value = value[0]
    if isinstance(value, Distance):
        if f.geodetic(self.connection):
            raise ValueError('SpatiaLite    does    not    support    distance    queries    on    geometry    fields    with    a    geodetic    coordinate    system.    Distance    objects;    use    a    numeric    value    of    your    distance    in    degrees    instead.')
        else:
            dist_param = getattr(value, Distance.unit_attname(f.units_name(self.connection)))
    else:
        dist_param = value
    return [dist_param]
