'Spatial lookup values are either a parameter that is (or may be
converted to) a geometry, or a sequence of lookup values that
begins with a geometry.  This routine will setup the geometry
value properly, and preserve any other lookup parameters before
returning to the caller.'

def get_prep_value(self, value):

    if isinstance(value, SQLEvaluator):
        return value
    elif isinstance(value, (tuple, list)):
        geom = value[0]
        seq_value = True
    else:
        geom = value
        seq_value = False
    if isinstance(geom, Geometry):
        pass
    elif (isinstance(geom, (bytes, six.string_types)) or hasattr(geom, '__geo_interface__')):
        try:
            geom = Geometry(geom)
        except GeometryException:
            raise ValueError('Could    not    create    geometry    from    lookup    value.')
    else:
        raise ValueError(('Cannot    use    object    with    type    %s    for    a    geometry    lookup    parameter.' % type(geom).__name__))
    geom.srid = self.get_srid(geom)
    if seq_value:
        lookup_val = [geom]
        lookup_val.extend(value[1:])
        return tuple(lookup_val)
    else:
        return geom
