def within(shape, *bounds, **bounds_map):
    """Build a ``$within`` query.

    This is a convenience function for ``$within`` queries.

    :param shape: The shape of the bounding area.
    :type shape: str.
    :param \\*bounds: Coordinate pairs defining the bounding area.
    :type \\*bounds: \\*args.
    :param \\*\\*bounds_map: Named coordinate pairs defining the bounding area.
    :type \\*\\*bounds_map: \\*\\*kwargs.
    :returns: dict -- the ``$within`` query.
    :raises: :class:`RuntimeError`.

    """
    if bounds and bounds_map:
        raise RuntimeError(
            "Only one of 'bounds' and 'bounds_map' can be provided.")
    bounds = bounds_map or list(bounds)
    query = {'$within': {'${0}'.format(shape): bounds}}
    return query
