def map_msg_extent(msg):
    """
    Returns the extent of the map in world coordinates

    :param msg: ((nav_msgs.OccupancyMap|gmapping.doubleMap) A map message.

    :return: (list) The extents of the map in world coordinates [x0, x1, y0, y1]
    """

    w = msg.info.width
    h = msg.info.height

    # Set the plot's extension in world coordinates for meaningful plot ticks
    delta = msg.info.resolution
    x0 = msg.info.origin.position.x
    y0 = msg.info.origin.position.y
    x1 = x0 + w * delta
    y1 = y0 + h * delta

    extent = [x0, x1, y0, y1]

    return extent