def boxuid(box, celltype='QXQ'):
    """Synthesize a uid attribute based on the box's centre.  *box* is a
    4-tuple of the boxes bounds: (south, north, west, east).

    There are 2 sorts of 12 character string returned:
    +NN.N+EEE.EQ
    QXQ@+NN-EEET
    The first is used when the width of the box is less than 10
    degrees; the second otherwise.  This is the distinction of cells
    versus boxes.

    *celltype* is used to determine either the last character (1st form,
    above) or the first 3 characters (2nd form, above).  In the 1st
    form, the first character of celltype determines the last character.
    """
    import eqarea
    lat, lon = eqarea.centre(box)
    _, _, w, e = box
    if e - w < 10:
        return '%+05.1f%+06.1f%s' % (lat, lon, celltype[0])
    else:
        return '%s@%+03.0f%+04.0fT' % (celltype[:3], lat, lon)
